/* 
BBC Scotland - Music - Rockness 2009
Glow/JS Code By Cris Walsh
*/

var DownloadsServer = 'http://downloads.bbc.co.uk';
var PlaylistServer = 'http://www.bbc.co.uk';

// load an instance of glow
 gloader.load(
        ["glow", "1.1.0", "glow.dom","glow.events","glow.net","glow.widgets.Panel","glow.anim","glow.tweens"],
        {
            async: true,
            onLoad: function(glow) {
              	// glow is now ready to use
				// console.log('glow ready');
				Site.pageOptions();

            }
        }
    );

/* ------------------------------------------------------------------------ */
/* -------------------->>>   G L O B A L  O B J E C T   <<<---------------- */
/* ------------------------------------------------------------------------ */
var Site = {
/* ------------------------------------------------------------------------ */
/* ---------------------->>> P A G E    O P T I O N S  <<<----------------- */
/* ------------------------------------------------------------------------ */
	pageOptions: function(){
		// console.log('pageOptions');
		// set the var "pageID" to the pages body class
		var pageID = glow.dom.get('body').attr('id');
		// run a conditional statement on the var "pageID" 
		switch(pageID)
		{
			case 'nav-artist':
				// console.log('nav-artist');
				// create  nodelist
				 var videoNodeList = glow.dom.get("a.video");
				 Site.createVideoPlayListLinks(videoNodeList);
				break;
			case 'gallery':
				// console.log("body id=\"gallery\"");
				break;
			default:
				break;
		}
	},
/* ------------------------------------------------------------------------ */
/* Function:Site.createVideoPlayListLinks() */
/* ------------------------------------------------------------------------ */
	createVideoPlayListLinks: function(myNodeList)
	{
		// console.log("createVideoPlayListLinks called");
		myNodeList.each(function(i){
			this == myNodeList[i];
			glow.events.addListener(glow.dom.get(this), 'click', function(e){
				glow.dom.get(this).addClass("nowplaying");
				Site.removeActive(myNodeList);
			});
		});
	},
/* ------------------------------------------------------------------------ */
/* Function:Site.removeActive() */
/* ------------------------------------------------------------------------ */
	removeActive:function (myNodeList)
	{
			// console.log("removeActive");
			myNodeList.each(function(i){
				this == myNodeList[i];
				glow.dom.get(this).removeClass("active");
			});
	}
}
