







var nsParam = '&nsid=a2e008382:1252943801f:7215';  
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:7215';


	


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=hpgateway";qstr += "&nsid=a2e008382:1252943801f:7215";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=a2e008382:1252943801f:7215"+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 = ['ifr_actionBox','divStories','divChannels','divHeader','divMasthead','divHelp','divCustom','divPowered','divFooter','divSlideshowPreview','divRss','divOmniture','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)) {
		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("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 += "hpgateway";
	}
	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",null+20,null+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 = null;
var highlightNowPlaying = true;
var search_onload = false;

function paintUnselected(id) {
	var obj = document.getElementById(id);
	if (obj != null) {
		if (obj.className.indexOf("_selected") > -1) {	
			obj.className = obj.className.substring(0, obj.className.indexOf('_selected'));
			return true;
		}
	}
	return false;
}
function paintNowPlaying(id) {
	var obj = document.getElementById(id);
	if (obj != null) {
		obj.className = obj.className + '_selected';			
	}
}

function renderNowPlaying(idx) {
    if (idx < 0) return;
	if (idx != null) {
		paintNowPlaying('story'+idx);
	}
}
function saveNowPlaying(id) {
    currentPlaying = id;
}
function resetNowPlaying() {
	if (currentPlaying != null) {
		paintUnselected('story'+currentPlaying);
	}
}

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
	}
	
}


function initCustom() {}






var ssPreview = null;
function loadPreview() {
	var so = new SWFObject("null/preview/frslideshow.swf?827999.5835556297", "sspPreview", "480", "405", "8", "#FFFFFF");

	so.addParam("menu", "false");
	so.addParam('allowScriptAccess', 'always');
	so.addVariable("baseURL", "null/");

	
	so.addVariable("nsid", "a2e008382:1252943801f:7215");
	so.addVariable('callbackFunction', 'init_preview');
	so.write("divSlideshowPreview");
}
function init_preview() {
	ssPreview = document.getElementById("sspPreview");
	if (ssPreview) {
		var bCfg = ssPreview.setConfigUrl('null/preview/config.jsp?nsid=a2e008382:1252943801f:7215');
	}
}
// ExternalInterface in flash will call ssLoadStatus when the ssPreview is initialized and XML feed is loaded
function ssLoadStatus(initSuccess) {
    if (initSuccess) {
        // call slideshow preview to begin playback
		if (ssPreview != null) {
            ssPreview.setDisplayMode('Auto');
		} else {
			alert('ssPreview object is null!');
		}
    } else {
	
    }
    
}

// ExternalInterface in flash will call ssPlayStory when the user clicks on a story image 
// since we do not have story/chl positions, default to -1/-1 and let calcStory find them based on IDs
function ssPlayStory(ssSID, ssCID) {
    // initiate playback 
	parent.AdminAB('playStory',1, [-1,-1,ssCID,ssSID, false]);

	
	// force highlighting 
	parent.postShowStories(-1, true);
	

	ssHidePreview();
}
function ssHidePreview() {
    // suspend/hide? preview
	if (ssPreview) ssPreview.setDisplayMode('Manual');

	//clean up/hide slideshow object/frame and show video player object
	var ssDiv = document.getElementById("divSlideshowPreview");
	if (ssDiv) ssDiv.style.display = "none";	
	var vidDiv = document.getElementById("divPlayer");
	if (vidDiv) vidDiv.style.visibility="visible";	
}







function init_video() { 


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

	if (initXtr++ > 1) return;
	

}

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;



function refreshBanner() {


}

function syncAds(state) {


	
	
}


var pingCt = 0;

var pingInterval = 5;
var bufferPingCt = 0;
var currentMedia = '';
function doRefresh() {
    if (bLongVideo || !mvideo.controls.isAvailable('Pause')) {
		try {
			ifrHlp2.replace('null/blank.jsp?r=600&nsid=a2e008382:1252943801f:7215')
		
		} catch (err) {}
	}
	//pingCt = 0;
}
var lastMediaName = 'none';
function flDurationTracker(curPos, curMediaName) {
	if (curMediaName == lastMediaName) {
	    pingCt += 1;
	} else {
    	pingCt = 1;
    	lastMediaName = curMediaName;
	}
    var band = "";
    if (pingCt == 1) band = "&band="+(isBB?"BB":"NB");
    if (curMediaName != undefined && curMediaName.indexOf("Video") > 0) {
		setTimeout('ping("duration", "&m='+curMediaName+'&cpos='+curPos+'&dr='+pingInterval+'&cgt='+pingCt+'&cid='+currentChannel_uoi_id+'&sid='+currentStory_uoi_id+band+'");',0);
	}
}
function durationTracker(curPosition) {
	if (mvideo.playState == 3){	
		clearTimeout(lPingTimer);
	    pingCt += 1;
	    var band = "";
	    if (pingCt == 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="+pingCt+"&cid="+currentChannel_uoi_id+"&sid="+currentStory_uoi_id+band);
			}
			lPingTimer = setTimeout("durationTracker()", pingInterval*1000);
		} else {
			ping("duration", "&m="+currentMedia+"&cpos="+curPosition+"&dr="+pingInterval+"&cgt="+pingCt+"&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() {
    bufferPingCt += 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) {
	
  
  	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 : "") ];
    }
}

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);
	pingCt = 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();


	

    itemQrep = "";
}


function updateUI() {
	if (!isUpdated) {

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

		if (hasChannelStateChanged == 'true') { 
			parent.Admin('showStories', [displayChannelStart,displayChannelEnd,currentChannel_uoi_id], [playChannel, 'true']);
		} 
		setNowPlaying(playStory);
		if (bGeoLocationRestriction) resetNowPlaying();
		if (btDone) AdminAB('loadBodyText',0,[currentStory_uoi_id]);
		if (btDone) ssHidePreview();
		if(!bPlayVideo) PausePlayVideo();
        isUpdated = true;
		
			 setDurationDisplay("00:00");
			
		isUpdated = true; 
	}
}

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();
	    pingCt = 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))
			if(seconds <10){
				seconds = "0"+seconds;
			}
			if(minutes<10){
				minutes = "0"+minutes;
			}
			setDurationDisplay(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 {
			lRefreshTimer = setTimeout('doRefresh()',15000); // check for live
		  clearTimeout(lDurationTimer);
			setDurationCounterDisplay("LIVE");
			setDurationDisplay("LIVE");
			show_duration();
			hide_slider();
		}
	
	
	//if (readyFor.getItemInfo("theTitle").indexOf("theVideo") != -1) {
	
	
	}
}

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

    clearTimeout(lPingTimer);
	pingPxUrl(); 
	pingCookieUrl();
    pingCt = 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(1);// sync frame
	setTimeout("doEntryCheck(1)",300);
	
	//alert('readyVideoAd(): ' + mvideo.currentMedia.getItemInfo("theTitle"));
	
}


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('null/redirect.jsp?r=1&url=' + 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();
	
	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;
	
	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", "_o<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:220)
	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>
