// x42 - Multimedia-Extension fuer Browser 4.x oder hoeher
// **********************************************************************
// Oliver Koelle
// oliver@webwichtel.de
// version 2 beta5, Jun 2001 - Sep 2001
// urheber: webwichtel 1996 - 2001
// **********************************************************************

// Allgemeine Funktionen
// v 1.3.2
// __________________________________________________________________________________

// Globale Variablen

// HV fuer DOM
var isNN = (document.layers ? true : false);
var isGecko = (document.getElementById ? true : false);
var isIE = ((document.all && !isGecko) ? true : false);
//andere
var docWidth, docHeight, hcenter, vcenter, screenWidth, screenHeight, screenWidthAvail, screenHeightAvail // HV fuer Darstellung
var tmpObj, theObj; // HV fuer layer-objekte
Jetzt = new Date(); // Timer holen
var Start = Jetzt.getTime(); // Timerstart fuer Verweildauer
var anzLay,geckoLay; // länge des Element-Arrays, geckoLay=ElementArray für Gecko

// Client-Daten auslesen
// v 2.0.1
function getClientInfo(){
 // bestimmen des DOM und auslesen der Fenstermitte
 if (document.layers){
  docWidth = parseInt(window.innerWidth);
  docHeight = parseInt(window.innerHeight);
  anzLay = document.layers.length-1;
 }
 if (document.all){
  docWidth = parseInt(document.body.clientWidth);
  docHeight = parseInt(document.body.clientHeight);
  anzLay = document.all.length-1;
 }
 if (document.getElementById){
  if (navigator.appName=="Microsoft Internet Explorer"){
   docWidth = parseInt(document.body.clientWidth);
   docHeight = parseInt(document.body.clientHeight);
  }
  // dl 23.06.2006 : Die Abfrage auf Opera war falsch
  if((navigator.appName=="Netscape") || (navigator.userAgent.indexOf("Opera") != -1)){
   docWidth = parseInt(window.innerWidth);
   docHeight = parseInt(window.innerHeight);
  }
  geckoLay = document.getElementsByTagName('div');
  anzLay = geckoLay.length-1;
 }
 hcenter = parseInt(docWidth/2);
 vcenter = parseInt(docHeight/2);
 screenWidth = screen.width;
 screenHeight = screen.height;
 screenWidthAvail = parseInt(screen.availWidth);
 screenHeightAvail = parseInt(screen.availHeight);
}


// Layer-Style-Objekte fuer Weiterbearbeitung
// v 1.01
function setObj(lay){
 if (isNN){
  theObj = eval("document.layers."+lay); // netscape DOM kennt kein style
 }
 if (isIE){
   theObj = eval("document.all."+lay+".style");
 }
 if (isGecko){
   theObj = eval("document.getElementById('"+lay+"').style");
 }
 return(theObj);
}

// Layer-No-Style-Objekte fuer Weiterbearbeitung
// v 1.0
function setNoStyleObj(lay){
 if (isNN){
  theObj = eval("document."+lay);
 }
 if (isIE){
  theObj = eval("document.all."+lay);
 }
 if (isGecko){
  theObj = eval("document.getElementById('"+lay+"')");
 }
 return(theObj);
}

// Objekte erstellen & Verwalten
// v 0.1 alpha
// geht nur mit IE
// __________________________________________________________________________________
function createNewElement(tag,x,y,vis,width,height,zidx,cont){
 tmpElem = document.createElement(tag);
 tmpElem.style.left = x;
 tmpElem.style.top = y;
 tmpElem.style.visibility = vis;
 tmpElem.style.width = width;
 tmpElem.style.height = height;
 tmpElem.style.zIndex = zidx;
 tmpElem.id = "maul";
 writeLay('maul',cont);
 //alert(tmpElem.id);
}


// Hilfsfuntionen fuer Window
// v 1.3
// __________________________________________________________________________________

// open a new window without upper elements
// v 1.2
function openWin(adr,winName,options,ratio){
 // parse options
 if (options != null){
  optstr = "resizable,scrollbars";
  // like a car's gear
  if(options >= 1) optstr += ",toolbar"; 
  if(options >= 2) optstr += ",menubar";
  if(options >= 3) optstr += ",status";
  if(options >= 4) optstr += ",location";
  if(options >= 5) optstr += ",copyhistory";
 }else{
  optstr = "*"; // nonsens for basic window
 }
 
 // window with ratio
 if(ratio != null){
  if((screenWidth >= 800) && (screenHeight >= 600)){
   x = parseInt((screenWidth * ratio) / 100);  
   y = parseInt((screenHeight * ratio) / 100);
  } else {
   // make new window max-size if screen is smaller than 800 x 600
   x = screenWidthAvail;  
   y = screenHeightAvail;
  }
  // never make win smaller than 640 x 480
  if(x < 640) x=640;
  if(y < 480) y=480;
  // set win-position to center of screen
  X = (screenWidthAvail / 2) - (x / 2);
  Y = (screenHeightAvail / 2) - (y / 2);
  if (isIE || isGecko){  
   optstr += ",width="+x+",height="+y+",top="+Y+",left="+X;
  }else{
   optstr += ",width="+x+",height="+y;
  }
 }
 // open the window
 window.open(adr,winName,optstr);
}

// Hilfsfuntionen fuer Layer
// v 1.3
// __________________________________________________________________________________

// Layer an eine Position (x,y) bewegen
function setLayPos(lay,x,y){
 setObj(lay);
 theObj.left = x;
 theObj.top = y;
}

// LayerPosition auslesen
function getLayPos(lay){
 // Kein Style Element, deshalb neue Obj-Definition
 setNoStyleObj(lay);
 if (isNN){
  x = theObj.left;
  y = theObj.top;
 }
 if (isIE){
  x = theObj.offsetLeft;
  y = theObj.offsetTop;
 }
 if (isGecko){
  x = theObj.offsetLeft;
  y = theObj.offsetTop;
 }
 return (x,y);
}

// Layer einblenden
function show(lay){
 setObj(lay);
 theObj.visibility = "visible";
}

// Layer ausblenden
function hide(lay){
 setObj(lay);
 theObj.visibility = "hidden";
}

// Layerinhalt schreiben
// v 1.1
function writeLay(lay,newHTML) {
 if (isNN) {
  writeLay = eval("document."+lay+".document");
  writeLay.open();
  writeLay.write(newHTML);
  writeLay.close()
 } 
 if(isIE){
  document.all [lay].innerHTML = newHTML;
 }
 if(isGecko){
  document.getElementById(lay).innerHTML = newHTML;
 }
}

// Layerinhalt lesen --> nur IE
// v 1.0
function readLay(lay) {
 theCont = navigator.appName + navigator.appVersion + "<br> can not do this, sorry.";
 if(isIE){
   theCont = document.all [lay].innerHTML;
 }
 if(isGecko){
  theCont = document.getElementById(lay).innerHTML;
 }
 return(theCont);
}

// Layergrösse festlegen
// v1.0
function setLaySize(lay,xdim,ydim){
 setObj(lay);
 theObj.width = xdim;
 theObj.height = ydim;
}

// Layergrösse auslesen
// v1.01
function getLaySize(lay){
 // dl 23.06.2006 : Die Abfrage auf Opera war falsch
 if(isIE || isGecko && !(navigator.userAgent.appName == "Opera")){
  setNoStyleObj(lay);
  xdim = theObj.clientWidth;
  ydim = theObj.clientHeight;
 } else if(isIE || isGecko){
  setObj(lay);
  xdim = theObj.pixelWidth;
  ydim = theObj.pixelHeight;
 }
 return(xdim,ydim);
}

// Layerhintergrundfarbe aendern
// v1.0
function setLayBgColor(lay,col){
 setObj(lay);
 if(isIE || isGecko)theObj.backgroundColor = col;
 if(isNN) theObj.borderColor = col;
}

// Layervordergrundfarbe aendern
// v1.0
function setLayFgColor(lay,col){
 setObj(lay);
 if(isIE || isGecko)theObj.color = col;
 if(isNN) theObj.color = col;
}

// Hilfsfuntionen fuer Images
// v3.0
// __________________________________________________________________________________

function img_act(imgName,picName) {
 imgOn = eval(imgName + "on.src");
 document [picName].src = imgOn;

}

// Verweildauer Anzeigen Methode
// v1.0
// ____________________________________________________________________________
	
function surfTime(lay) { 
   if(lay) timeLay = lay;
   var absSekunden = Math.round(secs()); 
   var relSekunden = absSekunden % 60;
   var absMinuten = Math.round((absSekunden-30)/60);
   var anzSekunden ="" + ((relSekunden > 9) ? relSekunden : "0" + relSekunden);
   var anzMinuten ="" + ((absMinuten > 9) ? absMinuten : "0" + absMinuten);
   newHTML = anzMinuten + ":" + anzSekunden;
   writeLay(timeLay,newHTML);
   //window.setTimeout('surfTime()',1000); 
}
   
function secs() { 
   var Immernoch = new Date(); 
   return((Immernoch.getTime()-Start)/1000); 
}

// _________________________________________________________________Uhr ENDE_