

 






var nsParam = '&nsid=a-2b20490e:12af3a2a1c5:-28d0';  
var skinParam = '';
var dbgParam = '';
var player = "WMP"; 


//document.oncontextmenu = function() {return false;}








var imgsrc = "http://metrics.feedroom.com/affiliate/_common/spacer.gif";
var imgbuffer = null;
var ct = 0;
var spx = -1;
var sd = -1;
var dt = new Date();
var ping_available = true;
var ping_queue = [];
var filterMap = new Object()
var filterAdd = new Object()
var suspendPing = false;
var nsid_index = -1;

var	nsid = 'a:-28d0';


	


function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function announce(action) {
	dt = new Date();
	calcReportingParams(true, false);
	
	var qstr = "?action="+action;
	qstr += "&player=WMP";qstr += "&site=bms";qstr += "&nsid=a-2b20490e:12af3a2a1c5:-28d0";qstr += "&userAgent=CCBot/1.0 (+http://www.commoncrawl.org/bot.html)";
		
		
	qstr=qstr+"&spx="+spx+"&sd="+sd;
	
	var ord = "&ord=" + Math.round(Math.random()*999999);
	var newimg = document.createElement("img");
	newimg.id = action;
	newimg.src = "http://metrics.feedroom.com/affiliate/_common/spacer.gif"+ qstr + ord;
	newimg.style.display = "none";
	imgbuffer = document.getElementById("rpt_imgbuffer");
	imgbuffer.appendChild(newimg);
}

function init_rpt() {
	imgbuffer = document.getElementById("rpt_imgbuffer");
	logbuffer = document.getElementById("rpt_logbuffer");

	filterMap['NAVIGATABLE'] = 'cid';
	filterMap['REDIRECT_TO_STORY'] = 'sid';
	filterMap['REDIRECT_TO_CHANNEL'] = 'cid';
	filterMap['SITE_TYPE'] = 'site';
	filterMap['SEARCH_TERM'] = 'searchwords';
	filterMap['REQ_SKIN_TYPE'] = 'skin';
	filterMap['STORY_START'] = 'ss';
	filterMap['STORY_END'] = 'se';
	filterMap['REDIRECT_URL'] = 'url';

    filterAdd['playStory'] = new Array('band','isBB');
    filterAdd['playNextStory'] = new Array('band','isBB');
}

function filter(name, qstr) {
	var zq = "?";
	var za = "&";
	var ze = "=";
	var out = "";
	if (qstr[0] == zq) {
		out = qstr[0];
		qstr = qstr.substring(1);
	}
	var qps = qstr.split(za);
	for (var i=0;i<qps.length;i++) {
		var kp = qps[i].split(ze);		
		if (filterMap[kp[0]]) {
			kp[0] = filterMap[kp[0]];
			qps[i] = kp.join(ze);
			
		}
	}
	out += qps.join(za);
    if (filterAdd[name]) { 
        var paramName = filterAdd[name][0];
        var paramValue = eval(filterAdd[name][1]);
        
        if (paramName == 'band' && paramValue != undefined) {
            paramValue = (paramValue ? "BB":"NB");
        }
        out +="&"+paramName+"="+paramValue;
    }
    out += za; 
    return out;
}

function clearbuffers() {
	imgbuffer.innerHTML = "";
	
	
}

function incrSessionDur(){
	var sec_diff = Math.floor(Math.abs(dt.getTime()- new Date().getTime())/1000)
	if (sdBefReload > 0)
		sd=new Number(sdBefReload)+sec_diff;
	else
		sd=sec_diff;
}
// use cookies as persistent spx/sd store per nsid.
// create nsid-keyed entry on exit only
function calcReportingParams(saveCookie, isExit){
  try {
	if (saveCookie == false){
		//Session Ping Index
		spx++;
		//Session Duration 
		incrSessionDur();
	} else {
		if (isExit==false){
			var c_nsid = readCookie('nsid');
			
			if (c_nsid==null) {
				spx = sdBefReload = 0;
				sd = new Number(0);
				nsid_index = -1; // re-inforce
			} else {
				var a_nsid = c_nsid.split(',');
				for (var i=0;i<a_nsid.length;i++) {
					if (a_nsid[i] == nsid) { nsid_index = i; break; }
				}

				// If does not exist, init sd and spx
				if (nsid_index < 0) {
					sd = sdBefReload = new Number(0);
					spx = 0;
				} else {
	
					//Get cookie values into spx and sd
					c_spx = readCookie('spx');
					spx = c_spx.split(',')[nsid_index];
					if (spx == null) {
						spx = 0;
					}
					c_sd = readCookie('sd');
					sdBefReload = c_sd.split(',')[nsid_index];
					if (sdBefReload == null) {
						sd = sdBefReload = new Number(0);
					} else {
						sd = new Number(sdBefReload);
					}
				}
			}
		} else {
			//Session Ping Index
			spx++;

			// calc nsid_index
			var c_nsid = readCookie('nsid');
			if (c_nsid) {
				var a_nsid = c_nsid.split(',');
				for (var i=0;i<a_nsid.length;i++) {
					if (a_nsid[i] == nsid) { nsid_index = i; break; }
				}
				if (nsid_index < 0) {
					// append
					CookieAppend('nsid',a_nsid.length,nsid,false);
					CookieAppend('spx',a_nsid.length,spx,false);
					CookieAppend('sd',a_nsid.length,sd,false);
				} else {
					// replace
					CookieAppend('spx',nsid_index,spx,true);
					CookieAppend('sd',nsid_index,sd,true);
				}

			} else { // no nsid cookie, create anew
				createCookie('nsid', nsid);
				createCookie('spx', spx);
				createCookie('sd', sd);
			}
		}
	}
  } catch (cErr) {  }
}

function CookieAppend(name,pos,value,replace) {
	var c = readCookie(name);
	var a = c.split(',');
	var i = replace ? 1 : 0;
	
	a.splice(pos,i,value);
	createCookie(name, a.join(','));
}

function ping(name, args) {
	calcReportingParams(false);
    var qstr = filter(name, "?action="+name+"&spx="+spx+"&sd="+sd+"&nsid=a-2b20490e:12af3a2a1c5:-28d0"+args);
    if (ping_available) {
		ping_available = false;
		send_ping(qstr);
	} else {
		ping_queue.push(qstr);
	}
}

function send_ping(qp) {

  
	if (!imgbuffer) init_rpt();
	if (++ct % 10 == 0) clearbuffers();
	var newimg = document.createElement("img");
	if (imgbuffer) imgbuffer.appendChild(newimg);
	var ord = "&ord=" + Math.round(Math.random()*999999);
	newimg.src = imgsrc + qp + ord;
	newimg.className = 'ping';





	ping_available = true;
	pop_ping();
}

function pop_ping() {
	if (ping_available && ping_queue.length > 0) {
		next_ping = ping_queue[0];
		ping_queue = ping_queue.slice(1);
		send_ping(next_ping);
	}
}



var useNativeVideoSize = "false";
var bMax=false;
var oldXPositions = {};
var oldYPositions = {};
function ScaleVideo() {	
	var flashDiv = document.getElementById("flashDiv");
	var vidControls = document.getElementById('divModVideoControls');
	var tileOverlay = document.getElementById("divTileOverlay" + currentPlaying)
	var masthead = document.getElementById('divMasthead');
	var clickLogo = document.getElementById('clickLogo');
	var wrapper = document.getElementById('divWrapper');
	var componentIds = ['divHeader','divFooter','ifr_actionBox','divStories','divStoriesNav','divChannels','divChannelDisplay','divSearch','divPowered','divRss','divMasthead','divSendVideo','divHelp','divBookmark','divPlayer','divGoogleAnalytics'];
	if (!bMax) {
		for (var i=0;i<componentIds.length;i++) {
			var cid = componentIds[i];
			oldXPositions[cid] = document.getElementById(cid).offsetLeft
			document.getElementById(cid).style.left="-1000";
			oldYPositions[cid] = document.getElementById(cid).offsetTop
			document.getElementById(cid).style.top="-1000";
		}
		document.body.className = "scaled";		
		if(tileOverlay !=null) tileOverlay.style.visibility="hidden";
		document.getElementById('divPlayer').className = "scaled";
		document.getElementById('divPlayer').style.left = "0px"
		document.getElementById('divPlayer').style.top = "0px"
		document.getElementById('divModVideo').className = "scaledFLV";
 		flashDiv.className = "scaled";
		if (masthead) masthead.className = "scaled";
		if (clickLogo) clickLogo.className = "scaled";
		if (wrapper) {
			wrapper.className = "scaled";
		}
		JumpUI();
	} else {

		for (var i=0;i<componentIds.length;i++) {
			var cid = componentIds[i];
			document.getElementById(cid).style.left = oldXPositions[cid] + "px"
			document.getElementById(cid).style.top = oldYPositions[cid] + "px"
		}
		document.body.className = "";
		if(tileOverlay!=null) setNowPlaying(currentPlaying);
		document.getElementById('divPlayer').className = "";
		document.getElementById('divModVideo').className = "";
		flashDiv.className = "";
		if (masthead) masthead.className = "";
		if (clickLogo) clickLogo.className = "";
		if (wrapper) wrapper.className = "";
		oldXPositions = new Object();
		oldYPositions = new Object();
	}
	bMax = !bMax;
}

var popup = "";
var existingWinName = "";
var existingURL = "";
var winTop = 0;
var winLeft = 0;
var winMenu = 0;
var winStatus = 0;
function winPopup(winURL, winName, winWidth, winHeight, winToolbar, winLocation, winResizeble, winScrollers, winClose) {
  try {

	if (winName.indexOf("donotgo") >= 0 || winURL.indexOf("donotgo") >= 0) {
		return false;
	} else if (false) {
		winTop = 0;
   		winLeft = 0;
	} else if (winName.indexOf("sponsor") >= 0 || winName.indexOf("suppLink") >= 0) {
		winLeft = (screen.width - winWidth) / 2;
		winTop = (screen.height - winHeight) / 2 - 40;
	} else if (winName.indexOf("about") >= 0) {
		winTop = (screen.height - winHeight) / 2;
		winLeft = (screen.width - winWidth) / 2; 
	} else if (winName.toLowerCase().indexOf("feedroom") >= 0) {
		winLeft = (screen.width - winWidth) / 2;
		winTop = (screen.height - winHeight) / 2 - 40;
	} else if ((winName.indexOf("branding") >= 0) || (winName.indexOf("network") >= 0)) {
		winLeft = ((screen.width - winWidth)/2);
  		winTop = ((screen.height - winHeight)/2) - 65;
	} else if ((winName.indexOf("faq") >= 0) || (winName.indexOf("policy") >= 0) || (winName.indexOf("embedthis") >= 0) || (winName.indexOf("embednatalie") >= 0) || (winName.indexOf("embedthat") >= 0)) {
		winLeft = (screen.width - winWidth) / 2;
		winTop = 0;
	} else if (winName.indexOf("survey") >= 0) {
		winTop = (screen.height - winHeight) / 2;
		winLeft = (screen.width - winWidth) / 2; 
	} else if (winName.indexOf("FullScreen") >= 0) {
		winTop = (screen.height - winHeight) / 2;
		winLeft = (screen.width - winWidth) / 2;
	} else if (winName.indexOf("signup") >= 0) {
		winTop = (screen.height - winHeight) / 2 - 30;
		winLeft = (screen.width - winWidth) / 2 - 6; 
	} else if (winName.indexOf("library") >= 0) {
		winTop = (screen.height - winHeight) / 2 - 20;
		winLeft = (screen.width - winWidth) / 2; 
	}else if (winName.indexOf("Bookmark") >=0) {
		winLeft = (screen.width - winWidth)/2 + 40;
		winTop = 0;
	}else if (winName.indexOf("Share") >=0) {
		winLeft = (screen.width - winWidth)/2 + 40;
		winTop = 0;
	}else if (winName.indexOf("BHG") >=0) {
		winLeft = (screen.width - winWidth)/2 + 10;
		winTop = 0;
	}else if (winName.indexOf("SendVideo") >=0) {
		winLeft = (screen.width - winWidth)/2 + 40;
		winTop = 0;
	}else if (winName.indexOf("StoryDownload") >=0) {
		winLeft = (screen.width - winWidth)/2 + 40;
		winTop = 200;
	} else if (winName.indexOf("broadcast") >= 0) {
		winTop = (screen.height - winHeight) / 2;
		winLeft = (screen.width - winWidth) / 2;
    } else {
        winLeft = ((screen.width - 779)/2) + 190;
 		winTop = ((screen.height - 579)/2) + 315;
	}
	
	if (winTop < 0) winTop = 0;
	if (winName.indexOf('_') != 0) {
		winName += "bms";
	}
	if (existingWinName != winName) popup="";

	winMenu = 0;
	winStatus = 0;
	if (winToolbar && winToolbar==1) {
        winMenu = 1;
		winStatus = 1;
	}
    
	if (!popup || popup.closed ||false||(existingURL!=winURL)){
		existingWinName = winName;
		
		if (!(winName.indexOf("banners") >=0)) {
			popup = window.open(winURL, winName, 'width=' + winWidth + ',height=' + winHeight + ',top='+ winTop +',left='+ winLeft +',menubar='+ winMenu +',toolbar='+ winToolbar +',location='+ winLocation +',resizable=' + winResizeble + ',scrollbars=' + winScrollers + ',screenX='+ winLeft +',screenY='+ winTop +',status=' + winStatus);
		} else {
			popup = window.open(winURL, winName);
		}
	}
	existingURL=winURL;var tmp="true";
	if (winClose != undefined && (winClose.toString()=="true") && (winName.toUpperCase() != (parent.name + "").toUpperCase())) parent.close();
	
	if (popup) popup.focus();
	
  
  } catch (ew) {

  }
}


function openLibrary() {
		var iMoreVideo = 0;
		var host_var = 'null';
		
		if (iMoreVideo==1) {
			host_var += "?fr_story="+currentStory_uoi_id;
		} else if (iMoreVideo==2) {
			host_var += "?fr_chl=" + currentChannel_uoi_id;
		} else if (iMoreVideo==3) {
			host_var += "?fr_story="+currentStory_uoi_id + "&fr_chl=" + currentChannel_uoi_id;
		}
		
    
		winPopup(host_var, "library",665+20,695+20,0,0,1,1,0);
	
}


var flso = null;

function createFlashLSO () {
	if ( flso == null ) {
		flso = new SWFObject( "null/lso.swf", "flashlso", "1", "1", "8", "#242424", true, "high", null, "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0");
		flso.addParam("allowScriptAccess", "samedomain");
		flso.write("flashlsodiv");
	} else {
		return;
	}
}

function setFlashLSO( p_key, p_val, p_callback ) {
	var flashlso = document.getElementById( "flashlso" );
	if ( flashlso != null && typeof flashlso.setUserSO == "function" ) {
		flashlso.setUserSO( "feedroom", p_key, p_val, p_callback );
	}
}

function getFlashLSO( p_key, p_callback ) {
	var flashlso = document.getElementById( "flashlso" );
	if ( flashlso != null && typeof flashlso.getUserSO == "function" ) {
		flashlso.getUserSO( "feedroom", p_key, p_callback );
	}
}

function init_flashLSO() {
}








var currentPlaying = -1;
var highlightNowPlaying = true
var showStoryHover = false
var search_onload = false
function renderNowPlaying(idx) {
    if (idx < 0) return;
    tile = document.getElementById("divTileOverlay" + idx)
    if (tile!=null) {
	    tile.style.visibility="visible";
    }
    text = document.getElementById("divTextUnderlay" + idx)
    if (text!=null) {
	    text.style.visibility="visible";
    }
}
function saveNowPlaying(idx) {
    currentPlaying = idx;
}
function resetNowPlaying() {
    tile = document.getElementById("divTileOverlay" + currentPlaying)
    
    if (tile!=null) {
        tile.style.visibility="hidden";
    }
    text = document.getElementById("divTextUnderlay" + currentPlaying)
    if (text!=null) {
	    text.style.visibility="hidden";
    }
}
function setNowPlaying(idx) {
    resetNowPlaying();

    if (playChannel == displayChannel) {
    	renderNowPlaying(idx);
   	} else if (search_onload) {
   		renderNowPlaying(idx);
   		search_onload = false;
   		playChannel = -4;
   	}
    saveNowPlaying(idx);
}


function postShowStories(displaychl, showNowPlaying) {
	//alert(displaychl + ' ' + showNowPlaying + ' ' + playChannel);
	if (displaychl) displayChannel = displaychl;
	
	if (showNowPlaying == 'true' && playChannel == displaychl) renderNowPlaying(currentPlaying);
    
    if(document.getElementById("story_display_offset")) 
			displayChannelStart = parseInt(document.getElementById("story_display_offset").innerHTML) || 0
}




 


/*
verifyCompatibleBrowser: sets the browser and other environment variables
*/
function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 

var speed=20 
var loop, timer, hasSubChannels 
var prevChannelId=""
var positionx=0;
var positiony=0;
var prevChannelId = 0;
var initialized = false;
var channelIdMap = new Object();
var thisChannelId=""
var lastSubChannelId="";



function channelClick(thisChannelPos) {	
  thisChannelId = "channel" + thisChannelPos
  unhighlightAllChannels()
	if (isSubChannel(thisChannelId)) {
		clickSubChannel(thisChannelId);
		lastSubChannelId = thisChannelId;
	} else {
		clickTopChannel(thisChannelId);
	}
	
	prevChannelId = thisChannelId	
	
	InitialiseScrollableArea(positionx,positiony)	  
	

}	
	
function clickTopChannel(thisChannelId) {
	if (hasSubChannel(thisChannelId)) {
		if (hasOpenSubChannel(thisChannelId)) {
			closeGroup(getGroupId(thisChannelId));
		} else {
 			openGroup(getGroupId(thisChannelId));
		}
	}
	highlightChannel(thisChannelId);
}

function clickSubChannel(thisChannelId) {
	thisChannelId = (!thisChannelId) ? 0 : thisChannelId; 
	highlightSubChannel(thisChannelId)
	
	thisGroupId = getGroupId(thisChannelId)
	if (!hasOpenSubChannel(thisGroupId)) {
		openGroup(thisGroupId);
	}
	highlightChannel(thisGroupId);
	
}

function unhighlightAllChannels() {
	if (prevChannelId) {
		//alert("!isSubChannel(thisChannelId): " + !isSubChannel(thisChannelId))
		if (!isSubChannel(thisChannelId) && hasSubChannel(thisChannelId) ) {
			unhighlightBullet(prevChannelId);
			unhighlightChannel(getGroupId(prevChannelId));
			//unhighlightBullet(getGroupId(prevChannelId));
        }
	else if (isSubChannel(thisChannelId)) {
			unhighlightSubChannel(lastSubChannelId);
			unhighlightBullet(prevChannelId);
			unhighlightChannel(getGroupId(prevChannelId));
			unhighlightBullet(getGroupId(prevChannelId));
	} else{
		unhighlightSubChannel(lastSubChannelId);
		unhighlightChannel(getGroupId(prevChannelId));
		unhighlightBullet(getGroupId(prevChannelId));
	}
	}
}

function highlightLoadedChannel(channelPos) {
	if (channelPos) {
		channelClick(channelPos);		
	} else {
		if (!initialized) {
			channelClick(-1);			initialized = true;
		}
	}
}

function highlightChannel(thisChannelId) {
	var channelDiv = document.getElementById(thisChannelId);
	if (channelDiv) channelDiv.className = "topChannel_selected";
}
function unhighlightChannel(thisChannelId) {
	var channelDiv = document.getElementById(thisChannelId);
if (channelDiv) channelDiv.className = "topChannel";

}

function highlightSubChannel(subChannelId) {
	var channelDiv = document.getElementById(subChannelId);
	if (channelDiv) channelDiv.className = "subChannel_selected";
	//alert('group is ' + getGroupId(subChannelId));
	openGroup(getGroupId(subChannelId));	
}
function unhighlightSubChannel(subChannelId) {
	var channelDiv = document.getElementById(subChannelId);
	if (channelDiv) channelDiv.className = "subChannel";
}

function openGroup(groupId) {
	var subchans = document.getElementById(groupId + "Sub")
	if (subchans) {
		subchans.className = "subChannelContainer_selected"
		openBullet(groupId)
	}
}

function closeGroup(groupId) {
	var subchans = document.getElementById(groupId + "Sub")
	if (subchans) {
		subchans.className = "subChannelContainer"
		closeBullet(groupId)
	}
}

function getGroupId(thisDivId) {
	var channel = document.getElementById(thisDivId)
	var groupid = null
	if (channel) {
		var parentbox = channel.parentNode
		if (parentbox.className == 'divChannelContainer') {
			groupid = thisDivId				
		} else if (parentbox.className == 'subChannelContainer_selected') {
			groupid = parentbox.id.substring(0,parentbox.id.indexOf("Sub")); 
		} else if (parentbox.className == 'subChannelContainer') {
			groupid = parentbox.id.substring(0,parentbox.id.indexOf("Sub"));
		}
	}
	return groupid
}


function openBullet(thisDivId) {
	var thisImg = document.getElementById(thisDivId + "Img");
	if (thisImg && thisImg.className.indexOf("none") == -1) rolloverImage(thisDivId+"Img", "channel_arrow_open_on");
}
function closeBullet(thisDivId) {
	var thisImg = document.getElementById(thisDivId + "Img");
	if (thisImg && thisImg.className.indexOf("none") == -1) rolloverImage(thisDivId+"Img", "channel_arrow_on");
}

function unhighlightBullet(thisDivId) {
	var thisImg = document.getElementById(thisDivId + "Img");
	if (thisImg && thisImg.className.indexOf("none") == -1) {
		//if (isOpenBullet(thisDivId)) {
        if (hasOpenSubChannel(thisDivId)) {
			rolloverImage(thisDivId+"Img", "channel_arrow_open_off");
		} else {
			rolloverImage(thisDivId+"Img", "channel_arrow_off");
		}
	}
}

function isOpenBullet(thisDivId) {
	var thisImg = document.getElementById(thisDivId + "Img");
	return (thisImg && thisImg.className.indexOf("open") > -1)
}
function isNonBullet(thisDivId) {
	var thisImg = document.getElementById(thisDivId + "Img");
	return (thisImg && thisImg.className.indexOf("none") > -1)
}


function isSubChannel(channelId) {
	var channel = document.getElementById(channelId);
	return channel && channel.className.indexOf("sub") == 0
}

function hasSubChannel(channelId) {
	var sub = document.getElementById(channelId + "Sub")
	var img = document.getElementById(channelId + "Img")
	//alert("hasSubChannel: " + (sub && img ? "yes" : " no"));
	return (sub && img)
}

function hasOpenSubChannel(channelId) {
	var sub = document.getElementById(channelId + "Sub")
	return sub && sub.className.indexOf("_selected") > -1
}

/*This function declares an object*/
function ConstructObject(obj,nest) { 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=  bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css= bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    this.up=MoveAreaUp;
	this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; 
	this.x; 
	this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 

function MoveArea(x,y) { 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
	positionx = this.x
	positiony = this.y
} 
 
function MoveAreaDown(move) { 
	if(this.y>-this.scrollHeight+objContainer.clipHeight) { 
	    this.MoveArea(0,this.y-move) 
	    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	}
	 
	
} 
function MoveAreaUp(move) { 
	if(this.y<0) { 
	    this.MoveArea(0,this.y-move) 
	    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	}

} 


function toggleScrollers(){
    var innerChannelBox = document.getElementById('divInnerChannelBox');
    var channelBox = document.getElementById('channels_box');
    var scrollUpButton = document.getElementById('divScrollUp');
    var scrollDownButton = document.getElementById('divScrollDown');

    if ( innerChannelBox && channelBox ){
		    if (innerChannelBox.offsetHeight > channelBox.offsetHeight){
		  	    scrollUpButton.style.display = "block"
		  	    scrollDownButton.style.display = "block"
			  }else{
			      /*if the top of the innerChannelBox is obscured from view by the outer box keep
			      *the top scrollbutton visible, else hide it.*/
			      if (parseInt(innerChannelBox.style.top) < 0){
			          scrollUpButton.style.display = "block" 
			      }else{
			          scrollUpButton.style.display = "none";
			      }
	
	      scrollDownButton.style.display = "none"
        }
    } 
}

function PerformScroll(speed) { 
	if (typeof objScroller == 'undefined')
		InitialiseScrollableArea(0,0)
	else
		InitialiseScrollableArea(objScroller.x,objScroller.y)
	
	if (initialised) { 
		loop=true; 
		if(speed>0) objScroller.down(speed) 
		else objScroller.up(speed) 
		
	} 
	
		
}
 
function CeaseScroll() {
    loop=false 
    if(timer) clearTimeout(timer) 
} 

var initialised;

function InitialiseScrollableArea(x,y) { 
    objContainer=new ConstructObject('channels_box') 
    objScroller=new ConstructObject('divInnerChannelBox', 'channels_box') 
    objScroller.MoveArea(x,y) 
    objContainer.css.visibility='visible' 
    initialised=true; 
    
    
    
}

/*This function basically only executes a rollover action for non-selected channels*/
function setMouseEvent(channelPos, state) {

	var channelId = "channel" + channelPos;
	//var currArrowPrefix = isOpenBullet(channelId)?"channel_arrow_open":isNonBullet(channelId)?"channel_arrow_none":"channel_arrow";
	var currArrowPrefix = hasOpenSubChannel(channelId)?"channel_arrow_open":isNonBullet(channelId)?"channel_arrow_none":"channel_arrow";
	
  	var currDiv = document.getElementById(channelId)
  	var currGroup = getGroupId(channelId)
  	var prevGroup = getGroupId(prevChannelId)
  	
  	if (currGroup != prevGroup) {
		if (channelId!=prevChannelId && state=='rollover'){
			rolloverImage(channelId + "Img", currArrowPrefix + "_on" );
			currDiv.className = "topChannel_selected";		
		}
		else if (channelId!=prevChannelId && state=='rollout'){
			rolloverImage(channelId + "Img", currArrowPrefix + "_off" );
			currDiv.className = 'topChannel';
		}
	} 
}





var search_and_play = false;
function clearDefaultText(inp) {
	if (inp.value == "") inp.value = '';
}
function submit_search(searchterm, bPlay) {
	if (searchterm) { 
		searchterm = searchterm.replace(/^\s*/,'');
		searchterm = searchterm.replace(/\s*$/,'');
		searchterm = escape(searchterm);
		if (searchterm.length > 0) {

			Admin("loadSearchResults", ['0','0',unescape(searchterm)]);
		
		}
	}
	search_and_play = (bPlay == true);
}
function postLoadSearchResults(displaychl, showNowPlaying) {
	postShowStories(displaychl, showNowPlaying);

	if (search_and_play) {
		AdminAB('playStory',1,['-1','0','search']);
	}
}


 



function init_video() { 


	mvideo = document.getElementById('wmPlayer');
	init_slider();

	if (initXtr++ > 1) return;
	AdminAB('playStory',1,['-1','0','2b905805e460e32d556889a31656850d4d58b392','41e62d9f52cef15633b67c128a7bedcca16f66be','false','false']);
}

var mvideo;



var hasBeenPaused = 'false';
var sync_type = 0;

var bvVideo = false;
var swf_file_1 = null;
var bInstreamMeta = false;
var bLongVideo = false;
var iVcount = 0;
var itemQrep = "";
var flashURL;
var syncUrl = null;
var lockAd = false;

var curIdx = -1;
var adBegin_tag = "";
var adEnd_tag = "";
var timeLabel = "";
var bGeoLocationRestriction = false;

var STATE_STARTING_FLASH          = 0; 
var STATE_FLASH_ENDED             = 1; 
var STATE_VIDEO_AD_ENDED          = 2; 
var STATE_VIDEO_CONTENT_ENDED     = 3; 
var STATE_VIDEO_CONTENT_STARTED   = 4; 

var adKeywords = "";


function refreshBanner() {


  if ( (sync_type==2 && lockAd) || sync_type==3 )
    return false;
  else
    return true;

}

function syncAds(state) {



  
  
  if (isNaN(state)) return;


  switch(state) {
    case STATE_STARTING_FLASH: 
      switch(sync_type) {
        case 0:
          manageRHS(false);
          break;
        case 1:
        case 2:
        case 3:
        case 4:
          manageRHS(true);
          break;
      }
      break;
    case STATE_FLASH_ENDED: 
      switch(sync_type) {
        case 1:
          manageRHS(false);
          break;
        case 11:
        case 12:
        case 13:
          manageRHS(true);
          break;
      }
      break;
    case STATE_VIDEO_AD_ENDED: 
      switch(sync_type) {
        case 2:
        case 11:
          manageRHS(false);
          break;
      }
      break;
    case STATE_VIDEO_CONTENT_ENDED: 
      switch(sync_type) {
        case 3:
        case 12:
          manageRHS(false);
          break;
      }
      break;
    case STATE_VIDEO_CONTENT_STARTED: 
      switch(sync_type) {
        case 1:
          manageRHS(false);
          break;
      }
      break;
  }
    
  if (state == sync_type)
    execSessionEraser('clearAdKeyword');
  if (state == STATE_VIDEO_AD_ENDED) lockAd = false;
  

  
  
}


var pingCount = 0;

var pingInterval = 5;
var bufferPingCount = 0;
var currentMedia = '';
function doRefresh() {
  if (bLongVideo || !mvideo.controls.isAvailable('Pause')) {
    try {
      ifrHlp2.replace('null/blank.jsp?r=600&nsid=a-2b20490e:12af3a2a1c5:-28d0')
    
    } catch (err) {}
  }
  //pingCount = 0;
}

var lastMediaName = 'none';
function flDurationTracker(curPos, curMediaName) {
  pingCount += 1; 
  if (curMediaName != lastMediaName){
    pingCount = 1;
    lastMediaName = curMediaName;
  }
  
  var band = "";
  if (pingCount == 1) band = "&band="+(isBB?"BB":"NB");
  if (curMediaName != undefined && curMediaName.indexOf("Video") > 0) {
    setTimeout('ping("duration", "&m='+curMediaName+'&cpos='+curPos+'&dr='+pingInterval+'&cgt='+pingCount+'&cid='+currentChannel_uoi_id+'&sid='+currentStory_uoi_id+band+'");',0);
  }
}
function durationTracker(curPosition) {
  if (mvideo.playState == 3){ 
    clearTimeout(lPingTimer);
    pingCount += 1;
    var band = "";
    if (pingCount == 1) band = "&band="+(isBB?"BB":"NB");
    if (curPosition == undefined) {
      try {
        curPosition = parseInt(mvideo.controls.currentPosition);
      } catch (pErr) {

        curPosition = -1;
      }
      if (currentMedia != undefined && currentMedia.indexOf("Video") > 0) {
        ping("duration", "&m="+currentMedia+"&cpos="+curPosition+"&dr="+pingInterval+"&cgt="+pingCount+"&cid="+currentChannel_uoi_id+"&sid="+currentStory_uoi_id+band);
      }
      lPingTimer = setTimeout("durationTracker()", pingInterval*1000);
    } else {
      ping("duration", "&m="+currentMedia+"&cpos="+curPosition+"&dr="+pingInterval+"&cgt="+pingCount+"&cid="+currentChannel_uoi_id+"&sid="+currentStory_uoi_id+band);
    }
  } else if (mvideo.playState > 3) {// transitioning or buffering
    lPingTimer = setTimeout("durationTracker()", 250);
  }
}
function pauseDurationTracker() {
  clearTimeout(lPingTimer);
}

function setPlayingMediaInfo(itemInfo) {
  currentMedia = itemInfo;
}

function getBufferingStatus() {
  bufferPingCount += 1;
  if (mvideo.network.bufferingProgress > 0) {


  } else {


  }
  return true;
}

var pxUrl = null;

function pingPxUrl() {
  if (pxUrl != null) {
    setTimeout("loadUrl('"+pxUrl+"')",0);
    pxUrl = null;
  }
}

var cookieUrl = null;

function pingCookieUrl() {
  if (cookieUrl != null) {
    setTimeout("loadUrl('"+cookieUrl+"')",0);
    cookieUrl = null;
  }
}


function loadUrl(link) {

  try {
    if (link.indexOf('javascript:') == 0) {
      eval(link);
    } else if (link.length > 0) {
      _tag = document.getElementById('trkTag');
      if (_tag) _tag.src = link;
    }
  } catch (er) {

  }
}

function doEntryCheck(idx) {
  if (curIdx != idx) {
    if (idx == 1 && adBegin_tag.length > 5) {
      _tag = document.getElementById('trkTag');
      _tag.src = adBegin_tag;
    } else if (curIdx == 1 && idx == 2 && adEnd_tag.length > 5) {
      _tag = document.getElementById('trkTag');
      _tag.src = adEnd_tag;
    }
    curIdx = idx;
  }
}


var qsForNext = null;
var qsNames = [ 'cp', 'pcnt', 'cid', 'sid' ];
var qsVals = null;
function pingNextStory() {
  if (qsForNext != null) {
    
    qsVals.splice(0,0,playChannel)
    qsVals.push(currentChannel_uoi_id)
    qsVals.push(currentStory_uoi_id)
    for (var t=0; t<qsNames.length && t<qsVals.length; t++ ) qsForNext+='&'+qsNames[t]+'='+qsVals[t];
    qsForNext += nsParam + skinParam;
    ping('playNextStory', qsForNext)
    qsForNext = null;
  }
}

function playNextStory(bResetCount) {
  
    syncAds(STATE_VIDEO_CONTENT_ENDED);// sync frame
    
  
    if (bMax) {
      ScaleVideo();
    }
  
    iPC = bResetCount ? "&pcnt=0" : "";
    if (iPt == 0) {
      Admin('playNextStory',[ playChannel, (bResetCount ? 0 : ""),currentChannel_uoi_id, currentStory_uoi_id,true]);
    
    qsForNext = "";
    qsVals = [ (bResetCount ? 0 : "") ];
    }
}

function playPreviousStory(bResetCount) {
  var bPlayPrevious = true;
  
    syncAds(STATE_VIDEO_CONTENT_ENDED);// sync frame
    
  
    if (bMax) {
      ScaleVideo();
    }
  
    iPC = bResetCount ? "&pcnt=0" : "";
    Admin('playPreviousStory',[ playChannel, (bResetCount ? 0 : ""), bPlayPrevious, currentChannel_uoi_id, currentStory_uoi_id]);
    
    qsForNext = "";
    qsVals = [ (bResetCount ? 0 : "") ];
}

var resume=0;
var videoMedia = false;
var readyFor = null;
var readyForAd = null;
var isUpdated = false;
var lRefreshTimer = 0;
var lPingTimer = 0;
var lDurationTimer = 0;

function goplayVideo() {
  // Clear any timeouts and vars from previous content requests
  clearTimeout(lRefreshTimer);
  // Clear pinging stuff
  clearTimeout(lPingTimer);
  clearTimeout(lDurationTimer);
  pingCount = 0;
  isUpdated = false;
  readyFor = null;
  readyForAd = null;
  lastMediaName = 'none';
  lockAd = xtraVideoFlag;
  
  
  ResetAutoRewind();
  
  //checkMute = true; // 09/06/2005 - removed to prevent resetting volume each story
  curIdx = -1; // Current entry index
  if (iPt != 2) {

  if (!bMax) {
    updateUI();
  }

  }


  mvideo.error.clearErrorQueue();
  OpenVideo("null/ModPlaylist_asx.jsp?vc="+iVcount + "&iPt=" + iPt + itemQrep + nsParam);
  hide_slider();
  
  hide_duration();

  syncAds(STATE_STARTING_FLASH);// sync frame


  

  itemQrep = "";
}

function updateUI() {
  if (!isUpdated) {

    extra = (bInstreamMeta && true)? "?instream=true" : "";

      if (hasChannelStateChanged == 'true') { 
        Admin('showStories', [displayChannelStart,displayChannelEnd,currentChannel_uoi_id], [playChannel, 'true']);
      } 
      setNowPlaying(playStory);
      if (bGeoLocationRestriction) resetNowPlaying();
      if (btDone) AdminAB('loadBodyText',0,[currentStory_uoi_id]);
      if(!bPlayVideo) PausePlayVideo();
      isUpdated = true;
      
       setDurationDisplay("00:00");
      
    isUpdated = true; 
  
    lRefreshTimer = setTimeout('doRefresh()',15000); // check for live
  }
}


function setDurationDisplay(p_duration) {
  if(mvideo.currentMedia && mvideo.playState == 3 && mvideo.controls.currentPosition > 0){
    clearTimeout(lDurationTimer);
    var durationDisplay = document.getElementById('duration_display');
    if (durationDisplay) {
      durationDisplay.innerHTML = p_duration;
    }
  } else {
    lDurationTimer = setTimeout("setDurationDisplay('"+p_duration+"')",250);
  }
}


function setDurationCounterDisplay(p_duration) {
  var durationCounterDisplay = document.getElementById('duration_counter_display');
  if (durationCounterDisplay) {
    durationCounterDisplay.innerHTML = p_duration;
  }
}



function readyVideo() {
  if (readyFor != null && mvideo.currentMedia.isIdentical(readyFor)) { // only once for the clip
    return;
  } else {      
    readyFor = mvideo.currentMedia;
        
    lockAd = false;
    clearTimeout(lPingTimer);
    pingPxUrl(); 
    pingCookieUrl();
    pingCount = 0;
    lPingTimer = setTimeout('durationTracker()',0); // want to start straight away to track video

    stayStopped = 0;
  
    var minutes = Math.floor(mvideo.currentMedia.duration/60);
    var seconds = Math.floor((mvideo.currentMedia.duration%60))
    var hours = Math.floor(minutes / 60);
    minutes = minutes % 60;
    if(seconds <10){
      seconds = "0"+seconds;
    }
    if(minutes<10){
      minutes = "0"+minutes;
    }
    setDurationDisplay((hours > 0 ? hours+":" : "") + minutes+":"+seconds);
  
    
    if (bInstreamMeta) AdminAB('loadBodyText',0,[currentStory_uoi_id]);

    
    if (mvideo.controls.isAvailable('Pause') || mvideo.currentMedia.duration > 0) {
      if (mvideo.currentMedia.getItemInfo("theTitle").indexOf("endslate") < 0) {
        videoMedia = true;
        duratio = readyFor.duration;
        show_slider();
        
        show_duration();
        DragLayer.resume();
        DragLayer.dragIt(duratio);
        
      } else { 
        hide_duration();
      }
    } else {
      clearTimeout(lDurationTimer);
      setDurationCounterDisplay("LIVE");
      setDurationDisplay("LIVE");
      show_duration();
      hide_slider();
    }

    // sync frame
    if (iVcount == 2) 
      syncAds(STATE_VIDEO_AD_ENDED)
    else 
      syncAds(STATE_VIDEO_CONTENT_STARTED);

  
  
  }
}

function readyVideoAd() {
  if (readyForAd != null && mvideo.currentMedia.isIdentical(readyForAd)) { // only once for the clip
    return;
  } 

  clearTimeout(lPingTimer);
  pingPxUrl(); 
  pingCookieUrl();
  pingCount = 0;
  lPingTimer = setTimeout('durationTracker()',0); // want to start straight away to track videoAd

  readyForAd = mvideo.currentMedia;


  setDurationDisplay(mvideo.currentMedia.durationString);
    

  show_duration();
  show_slider();
  DragLayer.resume();
  DragLayer.dragIt(mvideo.currentMedia.duration);


  syncAds(STATE_FLASH_ENDED);// sync frame
  setTimeout("doEntryCheck(1)",300);

}



function click_tracker(args) {

}
function PlayVideo() {

    mvideo.controls.Play();
    bPlayVideo = true;

}
function RestartVideo() {

  if (mvideo.currentMedia.getItemInfo("theTitle").indexOf("endslate") == 0) {
    if (mvideo.controls.isAvailable('Previous')) mvideo.controls.previous();
    setDurationCounterDisplay("00:00");
    DragLayer.moveIt(DragLayer.start);
    SlideVideo(0.01);
    setTimeout("PlayVideo()", 400) 
  } 
  
  else if (mvideo.currentMedia.getItemInfo("theTitle").indexOf("interstitial") != 0 && mvideo.currentMedia.getItemInfo("theTitle").indexOf("xtraVideo") != 0) {
    setDurationCounterDisplay("00:00");
    DragLayer.moveIt(DragLayer.start);
    SlideVideo(0.01);
    setTimeout("PlayVideo()", 400) 
  }

}

function StopVideo() {

  mvideo.Stop();

}

pI=0;
function PauseVideo() {

    if (mvideo.controls.isAvailable('Pause')) {
        mvideo.controls.pause();
      bPlayVideo = false;
    } else if (mvideo.PlayState >= 6) {
      pI = pI + 1;
        if (pI < 10) setTimeout("PauseVideo(pI)",100);
        else pI = 0;
    }

}

function OpenVideo(vsrc) {
    //avoid caching
    if (vsrc.indexOf('?') > 0) {
        vsrc = vsrc + "&ord=" + Math.random()*100000;
    }else{
        vsrc = vsrc + "?ord=" + Math.random()*100000;
    }

    mvideo.URL = vsrc;
    videoMedia = false;
    PlayVideo();

}

function MaxVideo() {

    mvideo.fullScreen = 'true';

}

function SetVolVideo(p_vol) {

  if (p_vol > 100)
    p_vol = 100;
  if (p_vol < 0)
    p_vol = 0;
  mvideo.settings.volume = p_vol;
  
  

   if (!checkMute) videoMute();

}

function VolUpVideo() {

        var Volume = mvideo.settings.volume;
        if (Volume < 100) {
        Volume += 10;
            if (Volume > 100) Volume = 100;
        }
        mvideo.settings.volume = Volume;

        if (!checkMute) videoMute();

}

function VolDownVideo() {

        var Volume = mvideo.settings.volume;
        if (Volume > 0) {
        Volume -= 10;
            if (Volume < 0) Volume = 0;
        }
        mvideo.settings.volume = Volume;

        if (!checkMute) videoMute();

}

var bMute = false;
function MuteVideo(_state) {
    bMute = _state;
    
        if (!_state) {
            mvideo.settings.mute = false;
        } else if (_state) {
            mvideo.settings.mute = true;
        }
    
    changeImage('muteImg','_off');
    
    var volLevel = (_state)? 0 : mvideo.settings.volume;
    setVolSlider(volLevel);
    
}


function ClickVideo() {
 // see if it's full screen

    if (mvideo.fullScreen) {
          mvideo.fullScreen = "false";
    } else {

    //if (mvideo.currentMedia.getItemInfo("theTitle") == "interstitial") return;


      if (mvideo.currentMedia.getItemInfo("theTitle") != "xtraVideo" && mvideo.currentMedia.getItemInfo("theTitle") != "theVideo") return;
  
    // not full screen
    if (bvVideo) { // boolean for double video
      providerURL = mvideo.currentMedia.getItemInfo("ClickUrl");
      if (null == providerURL) providerURL = "";
    }
    if (providerURL.length > 4) { // most URLs are longer than 4 chars
    
			window.open(providerURL);
    
    }
  }
    
}







var winDivRescaled = false;

function imageSwap(target, style) {
	changeImage(target,style);
}

function changeImage(target,style){
	if (target=="pausePlayImg"){
		style = (bPlayVideo) ? "pause"+style : "play"+style;
	} else if (target=="muteImg"){
		style = (bMute)? "unmute"+style:"mute"+style;
	} else if (target=="bandImg"){
		style = (!isBB)? "low"+style:"high"+style;
	}
	replaceImageById(target, style)
}

var isBB = false;
function bwMouseHandler(p_target, p_style) {
	var style = p_style;
	if (isBB) {
		if (p_target == "highBandImg") {
			style = "high_over";
		}
	} else {
		if (p_target == "lowBandImg") {
			style = "low_over";
		}
	}
	changeImage(p_target, style);
}

function changeBand(bReplay,band){



    if (band == undefined || isBB != (band=='BB')) {
		isBB = !isBB;


		if (isBB){
			changeImage("highBandImg", "high_over");
			changeImage("lowBandImg", "low_off");
			document.getElementById('highBandImg').alt = '';
			document.getElementById('highBandImg').title = '';
			document.getElementById('lowBandImg').alt = 'Switch to low band';
			document.getElementById('lowBandImg').title = 'Switch to low band';
			document.getElementById('lowBandImg').style.cursor = "pointer";
			document.getElementById('highBandImg').style.cursor = "default";
	    }else{
			changeImage("highBandImg", "high_off");
			changeImage("lowBandImg", "low_over");
			document.getElementById('highBandImg').alt = 'Switch to high band';
			document.getElementById('highBandImg').title = 'Switch to high band';
			document.getElementById('lowBandImg').alt = '';
			document.getElementById('lowBandImg').title = '';
			document.getElementById('lowBandImg').style.cursor = "default";
			document.getElementById('highBandImg').style.cursor = "pointer";
		}
		

		if (bReplay) Admin('playSameStory', ['true', 'true', currentChannel_uoi_id, currentStory_uoi_id,isBB]);
	}
	
}

var checkMute = true;
function videoMute(){

  


  if (videovideo){
    if (checkMute){
        MuteVideo(true);
        document.getElementById('muteImg').alt = 'Play audio';
        document.getElementById('muteImg').title = 'Play audio';
    }else{
        MuteVideo(false);
        document.getElementById('muteImg').alt = 'Mute audio';
        document.getElementById('muteImg').title = 'Mute audio';
    }
    checkMute = !checkMute;

  }
}

var bPlayVideo = true;
function PausePlayVideo(){
        
    if (bPlayVideo){
	    if (mvideo.controls.isAvailable('Pause') && mvideo.currentMedia.getItemInfo("theTitle").indexOf("endslate") < 0) { 
        	PauseVideo();
	        changeImage("pausePlayImg", "_off");
	        document.getElementById('pausePlayImg').className = 'play_off';
	        document.getElementById('pausePlayImg').alt = 'Click to play';
	        document.getElementById('pausePlayImg').title = 'Click to play';
	        pauseDurationTracker();
	    }
    } else {
        PlayVideo();
        changeImage("pausePlayImg", "_off");
        document.getElementById('pausePlayImg').className = 'pause_off';
        document.getElementById('pausePlayImg').alt = 'Click to pause';
        document.getElementById('pausePlayImg').title = 'Click to pause';
        durationTracker();
    }
}

function ForcePauseVideo() {
	if (mvideo.controls.isAvailable('Pause') && mvideo.currentMedia.getItemInfo("theTitle").indexOf("endslate") < 0) { 
    	PauseVideo();
	    changeImage("pausePlayImg", "_off");
	    document.getElementById('pausePlayImg').className = 'play_off';
	    document.getElementById('pausePlayImg').alt = 'Click to play';
	    document.getElementById('pausePlayImg').title = 'Click to play';
	    pauseDurationTracker();
	}
}

var pausePlayFunc = null
var rewindFunc = new Function('RewindVideo();return false;');
function AutoRewind() { 
	hide_duration();
	hide_slider();
	
	resetNowPlaying();
	highlightNowPlaying=false;
	
	bPlayVideo = false;
    changeImage("pausePlayImg", "_off");
    document.getElementById('pausePlayImg').className = 'play_off';
    document.getElementById('pausePlayImg').alt = 'Click to play';
    document.getElementById('pausePlayImg').title = 'Click to play';
	pausePlayFunc = document.getElementById('pausePlayLink').onclick;
	document.getElementById('pausePlayLink').onclick = rewindFunc
}


function RewindVideo() {
	show_duration();
	show_slider();
	document.getElementById('pausePlayLink').onclick = pausePlayFunc;
	bPlayVideo = true;
	
	highlightNowPlaying=true;
	setNowPlaying(currentPlaying);
	
	changeImage("pausePlayImg", "_off");
	document.getElementById('pausePlayImg').className = 'play_off';
	document.getElementById('pausePlayImg').alt = 'Click to pause';
	document.getElementById('pausePlayImg').title = 'Click to pause';
	RestartVideo();
}

function ResetAutoRewind() {
	if ((document.getElementById('pausePlayLink').onclick == rewindFunc)) {
		bPlayVideo = true;
		changeImage("pausePlayImg", "_off");
		document.getElementById('pausePlayImg').className = 'play_off';
		document.getElementById('pausePlayImg').alt = 'Click to play';
		document.getElementById('pausePlayImg').title = 'Click to play';
		document.getElementById('pausePlayLink').onclick = pausePlayFunc;
	}
}

var showInfoWinSession = true; //to display info on how to get back from the full screen mode set on server side
var showInfoWinClient = true;  //this is set on the client side
function VCommand(vcommand) {

    

    //special case for Max
if (videovideo){

    if (mvideo.playState == 3){

        if (vcommand.indexOf("Max")>=0 && showInfoWinSession && showInfoWinClient ) {  //check if already shown?
            //check if cookie is set
            if (document.cookie.indexOf("FullScreenInfoShown") == -1 ){
                winPopup('null/ModVideoControlsMax_dsp.jsp?nsid=a-2b20490e:12af3a2a1c5:-28d0','FullScreen',420,90,0,0,0,0,false);
            }else {
                showInfoWinClient = false;
                eval(vcommand + "Video()");
            }
        }else {
            eval(vcommand + "Video()");
        }
    }
 } 
}


var DragLayer;
var SliderFill;

var dodrag = 0;

function dragObj(obj){
    this.css=document.getElementById(obj).style;
	this.entity=document.getElementById(obj);	
	this.x=this.css.pixelLeft;
	this.moveIt=b_moveIt;
	this.init=b_init;
	this.drag=false;
	this.clickedX=0;
	this.dragIt=b_interval;
	this.dragPause=1000;
	this.start=0;
	this.pos=0;
	this.end=100;
	this.pause=b_pause;
	this.resume=b_continue;
	replaceImage(this.entity, "#" + this.entity.id) 
	return this;
}

function fillObj(obj) {
	this.css = document.getElementById(obj).style;
	return this;
}

function moveItSlowly(){
	if (mvideo.playState == 3 && !DragLayer.drag){
		_vp = mvideo.controls.currentPosition;
		_vd = mvideo.currentMedia.duration;
		
		DragLayer.pos = parseInt((_vp/_vd)*(DragLayer.end-DragLayer.start)) + DragLayer.start;
		if (DragLayer.pos<DragLayer.end){	 
			DragLayer.moveIt(DragLayer.pos);
			
 
			SliderFill.css.width = DragLayer.pos-DragLayer.start
			
			dodrag = setTimeout('moveItSlowly();',DragLayer.dragPause);
		}
	} else {
		setTimeout('moveItSlowly();',1000);
	}
	
}
var seconds=0;
var minutes=0;
var hours=0;
var sprefix;
var mprefix;
var hprefix;

function updateTime(){
	if (mvideo.playState == 3 && !DragLayer.drag){
		_vp = mvideo.controls.currentPosition;
		_vd = mvideo.currentMedia.duration;
		hprefix = (hours > 0) ? hours + ":" : "";
		mprefix = (minutes < 10)?"0":"";
		sprefix = (seconds < 10)?"0":"";
		
		if (mvideo.currentMedia.getItemInfo("theTitle").indexOf("endslate") != 0) {
			if (mvideo.controls.isAvailable('Pause')) {
				setDurationCounterDisplay(hprefix + mprefix + minutes + ":"+ sprefix + seconds);
			} else {
				setDurationCounterDisplay("LIVE");
            	setDurationDisplay("LIVE");
        	}
        }
		seconds = parseInt( _vp%60);
		minutes = parseInt(_vp/60);
		hours = Math.floor(minutes / 60);
		minutes = minutes % 60;
		setTimeout('updateTime();',1000)
	} else {
		setTimeout('updateTime();',1000)
	}
}

function show_duration(){
	document.getElementById("duration_counter_display").style.display="block";	
	document.getElementById("duration_default").style.display="none";	
}

function hide_duration(){	
	document.getElementById("duration_counter_display").style.display="none";
	document.getElementById("duration_default").style.display="block";
	
}


function b_interval(i) {
	if (i <= 0) i=0;
	DragLayer.dragPause = parseInt(i*3.3);
	moveItSlowly();
	
	updateTime();

	
}
function b_pause() {
	clearTimeout(dodrag);
}
function b_continue(i) {
	moveItSlowly();
	
	updateTime();

}
function b_init() {
	clearTimeout(dodrag);
	DragLayer.moveIt(DragLayer.start);
	DragLayer.pos=DragLayer.start;
}
function b_moveIt(x){
	this.x=x; 
	this.css.left=this.x;
}
function mmover(e){
	DragLayer.isOver=true;
}
function mmout(e){
	DragLayer.isOver=false;
}
function mup(){
    
    if(DragLayer.drag){
		DragLayer.drag=false;
		DragLayer.pos = DragLayer.x;
		ii = (DragLayer.x+1-DragLayer.start)/(DragLayer.end-DragLayer.start)*(DragLayer.dragPause/3.3);
		SlideVideo(ii);
		if (!bPlayVideo) PausePlayVideo();
	}
}
function mdown(){
    
	if(DragLayer.isOver && mvideo.controls.isAvailable("currentPosition")) {
		clearTimeout(dodrag);
		x=event.screenX;
		DragLayer.drag=true;
		DragLayer.clickedX=x-DragLayer.x;
		if (bPlayVideo) PausePlayVideo();  
	}
}
function mmove(e){
    
    x=event.screenX - DragLayer.clickedX
	if((DragLayer.drag)&&(x>=DragLayer.start)&&(x<=DragLayer.end)){
		DragLayer.moveIt(x);
	}
	return false;
}

function SlideVideo(pos) {
	mvideo.controls.currentPosition = pos;
	resume=pos;
}

function resumeSlider() {
	if (resume > 0) {
		DragLayer.resume();
		resume=0;
	}
}

function show_slider() { 
	DragLayer.css.visibility = "visible";
	SliderFill.css.visibility = "visible";
}

function hide_slider() { 
	DragLayer.css.visibility = "hidden";
	SliderFill.css.visibility = "hidden";
	
}



var VolLayer;
var VolFill;
var VolBg;
var voldrag = 0;

function volmover(e){
	VolLayer.isOver=true;
}
function volmout(e){
	VolLayer.isOver=false;
}

function setVolSlider(p_vol) {
	var pos = (p_vol / 100) * (VolLayer.end - VolLayer.start);
	pos += VolLayer.start;
	VolLayer.moveIt(pos);
}

function volmup(){
	if(VolLayer.drag){
		VolLayer.drag=false;
		VolLayer.pos = VolLayer.x;
		ii = Math.round((VolLayer.x-VolLayer.start)/(VolLayer.end-VolLayer.start)*100);
		SetVolVideo(ii);
	}
}
function volmdown(){
	if(VolLayer.isOver) {
		x=event.screenX
		VolLayer.drag=true;
		VolLayer.clickedX=x-VolLayer.x;
	}
}
function volmmove(e){
    

    x=event.screenX - VolLayer.clickedX
	if((VolLayer.drag)&&(x>=VolLayer.start)&&(x<=VolLayer.end)){
		VolLayer.moveIt(x);
		ii = Math.round((VolLayer.x-VolLayer.start)/(VolLayer.end-VolLayer.start)*100);
		SetVolVideo(ii);
	}
	return false;
}


function init_slider(){
	SliderFill = new fillObj('slider_fill'); 
	DragLayer=new dragObj('slider');
	DragLayer.entity.onmouseover=mmover;
	DragLayer.entity.onmouseout=mmout;	
	DragLayer.entity.onmousedown=mdown;
	DragLayer.entity.onmouseup=mup;
	DragLayer.entity.onmousemove=mmove;
	DragLayer.init();
	
	
	SliderBG = document.getElementById("slider_bg");
	DragLayer.start=SliderBG.offsetLeft
	DragLayer.end=SliderBG.offsetLeft+SliderBG.offsetWidth-DragLayer.entity.offsetWidth
	DragLayer.pos=DragLayer.start
	SliderFill.css.left=DragLayer.start+2
	
	
	
	VolFill = new fillObj('vol_fill'); 
	VolLayer=new dragObj('volslider');
	VolLayer.entity.onmouseover=volmover;
	VolLayer.entity.onmouseout=volmout;	
	VolLayer.entity.onmousedown=volmdown;
	VolLayer.entity.onmouseup=volmup;
	VolLayer.entity.onmousemove=volmmove;
	VolLayer.init();
	
	
	VolBG = document.getElementById("vol_bg");
	VolLayer.start=VolBG.offsetLeft + 3;
	VolLayer.end=VolBG.offsetLeft+VolBG.offsetWidth-VolLayer.entity.offsetWidth - 6;
	VolLayer.pos=VolLayer.start;
	VolFill.css.left=VolLayer.start+2;
	
	
	
	var playerVolume = 50;
	mvideo.settings.volume = playerVolume;
	if (playerVolume == 0)
		videoMute();
	else
		setVolSlider(mvideo.settings.volume);	
	
	
	replaceImage(SliderBG, "#SliderBG") 
	replaceImage(document.getElementById("duration_counter_display"), "#duration_counter_display");
	
}









function reboot() {
	window.location.href = "null/?" + skinParam + dbgParam;
}
function getLocation(id) {
	var locRef = null;
	var iRef = document.getElementById(id);
	if (iRef) {
		locRef = iRef.contentWindow ? iRef.contentWindow : frames[id];
	}
	return locRef
}
function JumpUI() {
	window.scrollTo(0,0); 
}
function exit(){
	calcReportingParams(true, true); 
}
function loadLocations() {

		ifrAction = getLocation('ifr_actionBox')
	ifrHlp2 = getLocation('ifr_helper2')
}



var initXtr = 0; 
var ifrHlp2 = null; 

var ifrAction = null;


function summonJsFragment(jsFragUrl) {
	var incJS = document.createElement('script');
	incJS.setAttribute('language', 'javascript');incJS.setAttribute('type', 'text/javascript');incJS.setAttribute('src', jsFragUrl);
	incJS.onload = function () {incs[incs.length] = true;}
	incJS.onreadystatechange = function () {	if(incJS.readyState == 'loaded') {incs[incs.length] = true;}	}
	document.getElementsByTagName('head').item(0).appendChild(incJS);
}
var incs=new Array();
var mxCntr=20;
var currCntr=0;
function spinUntilLoaded(iMustLoad) {
	if (incs.length < iMustLoad && ++currCntr < mxCntr) {
		setTimeout('spinUntilLoaded('+iMustLoad+')', 200);
	} else {
		sniffer();
	}
}


function loadIncludes() {
	
	summonJsFragment('null/include/dispatcher.jsp?nsid=a-2b20490e:12af3a2a1c5:-28d0');

	
	summonJsFragment('null/include/helper.jsp?nsid=a-2b20490e:12af3a2a1c5:-28d0');

	
	summonJsFragment('null/include/funcMouseOver.jsp?nsid=a-2b20490e:12af3a2a1c5:-28d0');

	

	// pass the number of expected loads
	spinUntilLoaded(3);
}
//************************************************************************
// Client side sniffer
//************************************************************************
function sniffer() {

	buffer_components();

}




function buffer_components() {
	document.getElementById("divWrapper").style.visibility="visible";
	var file_request = getXmlHttp()
	file_request.open("GET", "null/components.jsp?"+nsParam, true);
	file_request.onreadystatechange = function() { 
		if (file_request && file_request.readyState == 4) {
			if (file_request.status == 200) {
				var rcvd = getResponseText(file_request); 
				var wrapper = document.getElementById("divWrapper");
				wrapper.innerHTML=rcvd;
				setTimeout("check_embed();",100);
			}
		}
	}
	file_request.send(null);
}


var embed_methods = { "FLV" : embed_FLV, "WMP" : embed_WMP };
var embed_ids = { "FLV" : "flvPlayer", "WMP" : "wmPlayer" };
function check_embed() { 

	var missing = "";
	

	if (player == 'WMP' && false) {
		missing += "w"; 
	}
	if (missing != "") {
		location.replace("null/notenabled.jsp?miss=" + missing + nsParam + skinParam);
	} else {
		embed_methods[player]();
	}
	

}

function embed_FLV() {
	var so = new SWFObject("null/flvPlayer.swf?517051.10583296797", 
                          embed_ids[player], "100%", 
                          "100%", 
                          "7", 
                          "#000000", 
                          true, 
                          "high",
                          null,
                          "null/notenabled.jsp");
   
  // DO NOT CONFUSED allowFullScreen in info skins( clientname_info.jsp)                             
	so.addParam("allowFullScreen", "true"); 
	so.addParam("menu", "false");
	
	
	so.addVariable("baseURL", "null/");
	so.addVariable('stype', 'bms')
	
	
	
	so.addVariable("nsid", "a-2b20490e:12af3a2a1c5:-28d0");
	so.addVariable("autoplay", "true");
	so.addVariable("sigid", "null");
	var fd = document.getElementById("flashDiv");
	fd.onload=new function() { init(); }
	so.write("flashDiv");

}
function embed_WMP() {	
	var myObject = document.createElement('object');
	var winDiv = document.getElementById("winDiv");
	try {
		winDiv.appendChild(myObject);
		myObject.id = embed_ids[player]
		myObject.standby = "Loading Windows Media Player"
		myObject.codebase= "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,5,0803";

		myObject.classid= "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"; 
		myObject.width = "100%";
		myObject.height = "100%";
		myObject.autoStart = "1";
		myObject.enableContextMenu = "0";
		myObject.stretchToFit = "1";
		myObject.uiMode = "none";
		myObject.volume = "60";
		myObject.windowlessVideo = "0";
		myObject.onload = new function() { init() }
		
	} catch (e) {
		
	}
}


function init() {
	if (initXtr > 0) return;
	loadLocations();
	initXtr++; 
	init_rpt();
	announce('enter');
	init_flashLSO();
	bootstrap(1);
}


var btCtr = 0;
var btDone = false;
function bootstrap(x) {
	if (btDone) return;
	try {
		if (initXtr > 0 && x != 0) {
			btDone = true;
			setTimeout("Admin('bootstrap')", 0);
		} else if (btCtr < 5) {
			
			btCtr++;
			setTimeout('bootstrap(1)',500);
			
		}
	} catch (err) {}
}

loaded = 1;



