setTimeout(function() {document.getElementById("public_I_webcast").innerHTML = "<div id='pi_iframe_gizmo67d40159e8cd0_location_marker' style='width: 100%;height:1px;overflow:hidden;float:left;display:inline'>&nbsp;<\/div><div style='position:static;background: gray;display:none; width: 100%; height: 500px; border: none 0;' id='pi_iframe_gizmo67d40159e8cd0_placeholder'><\/div><iframe allowfullscreen=\"true\" id=\"pi_iframe_gizmo67d40159e8cd0\" title=\"video player : Planning Committee - Thursday, 6th February 2025 at 10:30am\" src=\"\/\/cardiff.public-i.tv\/core\/iframe\/justwidget\/560\/jsw\/1\/activity_id\/945338\/mg\/1\/autostart\/0\" style=\"position: static;width: 100%; height: 500px; border: none 0; z-index: 10;\"><\/iframe>";}, 0);

var pi_iframe_gizmo67d40159e8cd0_width = '100%';
var pi_iframe_gizmo67d40159e8cd0_height = '500px';
var pi_iframe_gizmo67d40159e8cd0_placeholder_visible = false; // needed in pi_resize_*
	
	function pi_resize_pi_iframe_gizmo67d40159e8cd0() {
		el = document.getElementById('pi_iframe_gizmo67d40159e8cd0');
		el_placeholder = document.getElementById('pi_iframe_gizmo67d40159e8cd0_placeholder');
		
		width = pi_iframe_gizmo67d40159e8cd0_placeholder_visible ? document.getElementById('pi_iframe_gizmo67d40159e8cd0_placeholder').offsetWidth :  document.getElementById('pi_iframe_gizmo67d40159e8cd0').offsetWidth;
		
		if(width != pi_iframe_gizmo67d40159e8cd0_width) {
			pi_iframe_gizmo67d40159e8cd0_width = width;
			pi_iframe_gizmo67d40159e8cd0_height = ((width*0.5625) + 0) + 'px';
			el.style.height = pi_iframe_gizmo67d40159e8cd0_height;
			if(el_placeholder != null && el_placeholder.style.height) {
				el_placeholder.style.height = pi_iframe_gizmo67d40159e8cd0_height;
			}
		}
	}
	

	if(window.attachEvent) {
		window.attachEvent('onresize', pi_resize_pi_iframe_gizmo67d40159e8cd0);
		window.attachEvent('DOMContentReady', pi_resize_pi_iframe_gizmo67d40159e8cd0);
	}
	else if(window.addEventListener) {
		window.addEventListener('resize', pi_resize_pi_iframe_gizmo67d40159e8cd0);
		window.addEventListener('DOMContentReady', pi_resize_pi_iframe_gizmo67d40159e8cd0);
	}

	// and in case something else causes it's width to change
	setInterval(pi_resize_pi_iframe_gizmo67d40159e8cd0, 500);


	function PiOnScroll() {
		var el = document.getElementById('pi_iframe_gizmo67d40159e8cd0');
		var el_location_marker = document.getElementById('pi_iframe_gizmo67d40159e8cd0_location_marker');
		var el_placeholder = document.getElementById('pi_iframe_gizmo67d40159e8cd0_placeholder');
		
		if(!el) {return;}
		
		if(pi_isElementVisible(el_location_marker)) {
			el.style.setProperty('position', 'static', 'important');
			el.style.setProperty('right', null);
			el.style.setProperty('bottom', null);
			el.style.setProperty('max-width', null);
			el.style.setProperty('max-height', null);
			el.style.setProperty('margin-bottom', null);
			el_placeholder.style.setProperty('display', 'none', 'important');
			pi_iframe_gizmo67d40159e8cd0_placeholder_visible = false;
		} else {
			el.style.setProperty('position', 'fixed', 'important');
			el.style.setProperty('right', '2px', 'important');
			el.style.setProperty('bottom', '2px', 'important');
			el.style.setProperty('max-width', '300px', 'important');
			el.style.setProperty('max-height', '172px', 'important');
			el.style.setProperty('margin-bottom', '0', 'important');
			el_placeholder.style.setProperty('display', 'inline-block', 'important');
			pi_iframe_gizmo67d40159e8cd0_placeholder_visible = true;
		}
		pi_resize_pi_iframe_gizmo67d40159e8cd0();
	};
	window.onscroll = PiOnScroll;
	PiOnScroll();
	jQuery('#public_I_toggle').click(function(){setTimeout(PiOnScroll, 10);setTimeout(PiOnScroll, 500);setTimeout(PiOnScroll, 1000);setTimeout(PiOnScroll, 2000);setTimeout(PiOnScroll, 3000)});
	
	function pi_isElementVisible(el) {
		var rect     = el.getBoundingClientRect(),
			vWidth   = window.innerWidth || doc.documentElement.clientWidth,
			vHeight  = window.innerHeight || doc.documentElement.clientHeight,
			efp      = function (x, y) { return document.elementFromPoint(x, y) };

		// Return false if it's not in the viewport
		if (rect.right < 0 || rect.bottom < 0 
			|| rect.left > vWidth || rect.top > vHeight)
			return false;

		// Return true if any of its four corners are visible
		return (
			el.contains(efp(rect.left,  rect.top))
			||  el.contains(efp(rect.right, rect.top))
			||  el.contains(efp(rect.right, rect.bottom))
			||  el.contains(efp(rect.left,  rect.bottom))
		);
	}


	var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
	var eventer = window[eventMethod];
	var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";

	// Listen to message from child window
	eventer(messageEvent,function(e) {
		var key = e.message ? "message" : "data";
		var data = e[key];
		if(typeof data == 'string' && data.match(/^add_play_button_to_mg_agenda_ids\:/)) {
			console.log('PI data '+data);
			// player is telling us a list of agenda points that want a button appended to
			var mg_agenda_ids = data.replace('add_play_button_to_mg_agenda_ids:', '').split(',');
			
			// Remove any already injected (duplicates started appearing after MG started pulling in the webcast pages content async)
			jQuery('.pi_play_btn').remove();
			
			jQuery('.mgAiTitleTxt a').filter(function(i, el) { a_name = jQuery(el).attr('name'); if( typeof a_name != 'string' ) { return false; } return a_name.replace(/AI\d*/) }).each(function(i, el) {
				var id = jQuery(this).attr('name');
				var mg_agenda_id = id.replace(/[^\d]/g, '');

				if(jQuery.inArray(mg_agenda_id, mg_agenda_ids)) {
					var el = document.getElementById('pi_iframe_gizmo67d40159e8cd0');
					var play_btn = jQuery('<button class="pi_play_btn" style="cursor:pointer;background:#000;color:#fff;border: 0;width: 30px;height: 30px;border-radius: 4px;padding-bottom: 3px;padding-left: 9px;display: inline;"/>').html('&#9658;').click(function() {
						//sUrl = el.src.replace(/#.*/, '');
						//el.src = sUrl + '#' + id;

						if( ! jQuery('#public_I_toggle').hasClass('opened') ) { jQuery('#public_I_toggle').click(); } /* open video window if closed */
						el.contentWindow.postMessage('mg_agenda_id:'+mg_agenda_id, 'https://cardiff.public-i.tv');
						return false;
					}.bind(this))
						.mouseover(function(el){jQuery(this).css({background: '#333'})})
						.mouseout(function(el){jQuery(this).css({background: '#000'})});

					jQuery(this).closest('p').append(play_btn);
				}
			});
		} else if (typeof data == 'string' && data.match(/^mg_agenda_id:\d+$/)) {
			// player is telling us that an agenda items is now being played
			var mg_agenda_id = data.replace('mg_agenda_id:', '');
			current_agenda_change_callback(mg_agenda_id);
		}
	},false);
	
	

	if(typeof current_agenda_change_callback == 'undefined'){
		window.current_agenda_change_callback = function(mg_agenda_id){
			// clear any already highlighted
			jQuery('.pi_current_agenda').css({background: ''});

			// set current highlighted (note: mg_agenda_id may be NULL or a number that doesn't match anything on the page)
			jQuery("a[name='AI"+mg_agenda_id+"']").closest('tr').find('td > .mgAiTitleTxt:first-child').css({background: 'yellow'}).addClass('pi_current_agenda');
		}
	}
