/*function loadFLV(f,a,i,h,w,li) {
	vi = (typeof i == "undefined") ? 0:i
	l = (typeof a == "undefined") ? "false":a;
	var F = {movie:"/flash/flvplayer/flvplayer-5.8.swf",width:w,height:h,majorversion:"7",build:"0",bgcolor:"#FFFFFF",id:"ftmovie",allowfullscreen:"true",
	            flashvars:"overstretch=false&showfsbutton=true&width=" + w + "&height=" + h +"&id=" + vi + "&file=" + f + "&image=" + li + "&enablejs=true&showdigits=false&autostart=" + l};
	UFO.create(	F, "flashbanner");
}*/

var player;
var videoid;
function loadFLV(f,a,i,h,w,li,sc,id,v,sum,hd,ads) {
	vi = (typeof i == "undefined") ? 0:i;
	l = (typeof a == "undefined") ? "false":a;
	c = (typeof sc == "undefined") ? "bottom" : sc;
	id = (typeof id == "undefined") ? "flashbanner" : id;
	oid = (id == 'flashbanner') ? 'ftmovie' : id+'_object';
	volume = (typeof v == "undefined") ? "100" : v;
	flashvars = null;

	// Build the plugins string depending on parameters
	var plugins;

	// Check to see if we have an HD version and if so, figure out the HD filename
	var hdfile = "";

	if (hd == true)
	{
		var pos;

		// Include the HD plugin
		plugins = "hd-1,drelated-1";

		// Figure out the HD filename and add that into the flashvars
		pos = f.lastIndexOf(".");
		hdfile = f.substr(0,pos) + ".720hd.mp4";
	}
	else
	{
		// Load the rest of the plugins.
		plugins = "drelated-1";
	}

	if (ads == true)
	{
		plugins += ",http://vox-static.liverail.com/swf/v4/plugins/jwplayer/5.0/LiveRail.swf";
	}

	flashvars = {	"overstretch":"false",
					"showfsbutton":"true",
					"width":w,
					"height":h,
					"id":vi,
					"file":f,
					"image":li,
					"enablejs":"true",
					"showdigits":"true",
					"type":"http",
					"repeat":"list",
					"abouttext":"AusGamers",
					"aboutlink":"/about/",
					"controlbar":c,
					"autostart":l,
					"volume":volume,
					"backcolor":"075F41",
					"frontcolor":"ffffff",
					"screencolor":"cccccc",
					"playerready":"playerReady",
					"plugins":plugins,
					"ltas.cc":"gjuxpssfujhfmlb",
					"drelated.dxmlpath":"/videos/related.php?search="+sum,
					"drelated.dtarget":"_self",
					"drelated.dskin":"/res/flash/grayskin.swf",
					"drelated.dposition":"center",
					"hd.file":hdfile,
					"hd.state":false,
					'liverail.LR_PUBLISHER_ID': '6656',
					'liverail.LR_LAYOUT_SKIN_MESSAGE': 'Please wait, yo! It is totally worth it! {COUNTDOWN}'
			}

	params = { 
		'allowscriptaccess':'always',
		'allowfullscreen':'true',
		'wmode':'transparent'
		}

	attributes = 
	{
		'id':vi,
		'name':vi
	}
					
	swfobject.embedSWF("/res/flash/flvplayer-5.8.swf", id, w, h, "7.0.115",null,flashvars,params,attributes);
}

var player = null;
function playerReady(e) {

	// 2010-12-09 - trog - changed to the documented method
	// 2011-12-06 - trog - note this doesn't work for IE it seems; the object passed in here doesn't have an
	// 'id' property. No idea why; I have posted to their forum about it: 
	// http://www.longtailvideo.com/support/forums/jw-player/javascript-interaction/23785/object-passed-to-playerready-invalid-if-just-using-embed
	player = document.getElementById(e['id']);

	// If the player isn't found properly, then we can't add the listener and thus can't track events. 
	// This currently will (or should) only happen on our lame <embed> code for IE users. 
	if (!player)
	{
	}
	else
	{
		player.addModelListener('STATE', 'stateMonitor');
	}
};

function stateMonitor(obj)
{
	// 2011-12-04 - trog - If we don't have a videoid variable set, it means we're probably using embeddable code. 
	// Let's try this hack to get the video id. 
	if (!videoid)
	{
		videoid = obj.id;
	}

	if(obj.newstate == 'BUFFERING')
	{
		new Ajax("/videos/sc.php", {postBody: 'state=start&id='+videoid, evalScripts:true}).request();
	}
	else if (obj.newstate == 'COMPLETED')
	{
		new Ajax("/videos/sc.php", {postBody: 'state=complete&id='+videoid}).request();
	}

	// Unset the videoid so that for pages with multiple videos (i.e., news home) this code fires correctly)
	videoid = false;
};

