document.cnnSwim10 = new Array();

function cnnPageOnload() {
	cnnStartList();
}

/****/
/* OMNITURE */
/****/

	var cnn_omnitureData = new Array();
	cnn_omnitureData = {
		path: cnn_omnitureGetPath(),
		server: document.domain,
		section: '2010 Swimsuit',
		pageType: null,
		branding: null,
		referrer: cnn_omnitureGetReferrer(),
		pageName: null
	}

	function cnn_omnitureGetPath() {
		// return the path of the story complete with parameters
		var retValue = document.location.pathname;
		retValue = retValue.replace( /\/\/+/, "/" ); // remove multiple slashes
		if( retValue.charAt( retValue.length - 1 ) == "/" ) retValue += "index.html"; // make sure there's always a filename
		retValue += document.location.search;
		return retValue;
	}

	function cnn_omnitureGetReferrer() {
		// return a proper string for referrer if one exists
		var retValue = '';
		var myQuery = queryString( 'eref' );
		var myQuery2 = queryString( 'xid' );
		if( myQuery != "false" ) {
			retValue += "from " + myQuery;
			if( myQuery2 != "false" ) { retValue += ", xid " + myQuery2; }
			retValue += " - " + cnn_omnitureGetPath();
			retValue = retValue.replace( 'eref=' + myQuery, "" ); // remove our eref
			retValue = retValue.replace( 'xid=' + myQuery2, "" ); // remove our xid
			retValue = retValue.replace( /\?&$/, "" ); // remove ending question mark cause there are no more parameters
		} else if( myQuery2 != "false" ) {
			retValue += "xid " + myQuery2 + " - " + cnn_omnitureGetPath();
			retValue = retValue.replace( 'xid=' + myQuery2, "" ); // remove our xid
			retValue = retValue.replace( /\?$/, "" ); // remove ending question mark cause there are no more parameters
		}
		if( retValue == '' ) retValue = null;
		return retValue;
	}

	function pageQuery( q ) {
		if( q.length > 1 ) this.q = q.substring( 1, q.length );
		else this.q = null;
		this.keyValuePairs = new Array();
		if( q ) {
			for( var i = 0; i < this.q.split( "&" ).length; i++ ) {
				this.keyValuePairs[i] = this.q.split( "&" )[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function( s ) {
			for( var j = 0; j < this.keyValuePairs.length; j++ ) {
				if( this.keyValuePairs[j].split( "=" )[0] == s )
				return this.keyValuePairs[j].split( "=" )[1];
			}
			return false;
		}
		this.getParameters = function() {
			var a = new Array( this.getLength() );
			for( var j = 0; j < this.keyValuePairs.length; j++ ) {
				a[j] = this.keyValuePairs[j].split( "=" )[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; } 
	}

	function queryString( key ){
		var page = new pageQuery( window.location.search ); 
		return unescape( page.getValue( key ) ); 
	}

	function writeData() {
		document.write( '<div class="cnnOmniture"><a name="cnnOmniture"></a>' );
		document.write( '<table border="0" cellpadding="0" cellspacing="0">' );
		document.write( '<tr><th colspan="2">Omniture Values</th></tr>' );
		for( key in cnn_omnitureData ) {
			document.write( '<tr><td>' + key + '</td><td>' + cnn_omnitureData[key] + '</td></tr>' );
		}
		document.write( '</table></div>' );
	}

/****/
/* ADCODE */
/****/

	/* start audience science */
	var rsi_segs = [];
	var segs_beg=document.cookie.indexOf('rsi_segs=');
	if(segs_beg>=0){
		segs_beg=document.cookie.indexOf('=',segs_beg)+1;
		if(segs_beg>0){
			var segs_end=document.cookie.indexOf(';',segs_beg);
			if(segs_end==-1)segs_end=document.cookie.length;
				rsi_segs=document.cookie.substring(segs_beg,segs_end).split('|');
		}
	}
	var segLen=20
	var segQS="",segArr=new Array()
	if (rsi_segs.length<segLen){segLen=rsi_segs.length}
	for (var i=0;i<segLen;i++){
		segArr=rsi_segs[i].split("_")
		if (segArr.length>1) segQS+=("rsseg"+"="+segArr[1]+";")
	}
	/* end audience science */

	/* start quantcast */
	function _quantgc(n) {
		var c=document.cookie;
		if(!c)return '';
		var i=c.indexOf(n+"=");
		if(-1==i)return '';
		var len=i+n.length+1;
		var end=c.indexOf(";", len);
		return c.substring(len,end<0?c.length:end);
	}
	// Code below is customizable per publisher
	quantSegs = "";
	var _qsegs = _quantgc('__qseg').split('|');
	for (i in _qsegs) {
		var qArr=_qsegs[i].split("_");
		quantSegs += ("qc=" + qArr[1] + ";");
	}
	/* end quantcast */

	function cnnCreateAd( width, height ) {
		// if this is a 260px or 1px wide ad, only make the call for the special models.  for any other ad, continue as normal
		// document.write( '<div class="cnnAdHolder" style="height:' + height + 'px;line-height:' + height + 'px;width:' + width + 'px;">' + width + 'x' + height + '</div>' );
		if( width == 260 ) {
			if( document.cnnSwim10.subsection && ( ( document.cnnSwim10.subsection == "bar-refaeli" ) || ( document.cnnSwim10.subsection == "brooklyn-decker" ) || ( document.cnnSwim10.subsection == "esti-ginzburg" ) || ( document.cnnSwim10.subsection == "buy" ) ) ) {
				cnnCreateAnAd( width, height );
			} else if( document.cnnSwim10.section && ( ( document.cnnSwim10.section == "oneshot" ) || ( document.cnnSwim10.section == "clock" ) || ( document.cnnSwim10.section == "winter" ) || ( document.cnnSwim10.section == "bracket" ) ) ) {
				cnnCreateAnAd( width, height );
			} else {
			}
		} else if( width == 1 ) {
			if( document.cnnSwim10.pagetype && ( document.cnnSwim10.pagetype != "player" ) ) {
				if( document.cnnSwim10.subsection && ( ( document.cnnSwim10.subsection == "bar-refaeli" ) || ( document.cnnSwim10.subsection == "brooklyn-decker" ) || ( document.cnnSwim10.subsection == "esti-ginzburg" ) ) ) {
					cnnCreateAnAd( width, height );
				} else if( document.cnnSwim10.section && ( ( document.cnnSwim10.section == "bracket" ) || ( document.cnnSwim10.section == "oneshot" ) ) ) {
					cnnCreateAnAd( width, height );
				} else {
				}
			}
		} else {
			cnnCreateAnAd( width, height );
		}
	}

	function cnnCreateAnAd( width, height ) {
		var retValue = "http://ad.doubleclick.net/adj/3475.si/" + cnnAdGetDart() + "/;";
		retValue += cnnAdGetParams(); // append page specific params
		retValue += cnnAdGetFolders(); // append the folders as path variables
		retValue += "file=" + ( document.cnnSwim10.filename ).replace( /\./, "_" ) + ";" // append filename
		retValue += "dcove=d;" // append dcove
		retValue += segQS // append revenue science
		retValue += quantSegs // append quantcast
		retValue += "sz=" + width + "x" + height; if( width == 988 ) retValue += ",728x90"; else if( ( width == 300 ) && ( height == 600 ) ) retValue += ",300x250"; retValue += ";"; // append sizes
		retValue += ""; document.cnnAdInterstitial = ( document.cnnAdInterstitial == undefined ? "ist" : "" ); if( document.cnnAdInterstitial != "" ) retValue += 'dcopt=' + document.cnnAdInterstitial + ';'; // append dcopt on first ad request
		if( ( document.cnnSwim10.section == "video" ) && ( document.cnnSwim10.section != "index.html" ) ) {
			document.cnnAdTile = (document.cnnAdTile||1) + 1; // account for the preroll as tile 1
		} else {
			document.cnnAdTile = (document.cnnAdTile||0) + 1; // otherwise start with 0
		}
		retValue += ""; retValue += "tile=" + document.cnnAdTile + ";"; // append tile which increments on each ad request
		retValue += ""; document.cnnAdRandom = document.cnnAdRandom || Math.ceil(1+1E12*Math.random()); retValue += "ord=" + document.cnnAdRandom + "?"; // append random number (always last)
		if( allCookies['cnnad_solbright'] == "set" ) {
			document.write( '<div class="cnnSiteDebug">' + cnnAdWriteDebug( retValue ) + '</div>' );
		}
		document.write( '<scr'+'ipt language="JavaScript1.1" src="' + retValue + '"></scr'+'ipt>' );
	}

	function cnnCreateVideoAd( file, dc_seed ) {
		var retValue = "http://ad.doubleclick.net/adj/3475.si/video.swimsuit/;spt=swimsuit;file=" + file +";dcove=d;sz=300x600;tile=3;dc_seed=" + dc_seed;
		document.write( '<scr'+'ipt language="JavaScript1.1" src="' + retValue + '"></scr'+'ipt>' );
	}

	function cnnAdGetDart() {
		var retValue = "swimsuit";
		if( document.cnnSwim10.section ) {
			if( document.cnnSwim10.section == "models" ) retValue += "." + document.cnnSwim10.section;
			else if( document.cnnSwim10.section == "main" ) retValue += "/" + document.cnnSwim10.section;
			else if( document.cnnSwim10.section == "painting" ) retValue += ".bodypainting";
		}
		return retValue;
	}

	function cnnAdGetParams() {
		var retValue = "spt=swimsuit;";
		if( document.cnnSwim10.subsection ) { retValue += "kw=" + document.cnnSwim10.subsection + ";"; }
		if( document.cnnSwim10.pagetype ) { retValue += "ptyp=" + document.cnnSwim10.pagetype + ";"; }
		return retValue;
	}

	function cnnAdGetFolders() {
		var retValue = "";
		if( document.cnnSwim10.section ) {
			if( document.cnnSwim10.section != "" ) {
				retValue += "path=" + document.cnnSwim10.section + ";";
			}
		}
		if( document.cnnSwim10.subsection ) {
			if( document.cnnSwim10.subsection != "" ) {
				retValue += "path=" + document.cnnSwim10.subsection + ";";
			}
		}
		return retValue;
	}

	function cnn10Swim_isRookie() {
		var retValue = false;
		if( document.cnnSwim10.subsection ) {
			switch( document.cnnSwim10.subsection ) {
				case 'sonia-dara': retValue = true; break;
				case 'zoe-duchesne': retValue = true; break;
				case 'genevieve-morton': retValue = true; break;
				case 'julie-ordon': retValue = true; break;
				case 'dominique-piek': retValue = true; break;
				case 'christine-tiegen': retValue = true; break;
				default: break;
			}
		}
		return retValue;
	}

	function cnnAdWriteDebug( input ) {
		return ( ( input.replace( /;/g, "; " ) ).replace( /\//g, " / " ) ).replace( /\./g, ". " );
	}

	function cnnAdWriteSpecialAd() {
		if( document.cnnSwim10.subsection && ( document.cnnSwim10.subsection == "brooklyn-decker" ) ) {
			document.write( '<li class="cnnItem3"><div id="cnnAdSpecialAd"></div></li>' );
			var cnnAdSpecialAd_params = {
				quality: "high",
				scale: "noscale",
				wmode: "transparent",
				bgcolor: "#000000",
				allowfullscreen: "true"
			};
			var cnnAdSpecialAd_flashvars = {
				isIE: "0",
				flashMedia: "full/images/"
			};
			var cnnAdSpecialAd_attributes = {
				id: "cnnAdSpecialAd",
				name: "cnnAdSpecialAd"
			};
			swfobject.embedSWF( "http://i.cdn.turner.com/si/2010_swimsuit/models/brooklyn-decker/full/brooklyn_fullScreenGallery.swf", "cnnAdSpecialAd", "240", "38", "9.0.124", "http://i.cdn.turner.com/si/.e/swf/4.1/global/expressInstall.swf", cnnAdSpecialAd_flashvars, cnnAdSpecialAd_params, cnnAdSpecialAd_attributes );
		}
	}

/****/
/* SPONSORED LINKS */
/****/

	function cnnCreateSL() {
		document.write( '<scr'+'ipt type="text/javascript">adsonar_placementId=1489951;adsonar_pid=769767;adsonar_ps=-1;adsonar_zw=800;adsonar_zh=108;adsonar_jv=\'ads.tw.adsonar.com\';</scr'+'ipt><scr'+'ipt language="JavaScript" src="http://js.adsonar.com/js/tw_cnn_adsonar.js"></scr'+'ipt>' );
	}


/****/
/* GALLERY */
/****/

	function cnnCreateWatermark() {
		// grab the anchor tag of id cnnWatermark, grab the alt tag from the image inside said anchor, and append the code for the overlay (a blank pixel with the same alt tag as the real photo to mimic the hover state) to the anchor's innerHTML.
		try {
			var title = document.getElementById("cnnWatermark").getElementsByTagName("IMG")[0].alt;
			document.getElementById("cnnWatermark").innerHTML += '<img src="http://i.cdn.turner.com/si/.e/img/4.0/global/pixels/blank_pixel.gif" border="0" alt="' + title + '" title="' + title + '" class="cnnImageWatermark"/>';
		} catch( e ) {
			// do nothing
		}
	}

	var siPhotoGallery = function() {
		var that = {};
		var bodyId = '#sipg';
		/**
		 * Initializes the photo gallery page
		 */
		that.init = function(urlPrev, urlNext) {
			// make sure dom has fully loaded before performing
			$(document).ready(function(){
				cnnCreateWatermark();
				// initialize image nav arrow functionality
				initPhotoArrows(urlPrev, urlNext);
			});
		};
		/**
		 * Initializes left/right arrow nav over large photo
		 */
		initPhotoArrows = function(urlPrev, urlNext) {
			$('#cnnImage').arrowNav({prevUrl:urlPrev,nextUrl:urlNext,showArrows:false,arrowHeight:107,arrowWidth:35});
		};
		return that;
	};

/****/
/* NAVBAR */
/****/

	function cnnStartList() {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("cnnSwim10Nav");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" cnnOver";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" cnnOver", "");
					}
				}
			}
		}
	}

	function ET()
	{
		window.open('email.php?url='+document.location.href, 
				  'windowname1', 
				  'width=600, height=600');
	}
/****/
/* SHARE */
/****/

	var cnnShare = {
		"t" : document.title, // title
		"t2" : "", // title, shorter
		"l" : document.location.href, //link
		"m" : "", //media (news, video, image)
		"d" : "", //description
		"c1" : "", // digg category
		"rss":"http://rss.cnn.com/rss/si_topstories.rss"
	}
	cnnShare.o = function(t, add) { 
		out = this[t];
		// if add is present, append as a query parameter
		if (add != null) {
			out = out.replace(/\#/,'');
			if (out.indexOf('?') > 0) out = out + '&' + add;
			else out = out + '?' + add;
		}
		return encodeURIComponent(out); 
	}

	cnnShare.popup = function(url, opt) { 
		if (opt) { window.open(url, 'si_bookmark', opt);
		} else { window.open(url, 'si_bookmark'); }
	}

	cnnShare.init = function() {
		if (cnnShare.t2) { return; }
		// Grab Short Title
		var tmp = document.getElementsByTagName("h1");
		if (tmp[0]) { cnnShare.t2 = tmp[0].innerHTML;  } else { cnnShare.t2 = cnnShare.t; }
		// Grab Page Description
		tmp = document.getElementsByTagName("meta");
		for (var i=0; i<tmp.length; i++){
			if (tmp[i].name.toLowerCase() == 'description') { cnnShare.d = tmp[i].getAttribute('content'); }
		}
		// Grab RSS
		tmp = document.getElementsByTagName("link");
		for (var i=0; i<tmp.length; i++){
			if (tmp[i].getAttribute('type') == 'application/rss+xml') { cnnShare.rss = tmp[i].href; }
		}
		// WRITER RSS
		if (document.location.href.indexOf('/writers/') > 0) {
			cnnShare.rss = document.location.href.replace(/^.*\/writers\//i,'').replace(/\/.*$/,'');
			cnnShare.rss="http://rss.cnn.com/rss/si_"+cnnShare.rss+".rss";
		}
	}

	cnnShare.addRef = function(add) {
		link = this.l.replace(/\#/,'');
		if (link.indexOf('?') > 0) { link = link + '&' + add; }
		else { link = link + '?' + add; }
		return link;
	}

	cnnShare.submit = function(t) {
		var url = '';
		var media = 'news';
		// FACEBOOK
		if (t == 'facebook') {
			this.popup('http://www.facebook.com/sharer.php?u='+cnnShare.o('l','eref=shareFB')+'&t='+cnnShare.o('t2'), 'width=500,height=400');
		}
		if (t == 'digg') {
			this.popup('http://digg.com/submit?title='+this.o('t2')+'&url='+this.o('l','eref=shareDigg')+'&media='+media+'&bodytext='+this.o('d'), 'width=900,height=600,scrollbars=yes');
		}
		if (t == 'twitter') {
			//alert(this.o('l'));
			this.popup('http://twitter.com/home?status='+this.o('t2')+' '+this.o('l'));
		}
		if (t == 'rss') {
			document.location = cnnShare.rss;
		}
	}
	// AddThis Params
	var addthis_pub   = 'sicom';
	var addthis_url = cnnShare.addRef('eref=shareAdd');
	var addthis_brand = 'SI';
	var addthis_logo  = 'http://s7.addthis.com/custom/si/si_com.gif';
	var addthis_options = 'stumbleupon,delicious,google,reddit,myspace,more';
	var addthis_exclude = 'facebook,twitter,digg,email,live,tehnorati';
	// Yahoo Buzz
	var yahooBuzzArticleHeadline = cnnShare.t;
	var yahooBuzzArticleSummary = cnnShare.d;
	var yahooBuzzArticleCategory = "sports";
	var yahooBuzzArticleType = "text";
	var yahooBuzzArticleId = cnnShare.l;


/****/
/* COOKIES */
/****/

	function CNN_getCookies() {
		var hash = new Array;
		if ( document.cookie ) {
			var cookies = document.cookie.split( '; ' );
			for ( var i = 0; i < cookies.length; i++ ) {
				var namevaluePairs = cookies[i].split( '=' );
				hash[namevaluePairs[0]] = unescape( namevaluePairs[1] ) || null;
			}
		}
		return hash;
	}

	function CNN_parseCookieData( cookieDataString ) {
		var cookieValues = new Object();
		var separatePairs = cookieDataString.split( '&' );
		for ( var i = 0; i < separatePairs.length; i++  ) {
			var separateValues = separatePairs[i].split( ':' );
			cookieValues[separateValues[0]] = separateValues[1] || null;
		}
		return cookieValues;
	}

	function CNN_setCookie( name, value, hours, path, domain, secure ) {
			var numHours = 0;

			if ( hours) {
				if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
					numHours = hours;
				} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
					numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
				}
			}

			document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.

	}


	function CNN_killCookie( name, path, domain ) {
		var allCookies = CNN_getCookies();

		var theValue = allCookies[ name ] || null; // We need the value to kill the cookie
		if ( theValue ) {
			document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
		}
	}

	var allCookies = CNN_getCookies();

/****/
/* VIDEO */
/****/

	function showTab(tabId, tabNo) {
		var tabCollection=document.getElementById(tabId);
		tabCollection.className=tabId+tabNo+'Visible';
	}

	var cnnVideoUtils = {
		default_div			:	"playerarea",
		instance_count		:	0,
		cvp_swf				:	"http://i.cdn.turner.com/si/.element/swf/4.1/global/cvp/si_video.swf",
		players				:	[],
		play				:	function (video_id,context,h,w){
			var instance_id = this.instance_count;
			if (h===null || w===null) { h = 373; w = 662; }
			if (context === null) { context = 'main'; }
			this.players[instance_id] = new CVP({
				id : 'cvp_'+this.instance_count, 
				width : w, 
				height : h,
				flashVars : { contentId : video_id, context : context, wmode : 'transparent' },	
				embed : {
					containerSwf : this.cvp_swf,
					expressInstallSwf : 'http://i.cdn.turner.com/si/.element/swf/4.1/global/expressInstall.swf',
					options : {
						quality : 'high', bgcolor : '#000000', allowFullScreen : 'true', 
						allowScriptAccess : 'always', wmode : 'transparent'
					}
				}
			});
			this.players[instance_id].embedSWF(this.default_div);			
			this.instance_count++;
		},
		noflash				:	function(id) {
			var msg = '<a href="http://get.adobe.com/flashplayer/" target="_blank" class="msg">This video requires a Flash client to play. <br/> Please click here to download the latest version of Flash.<\/a>';
			if(navigator.userAgent.indexOf('iPad')>-1) {
				msg = '<a href="/video" target="_blank" class="msg">This video is not available for your device at this time. <br/> Please click here for more SI videos.<\/a>';
			}
			if (document.getElementById(id)) { document.getElementById(id).innerHTML = msg; }
			this.generic_ad();
		},
		generic_300x250		:	'http://ad.doubleclick.net/adi/3475.si/video/;path=video;file=index_html;dcove=d;sz=300x250;tile=2',
		generic_ad			:	function() {
			if (document.getElementById('ad300x250')) { document.getElementById('ad300x250').src = this.generic_300x250; }
			else if (typeof cnnPageOnload == 'function') {
				var old_func = cnnPageOnload;
				cnnPageOnload = function() {
					if (document.getElementById('ad300x250')) { document.getElementById('ad300x250').src = this.generic_300x250; }
					old_func();
				};
			}	
		},
		"last"				:	""
	};

	/* 
	instantiate cvp
		videoId - video to play
		vArea - div id to embed player
		vContext - player context name
		vReturn - return the name of the player if mulitple players on the page (0,1)
	 */
	// define global var for default player
	var cnnCVP;
	function cnnVideoNewPlayer(videoId, vArea, vContext, vReturn) {
		if (vArea.length == 0) { vArea = "playerarea"; }
		if (vContext.length == 0) { vContext = "swim10embed";}
		var cvpTmp;	var vWidth; var vHeight; var autoStart = 1;
		if (vContext == "swim10player") {
			vWidth = 672; vHeight = 378;
		} else if (vContext == "swim10home") {
			vWidth = 704; vHeight = 396;
		} else if (vContext == "swim10model") {
			vWidth = 320; vHeight = 180;
		} else { // embed
			vWidth = 400; vHeight = 225; autoStart = 0;
		}

		/* Test for iPAD */
		if(navigator.userAgent.indexOf('iPad')>-1) {
			cnnVideoAlt( vWidth, vHeight, vArea, videoId, autoStart); return;
		}	

		cvpTmp = new CVP({
			id : 'cvp_'+videoId,
			width : vWidth,
			height : vHeight,
			flashVars : {
				contentId : videoId,
				context : vContext
			},
			embed : {
				containerSwf : 'http://i.cdn.turner.com/si/.element/swf/4.1/global/si_video.swf',
				expressInstallSwf : 'http://i.cdn.turner.com/si/.e1d/swf/4.0/global/expressInstall.swf',
				options : {
					quality : 'high',
					bgcolor : '#000000',
					allowFullScreen : 'true',
					allowScriptAccess : 'always',
					wmode : 'transparent'
				}
			}
		});
		// return a new named player instance
		if (vReturn == 1 || vReturn == 'true') {
			cvpTmp.embedSWF(vArea);
			return cvpTmp;
		// else use default cnnCVP
		} else {
			cnnCVP = cvpTmp;
			cnnCVP.embedSWF(vArea);
		}
	}

	/* 
	instantiate cvp
		videoId - video to play
		vArea - div id to embed player
		vContext - player context name
	 */
	function cnnVideoPlayer(videoId, vArea, vContext) {
		cnnVideoNewPlayer(videoId, vArea, vContext, 0);
	}

	/* ALTERNATIVE HTML5 PLAYER */
	function cnnVideoAlt(width, height, domIdStr, videoId, autoStart) {
		cnn_html5video.init(width, height, domIdStr, videoId, autoStart);
	}

	var cnn_html5video = {
		"playerDomId"		:	"",
		"videoId"			:	"",
		"containerDomId"	:	"",
		"width"				:	662,
		"height"			:	373,
		"autoplay"			:	0,
		"headline"			:	"",
		"halfway"			:	0,
		"video"				:	"",
		"omniture_acct"	:	"aolturnersi",
		"init"				:	function(width, height, domIdStr, videoId, autoplay) {

			/* Object to be returned */
			// NO FLASH - WebKit
			this.height = height;
			this.width = width;
			this.autoplay = autoplay;
			this.playerDomId = domIdStr + '_html5videoplayer';
			this.videoId = videoId;
			this.containerDomId = domIdStr;
			var videoXmlUrl = '/.element/auto/video/tvp_mdf/swimsuit/'+this.videoId+'.xml';

			this.req = new XMLHttpRequest();
			this.req.onreadystatechange = function(response) {
				if(cnn_html5video.req.readyState!=4) { return;}
				cnn_html5video.request(response); 
			};
			this.req.open("GET", videoXmlUrl, true);
			this.req.send('');
		},

		"request" 			:	function(response) {
				this.halfway = 0;
				var data = this.req.responseText;
				var flvurl = false;
				var matchArr = data.match(/<file bitrate="1200"[^>]+>([^<]+)<\/file>/);
				if(matchArr) {
					flvurl = matchArr[1].replace(/\d+\.f4v/,'mp4');
					flvurl = flvurl.replace(/f[l4]v$/,'mp4');
					if (flvurl.indexOf('swimsuit')>-1) { flvurl = flvurl.replace(/\%[20\%]+/g,'.'); }
					if(flvurl.indexOf('mp4:turner-si/')>-1) {
						// DANPATRICK
						cnnVideoUtils.noflash(this.containerDomId); return;
					} else {
						flvurl = 'http://ht.cdn.turner.com/si/big/video'+flvurl;
					}
				} else {
					cnnVideoUtils.noflash(this.containerDomId); return;
				}
				this.posterurl = '';
				matchArr = data.match(/<image name="embed" [^>]+>([^<]+)<\/image>/);
				if( matchArr) { this.posterurl = matchArr[1]; }
				matchArr = data.match(/<headline[^>]*>([^<]+)<\/headline>/);
				if( matchArr) { this.headline = matchArr[1]; }
				this.video = document.getElementById(this.playerDomId);
				if ( this.video !== null ) {
					this.video.setAttribute('poster',this.posterurl);
					this.video.setAttribute('src', flvurl);
				} else {
					document.getElementById(this.containerDomId).innerHTML = '';
					html = '<div class="html5player"><video id="'+this.playerDomId+'" width="'+this.width+'" height="'+this.height+'" poster="'+this.posterurl+'" '+
							'controls="controls" src="'+flvurl+'" ></video></div>';
					document.getElementById(this.containerDomId).innerHTML = html;
				}

				/* Add Trackers - none */
				this.video = document.getElementById(this.playerDomId);
				this.video.addEventListener('playing', function () { cnn_html5video.event('playing'); }, false);
				this.video.addEventListener('timeupdate', function () { cnn_html5video.event('timeupdate'); }, false);
				this.video.addEventListener('ended', function () { cnn_html5video.event('ended'); }, false);
				/* Other actions */
				cnnVideoUtils.generic_ad();

		},
		"event"		:	function(event) {
			switch(event) {
				case 'playing':
					this.nielsen();
					this.omni('playing');
					/* pause T1 */
					if (window.cnnT1) { 
						cnnT1.play(false); 
						document.getElementById('cnnCredit').style.visibility="hidden";
					} 
					break;
				case 'timeupdate':
					if (this.halfway) { return; }
					if (this.video.currentTime / this.video.duration >= 0.5 ) {
						this.halfway = 1;
						this.video.removeEventListener( 'timeupdate', this, false );
						this.omni('halfway');
					}
					break;
				case 'ended':
					this.omni('ended');
					break;
				default:
					break;
			}
		},

		"nielsen"		:	function(){
			var bug = document.createElement('img');
			bug.setAttribute('src', 'http://secure-us.imrworldwide.com/cgi-bin/m?cc=1&ci=us-100120&c6=vc,c03&tl=dav0-HTML5&cg=HTML5&rnd='+Date.now().toString().slice( 0, -3 ) );
			document.getElementById(this.containerDomId).appendChild(bug);
		},
		"omni"	:	function(event){
			if (window.s_account) { this.omniture_acct = window.s_account; }
			/* Skip Vault */
			if (this.omniture_acct.indexOf('vault')>-1) { return; }
			var s = s_gi(this.omniture_acct);
			if (event == 'playing') {
			/* PLAYING */
				s.linkTrackVars = 'prop11,prop13,eVar7,eVar8,eVar9,channel,events';
				s.linkTrackEvents = 'event8';
				s.events = 'event8';
				s.channel = 'HTML5 SI';
				s.prop11 = 'video play|mainnull|' + this.videoId;
				s.prop13 = 'video player|HTML5';
				s.eVar7 = 'video play|mainnull|' + this.videoId; 
				s.eVar8 = 'video player|HTML5';
				s.eVar9 = '';
				s.tl( this, 'o', this.headline );
			} else if (event == 'halfway') {
			/* HALFWAY */
				s.linkTrackVars = 'eVar7,eVar8,eVar9,channel,events';
				s.linkTrackEvents = 'event11';
				s.events = 'event11';
				s.channel = 'HTML5 SI';
				s.eVar7 = 'video play|mainnull|' + this.videoId; 
				s.eVar8 = 'video player|HTML5';
				s.eVar9 = '';
				s.tl( this, 'o', this.headline );
			} else if (event == 'ended') {
			/* ENDED */
				s.linkTrackVars = 'eVar7,eVar8,eVar9,channel,events';
				s.linkTrackEvents = 'event12';
				s.events = 'event12';
				s.channel = 'HTML5 SI';
				s.eVar7 = 'video play|mainnull|' + this.videoId; 
				s.eVar8 = 'video player|HTML5';
				s.eVar9 = '';
				s.tl( this, 'o', this.headline );
			}
		}

	};


