//////////// MAIN PLAYER SCRIPTS ///////////

// define videos (large scale id; petatv/embed id)
videoList = new Array(
	'Stolen_for_fashion_peta2_022509_640_high,whose_skin_are_you_in-peta-peta2_lrg_high,tim_gunn_fashion_victims_peta2_lrg_high&i=stolen-for-fashion-640-high', 'Stolen_for_fashion_peta2_022509_std_high,whose_skin_are_you_in-peta2_high,tim_gunn_fashion_victims_peta2_high',
	'whose_skin_are_you_in-peta-peta2_lrg_high,tim_gunn_fashion_victims_peta2_lrg_high,Stolen_for_fashion_peta2_022509_640_high', 'whose_skin_are_you_in-peta2_high,tim_gunn_fashion_victims_peta2_high,Stolen_for_fashion_peta2_022509_std_high',
	'tim_gunn_fashion_victims_peta2_lrg_high,Stolen_for_fashion_peta2_022509_640_high,whose_skin_are_you_in-peta-peta2_lrg_high', 'tim_gunn_fashion_victims_peta2_high,Stolen_for_fashion_peta2_022509_std_high,whose_skin_are_you_in-peta2_high'
);

// play function
videoLoaded = false;
function playVideo(vId) {
	// reset video links
	aEls = document.getElementById('videoListContent').getElementsByTagName('A');
	for(i=0;i<aEls.length;i++) {
		aEl = aEls[i];
		// highlight the selected video thumbnail
		aEl.className = (vId==i) ? 'selected' : '';		
	}
	// identify video information
	playerLink = videoList[(vId*2)];
	embedLink = videoList[(vId*2)+1];
	firstEmbedLink = (embedLink.indexOf(',')!=-1) ? embedLink.substr(0,embedLink.indexOf(',')) : embedLink;
	if (firstEmbedLink.substr(-5)=='_high') firstEmbedLink = firstEmbedLink.substr(0,firstEmbedLink.length-5);

	// load large player
	videoSource = 'http://www.petatv.com/swf/video.swf?v='+playerLink+((videoLoaded)?'&ap=1':'');
	iframeEl = document.getElementById('video_iframe');
	iframeEl.src = videoSource;

	// customise embed link text for first video
	embedLinkText = ((vId*1)) ? '' : "&quot;Stolen for Fashion&quot;&amp;mdash;Learn More at peta2.com.";

	// set video option links
	document.getElementById('vid_options_link').href = "http://www.petatv.com/tvpopup/Prefs.asp?video="+firstEmbedLink;
	document.getElementById('vid_download_link').href = "http://www.petatv.com/downloads/"+firstEmbedLink+".zip";
	document.getElementById('vid_embed_link').href = "javascript:showEmbedCode('"+embedLink+"','"+embedLinkText+"');void(0);";
	videoLoaded = true;
}

// pop up dynamic embed code window for main player
function showEmbedCode(v,t) {
	if (!t) t = 'Learn more at peta2.com.';
	window.open('embed.aspx?vid='+v+'&t='+escape(t), '_blank', 'width=300,height=140,scrollbars=yes,resize=yes,status=yes');
}



