/* EMP scripts */

/* IMPORTANT NOTE FOR EDITORIAL:

	- EMP settings must be edited BOTH in this file AND in 'emp.sssi' in the 'includes/content' folder

	- referenced EMP playlists must be edited in the 'media/emp/playlists' folder.

	- referenced carousel thumbnails and video placholder images must be placed in the 'images/emp' folder.

*/


/* Requires Glow, /emp/swfobject.js & /emp/embed.js */

/* this function needs to be in global scope */
function reload(playlist_url, objID) {
	var emp = new bbc.Emp();
	emp.setWidth("448");
	emp.setHeight("287");
	emp.setDomId("emp-1");
	emp.set("config_settings_skin", EMP_THEME); 
	emp.set("config_settings_autoPlay", "true"); 
	emp.setPlaylist(playlist_url);
	emp.write();
	glow.dom.get('#videoDesc').html(glow.dom.get('#desc_'+objID).html());
	glow.dom.get('#'+highlightedVideo).removeClass("borded");
	glow.dom.get('#'+objID).addClass("borded");
	highlightedVideo = objID;
	return false;
}


(function() {

// embed the EMP
function do_embed() {
	var emp = new bbc.Emp();
	emp.setWidth("448"); 
	emp.setHeight("287");
	emp.setDomId("emp-1"); 
	emp.set("config_settings_skin", EMP_THEME); /* theme set in head.sssi */
	emp.setPlaylist("http://www.bbc.co.uk/genius/media/emp/playlists/genius_episode6.xml");
	emp.write();
	glow.dom.get('#videoDesc').html(glow.dom.get('#desc_video1').html());

}
//-----

// If not removed by JS, redisplay the previously hidden no-flash message
function make_visible(o_nodes /* nodes to display */) {
	var obj = null, i = 0;

	for (i = 0; obj = o_nodes[i]; ++i)
		obj.style.visibility = 'visible';
}
//-----

/* code to execute */

glow.ready(function() { 
	var o_nodes;

	do_embed();  

	o_nodes = glow.dom.get('.p-emp .nojsmessage');
	make_visible(o_nodes);

	o_nodes = glow.dom.get('.prg-carousel');
	make_visible(o_nodes);
});


})();

/* end of script */