/*
 * Flash helpers
 * $Id: write_flash.js 2978 2008-08-15 20:24:59Z tsigouin $
 */

var currentPlaybackVideoId = null;
var playid;
var flash;
var ran=0;

// ---------------------------------------------------
// No commerical flag.
// 0 = all commericals
// 1 = no prerolls
// 2 = no commericals
// 3 = commericals allowed + pre roll is mandatory
// ---------------------------------------------------
var ncf = 0;

function flashControlObjectLoaded() 
{
	if (ran==0) 
	{
		ran=1;
		if(navigator.appName.indexOf ("Microsoft") != -1) 
		{
			flash = window.flashPlayer;
		}
		else 
		{
			flash = window.document.flashPlayer;
		}
	}
	
	var url = '/program/?op=view&id='+playid;
	
	if (ncf)
	{
		url += '&ncf='+ncf;
	}
	
	playList(url);
}


function play(vid)
{
	var url = '/program/?op=view&id='+vid;
	
	if (ncf)
	{
		url += '&ncf='+ncf;
	}
	
	playList(url)
}

function writeEditor(id, vid, sourceid, videoid) 
{
	//var thisdate = new Date();
	//var newdate = thisdate.getTime();
	var editmode = true;
	var volume = 50;
	var swffile = '/flash/player/player.swf';
	
	var mainControl = '<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="100%" height="100%" id="flashPlayer" align="left"><param name="movie" value="'+swffile+'" /><param name=FlashVars value="vid='+vid+'&volumeLevel='+volume+'&sourceid='+sourceid+'&editmode='+editmode+'&videoid='+videoid+'"><param name="quality" value="high" /><param name="allowFullScreen" value="true" /><param name="bgcolor" value="#ffffff" /><param name="allowScriptAccess" value="sameDomain" /><embed src="'+swffile+'" FlashVars="vid='+vid+'&volumeLevel='+volume+'&sourceid='+sourceid+'&editmode='+editmode+'&videoid='+videoid+'" quality="high" bgcolor="#ffffff"  width="100%" height="100%" swLiveConnect="true" allowFullScreen="true" name="flashPlayer" align="left" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	
	document.getElementById(id).innerHTML = mainControl;
	playid = vid;
}



function writePlayer(id, vid, videoid) 
{
	//var playback = true;
	//var thisdate = new Date();
	//var newdate = thisdate.getTime();
	var volume = 50;
	var swffile = '/flash/player/player.swf';
	
	var mainControl = '<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="100%" height="100%" id="flashPlayer" align="left"><param name="movie" value="'+swffile+'" /><param name=FlashVars value="vid='+vid+'&volumeLevel='+volume+'&videoid='+videoid+'"><param name="quality" value="high" /><param name="allowFullScreen" value="true" /><param name="bgcolor" value="#ffffff" /><param name="allowScriptAccess" value="sameDomain" /><embed src="'+swffile+'" FlashVars="vid='+vid+'&volumeLevel='+volume+'&videoid='+videoid+'" quality="high" bgcolor="#ffffff"  width="100%" height="100%" swLiveConnect="true" allowFullScreen="true" name="flashPlayer" align="left" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	
	document.getElementById(id).innerHTML = mainControl;
	playid = vid;
}








function ytPlayer(id, vid, volume) 
{
	//var thisdate = new Date();
	//var newdate = thisdate.getTime();
	var swffile = '/flash/ytRipPlayer/swf/ytRipPlayer.swf';
	
	var mainControl = '<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="100%" height="100%" id="flashPlayer" align="left"><param name="movie" value="'+swffile+'" /><param name=FlashVars value="vid='+vid+'&volumeLevel='+volume+'"><param name="quality" value="high" /><param name="allowFullScreen" value="true" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="sameDomain" /><embed bgcolor="#000000" src="'+swffile+'" FlashVars="vid='+vid+'&volumeLevel='+volume+'" quality="high" bgcolor="#ffffff"  width="100%" height="100%" swLiveConnect="true" allowFullScreen="true" name="flashPlayer" align="left" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	
	document.getElementById(id).innerHTML = mainControl;
	playid = vid;
}


function writeRating(id, rating)
{
	var swffile = '/flash/starRating/starRating.swf';
	
	var mainControl = '<embed  src="'+swffile+'" FlashVars="currentRate='+rating+'" quality="high" bgcolor="#ffffff"  width="100%" height="100%" swLiveConnect="true" align="left" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	document.getElementById(id).innerHTML = mainControl;
}

function playList(thelist) 
{
	flash.submitPlaylist(thelist);
}


function getXmlFeedUrl(feedname, param1name, param1value)
{
	var url = "/program/xml/feed/" + feedname;
	
	if (param1name && param1value)
	{
		url += "/" + param1name + "/" + param1value;
	}
	
	return url;
}


function writeRipFlow2(id, xmlurl, width, height) 
{
	var path='/flash/ripFlow/';
	var ctrl_file='ripFlowLight.swf';
	var ctrl_file_path=path+ctrl_file;
	
	document.getElementById(id).innerHTML = "<embed src='"+ctrl_file_path+"' FlashVars='xmlurl="+xmlurl+"&wide="+width+"&high="+height+"' quality='high' width='100%' height='100%' swLiveConnect='true' name='flashObject' align='left' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}

function writeFeatured(id, xmlurl, theName) 
{
	var path='/flash/featured/';
	var ctrl_file='featured.swf';
	var ctrl_file_path=path+ctrl_file;
	
	document.getElementById(id).innerHTML = "<embed src='"+ctrl_file_path+"' FlashVars='xmlurl="+xmlurl+"&theName="+theName+"' quality='high' width='100%' height='100%' swLiveConnect='true' name='flashObject' align='left' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}

function writeFeaturedLong(id, xmlurl, theName) 
{
	var path='/flash/featured/';
	var ctrl_file='featuredLong.swf';
	var ctrl_file_path=path+ctrl_file;
	
	document.getElementById(id).innerHTML = "<embed src='"+ctrl_file_path+"' FlashVars='xmlurl="+xmlurl+"&theName="+theName+"' quality='high' width='100%' height='100%' swLiveConnect='true' name='flashObject' align='left' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}

function writeRipFlowSml(id, xmlurl, width, height)
{
	var path='/flash/ripFlow/';
	var ctrl_file='ripFlowSml.swf';
	var ctrl_file_path=path+ctrl_file;
	
	document.getElementById(id).innerHTML = "<embed src='"+ctrl_file_path+"' FlashVars='xmlurl="+xmlurl+"&wide="+width+"&high="+height+"' quality='high' width='100%' height='100%' swLiveConnect='true' name='flashObject' align='left' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}

function writeRipFlowTall(id, xmlurl, width, height)
{
	var path='/flash/ripFlow/';
	var ctrl_file='ripFlowTall.swf';
	var ctrl_file_path=path+ctrl_file;
	
	document.getElementById(id).innerHTML = "<embed src='"+ctrl_file_path+"' FlashVars='xmlurl="+xmlurl+"&wide="+width+"&high="+height+"' quality='high' width='100%' height='100%' swLiveConnect='true' name='flashObject' align='left' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}


function writeSendTo(id, vid, title)
{
	var path='/flash/sendto/';
	var ctrl_file='sendto.swf';
	var ctrl_file_path=path+ctrl_file;
	
	document.getElementById(id).innerHTML = "<embed src='"+ctrl_file_path+"' FlashVars='v="+vid+"&title="+title+"' quality='high' width='100%' height='100%' swLiveConnect='true' name='flashObject' align='left' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}



function autoplay()
{
//	playList('/program/?op=view&id=321');
}





//old player functions
function writeFlash(){};
function writeFlash2(){};

function onVideoStart(id)
{
	if (currentPlaybackVideoId == id)
	{
		return;
	}
	
	currentPlaybackVideoId = id;
	doBannerAds(id);
}

//TODO - evaluate ie bug.
// ie does not seem to call onVideoStart on first load
function onVideoFirstStart(id)
{
	onVideoStart(id);
}

function ShowContent(){};
function HideContent(){};
