var theItem;
var selFile;
var init;
var currentItem;
var theOutput;

function loadPlay(file,image) { 
	//theItem=idx;
	selFile=file;
	createPlayer(file,image);
	//setTimeout("play()",1100);
};

function play() {
	sendEvent('playitem',theItem);
};

function sendEvent(typ,prm) {
	thisMovie("player").sendEvent(typ,prm);
};

function getUpdate(typ,pr1,pr2,pid) {
	if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
};

function getItemData(idx) {
	///var obj = thisMovie("player").itemData(idx);

	//var theTitle = obj["title"];
	//var theDescription = obj["link"];
	//var theOutput = '<b>'+theTitle+'</b><br />'+theDescription+'';

	//document.getElementById("theCaption").innerHTML = theOutput; 

};

function updateCaption( title, description ) {
		var theOutput = '<b>' + title + '</b><br />' + description + '';
		document.getElementById("theCaption").innerHTML = theOutput; 
}

function thisMovie(movieName) {
    if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};

function createPlayer( id, image ) {
var so = new SWFObject('flvplayer.swf','player','322','243','7');
	so.addParam('allowfullscreen','true');
	so.addParam('wmode','opaque');
	so.addVariable('backcolor','0x000000');
	so.addVariable('frontcolor','0xFFFFFF');
	so.addVariable('screencolor','0x000000');
	so.addVariable('autostart','true');
	if ( image ) so.addVariable('image','/images/videos/' + image);
	so.addVariable('enablejs','true');
	so.addVariable('type','rtmp');
	so.addVariable('id', id );
	so.addVariable('file','rtmp://kera-flash.streamguys.us:80/jwplayer');

	so.write('flashbanner');
}
