var varr = new Array();
    varr[0]=0;
    varr[1]=7;
    varr[2]=14;
    varr[3]=21;
    varr[4]=28;
    varr[5]=35;
    varr[6]=42;
    varr[7]=49;
    varr[8]=56;
    varr[9]=63;
    varr[10]=70;
    varr[11]=77;
    varr[12]=84;
    varr[13]=100;

    var gN=0;
    var vFT1=1;
		var gV=0;
		var gDrag=0;
		var gDragInx=6;
		var gDragX=0;
		var	gImgDestI;
		var gImgDestN;
		var gVol=0;
		var gVolPos;
		var gVMouseX;
		var gVMouseY;
		var gNewVolX;
		var gFullScr=0;
		var g_arrVolume=new Array(10);
		var gIsPressedStop=false;
		var G_START_PLAY=0;
		var G_VOL_START;
		var G_VOL_LENGTH=38;
    var ARR_SIZE=100;
		var vIsPlay = new Array(ARR_SIZE);
    var StateFlag = new Array(ARR_SIZE);
    var next = new Array(ARR_SIZE);
    var CanSetPos = new Array(ARR_SIZE);
    var SetPosStart = new Array(ARR_SIZE);
    var orix = new Array(ARR_SIZE);
    var moveon = new Array(ARR_SIZE);
    var movelen = new Array(ARR_SIZE);
    var dragapproved = new Array(ARR_SIZE);
    var z;
    var x;
    var y;
    var temp1;
    var temp2;
		var isMute=false;
		var bname = navigator.appName;
	var	isExlorer=(bname == "Microsoft Internet Explorer")?true:false;
    for(var i=0; i<ARR_SIZE; i++){
	   StateFlag[i]=0;
    	next[i]=1;
    	CanSetPos[i]=true;
    	SetPosStart[i]=false;
    	orix[i]=0;
    	moveon[i]=false;
    	movelen[i]=96;
    	dragapproved[i]=false;
			vIsPlay[i]=0;
    }

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }


    function Preload(n){
		 vIsPlay[n]=0;
	   window.document.getElementById("player"+n).Controls.stop();
		 gIsPressedStop=true;
		 window.document.getElementById("divScreen"+n).style.display="none";
		 window.document.getElementById("divPict"+n).style.display="";
		 document.getElementById("spnMovieNameStatic"+n).style.display="none";
		 document.getElementById("spnMovieName"+n).style.display="none";
		 window.document.getElementById("times"+n).style.display="none";
    }


    function doPlay(n){
		try{
				if(isExlorer)
				{

					window.document.getElementById("player"+n).Controls.play();
				window.document.getElementById("player"+n).Settings.mute=isMute;

				gIsPressedStop=false;
  		 		window.document.getElementById("divPict"+n).style.display="none";
  		 		window.document.getElementById("divScreen"+n).style.display="";
				window.document.getElementById("times"+n).style.display="block";
				}

				else if(typeof(path) != "undefined")
				{
						//var w=window.open(path);
						//w.close();
				}
			}
			catch(err){
							 ;
		}
    }
    function doStop(n){

		 vIsPlay[n]=0;
	   window.document.getElementById("player"+n).Controls.stop();
		 gIsPressedStop=true;
		 window.document.getElementById("divScreen"+n).style.display="none";
		 window.document.getElementById("divPict"+n).style.display="";
		 document.getElementById("spnMovieNameStatic"+n).style.display="none";
		 document.getElementById("spnMovieName"+n).style.display="none";
		 window.document.getElementById("times"+n).style.display="none";
    }
    function doPause(n){
		try{
	   		window.document.getElementById("player"+n).Controls.pause();
			}
			catch(err){
							 ;
		}
    }



    function doFastForward(n){
	   window.document.getElementById("player"+n).Controls.FastForward();
    }



    function FullScreen(n){
			try{
						var p=window.document.getElementById("player"+n);
							 if (p.playState==3)
							 {

							 		if(gFullScr>0)
									{

							 			window.document.getElementById("player"+gFullScr).fullScreen = 'false';

								  }
	   					 		p.fullScreen = 'true';
									gFullScr=n;

							}

		  }
		  catch(err){;}
    }


//Mute or unMute the volume
    function doVolumeMute(n,btn_on,btn_off){
	   var p=window.document.getElementById("player"+n);
	   if(p.settings.mute==true){
      		p.Settings.mute=false;
      		window.document.getElementById("mButton"+n).src=btn_on;
   	    }
       else
   	    {
      		p.Settings.mute=true;
      		window.document.getElementById("mButton"+n).src=btn_off;
   	    }
				isMute=p.Settings.mute;
    }


//Change the volume
function adjVol(n,num)
{
 	var p=window.document.getElementById("player"+n);
	if (num == null)num = 7;
	if (num>13) num=13;
	if (num<0) num=0;

	nVol=num;

  p.Settings.volume=varr[nVol];
	p.Settings.mute=isMute;
}

//Write current and total time
function sdu(n)
{

	var p=window.document.getElementById("player"+n);
	if (!p ||!p.currentMedia) return;
    
    var sh = document.getElementById("show_hide");
    var tb = document.getElementById("trackball_bg1");
    if (!sh || !tb) return;
    
	if(p.currentMedia.getItemInfo('WMS_CONTENT_DESCRIPTION_PLAYLIST_ENTRY_URL') != 'Content'){
		sh.style.display="none";
		tb.style.display="none";

	}else{
		sh.style.display="block";
		tb.style.display="block";
	}
	var cur=p.controls.currentPositionString,tot=p.currentMedia.durationString;

			var totMin=parseInt(tot);
			var curMin=parseInt(cur);
			var minDif=totMin-curMin;
			var curSec=parseInt(cur.substring(cur.indexOf(':')+1));
			var totSec=parseInt(tot.substring(tot.indexOf(':')+1));
			var secDif=totSec-curSec;
			if(secDif<0)
			{
			 		secDif+=60;
					minDif--;
			}
			minDif+="";
			secDif+="";
			if(minDif.length<2)
					minDif="0"+minDif;
			if(secDif.length<2)
					secDif="0"+secDif;
			if(!isNaN(minDif)&&!isNaN(secDif)&&minDif>=0)
					window.document.getElementById("times"+n).innerHTML =minDif+':'+secDif;
			else
					window.document.getElementById("times"+n).innerHTML ="";

}
function playMedia(n){
	try{
		var p=window.document.getElementById("player"+n);
		showPos(n);

		//Set "Play" after movie end
		if(p.status=="Stopped" && gIsPressedStop==false)
		{
					window.document.getElementById("imgStop"+n).click();
					vIsPlay[n]=0;
					gIsPressedStop=true;
					doPause(n);
		}

		window.setTimeout("playMedia("+n+")",1000);
	}
	catch(err){;}
}
function moves(n)
{
	if(CanSetPos[n] && event.button!=2)
        {
 		orix[n]=event.x;
		orileft[n]=window.document.getElementById("trackball"+n).style.pixelLeft;
                SetPosStart[n]=true;
        }
        else
        {
                return false;
        }
}
//Set position of the movie
function setpos(n)
{
	var p=window.document.getElementById("player"+n);
	SetPosStart[n]=false;
	var newleft=window.document.getElementById("trackball"+n).style.pixelLeft-G_START_PLAY;
	var rcp=newleft * p.currentMedia.duration / movelen[n];
	p.controls.currentPosition  = rcp;

}
//Show slider position
function showPos(n){
	try{
		var p=window.document.getElementById("player"+n);
		if(SetPosStart[n])return;
	  var blockpos=movelen[n]*p.controls.currentPosition/p.currentMedia.duration;
		var tmp=G_START_PLAY;
		if(blockpos)tmp+=blockpos;

	  window.document.getElementById("trackball"+n).style.pixelLeft=tmp;
		window.document.getElementById("trackbg"+n).style.width=tmp-G_START_PLAY;
	}
	catch(err){;}
}

//Move volume slider
function moveVolume(){
	if(event.button==1 && gVol==1)
	{
	 		var newPosX=gNewVolX + event.clientX - gVMouseX;
			var part;
			//Check desired volume position in reqiered interval
			if(newPosX <=	G_VOL_START || newPosX >= G_VOL_START + G_VOL_LENGTH-7)
						return;
			else
			{
			 		window.document.getElementById("spnVolSlider"+gV).style.pixelLeft=newPosX;

					part=G_VOL_LENGTH/13;
					gVolPos=(newPosX-G_VOL_START-7)/part;
					gVolPos=parseInt(gVolPos);
					adjVol(gV,gVolPos);

					return false;
			}
	}
}

//Move movie slider
function move(){
	if (event.button==1 && dragapproved[gN]){
        	var newPosX = temp1+event.clientX-x;
          if(newPosX <=G_START_PLAY || newPosX > G_START_PLAY + movelen[gN])
								return;
          window.document.getElementById("trackball"+gN).style.pixelLeft=newPosX;

		  window.document.getElementById("trackball_bg"+gN).style.width=newPosX-G_START_PLAY;
          rcp=newPosX * window.document.getElementById("player"+gN).currentMedia.duration / movelen[gN];
					return false;
        }
}

function drags(){
	if (!document.all)return;
		if(event.srcElement.id=="imgPointer"+gN)
		{
  	  dragapproved[gN]=true;
  		temp1=window.document.getElementById("trackball"+gN).style.pixelLeft;
  		temp2=window.document.getElementById("trackball"+gN).style.pixelTop;
			x=event.clientX;
		  y=event.clientY;
		  document.onmousemove=move;
			SetPosStart[gN]=true;
		}

}


function volMouseDown(n){
				gVol=1;
				gNewVolX=window.document.getElementById("spnVolSlider"+n).style.pixelLeft;
				gVMouseX=event.clientX;
		  	gVMouseY=event.clientY;
		  	document.onmousemove=moveVolume;
}


function mouseUped(){
	if(gVol==1 && event.srcElement.id=="imgVolSlider")
	{
		gVol=0;
		gV=0;
	}
	else if(gN!=0)
	{
	 		 dragapproved[gN]=false;
       if(SetPosStart[gN])
			 		setpos(gN);
	}
}


function init(n, path){
	G_START_PLAY=window.document.getElementById("trackball"+n).style.pixelLeft;
	G_VOL_START=0;
	//setVolume(n);

    if (isExlorer) {
        var p=window.document.getElementById("player"+n);
        if (!p) return;
        p.url = path;
        //p.fileName = path;
        //alert("url " + p.url);
    } else {
        var p=window.document.getElementById("embed_player"+n);
        if (!p) return;
        //p.src = path;
        //alert("src " + p.src);
    }

	document.onmousedown=drags;
	document.onmouseup=mouseUped;
	document.body.onmousedown=drags;
	document.body.onmouseup=mouseUped;
	chkState(n);

	if (window.Event)
	{
		 //document.captureEvents(Event.MOUSEUP);
	}
}



function chkState(n){

	var k = document.getElementById('infoState');
    var plid = document.getElementById('player'+n);
    //if (plid == null) return;
    if (!this.isExlorer) return;
    k.innerHTML =  plid.status;
    setTimeout('chkState('+n+')',100);
}


function mouseOnSound(imgObj,n,btn_on_on,btn_off_on){
	var p=window.document.getElementById("player"+n);
	imgObj.src=(p.Settings.mute)?btn_off_on:btn_on_on;
}

function mouseOutSound(imgObj,n,btn_on,btn_off){
	var p=window.document.getElementById("player"+n);
	imgObj.src=(p.Settings.mute)?btn_off:btn_on;
}

function getX(obj) {
    try{
        return(obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent));
    }catch (e) {
				;
		}
}

function getY(obj) {
    try{
        return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
    } catch (e) {}
}


function setVolume(n){
		var volWidth=window.document.getElementById("spnVolSlider"+n).style.pixelLeft-G_VOL_START;
		window.document.getElementById("imgVolWhite"+n).style.width=volWidth;

}

function setDescription(n){


var marq=window.document.getElementById("mrqDescr"+n);
var desc=marq.innerHTML;
		if(desc.length>15)
		{
				marq.scrollAmount=2.5;
				document.getElementById("spnMovieName"+n).style.display="";
				document.getElementById("spnMovieNameStatic"+n).style.display="none";
		}
		else
		{
		 		marq.scrollAmount=0;
				document.getElementById("spnMovieNameStatic"+n).style.display="";
				document.getElementById("spnMovieName"+n).style.display="none";
		}

}