
var currentPosition;
var currentRemaining;
var currentVolume;
var currentItem;
var currentState;
var currentLoad;
var currentXsize;
var currentYsize;

var seekstat = 0;
var seekflag = 0;

function sendEvent(typ, prm){
    thisMovie("vmp1").sendEvent(typ, prm);
};



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);}
    
    var pl = $('pp');
//	vol.set(currentVolume);
    
    if (currentState == 0) {
        if (pl.hasClass('pause')) {
            pl.removeClass('pause');
            pl.addClass('play');
        }
    }
    if (currentState == 1) {
    }
    if (currentState == 2) {
        if (pl.hasClass('play')) {
            pl.removeClass('play');
            pl.addClass('pause');
        }
        
    }
    if (currentState == 3) {
    
    }
    
    
    pb1.setValue(currentLoad);
    
    var seek = new Slider($('seek-bar'), $('seek-pointer'), {
        steps: currentRemaining,
        onComplete: function(pos){
            sendEvent('sbrub', pos);
        }
    }).set(currentPosition);
};

function getItemData(idx){
    var obj = thisMovie("vmp1").itemData(idx);
    
    
};



function loadFile(obj){
    thisMovie("vmp1").loadFile(obj);
};

function addItem(obj, idx){
    thisMovie("vmp1").addItem(obj, idx);
};

function removeItem(idx){
    thisMovie("vmp1").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];
    }
};



function vmp(){
	if (arguments[0] && arguments[0]!="") {
		var theFile = arguments[0];
	} else {
		var theFile = "videos/playlist.php";
	}
	if (arguments[1] && arguments[1]!="") {
		var width = arguments[1];
	} else {
		var width = "300";
	}
	if (arguments[2] && arguments[2]!="") {
		var height = arguments[2];
	} else {
		var height = "247";
	}
    //	    var so = new SWFObject("mediaplayer.swf","acirplayer","465","253","3");
	
	
	if (arguments[3] && arguments[3] != "") {
		var so = new SWFObject("/vmp/mediaplayer.swf", "vmp1", width, height, "3");
	}
	else {
		var viewHeight = height - 20;
		var so = new SWFObject("/vmp/mediaplayer.swf", "vmp1", width, viewHeight, "3");
	}
	so.addParam("allowfullscreen", "true");
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','opaque');
	so.addVariable('javascriptid','vmp1');
    so.addVariable("file", theFile);
	so.addVariable("width", width);
	so.addVariable("height", height);
	so.addVariable("logo", "logo.png");
    so.addVariable("overstretch", "fit");
    so.addVariable("shuffle", "false");
    so.addVariable("enablejs", "true");
    so.write("video");
	
   /*
 var vol = new Slider($('vol-bar'), $('vol-pointer'), {
        steps: 100,
        onChange: function(e){
        sendEvent('volume', e);
        }
    }).set(100);
	
*/
	return true;
}



window.addEvent('domready', function(){
/*
	     vmp();
    var pl = $('pp');
    pl.addEvent('click', function(){
        if (pl.hasClass('pause')) {
            pl.removeClass('pause');
            pl.addClass('play');
            sendEvent('playpause');
        }
        else {
			
            if (pl.hasClass('play')) {
                pl.removeClass('play');
                pl.addClass('pause');
            	sendEvent('playpause');
            }
		} 
    })
*/

});

