var BridgeConnectionId = Math.floor(Math.random()*9999999);
var adBugConnectionId = BridgeConnectionId + 1;
var initialVolume = 75;

function Init()
{
	//registerTabs();
	
	if (MN.GetPageParams().debug)
		MN.Log.ShowPane(2000);

	var so = new SWFObject("flash/HybridPlayer.swf", 'mn_movie', '100%', '100%', '9.0.115', '#000000');
	so.addParam('allowScriptAccess', 'always');	// (REQUIRED)
	so.addParam('wmode', 'transparent'); // allows move install process to be shown
	so.addParam('scale', 'noscale'); // Prevents the player from scaling when resized (RECOMMENDED)
	so.addParam('salign', 'tl');
	so.addVariable("initialVolume", initialVolume);	// Initial volume of the player
	so.addVariable('movieID', 'mn_movie');	// Makes the flash aware of its own ID	(REQUIRED)
	so.addVariable('playerParentID', 'mn_playerDiv');	// ID of the div that gets the client inside of it (REQUIRED)
	
	// localconnection parameters
	so.addVariable('connectionId', BridgeConnectionId); // for the control bridge
	so.addVariable('adBugConnectionId', adBugConnectionId); // for the ad bridge
	
	/* START: playlist */	
	so.addVariable("playlistHost", "cms027.sv1.qcn3.movenetworks.com");
	so.addVariable("playlistPublisher", "byutv");
	so.addVariable("selectedChannels", "*");
	so.addVariable("selectedCategories", "*");
	
	so.addVariable("skipSubCategories", "true");
	
	so.addVariable("webFeedDays", "14");
	so.addVariable("channelMax","6");
	so.addVariable("liveIcon","http://byu.tv/images/live.png");
	
	/* END: playlist */

		
	if (MN.GetPageParams().defaultClipId)
	{
		so.addVariable('defaultClipId', MN.GetPageParams().defaultClipId);
	}
	
	if (MN.GetPageParams().forceNative)
	{
		so.addVariable('forceNative', "true");
	}
	
	if (!so.write('mn_movieDiv'))
	{
		$("mn_playerDiv").innerHTML = "Please install or upgrade to the latest flash version<br/>found here <a href='http://adobe.com'>adobe.com</a>";
		$("mn_playerDiv").style.fontSize = "16px";
	}
}

function registerTabs() {
	//for the sake of ie6
	MN.Event.Observe($("tab0"), "mouseover", tabover);
	MN.Event.Observe($("tab0"), "mouseout", tabout);	
	MN.Event.Observe($("tab1"), "mouseover", tabover);
	MN.Event.Observe($("tab1"), "mouseout", tabout);
	MN.Event.Observe($("tab2"), "mouseover", tabover);
	MN.Event.Observe($("tab2"), "mouseout", tabout);
	MN.Event.Observe($("tab3"), "mouseover", tabover);
	MN.Event.Observe($("tab3"), "mouseout", tabout);
	MN.Event.Observe($("tab4"), "mouseover", tabover);
	MN.Event.Observe($("tab4"), "mouseout", tabout);
}

function tabover(e) {
	e = e ? e : window.event;
    var targ = null;
    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    
	targ.style.backgroundPosition = "top left";
}

function tabout(e) {
	e = e ? e : window.event;
    var targ = null;
    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    
	targ.style.backgroundPosition = "bottom left";
}

MN.Event.Observe(window,"load",Init);
