var lastVid = "";


var thisFLVPlayer = null; 
function playerReady(thePlayer) { 
	thisFLVPlayer = window.document[thePlayer.id]; 
	thisFLVPlayer.addViewListener("PLAY", "onLoadTracker");
}

function muteTracker(obj) { alert('the new mute state is: '+obj.state); };
function loadPlayer(pid) {
		// Create child for swfobject
		document.getElementById('videoContainer').innerHTML = "";
		var flvVideoDiv = document.createElement('div');
		flvVideoDiv.id = 'flashVideo';
		document.getElementById('videoContainer').appendChild(flvVideoDiv);
        var flvVars = {
//                listbnqt: escape("http://www.bnqt.com/embed.php?pid=" + pid ),
                enablejs: "true",
		controlbar: 'none',
		config: escape("http://www.bnqt.com/flvConfig/"+ pid + ".xml"),
                javascriptid: "bnqtmovie",
                overstretch: "exactfit",             
                autostart: "false",
                displaywidth: "320",
              	displayheight: "263",
//                callback: "eventCallback",
                bufferlength: "2"
        };
        var flvParams = {
                        allowscriptaccess: "always",
                        allowfullscreen: "true",
                        wmode: "transparent"
        };
        var attrib = { id: "movie1", name: "movie1" };
		
        var so = swfobject.embedSWF("http://www.bnqt.com/bnqtPlayer/vid_"+ pid, "flashVideo", "320", "293", "9.0.115", "/swf/expressInstall.swf", flvVars, flvParams, attrib);
}




function loadVideo(pid) {
	if (lastVid != "") {
		document.getElementById('nowPlaying_'+ lastVid).innerHTML = "";
	} 
	thisFLVPlayer.sendEvent('STOP');
	swfobject.removeSWF('movie1');
	loadPlayer(pid);
	setTimeout('thisFLVPlayer.sendEvent("PLAY")', 3000);
	document.getElementById('nowPlaying_'+ pid).innerHTML = "NOW PLAYING";
	lastVid = pid;
}
/*
function onLoadTracker(obj) {

	alert('video loaded');
		var pObj = thisFLVPlayer.getPlaylist()[0];
	document.getElementById('nowPlaying_'+ pObj.platform_id).innerHTML = "NOW PLAYING";
	document.getElementById('vidTitle').innerHTML = '<a href="'+ pObj.info +'" style="color: #000000;">'+ 
		pObj.title + '</a>';

alert('video loaded 2');	
	}
}
*/
function onLoadTracker(obj) {

	var pObj = thisFLVPlayer.getPlaylist()[0];
	
	document.getElementById('vidTitle').innerHTML = '<a href="'+ pObj.link +'" style="color: #000000;">'+  pObj.title + '</a>';
	document.getElementById('vidDesc').innerHTML = pObj.description.substr(0, 150) + '... <a href="'+ pObj.link +'" class="more">More</a>';		


}


function getUpdate(typ,pr1,pr2,pid) {
	if (typ == "time") { 
		currentPosition = pr1; 
	} else if (typ == "volume") { 
		currentVolume = pr1; }
	else if (typ == "item") { 
		currentItem = pr1; 
		setTimeout("getItemData(currentItem)",100); 
	}
	var id = document.getElementById(typ);
	id.innerHTML = typ+ ": "+Math.round(pr1);
	pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
};

