var currentPosition;
var currentRemaining;
var currentVolume;
var currentItem;
var currentState;
var currentLoad;
var currentXsize;
var currentYsize;

// this function is caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { 
	var player = document.getElementById('playerID');
	player.sendEvent(typ,prm); 
	$("#video_playlist .video").removeClass('video_playing');
	$("#video_playlist .v"+prm).addClass('video_playing');

};


// these functions is called by the JavascriptView object of the player.
function getUpdate(typ,pr1,pr2,swf) {
	if(typ == "time") { currentPosition = pr1; pr2 == undefined ? null: currentRemaining = Math.round(pr2); }
	else if(typ == "volume") { currentVolume = pr1; }
	else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100);}
	else if(typ == "state") { currentState = pr1; }
	else if(typ == "load") { currentLoad = pr1; }
	else if(typ == "size") { currentXsize = "X=" + pr1; pr2 == undefined ? null: currentYsize = "Y=" + Math.round(pr2); }
};

function getItemData(idx) {
	var obj = thisMovie("playerID").itemData(idx);
	var vID = 'video_' + (currentItem + 1);

 $("#video_playlist .video").removeClass('video_playing');
 $("#"+vID).addClass('video_playing');
};


// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("playerID").loadFile(obj); };

function addItem(obj,idx) { thisMovie("playerID").addItem(obj,idx); };

function removeItem(idx) { thisMovie("playerID").removeItem(idx); };

function getLength(swf) { return(thisMovie(swf).getLength()); };


// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};


// This creates the player after the page has finished loading (onload).
function createPlayer() {
	var fo = new FlashObject("/flash/jw_player.swf", "playerID", "320", "260", "8", "#FFFFFF");
	fo.addParam("allowScriptAccess", "sameDomain");
	fo.addParam("quality", "high");
	fo.addParam("scale", "noscale");
	fo.addParam("loop", "false");
	fo.addParam("wmode", "transparent");
	fo.addVariable("enablejs","true");
	fo.addVariable("javascriptid","playerID");
	fo.addVariable('file','/xml/mrss.xml');
	fo.addVariable('image','http://v2.igametv.com/images/layout/temp_video_bg.jpg');
	//fo.addVariable('callback','analytics');
	//fo.addVariable('logo','/images/video_overlay.png');
	fo.write("vid_player");
};