// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	var layer;
	var timer;
	var scrollheight=160;		// Sollte in jedem Fall identisch mit der Größe des
					// sichtbaren Bereiches sein. Also die Höhe des
					// Container Layers.
					// Kann auch über das Elternobjekt ausgelesen werden.
		
	// Initialisieren des Scriptes
	function init(id) {
		layer = document.getElementById(id);
		layer.style.top = 0;
	}
	
	// Ermittelt die Höhe des Layers und gibt sie zurück
	function gethoehe() {
		return layer.offsetHeight;
	}

	// Nach unten scrollen. Mit speed wird gesteuert wie schnell gescrollt
	// werden soll (Pixel/25ms)
	function scrolldown(speed) {
		// Solange wie wir noch nicht alles gesehen haben scrollen wir nach unten.
		if ( gethoehe() + parseInt(layer.style.top) > scrollheight) {
			layer.style.top = parseInt(layer.style.top) - parseInt(speed) + 'px';
			timer = window.setTimeout("scrolldown('"+speed+"')",10);
		}
	}

	// Nach oben scrollen. Mit speed wird gesteuert wie schnell gescrollt
	// werden soll (Pixel/25ms)
	function scrollup(speed) {
		// Solange wir die Ausgangsposition noch nicht wieder erreicht haben
		// scrollen wir nach oben.
		if (  parseInt(layer.style.top) < 0) {
			layer.style.top = parseInt(layer.style.top) + parseInt(speed) + 'px';
			timer = window.setTimeout("scrollup('"+speed+"')",10);
		}
	}

	// Den Timer der das Hoch- oder Runterscrollen steuert anhalten.
	function stopscroll() {
		window.clearTimeout(timer);
	}

	// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };
	/*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);
		if(pid != "null") {
			document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
		}
	};

	
	*/
	function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
	/*function addItem(obj,idx) { thisMovie("mpl").addItem(obj,idx); }
	function removeItem(idx) { thisMovie("mpl").removeItem(idx); }
	function getItemData(idx) {
		var obj = thisMovie("mpl").itemData(idx);
		var nodes = "";
		for(var i in obj) { 
			nodes += "<li>"+i+": "+obj[i]+"</li>"; 
		}
		document.getElementById("data").innerHTML = nodes;
	};*/

	// 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 StartMovie(obj)
	{
		loadFile(obj);
		sendEvent('playpause');
	};