

 






var nsParam = '&nsid=a-30ee253c:12516d09520:1b97';  
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:1b97';


	


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 += "&fr_puid=112109_100951620_w30ee253cx12516d09520x1a64";qstr += "&site=erepublic";qstr += "&nsid=a-30ee253c:12516d09520:1b97";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-30ee253c:12516d09520:1b97"+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 = "true";
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 = ['divStories','divStoriesNav','divChannels','divChannelDisplay','ifr_adBox','ifr_adSponsor','ifr_adSky','divSearch','divSendVideo','divHelp','divBookmark','divMasthead','ifr_actionBox','divRss','divEmbedNatalie','divSponsoredVideos','divRateThis','divCustom','divPlayer'];
	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 += "erepublic";
	}
	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 = 'http://www.govtech.com/gt/video/';
		
		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",780+20,785+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=3;
var scrollSpeed=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="";

var doscroll = 0;
var VScrollBar;
var VScrollHandle;


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) {
		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) {
			initVerticalScroller();
			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";
	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);
		setTimeout('moveBar()',50); 
	}
}

function closeGroup(groupId) {
	var subchans = document.getElementById(groupId + "Sub")
	if (subchans) {
		subchans.className = "subChannelContainer"
		closeBullet(groupId)
		setTimeout('moveBar()',50); 
	}
}

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")
	return (sub && img)
}
function hasOpenSubChannel(channelId) {
	var sub = document.getElementById(channelId + "Sub")
	return sub && sub.className.indexOf("_selected") > -1
}

function initVerticalScroller() {
	VScrollBar = document.getElementById("verticalScrollBar");
	VScrollBar.onclick=scrollbarclick;

	VScrollHandle=new dragObj2('verticalScrollHandle');
	VScrollHandle.entity.onmousedown=scrollmdown;
	VScrollHandle.entity.onmouseover=scrollmover;
	VScrollHandle.entity.onmouseout=scrollmout;	
	VScrollHandle.entity.onmouseup=scrollmup;
	VScrollHandle.entity.onmousemove=scrollmmove;
	VScrollHandle.init();	
	VScrollHandle.start=0;
	VScrollHandle.end=VScrollBar.offsetHeight-VScrollHandle.entity.offsetHeight;
	VScrollHandle.pos=VScrollHandle.start;
}

function getScrollHeight() {
	return objScroller.clipHeight - objContainer.clipHeight;
}

function scrollbarclick(e) {
	if (!VScrollHandle.drag&&!VScrollHandle.isOver) {
		var offsetTop = document.getElementById("channels_box").parentNode.offsetTop+this.offsetTop;
  		y=(e? e.clientY : event.clientY);
  		y = y-offsetTop;
  		
  		var scrollHeight = getScrollHeight();
  		if (scrollHeight<0&&y>VScrollHandle.y) return;
  		
		// If click below the handle, adjust the click position
		if (e&&y>VScrollHandle.y)
			y=y-VScrollHandle.height;
		else if (!e&&y>VScrollHandle.y) {
			y=y-VScrollHandle.height;
		}
		
		VScrollHandle.moveIt(y);
	}
}

function dragObj2(obj){
  this.css=document.getElementById(obj).style;
	this.entity=document.getElementById(obj);
	this.y=this.css.pixelTop;
	this.moveIt=scroll_moveIt;
	this.height=document.getElementById(obj).offsetHeight;
	this.init=scroll_init;
	this.drag=false;
	this.clickedY=0;
	this.dragIt=scroll_interval;
	this.dragPause=0;
	this.start=0;
	this.pos=0;
	this.end=100;
	this.pause=scroll_pause;
	this.active=false;
	return this;
}

function scroll_interval(i) {
	if (i <= 0) i=0;
	VScrollHandle.dragPause = parseInt(i*3.3);
}

function scroll_pause() {
	clearTimeout(doscroll);
}

function scroll_init() {
	clearTimeout(doscroll);
	VScrollHandle.moveIt(VScrollHandle.start);
	VScrollHandle.pos=VScrollHandle.start;
}

function scrollmover(e){
	VScrollHandle.isOver=true;
}

function scrollmout(e){
	VScrollHandle.isOver=false;
}

function scrollmup(){
	loop=false;
	if(VScrollHandle.drag){
		VScrollHandle.drag=false;
		VScrollHandle.pos = VScrollHandle.y;
	}
}

function scrollmdown(e){
	if(VScrollHandle.isOver) {
		y=(e ? e.screenY : event.screenY);
		VScrollHandle.drag=true;
		VScrollHandle.clickedY=y-VScrollHandle.y;
	}
}

function MoveAreaDown(move) { 
	if(this.y>-this.scrollHeight+objContainer.clipHeight) { 
	    this.MoveArea(0,this.y-move) 
	    if(loop) setTimeout(this.obj+".down("+move+")",scrollSpeed) 
	}
}
	
function MoveAreaUp(move) {
	if(this.y<0) { 
	    this.MoveArea(0,this.y-move)
	    if(loop) setTimeout(this.obj+".up("+move+")",scrollSpeed) 
	}
} 

function scroll_moveIt(y){	
	
	var old_y = this.y;
	
	if (y>VScrollHandle.end) y=VScrollHandle.end;
	if (y<VScrollHandle.start) y=VScrollHandle.start;
	
	this.y=y;
	this.css.top=this.y;
	
	if (typeof objScroller == 'undefined')
		InitialiseScrollableArea(0,0)
	else
		InitialiseScrollableArea(objScroller.x,objScroller.y)

	if (initialised) { 
		var scrollHeight = getScrollHeight();
		if (scrollHeight < 0)  {
			if (old_y > this.y) {
				var iMove = objScroller.y - parseInt(((old_y-y)/old_y)*objScroller.y);
				loop=true;
				objScroller.MoveArea(0,iMove);
			}
		} else {
			loop=true;   
			var iMove = 0;
			iMove = -parseInt(scrollHeight*(y/VScrollHandle.end));
	  		objScroller.MoveArea(0,iMove);
		}
	}
}

function moveBar() {
	var scrollHeight = getScrollHeight();
	if (objScroller.y<0&&scrollHeight>0)
		VScrollHandle.moveIt( (VScrollHandle.end) * (objScroller.y/-scrollHeight) );
}

function scrollmmove(e){
	
	y=(e? e.screenY : event.screenY) - VScrollHandle.clickedY
	
	var scrollHeight = getScrollHeight();
	if (scrollHeight<0&&y>VScrollHandle.y) return;
		
	if((VScrollHandle.drag)&&(VScrollHandle.start<=VScrollHandle.y)&&(VScrollHandle.end>=VScrollHandle.y)){
		//Check the boundries
		if (y>VScrollHandle.end)
			y=VScrollHandle.end;
		else if (y<VScrollHandle.start)
			y=VScrollHandle.start;
		doscroll = setTimeout('VScrollHandle.moveIt('+y+');',VScrollHandle.dragPause);
	}
}

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 PerformScroll(speed) {   
	loop=true;
	y=VScrollHandle.y+speed;
	
	var scrollHeight = getScrollHeight();
	if ( (scrollHeight<0&&VScrollHandle.y==0) || (scrollHeight<0&&speed>0) ) return;
	
	//Check the boundries
	if (y>VScrollHandle.end)
		y=VScrollHandle.end;
	else if (y<VScrollHandle.start)
		y=VScrollHandle.start;
			
	if((loop)&&(y>=VScrollHandle.start)&&(y<=VScrollHandle.end)) {
		VScrollHandle.moveIt(y);
		timer = setTimeout("PerformScroll("+speed+");" ,30);
	}
}

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() 

/*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 InitialiseScrollableArea(x,y) { 
    objContainer=new ConstructObject('channels_box');
    objScroller=new ConstructObject('divInnerChannelBox', 'channels_box');
    objScroller.MoveArea(x,y);
    objContainer.css.visibility='visible';
    initialised=true;
		
		document.onselectstart = function() { if(event.srcElement.id=='inputSearchBox') return true; else return false; };
		document.onmouseup=scrollmup;
		document.onmousemove=scrollmmove;
}

var initialised;

function CeaseScroll() {
    loop=false;
    if(timer) clearTimeout(timer);
} 

/*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';
		}
	} 
}




function refreshAdBox () {
    var qStr = nsParam + skinParam + '&ord=' + Math.random()*999999;
	try {
		if (refreshBanner() || false) ifrAdBox.replace('null/ifr_ads.jsp?hp=box'+qStr);
    } catch (e) {
		// do nothing
	}
}


function refreshAdSponsor () {

    var qStr = nsParam + skinParam + '&ord=' + Math.random()*999999;
	try {
		if (refreshBanner() || false) ifrAdSponsor.replace('null/ifr_ads.jsp?hp=top'+qStr);
	} catch (e) {
		// do nothing
	}
}


function refreshAdSky () {
    var qStr = nsParam + skinParam + '&ord=' + Math.random()*999999;
	try {
		if (refreshBanner() || false) ifrAds.replace('null/ifr_ads.jsp?hp=sky'+qStr);
   } catch (e) {
		// do nothing
	} 
}



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']);
	}
}




var rt_current_rating = 0; 
var rt_img_on = "http://feedroom.speedera.net/static.feedroom.com/affiliate/erepublic/telegraph/bt_starfull.gif"
var rt_img_off = "http://feedroom.speedera.net/static.feedroom.com/affiliate/erepublic/telegraph/bt_starempty.gif"

function rtShowDescription(rt_star, idx) {
	if (rt_star != null) {
		var rt_scale = rt_star.parentNode
		var rt_rating_space = rt_scale.parentNode
		var spans = rt_rating_space.childNodes
		for (var i=0;i<spans.length;i++) {
			var span = spans[i]
			if (span.className == 'userRatingLabel') {
				span.innerHTML = rt_star.title				
			} else if (span.className == 'userRatingScale') {
				var stars = span.childNodes;
				for (var j=0;j<stars.length;j++) {
					if (j <= idx) {
						stars[j].src = rt_img_on
					} else {
						stars[j].src = rt_img_off
					}
				}
			}
		}		
	}
}
function rtHideDescription(rt_star) {
	if (rt_star != null) {
		var rt_scale = rt_star.parentNode
		var rt_rating_space = rt_scale.parentNode
		var spans = rt_rating_space.childNodes
		for (var i=0;i<spans.length;i++) {
			var span = spans[i]
			if (span.className == 'userRatingLabel') {
				span.innerHTML = span.title
			} else if (span.className == 'userRatingScale') {
				var stars = span.childNodes;
				for (var j=0;j<stars.length;j++) {
					if (j <= rt_current_rating-1) {
						stars[j].src = rt_img_on
					} else {
						stars[j].src = rt_img_off
					}
				}
			}
		}		
	}
}


function rtSetRating(story_id, rating) {
	rt_current_rating = rating
	Admin("setUserRating", [story_id, rating], [])
	ping("setUserRating", "&sid="+story_id+"&rating="+rating+"&site=erepublic")
}


function initCustom() {}



 



function init_video() { 


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

	if (initXtr++ > 1) return;
	AdminAB('playStory',1,['-1','0','ee847c1e0eaca99061e17bc32287a8753c106263','d1e244cf13ce94c4ee98ab1ce35199dcd48ce85d','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-30ee253c:12516d09520:1b97')
    
    } 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 (btDone) Admin('loadSponsoredVideos');
      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.<html>
<body>
<h1>500 Servlet Exception</h1>
<code><pre>
<script language='javascript' type='text/javascript'>
function show() { document.getElementById('trace').style.display = ''; }
</script>
<a style="text-decoration" href="javascript:show();">[show]</a> java.lang.NullPointerException
<span id="trace" style="display:none">
java.lang.NullPointerException
	at _jsp._domovoi__jsp._jspService(domovoi.jsp:235)
	at com.caucho.jsp.JavaPage.service(JavaPage.java:61)
	at com.caucho.jsp.Page.pageservice(Page.java:578)
	at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:195)
	at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)
	at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
	at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:435)
	at com.caucho.server.port.TcpConnection.run(TcpConnection.java:678)
	at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
	at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
	at java.lang.Thread.run(Thread.java:595)
</span>
</pre></code>
</body></html>
