
function setupVideoHeader(){

	var playerPath = "/vgn-ext-templating/overrides/flash/player.swf";
	var headerId = "video-header";
	var playerHeight = 250;
	var playerWidth = 590;
	var expressInstallUrl = "";
	
	var filePath = $('#fileURL').attr("href");
	var imagePath = $('#imageURL').attr("href");
	var flashvars = {
		screencolor: '000000',
		file: filePath,
		autostart: false,
		icons: false,
		image: imagePath,
		controlbar: 'none'
	};

	var params = {
			wmode: 'transparent',
			allowscriptaccess: 'always'
	};
		
	var attributes = {};

	if(filePath != null && filePath != "" ){
		swfobject.embedSWF(playerPath, headerId, playerWidth, playerHeight , '9.0.0', expressInstallUrl, flashvars, params, attributes);
	}else{
		var imgString = '<img alt="Header" src="' + imagePath + '"/>';
		$('#video-header').html(imgString);
	}
}

function setupFancyBoxVideoHeader(){

	var playerPath = "/vgn-ext-templating/overrides/flash/player.swf";
	var headerId = "fancybox-video-header";
	var playerHeight = 320;
	var playerWidth = 608;
	var expressInstallUrl = "";
	
	var filePath = $('#fileURL').attr("href");
	var imagePath = $('#imageURL').attr("href");
	var flashvars = {
		screencolor: '000000',
		file: filePath,
		autostart: false,
		icons: false,
		image: imagePath,
		controlbar: 'none'
	};

	var params = {
			wmode: 'transparent',
			allowscriptaccess: 'always'
	};
		
	var attributes = {};

	if(filePath != null && filePath != "" ){
		swfobject.embedSWF(playerPath, headerId, playerWidth, playerHeight , '9.0.0', expressInstallUrl, flashvars, params, attributes);
	}else{
		var imgString = '<img alt="Header" src="' + imagePath + '"/>';
		$('#video-header').html(imgString);
	}
}

function writeSustainabilityVideo()
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="710" height="373" id="FlashHeader"><param name="movie" value="/upscommunity/overrides/media/sustainability/upsSustain.swf"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="quality" value="high"><param name="flashvars" value="xmlRef=/upscommunity/overrides/media/sustainability/xml/upsSustain.xml"><param name="wmode" value="transparent"><embed src="/upscommunity/overrides/media/sustainability/upsSustain.swf" flashvars="xmlRef=/upscommunity/overrides/media/sustainability/xml/upsSustain.xml" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="710" height="373" name="FlashHeader" allowScriptAccess="sameDomain" allowFullScreen="false"></embed></object>');
} 

$(document).ready(function() {
	if($('#video-header').length){
		setupVideoHeader();
	}
	
	if($('#fancybox-video-header').length){
		setupFancyBoxVideoHeader();
	}
	
	$('a.webtrends_fix').each(function() {
		var href = $(this).attr('href');
		var index = href.lastIndexOf('/');
		var title = href.substr(index+1);
		//$(this).attr('onclick', "dcsMultiTrack('DCS.dcsuri', '" + href + "','WT.ti','" + title + "');");
		$(this).bind('click', function(){ 
				dcsMultiTrack('DCS.dcsuri', href,'WT.ti', title);
		});
	});
});


