<!--

// ALA's StyleSwitcher
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;
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

// patch IE's :hover & :focus problems with tags other than <a>

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			sel = document.getElementsByTagName("select");
			for (var i=0; i<sel.length; i++) {
				sel[i].style.visibility = 'hidden';	
			}
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			sel = document.getElementsByTagName("select");
			for (var i=0; i<sel.length; i++) {
				sel[i].style.visibility = 'visible';	
			}
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
// only win:
if (window.attachEvent) window.attachEvent("onload", sfHover);

// TABS Boxen rechts

function _gEl(i){
	return document.getElementById(i);
}
var _forms = ['t_infobox','t_werkzeuge'];
var _focusInp = {'t_infobox': 'q','t_werkzeuge': 'what'};
var _currentform = null;

function _form(name, focus) {
	for (var i = 0; i < _forms.length; i++) {
		var n = _forms[i];
		var t = _gEl(n);
		var f = _gEl(n + '_form');
		if (t) {
			t.className = (n == name) ? 'tab_sel' : 'tab_unsel';
		}
		if (f) {
			f.style.display = (n == name) ? '' : 'none';
		}
	}
	if (focus) {
		//_gEl(_focusInp[name]).focus();
	}
	_currentform = name;
	return false;
}


// INPUT Felder

function blur_(obj_) {
	obj_ = this;
	//alert(obj_.id)
	obj_.style.backgroundColor ="#FFFFFF";
	if(obj_.value.length == 0 || obj_.value == obj_.title) {
		obj_.value = obj_.title;
		if(obj_.id == "qs_inp") {
			obj_.style.color = "#969696";
		} else
			obj_.style.color = "#595A5A";
	}
}

function focus_(obj_) {
	obj_ = this;
	obj_.style.color = "#595A5A";
	obj_.style.backgroundColor ="#FFFFE5";
	obj_.focus();
	obj_.select();
	if(obj_.value == obj_.title) {
		obj_.value ="";
	}
}

function getInpToFocus() {
	//if (!document.getElementById) return
	inp = document.getElementsByTagName("input");
	are = document.getElementsByTagName("textarea");
	for(i=0; i<inp.length; i++) {
		inp[i].onfocus = focus_;
		inp[i].onblur = blur_;
	}
	for(i=0; i<are.length; i++) {
		are[i].onfocus = focus_;
		are[i].onblur = blur_;
	}
}

function checkSearchVal(str) {
 if(isNaN(str) != true && str != "") {
  var goID = 'index.php?id='+ str;
  window.location.href = goID;
  return false;
 }
 if(str == document.qs_form.elements[0].title) {
  alert('Bitte geben Sie einen Suchbegriff oder eine Seiten-ID ein!')
  return false;
 }
 else return true;
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

//-->
