function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

/* print */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* bilder laden */
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 GL_checkBrowser(){
	this.dom= (document.getElementById);
	this.op=this.opera= (navigator.userAgent.indexOf("Opera")>-1);
	this.konq=  (navigator.userAgent.indexOf("Konq")>-1);
	this.firefox =  (navigator.userAgent.indexOf("Firefox")>-1);
	this.ie4= (document.all && !this.dom && !this.op && !this.konq);
	this.ie5= (document.all && this.dom && !this.op && !this.konq);
	this.ns4= (document.layers && !this.dom && !this.konq);
	this.ns5= (!document.all && this.dom && !this.op && !this.konq);
	this.ns6= (this.ns5);
	this.fire = (document.all && this.firefox && this.dom && !this.op && !this.konq);
	this.bw=  (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq || this.fire);
	return this;
}
var bw= new GL_checkBrowser();

function GL_getObj(obj){
//	nest= (!nest)?"":"document."+nest+".";
	nest="";
	this.el= bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);	
   this.css= bw.ns4?this.el:this.el.style;
	this.ref= bw.ns4?this.el.document:document;		
	this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
	this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
	this.height= (bw.ie4||bw.ie5||bw.ns6)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
	this.width= (bw.ie4||bw.ie5||bw.ns6)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
	return this;
}

 
 
 function WinOpen2(url) {
     //window.open(url,'PicWindow','resizable=yes,width=730,height=600,toolbar=no,status=no,menubar=no,scrollbars=yes');
		window.open(url,'PicWindow','resizable=yes,width=635,height=530,toolbar=no,status=no,menubar=no,scrollbars=yes');
 }
 
 
  function WinOpen2OLD(url) {
		window.open(url,'PicWindow','resizable=yes,width=720,height=520,toolbar=no,status=no,menubar=no,scrollbars=yes');
 }
 
if (document.images){
	//Ibox Close Button
	close_over= new Image(108,19);
	close_over.src="/g/ibox_close-hover.gif";  

	close_out= new Image(108,19);
	close_out.src="/g/ibox_close.gif";
	
	//Download Button
	download_over= new Image(83,19);
	download_over.src="/g/download-hover.gif";  

	download_out= new Image(83,19);
	download_out.src="/g/download.gif";
	
	//Abschicken Button
	abschicken_over= new Image(90,19);
	abschicken_over.src="/g/abschicken-hover.gif";  

	abschicken_out= new Image(90,19);
	abschicken_out.src="/g/abschicken.gif";
}
 
function close_mouseover(imgName, btn) {
	if (document.images) {
		imgOn=eval(btn + "_over.src");
      	document[imgName].src= imgOn;
	}
}

function close_mouseout(imgName, btn) {
	if (document.images) {
		imgOff=eval(btn + "_out.src");
      	document[imgName].src= imgOff;
	}
}



// Ein und ausklappen
function toggle (id, link)
{     
    var img = 'img_' + id;
    if (!link)
      link = document.getElementById('img_link_' +id);
    if (document.getElementById(id).style.display == 'none')
    {
        document.getElementById(id).style.display = "block";
        document.getElementById(img).src = "/g/b-show.gif";
        if (link)
            link.firstChild.nodeValue = "ausblenden";
    }
    else
    {
        document.getElementById(id).style.display = "none";
        document.getElementById(img).src = "/g/b-hide.gif";
        if (link)
            link.firstChild.nodeValue = "einblenden";
    }
}
