
var loading = new Image();
loading.src = "/images/loading.gif";
var y = YAHOO.util.Dom;
var container;

YAHOO.util.Event.onDOMReady(init);

function init() {
    container = y.get("divContent");
   // GetContents(1);
}

function GetContents(Id) {
    
    showLoading();    
    var callback = {
        success: handleSuccess,
        failure: handleFail,
        timeout: 5000
    };
    var request = YAHOO.util.Connect.asyncRequest("POST", "getvideopresentation.php", callback, "Id=" + Id); 
}

function showLoading() {
    container.innerHTML = "";    
    y.get("player1").innerHTML="";	
    container.appendChild(loading);
}

function handleSuccess(o) {
	var match = /<!--Movie::(.*)-->/.exec(o.responseText);
    container.innerHTML = o.responseText;
	if (match) 
		displayMovie(match[1]);	
	else
		 y.get("player1").innerHTML="";
}

function handleFail(o) {
    alert(o.statusText);
}

function displayMovie(file) {
	if(file != "")
	{
		var swo = new SWFObject('inthenews/flvplayer.swf','single','320','260','8');
		swo.addParam('allowfullscreen','false');
		swo.addVariable('file','/uploads/moviefiles/' +file);
		swo.addVariable('autostart','false');
		swo.addVariable('backcolor','0x97ADB5');
		swo.addVariable('frontcolor','0xffffff');
		swo.addVariable('lightcolor','0x999999');
		swo.write('player1');
	}
}

