
/* TurnTo23.com scripts */
// Begin national js scripts


/*
 * Copyright 2006, Internet Broadcasting Systems. All Rights Reserved.
 * CVS: $Id: home.js,v 1.6 2007/06/14 20:09:50 breisinger Exp $
 * CVS Path: $Source: /u01/cvsroot/javascript/video/mere_post/home.js,v $
 * Phaedra Content ID: 9363102
 * Example URL: http://www.wfsb.com
*/

/******
/ Flexible Video Player (fvp)
/ Copyright 2006, Internet Broadcasting Systems, Inc.
/******/

<!-- kjoseph 20081029 - included to ensure that AC_OETags.js is included for expanding players - PTS 163367 -->
document.write('<scr' + 'ipt type="text/javascript" src="/sh/flash/js/AC_OETags.js"></scr' + 'ipt>');

if(typeof fvpconfig == "undefined") {
	var fvpconfig = {
		defaultState: {
			outerWidth: 200,
			outerHeight: 250,
			slideWidth: 200,
			slideHeight: 150
		},
		enlargedState: {
			outerWidth: 435,
			outerHeight: 410,
			slideWidth: 105
		}
	}
}
using("IBSYS.vp");

/******************
* gets ibIndeces in a parent conatiner, returns an array of the names
*******************/
IBSYS.vp.getIbIndeces = function(parent) {
	var indeces = new Array();
	var spans = parent.getElementsByTagName("span");
	for(var i=0;i<spans.length;i++) {
		if(spans[i].id.substr(0,5) == "index") {
			indeces.push(spans[i].id);
		}
	}
	return indeces;
}
IBSYS.vp.main = document.getElementById("flexibleContainer");
//initialize some vars
IBSYS.vp.indexName = IBSYS.vp.getIbIndeces(IBSYS.vp.main.parentNode)[0];
IBSYS.vp.enlargedSlideWidth = fvpconfig.enlargedState.slideWidth;
IBSYS.vp.partner = siteinfo.owner.toLowerCase();
//to keep track of currently selected item
IBSYS.vp.currentItemCoid = ibIndex[IBSYS.vp.indexName].co[0].coid;
IBSYS.vp.currentVideoType = false;

//small state sliding tray
IBSYS.vp.horiz = document.getElementById("vidSmallInnerTray");
IBSYS.vp.l = document.getElementById("vidSmallPrev");
IBSYS.vp.r = document.getElementById("vidSmallNext");
IBSYS.vp.playButton = document.getElementById("vidSmallPlay");
IBSYS.vp.pos = document.getElementById("vidSmallPos");
//large state scrolling tray
IBSYS.vp.largeHoriz = document.getElementById("vidLargeInnerTray");
IBSYS.vp.largeOuterTray = document.getElementById("vidLargeOuterTray");
//more info container 
IBSYS.vp.moreInfo = document.getElementById("moreInfo");
IBSYS.vp.moreInfoText = document.getElementById("moreInfoText");
IBSYS.vp.moreInfoButtonImage = document.getElementById("moreInfoButton").firstChild;
IBSYS.vp.adTarget = "homepage";	//ad targeting for post/pre roll ads
//video player elements
IBSYS.vp.playerBox = document.getElementById("player");
IBSYS.vp.flashPlayerBox = document.getElementById("flvPlayerHolder");
IBSYS.vp.wmvControlStrip = document.getElementById("filmstrip");
IBSYS.vp.wmvFullScreenButton = document.getElementById("fullScreen");
/*****************************************************************************************
* VIDEO
*****************************************************************************************/

/****************
* plays the next video in the tray
* ~ this fct is called by flash player when video is done
*****************/
IBSYS.vp.playlist = {
	advance: function() {
		var currentTab = getElementsByClassName(IBSYS.vp.largeHoriz,"enlargedTabActive")[0];
		var coid = currentTab.id.split("_")[1];
		
		var nextVideo;
		if(currentTab.nextSibling && currentTab.nextSibling.className == "enlargedTabInactive") {
			nextVideo = currentTab.nextSibling;
		} else {
			nextVideo = IBSYS.vp.largeHoriz.firstChild;
		}
		var nextVideoCoid = nextVideo.id.split("_")[1];
		var co = IBSYS.vp.getContentItemByCoid(nextVideoCoid);
		
		IBSYS.vp.showEnlargedCurrentHeadline(nextVideoCoid);
		IBSYS.vp.changeMoreInfo(nextVideoCoid);
		//set active tab (highlights it)
		var currentSlideNumber = IBSYS.vp.setActiveTabClassName("enlargedTab_" + nextVideoCoid);
		//scroll to slide if it's beyond bounds of container
		IBSYS.vp.largeOuterTray.scrollLeft = (currentSlideNumber - 4) * IBSYS.vp.enlargedSlideWidth;
		//play video
		IBSYS.vp.createVideo(nextVideoCoid,co.headline)();
		//switch out "more info" state in tray
		IBSYS.vp.moreInfo.style.display = "none";
		IBSYS.vp.largeOuterTray.style.display = "block";
		IBSYS.vp.moreInfoButtonImage.src = "http://images.ibsys.com/sh/images/videoplayer/" + siteinfo.owner.toLowerCase() + "/btn_more_info.png";
		IBSYS.vp.moreInfoButtonImage.tested = false;
		fixPngImage(IBSYS.vp.moreInfoButtonImage);
	}
}
/*****************
* creates new video player on page, loads video player based on type (flv or wmp)
*****************/
IBSYS.vp.createVideo = function(coid,headline) {
	return function() {
		var co = IBSYS.vp.getContentItemByCoid(coid);
		IBSYS.vp.stopVideo();	
		IBSYS.vp.currentVideoType = IBSYS.vp.determineVideoType(co);
		//set current item content id for global use
		IBSYS.vp.currentItemCoid = coid;
		//Play WMV video (mediaPlayer)
		if(IBSYS.vp.currentVideoType == "wmv") {
			IBSYS.vp.wmp.play(co.coid,false);
		
		//play Flash Video
		} else if (IBSYS.vp.currentVideoType == "flv") {
			var location = IBSYS.vp.flvp.params.swf + 
				"?xspf=" + IBSYS.vp.flvp.generatePlaylistLink(co.coid);
			if(mediaPlayer.getInstance('player').isActiveX) {
				location += "&activex=true";
			}
			location += "&skin=" + IBSYS.vp.flvp.params.skin +
				"&loading=http://" + window.location.host + 
					"/download/sh/images/videoplayer/" + IBSYS.vp.partner + "/buffering.swf";
			IBSYS.vp.flvp.load("document", location, IBSYS.vp.flvp.params.width, IBSYS.vp.flvp.params.height);
		}
		//web trends
		if (typeof dcsMultiTrack == "function") {
			dcsMultiTrack('WT.ti',co.headline, 'DCS.dcsuri', '/video/' + co.coid + '/index.html','DCSext.mtype','Video','DCSext.vtype','Clickplay','DCSext.ib_coid',co.coid,'DCSext.ib_pool',co.pool, 'WT.cg_s', co.videocategory, 'WT.cg_n', co.topic);
		}
		/* set new banner1 content id for ad refreshing */
		if(typeof AdObj.elements.banner1 != "undefined") {
			AdObj.elements.banner1.coId = "+" + IBSYS.vp.currentItemCoid;
		}
		return false;
	}
}

IBSYS.vp.stopVideo = function() {
	if(IBSYS.vp.currentVideoType == "flv") {
		IBSYS.vp.flvp.stop();
	} else if (IBSYS.vp.currentVideoType == "wmv") {
		IBSYS.vp.wmp.destroyPlayers();
	}
}
IBSYS.vp.determineVideoType = function(co) {
	//temp hack
	//if(vp.partner == "mere") return "wmv";
	
	for(var i=0; i<co.videostream.length; i++) {
		if(co.videostream[i].type == "flv") {
			return "flv";
		}
	}
	return "wmv";
}
/*********************************************************
* FLASH VIDEO
*********************************************************/
IBSYS.vp.flvp = {
	// Load the player
	load: function(target,location,width,height) {
		IBSYS.vp.wmvFullScreenButton.style.display = "none";
		IBSYS.vp.wmvControlStrip.style.display = "none";
		IBSYS.vp.playerBox.style.visibility = "hidden";
		IBSYS.vp.flashPlayerBox.style.display = "block";
		var prefix = '<html><head><title>Video Player</title></head><body '+
			'marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0';
		var requiredMajorVersion = 8;
		var requiredMinorVersion = 0;
		var requiredRevision = 0;
		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if (hasReqestedVersion) {
			var code = 
				'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '+
					'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/'+
					'swflash.cab#version=8,0,0,0" '+
					'width="'+width+'" '+
					'height="'+height+'" id="flvPlayerObject" align="middle"> '+
				'<param name="allowScriptAccess" value="sameDomain" /> '+
				'<param id="flvPlayerMovieParam" name="movie" '+
					'value="'+location+'" /> '+
				'<param name="quality" value="high" /> '+
				'<param name="bgcolor" value="#000000" /> '+
				'<embed id="embedFLVplayer" '+
					'src="'+location+'" '+
					'quality="high" bgcolor="#000000" width="'+width+'" '+
					'height="'+height+'" name="flvPlayerEmbed" '+
					'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" '+
					'pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
				'</object>';
		}
		else {
			var code = '<font color=ffffff>This video requires Flash Player 8 or higher. ' + 
				'<a href=http://www.adobe.com/go/getflash/>Click here</a> to download.</font>';
		}
		var suffix = '</body></html>';
		if (target == "flvFullScreen") {
			top.flvFullScreen.document.write(prefix+code+suffix);
		}
		else {
			document.getElementById('flvPlayerHolder').innerHTML = code;
		}
	},
	// Actions once player is written
	action: function(action,startVideo,startTime) {
		// Enter Full Screen Mode
		var url = IBSYS.vp.flvp.params.swf + 
			"?xspf=" + IBSYS.vp.flvp.generatePlaylistLink();
		if(mediaPlayer.getInstance('player').isActiveX) {
			url += "&activex=true";
		}
			url += "&skin=" + IBSYS.vp.flvp.params.skin +
			"&loading=http://" + window.location.host + 
				"/download/sh/images/videoplayer/" + IBSYS.vp.partner + "/buffering.swf";
		if (action == "goFullScreen") {
			if(confirm("You are about to enter \"Full Screen\" mode.  \n Please click this button again to return to \"Normal\" mode.")) {
				IBSYS.vp.stopVideo();
				top.flvFullScreen = window.open('about:blank','fullscreen','fullscreen=yes');
				IBSYS.vp.flvp.load("flvFullScreen",url+"&startVideo="+
					startVideo+"&startTime="+
					startTime+"&fullScreen=1","100%","100%");
			}
		}
		// Exit Full Screen Mode
		else if (action == "goNormal") {
			var location = url+"&fullScreen=0&startVideo="+startVideo+
				"&startTime="+startTime;
			IBSYS.vp.flvp.load(top.flvFullScreen, location, IBSYS.vp.flvp.params.width, IBSYS.vp.flvp.params.height);
		}
	},
	//Define Parameters
	params: {
		width:428,
		height:270,
		// swf:"/download/sh/upp/player.swf",
		// swf:"/2006/0707/9484988.swf",
		swf:"/download/sh/upp/player.swf",
		skin:"http://" + window.location.host + "/sh/images/videoplayer/" + IBSYS.vp.partner + "/player.skin"
	},
	generatePlaylistLink: function(coid) {
		if(typeof coid == "undefined") {
			coid = IBSYS.vp.currentItemCoid;
		}
		var url = "http://" + window.location.host + "/flashvideo/";
		url += coid + "/playlist.html?qs=;ng=y;adtarget=" + IBSYS.vp.flashAdTarget;
		url += ";speed=";
		url += (akamaispeed == "high" ? "high" : "low");
		return url;
	},
	finished: function(url) {
		//stub
	},
	play: function() {
		//stub
	},
	stop: function() {
		IBSYS.vp.flashPlayerBox.innerHTML = "";
		return false;
	}
}
/**********************************************************
* WINDOWS MEDIA VIDEO
**********************************************************/
IBSYS.vp.wmp = {
	timer: false,	//timer to monitor video progress
	nextVideoButton: false,
	/***************
	* Constructs controls and buffering container support
	***************/
	initializePlayer: function() {
		//instantiate custom controls 
		if(window.attachEvent) {
			var co = ibIndex[IBSYS.vp.indexName].co[0];
			mediaPlayer.controls["player"] = new Controls("filmstrip","player",true);
			mediaPlayer.controls["player"].setEnabled(true);
			mediaPlayer.controls["player"].getPlay().onclick = IBSYS.vp.createVideo(co);
			var swfurl = "/sh/images/videoplayer/" + IBSYS.vp.partner + "/buffering.swf";
			mediaPlayer.buffering["player"] = new BufferingSwf("buffer",swfurl).loadSwf();
			mediaPlayer.adTarget["player"] = IBSYS.vp.adTarget;
			/**
			* overwrite default setEnabled fct
			**/
			mediaPlayer.controls["player"].setEnabled = function(b) {
				this.enabled = b;
				var str = b ? "" : "off";
				this.getBack().className = "control back" + str;
				this.getPlay().className = "control play" + str;
				this.getStop().className = "control stop" + str;
				this.getTrack().className = "track track" + (b ? "on" : "off");
				this.getFill().className = "fill fill" + (b ? "on" : "off");
				//heres the extra line i needed to add
				document.getElementById("nextVideoButton").className = "control next" + str;
				if(this.getSeekKnob()) {
					this.getSeekKnob().className = "seekKnob" + str;
				}
			}
			
			/***************
			* NEXT VIDEO button
			****************/
			IBSYS.vp.wmp.nextVideoButton = document.createElement("div");
			IBSYS.vp.wmp.nextVideoButton.className = "control next";
			IBSYS.vp.wmp.nextVideoButton.id = "nextVideoButton"; 
			IBSYS.vp.wmp.nextVideoButton.title = "Skip to Next Video";
			var controls = document.getElementById("filmstrip").firstChild;
			controls.insertBefore(IBSYS.vp.wmp.nextVideoButton,controls.childNodes[1]);
			//function to fire when next button is clicked
			addEvent(IBSYS.vp.wmp.nextVideoButton,"click",function() {
				if(mediaPlayer.controls["player"].enabled) {
					IBSYS.vp.playlist.advance();
				}
			});
			
			/***************
			* BACK TO START button
			****************/
			var toStart = document.createElement("div");
			toStart.className = "control toStart";
			toStart.id = "toStartButton";
			toStart.title = "Back to Start of Video";
			controls.insertBefore(toStart,controls.childNodes[1]);
			//fct to go back to beginning of video
			addEvent(toStart,"click",function() {
				if(document.getElementById("videoplugplayer") != null) {
					document.getElementById("videoplugplayer").controls.currentPosition = 0;
				}
			});
		}
	},
	/*****************
	* reliable way to stop/destroy wmp video 
	*****************/
	destroyPlayers: function() {
		//delete embedded player
		if(document.getElementById("videoplugplayer")) {
			el = document.getElementById("videoplugplayer");
			//kills player in IE / Win
			if(mediaPlayer.getInstance('player').isActiveX) {
				if(IBSYS.vp.wmp.timer) {
					window.clearInterval(IBSYS.vp.wmp.timer);
				}
				el.controls.stop();
				//el.close();
			//For other browsers
			} else {
				if(document.getElementById("player")) {
					document.getElementById("player").innerHTML = "";
				}
			}
		}
		return false;
	},
	/*****************
	* play a wmp video 
	*****************/
	play: function(coid,isAd) {
		if(typeof isAd != "boolean") {
			isAd = false;
		}
		IBSYS.vp.wmp.destroyPlayers();
		if(document.attachEvent) {
			IBSYS.vp.wmvFullScreenButton.style.display = "block";
			IBSYS.vp.wmvControlStrip.style.display = "block";
		}
		IBSYS.vp.flashPlayerBox.style.display = "none";
		IBSYS.vp.playerBox.style.display = "block";
		IBSYS.vp.playerBox.style.visibility = "visible";

		IBSYS.vp.wmp.nextVideoButton.className = "control next";
		if(isAd) {
			mediaPlayer.getInstance("player").createPlayer("url",coid,true,"none",true);
		} else {
			mediaPlayer.getInstance("player").createPlayer("video",coid,true,"none",true);
		}		
		if(mediaPlayer.getInstance("player").isActiveX) {
			IBSYS.vp.wmp.timer = window.setInterval("IBSYS.vp.wmp.monitorVideo()",20);
			
			if(document.getElementById("videoplugplayer") &&
				document.getElementById("videoplugplayer").attachEvent)
			{
				document.getElementById("videoplugplayer").attachEvent(
					"currentItemChange",
					AdObj.createAdRefreshHandler("videoplugplayer"));
			}
		}
	},
	/*****************
	* monitor for end of playlist, advance to next item if end
	*****************/
	monitorVideo: function(newstate) {
		//check for playlist end, advance if so
		var percentComplete = parseInt((videoplugplayer.controls.currentPosition / videoplugplayer.currentMedia.duration) * 100);
		var isEndOfAsxPlaylist = (videoplugplayer.currentMedia.getItemInfo("LastEntry") != "") ? true : false;
		//debug("end: " + isEndOfAsxPlaylist + " complete: " + percentComplete,true);
		if(percentComplete >= 97 && isEndOfAsxPlaylist) {
			//prevent an advance() loop
			//window.clearInterval(vp.wmp.timer);
			IBSYS.vp.playlist.advance();
		}
	}
}
/******************
/ full-screens the video
/*****************/
IBSYS.vp.fullScreen = function() {
	var failMessage = "Video must be playing in order to view it in full-screen mode";
	var confirmMessage = "You are about to go to Full Screen mode. Press ESC to return to normal mode. Do you wish to continue?";
	// first, check to see if video player is playing or paused
	if(document.getElementById("videoplugplayer")) {
		if (document.getElementById("videoplugplayer").playState == 3) {
			if(confirm(confirmMessage)) {
				try {
					document.getElementById("videoplugplayer").fullScreen = true;
				} catch(e) {}
			}
		} else {
			alert(failMessage);
		}
	} else {
		alert(failMessage);
	}
}

/*****************************************************************************************
* SLIDING BLURB TRAY STUFF
*****************************************************************************************/

/******
/ blurb tray class extension - changes headline under tray
/*****/
IbsSlider.prototype.headlineChangerInit = function(elementId) {
	this.headlineDiv = document.getElementById(elementId);
	var self = this;
	var co;
	addEvent(this.l, "click", function() {
		if(self.currentSlide > 1) {
			co = ibIndex[IBSYS.vp.indexName].co[(self.currentSlide - 2)];
			IBSYS.vp.currentItemCoid = co.coid;
			self.headlineDiv.innerHTML = padTags(fixString(co.headline));
			self.headlineDiv.onclick = IBSYS.vp.enlargeAndPlay(co.coid);
		}
	});
	addEvent(this.r, "click", function() {
		if(!self.isEnd()) {
			co = ibIndex[IBSYS.vp.indexName].co[self.currentSlide];
			IBSYS.vp.currentItemCoid = co.coid;
			self.headlineDiv.innerHTML = padTags(fixString(co.headline));
			self.headlineDiv.onclick = IBSYS.vp.enlargeAndPlay(co.coid);
		}
	});
}

//instantiate video tray
var mySlider = new IbsSlider(IBSYS.vp.horiz,ibIndex[IBSYS.vp.indexName].co.length,IBSYS.vp.l,IBSYS.vp.r,20,1,fvpconfig.defaultState.slideWidth,IBSYS.vp.pos);
mySlider.headlineChangerInit("vidSmallHeadline");


/***********
/ overwrites "reportpos" for the parent class
/ overwritten to show/hide controls based on position
/*********/
mySlider.reportPos = function() {
	if(this.currentSlideContainer) {
		this.currentSlideContainer.innerHTML = this.currentSlide + " of " + this.numSlides;
	}
	if(this.currentSlide == this.numSlides) {
		IBSYS.vp.r.style.display = "none";
	} else {
		IBSYS.vp.r.style.display = "block";
	}
	if (this.currentSlide == 1) {
		IBSYS.vp.l.style.display = "none";
	} else {
		IBSYS.vp.l.style.display = "block";
	}	
}

/*****************************************************************************************
* CONTENT OBJECT TOOLS
*****************************************************************************************/
/******
/ returns a content item (co[i]) matching coid
/*****/
IBSYS.vp.getContentItemByCoid = function(coid) {
	for(var i=0; i<ibIndex[IBSYS.vp.indexName].co.length; i++) {
		if(ibIndex[IBSYS.vp.indexName].co[i].coid == coid) {
			return ibIndex[IBSYS.vp.indexName].co[i];
		}
	}
}

/*******************
* Finds image source based on width. If not present, gets next smallest width available.
/******************/
IBSYS.vp.buildImgSrcFromTargetWidth = function(imgObj,targetW) {
	var k = imgObj.availableSizes.length;
	var temp = 0;
	var src;
	while(k > 0) {
		var currImg = parseInt(imgObj.availableSizes[k]);
		//return source if matches target width
		if(currImg == targetW) {
			src = imgObj.imgSrc.split("_")[0] + "_" + imgObj.availableSizes[k] + ".jpg";
			return src;
		}
		
		//if this width is smaller than target, but bigger than last width, make last 
		//width this width
		if(currImg < targetW && currImg > temp) {	
			temp = currImg;
		}
		k--;
	}
	src = imgObj.imgSrc.split("_")[0];
	src += "_" + temp + "X" + parseInt(temp*0.75) + ".jpg";
	return src;
}

/*****
/ get elements by class name
/****/
function getElementsByClassName(node, classname) {
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
    return a;
}
/*****************************************************************************************
* HTML OUTPUT
*****************************************************************************************/
/*****
/ Load content into slide container (both small and large states)
/*****/
IBSYS.vp.loadSlides = function() {
	for(var i=0; i<ibIndex[IBSYS.vp.indexName].co.length; i++) {
		var co = ibIndex[IBSYS.vp.indexName].co[i];
		//
		// Contracted state
		//
		var div = document.createElement("div");
		div.id = "tab_" + co.coid;
		div.className = "tabSlide";
		div.setAttribute("coid",co.coid);
		//image
		var blurbImg = document.createElement("img");
		if(typeof co.img.imgSrc != "undefined") {
			blurbImg.src = IBSYS.vp.buildImgSrcFromTargetWidth(co.img,fvpconfig.defaultState.slideWidth);
		} 
		//blurbImg.title = padTags(fixString(co.headline));
		blurbImg.width = 240;
		blurbImg.height = 180;
		div.appendChild(blurbImg);
		IBSYS.vp.horiz.appendChild(div);
		
		//
		// Enlarged state
		//
		//wrapper
		var div = document.createElement("div");
		div.id = "enlargedTab_" + co.coid;
		div.className = "enlargedTabInactive";
		div.onclick = function() {
			var coid = this.id.split("_")[1];
			IBSYS.vp.showEnlargedCurrentHeadline(coid)
			IBSYS.vp.changeMoreInfo(coid);
			IBSYS.vp.setActiveTabClassName(this.id);
			var cr = IBSYS.vp.createVideo(coid,co.headline);
			cr();
			
		}
		//image
		var blurbImg = document.createElement("img");
		if(typeof co.img.imgSrc != "undefined") {
			blurbImg.src = IBSYS.vp.buildImgSrcFromTargetWidth(co.img,80);
		} 
		blurbImg.title = co.headline.replace(/~/g,'\'');
		blurbImg.width = 80;
		blurbImg.height = 60;
		div.appendChild(blurbImg);
		IBSYS.vp.largeHoriz.appendChild(div);
	}
}

/****
/ set active tab class name
/****/
IBSYS.vp.setActiveTabClassName = function(nameUnderscoreCoid) {
	var divs = IBSYS.vp.largeHoriz.getElementsByTagName("div");
	var coid = nameUnderscoreCoid.split("_")[1];
	var bingo;
	for(var i=0; i<divs.length; i++) {
		var currCoid = divs[i].id.split("_")[1];
		if(currCoid == coid) {
			divs[i].className = "enlargedTabActive";
			bingo = i + 1;
		} else {
			divs[i].className = "enlargedTabInactive";
		}
	}
	return bingo;
}

/****
/ show text headline of current movie in enlarged state
/****/
IBSYS.vp.showEnlargedCurrentHeadline = function(currentItemCoid) {
	var el = document.getElementById("tab_" + currentItemCoid);
	var headline = padTags(fixString(IBSYS.vp.getContentItemByCoid(currentItemCoid).headline));
	document.getElementById("enlargedCurrentHeadline").innerHTML = headline;
	return headline;
}



/*****
/ swaps out blurb text of moreInfo section in enlarged player
/*****/
IBSYS.vp.changeMoreInfo = function(coid) {
	var blurb = (padTags(fixString(IBSYS.vp.getContentItemByCoid(coid).teaser)));
	blurb = blurb.replace(/<[\/]{0,1}[\w]+.+>/gi,"");
	IBSYS.vp.moreInfoText.innerHTML = blurb;
}

/*****************************************************************************************
* ENLARGING BEHAVIOR
*****************************************************************************************/
/****
/ function executed after video container finishes enlarging
/***/
var onEnlarge = function() {
	var headline = IBSYS.vp.showEnlargedCurrentHeadline(IBSYS.vp.currentItemCoid);
	IBSYS.vp.setActiveTabClassName("tab_" + IBSYS.vp.currentItemCoid);
	var cr = IBSYS.vp.createVideo(IBSYS.vp.currentItemCoid,headline);
	cr();
}
var onShrink = function() {
	var ads = getElementsByClassName(
IBSYS.vp.main.parentNode.parentNode.parentNode,"adObj");
	if(ads.length > 0) {
		ads[0].style.display = "block";
	}
}

/****
/ Fires off all of the events needed if a user selects a video to play from the 
/ contracted state
/****/
IBSYS.vp.enlargeAndPlay = function(coid) {
	return function() {
		if (coid) {
			IBSYS.vp.currentItemCoid = coid;
		}
		//highlight current video image in expanded state
		IBSYS.vp.setActiveTabClassName("tab_ " + IBSYS.vp.currentItemCoid);
		//load headline text in expanded state
		IBSYS.vp.showEnlargedCurrentHeadline(IBSYS.vp.currentItemCoid);
		//load "more info" text in expanded state
		IBSYS.vp.changeMoreInfo(IBSYS.vp.currentItemCoid);
		//hide ad
		var ads = getElementsByClassName(
IBSYS.vp.main.parentNode.parentNode.parentNode,"adObj");
		if(ads.length > 0) {
			ads[0].style.display = "none";
		}

		//expand and play video
		IBSYS.vp.resizeVidPlayer.go();
		return false;
	}
};

/****
/ Attach resizing code function to buttons
/****/
IBSYS.vp.resizeVidPlayer = new SmoothResizer(
	IBSYS.vp.main,
	fvpconfig.defaultState.outerWidth,
	fvpconfig.defaultState.outerHeight,
	fvpconfig.enlargedState.outerWidth,
	fvpconfig.enlargedState.outerHeight,
	20,
	"vidSmall",
	"vidExpanding",
	"vidLarge",
	onEnlarge,
	onShrink
);
IBSYS.vp.playButton.onclick = IBSYS.vp.enlargeAndPlay(false);
document.getElementById('vidLargeClose').onclick = function() {
	IBSYS.vp.resizeVidPlayer.go();
	IBSYS.vp.stopVideo();
	return false;
}



/********
/ Stuff executed on page load 
/*******/
IBSYS.vp.wmp.initializePlayer();
IBSYS.vp.loadSlides();
//initialize headline
document.getElementById("vidSmallHeadline").innerHTML = padTags(fixString(ibIndex[IBSYS.vp.indexName].co[0].headline));
document.getElementById("vidSmallHeadline").onclick = IBSYS.vp.enlargeAndPlay(false);
//write out width of expanded clip list container
IBSYS.vp.largeHoriz.style.width = (ibIndex[IBSYS.vp.indexName].co.length * IBSYS.vp.enlargedSlideWidth) + "px";
//hide "left" button on load
IBSYS.vp.l.style.display = "none";
//hide "right" button if there's only one item popped
if(ibIndex[IBSYS.vp.indexName].co.length == 1) {
	IBSYS.vp.r.style.display = "none";
}

//full screen button
addEvent(IBSYS.vp.wmvFullScreenButton,"click",IBSYS.vp.fullScreen);

//add swapping behavior to "moreInfo" button in expanded tray
addEvent(document.getElementById("moreInfoButton"),"click",function() {
	if(IBSYS.vp.moreInfo.style.display == "none") {
		IBSYS.vp.moreInfo.style.display = "block";
		IBSYS.vp.largeOuterTray.style.display = "none";
		IBSYS.vp.moreInfoButtonImage.src = "http://images.ibsys.com/sh/images/videoplayer/" + siteinfo.owner.toLowerCase() + "/btn_hide_info.png";
	} else {
		IBSYS.vp.moreInfo.style.display = "none";
		IBSYS.vp.largeOuterTray.style.display = "block";
		IBSYS.vp.moreInfoButtonImage.src = "http://images.ibsys.com/sh/images/videoplayer/" + siteinfo.owner.toLowerCase() + "/btn_more_info.png";
	}
	//fix more info button transparency
	IBSYS.vp.moreInfoButtonImage.tested = false;
	fixPngImage(IBSYS.vp.moreInfoButtonImage);
});


// End national_js scripts

