/*
         Basis-JavaScript Funktionen
         © by Martin Hasieber, hasieber@design-muenchen.de
*/


/*  function checkBrowser()           Konstruktor für ein Objekt, das die aktuelle Browserversion enthält
                                      Aufruf über var is = new checkBrowser()

    function layerSetup(id,x,y)       Funktion, die mit posLayer ein neues Layer-Objekt erzeugt
                                      überschreibt das alte Layer Objekt(id) und richtetet es an
                                      x und y aus
                                      Verwendet das oben erzeugte >is< Objekt

    function changeImages()           Funktion zum Austausch von Bildern (mouseover), Übergeben wird
                                      eine Argumentenliste mit folgendem Aufbau:
                                      layer-Id, bildname1, bilort1, bildname2, bildort2 ...
																			
	function buttonON(getin)					Funktion zum aktivieren (wechseln des Img) eines Buttons der 
																			als Button-Objekt ueber den Konstruktor makeButton() erzeugt wurde.
																			Übergeben wird das Button-Objekt getin.
															

	function buttonOFF(getin)					Funktion zum deaktivieren (wechseln des Img) eines Buttons der 
																			als Button-Objekt &uuml;ber den Konstruktor makeButton() erzeugt wurde.
																			Übergeben wird das Button-Objekt getin.
																			Ist abhaengig von dem Button-Objekte hotbutton, das den momentan aktiven 
																			Button repräsentiert.
																			
	function switchbutton(getin)			Funktion die den Status des Button-Objektes hotbutton ändert. Übergeben wird
																			das zu aktivierende Button-Objekt getin.
																			
*/
function checkBrowser(){
	this.ver = navigator.appVersion;
	this.dom = document.getElementById?1:0;
	this.agt = navigator.userAgent.toLowerCase();
	this.linux = (this.agt.indexOf("linux")!=-1) ? 1:0;
	this.mac = (this.agt.indexOf("mac")!=-1) ? 1:0;
	this.win = (this.agt.indexOf("win")!=-1) ? 1:0;
	this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie55 = (this.ver.indexOf("MSIE 5.5")>-1 && this.dom)?1:0;
	this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.ie55)?1:0;
	this.ie4 = (document.all && !this.dom) ? 1:0;
	this.ns6 = (this.dom && parseInt(this.ver) >= 5 && this.ver.indexOf("Gecko")>-1) ? 1:0;
	this.ns5 = (this.dom && parseInt(this.ver) >= 5 && !this.ns6 && !this.linux && (this.agt.indexOf('opera')==-1)) ? 1:0;
	this.ns4 = (document.layers) ? 1:0;
	this.nn = ((document.captureEvents) && (!this.dom)) ? 1:0;
	this.mz = (((this.dom) && (!document.all) && (document.documentElement)) && (this.agt.indexOf("safari")==-1)) ? 1:0;
	this.op = ((this.dom) && (this.agt.indexOf('opera')!=-1)) ? 1:0;
	this.kon = ((this.agt.indexOf("konqueror")!=-1) || (this.agt.indexOf("safari")!=-1)) ? 1:0;
	this.bw  = (this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ie55 || this.ie6);
	this.os  = (this.ver.indexOf("Macintosh")>-1)? "mac":"pc";
	this.ie  = (this.ie5 || this.ie4 || this.ie55 || this.ie6);
	this.ns  = (this.ns4 || this.ns5 || this.ns6);
	this.client = (!this.ns4) ? "ie" : "ns";
	return this;
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function ignoreError(meldung, url, zeile) {
	return true;
}

function button(a,b,c,d) {   // Konstruktor für das Button Objekt
   this.bildname = a;
   this.ortan    = b;
   this.ortaus   = c;
   this.ortover   = d;
 	 newImage(b);
 	 newImage(c);
	 newImage(d);
}

function findObj(n, d)
{	var x, s = new String();
	if (!d) d = document;
	if (!(x = d[n]) && d.all)
		x = d.all[n];

	if(d.id == n)
		x = d;

	for (i = 0; d.anchors && !x && i < d.anchors.length; i++)
		if (d.anchors[i].name == n)	x = d.anchors[i];
	for (i = 0; !x && d.layers && i < d.layers.length; i++)
		x = findObj(n, d.layers[i].document);
	for (var i = 0; d.children && !x && d.all && i < d.children.length; i++)
		x = findObj(n, d.children[i]);
	if(!x && d.getElementById) x=d.getElementById(n);

	return x;
}

function changeImages() {
	var bildname = changeImages.arguments[0];
	if (document.images) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findObj(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}

function buttonOVER(getin) {
	if (getin != hotbutton) {
		with(getin){changeImages(bildname, ortover)};
	}
}

function buttonON(getin) {
   with(getin){changeImages(bildname, ortan)};
}

function bottonOFF(getin) {
   if (getin != hotbutton) {
      with(getin){changeImages(bildname, ortaus)};
   }
}


function switchbutton(getin) {
   if (getin != hotbutton) {
      savebutton = null;
      if (hotbutton) {savebutton = hotbutton;}
      hotbutton = getin;
      if (savebutton) {bottonOFF(savebutton)};
      buttonON(getin);
   }
}

function showid(id) {
		 alert("Heureka");
   if (id) {
      if (is.dom){
         obj = document.getElementById(id).style;
         obj.visibility = "visible";
      } else if(is.ie4) {
         obj = document.all[id].style;
         obj.visibility = "visible";
      } else if(is.ns4) {
         obj = document.layers[id];
         obj.visibility = "show";
      } 
   }
}

function hideid(id) {
	 if (id) {
      if (is.dom){
         obj = document.getElementById(id).style;
         obj.visibility = "hidden";
      } else if(is.ie4) {
         obj = document.all[id].style;
         obj.visibility = "hidden";
      } else if(is.ns4) {
         obj = document.layers[id];
         obj.visibility = "hide";
      }
   }
}

function switchid(id) {
   if (id != activelayer) {
      hideid(activelayer);
      showid(id);
      activelayer = id;
   }
}

function loadUrl(framename, url) {
	if((parent.frames.length != 0) && (window.parent[framename].document.location != url)) {
		window.parent[framename].document.location = url;
	}
}

function layerSetup(id,x,y,w,h) {
    centerLyr = new posLayer(id,x,y,w,h);
}

function posLayer(id,left,top,width,height) {
    if (is.dom){
	   if (document.getElementById(id)) {this.obj = document.getElementById(id).style;}
    } else if(is.ie4) {
       if (document.all[id]) {this.obj = document.all[id].style;}
    } else if(is.ns4) {
       if (document.layers[id]) {this.obj = document.layers[id];}
    }
/*	for (var i in this.obj) {
	document.write(i+"<BR>"); }
*/ 
	if (this.obj) {
		if (left && (left != -1)) this.obj.left = left;
	    if (top && (top != -1))  this.obj.top = top;
	    if (width && (width != -1))  this.obj.width = width;
	    if (height && (height != -1))  this.obj.height = height;
	}
}

function sendformdata() {
	document.sendform.submit();
}



function redoNS()
{	
	window.history.go(0);
}
