window.onload = function() {
  katalog();
}


var resources = new Array();
function homeMovie(movies, intro, width, height, id) {
  var r = resources.length;
  
  resources[r] = ({'movies' : movies, 'id' : id, 'intro' : intro, 'active' : null});
  
  /**
   * Insert intro movie
   */     
  var intro = new SWFObject(intro, 'intro'+id, width, height, 9, '', 'high', true);
  intro.addParam("wmode","transparent");
		
  intro.addVariable("repeat","true");
  intro.write(id);
  
  return r;
}

function mNext(r) {
  if(typeof(resources[r].active) == 'object')
    resources[r].active = 0;
  else
    resources[r].active++;
  
  var obj = resources[r];
  var i = obj.active;

  if(i > (obj.movies.length - 1))
    i = resources[r].active = 0;  
  
  var m = obj.movies[i];
  createSo(m.file, m.image, m.width, m.height, obj.id);
  
  return false;
}

function mPrev(r) {
  if(typeof(resources[r].active) == 'object')
    resources[r].active = (resources[r].movies.length - 1);
  else
    resources[r].active--;
  
  var obj = resources[r];
  var i = obj.active;
  
  if(i < 0)
    i = resources[r].active = (obj.movies.length - 1);
  
  var m = obj.movies[i];
  createSo(m.file, m.image, m.width, m.height, obj.id);
  
  return false;
}


function mPlay(r) {
}

function createSo(file, image, width, height, id) {
  var mpl = 'mpl'+Math.ceil(Math.random()*1000000);

  var so = new SWFObject('/public/img/mediaplayer.swf',mpl, width, height);
  so.addVariable("file", file);                
  so.addVariable("image", image);
  
  so.addParam("allowfullscreen","false");
  so.addParam("wmode","transparent");
  so.addParam('align', 'center');
  
  so.addVariable("enablejs","true");
  so.addVariable("javascriptid", mpl);
  so.addVariable("screencolor","0xffffff");
  so.addVariable("showdigits","true");
  so.addVariable("showvolume","true");
  so.addVariable("autostart","true");
  so.addVariable("bufferlength","3");
  so.addVariable("repeat","false");
  so.addVariable("overstretch","true");
  so.addVariable("shuffle","false");
  so.addVariable("volume","90");
  so.addVariable("linkfromdisplay","true");
  so.addVariable("linktarget","_self");
  so.addVariable("usefullscreen","false");
  so.addVariable("usekeys","false"); 
  so.addVariable("showicons","true");
  so.addVariable("autoscroll","true");
  
  so  .useExpressInstall('/public/script/expressinstall.swf');
  so.write(id);
  
  return mpl;
}


function sendEvent(swf,typ,prm) {
  thisMovie(swf).sendEvent(typ,prm);
}
function getUpdate(typ,pr1,pr2,swf) {
}
function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1)
    return window[swf];
  else
    return document[swf];
}