var currentPosition;
var currentVolume;
function sendEvent(typ,prm) {
  thisMovie("mediaplayer").sendEvent(typ,prm);
};

function loadFile(fil,tit,lnk,img,fid) {
  thisMovie("mediaplayer").loadFile(fil,tit,lnk,img,fid);
};

function thisMovie(movieName) {
if(navigator.appName.indexOf("Microsoft") != -1) {
   return window[movieName];
  } else {
   return document[movieName];
  }
};
	
function itemData(obj) {
  var nodes = "";
  for(var i in obj) { 
   nodes += "<li>"+i+": "+obj[i]+"</li>"; 
  }
  document.getElementById("data").innerHTML = nodes;
};


var FO = {movie:"mediaplayer.swf",id:"mediaplayer",name:"mediaplayer",width:"0",height:"0",majorversion:"8",build:"0",bgcolor:"#FFFFFF",allowfullscreen:"true",flashvars:"file=mediaplayer.xml&enablejs=true" };
UFO.create(FO, "player");
	
var playId = 0;
var demotype = '';

function getUpdate(typ,pr1,pr2) {
  if(typ == "time") { currentPosition = pr1; }
  else if(typ == "volume") { currentVolume = pr1; }
  var id = document.getElementById(typ);
  id.innerHTML = typ+ ": "+Math.round(pr1);
  pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
	};

function stopCurrent()
{
    if(playId>0)
    {	
	setPlayIcon();
     sendEvent('playpause');
     playId = 0;
     demotype = '';
    }     
}


function playClicked(id, filename, dt)
{
	if(playId==id)
	{
  setPlayIcon();
      sendEvent('stop');
      playId = 0;
      demotype = '';
	}
	else
	{
  if(playId>0)
  {
   stopCurrent();
   loadFile('http://system.arnsbomedia.com'+filename,'','','',123);
   sendEvent('playpause');
   playId = id;
       demotype = dt;
   setStopIcon();
  }
  else
  {
   loadFile('http://system.arnsbomedia.com'+filename,'','','',123);
   sendEvent('playpause');
   playId = id;
       demotype = dt;
   setStopIcon();
  }
	}
}


function setStopIcon()
{
	document.getElementById(demotype+'-icon-'+playId).src = '/fileadmin/template/stop.png';
}

function setPlayIcon()
{
	document.getElementById(demotype+'-icon-'+playId).src = '/fileadmin/template/play.png';
}


