/* Basics */

// BrowserCheck Object (based on 'DynAPI' BrowserCheck Object)
function BrowserCheck() {
  var b = navigator.appName;
  this.a = this.agent = navigator.userAgent;
  this.version = navigator.appVersion;
  this.v = parseInt(this.version);
  this.vAll = parseFloat(this.version);
  this.p = this.platform = navigator.platform;

  //Platform
  this.win = (this.p.indexOf("Win")>-1);
  this.mac = (this.p.indexOf("Mac")>-1);
  this.linux = (this.p.indexOf("X11")>-1 || this.p.indexOf("Linux")>-1);

  //Browser Name
  if (b.indexOf("Netscape")>-1) b = "Netscape";
  if (this.a.indexOf("Safari")>-1) b = "Safari";
  if (this.a.indexOf("Opera")>-1) b = "Opera";
  switch(b) {
    case "Netscape":
      this.b = "ns";
      break;
    case "Microsoft Internet Explorer":
      this.b = "ie";
      break;
    case "Opera":
      this.b = "op";
      break;
    case "Konqueror":
      this.b = "ko";
      break;
    case "Safari":
      this.b = "sa";
      break;
    default:
      this.b = b;
      break;
  }

  //Browser Version
  this.ns = (this.b=="ns" && this.v>=4);
  this.ns4 = (this.b=="ns" && this.v==4);
  this.ns5 = this.ns6 = (this.b=="ns" && this.v==5);
  this.nsMin = (this.b=="ns" && this.vAll>=4.04)
  this.ie = (this.b=="ie" && this.v>=4);
  this.ie4 = (this.b=="ie" && this.version.indexOf("MSIE 4")>-1);
  this.ie45 = (this.b=="ie" && this.version.indexOf("MSIE 4.5")>-1);
  this.ie5 = (this.b=="ie" && this.version.indexOf("MSIE 5")>-1);
  this.ie55 = (this.b=="ie" && this.version.indexOf("MSIE 5.5")>-1);
  this.ie6 = (this.b=="ie" && this.version.indexOf("MSIE 6")>-1);
  this.ie7 = (this.b=="ie" && this.version.indexOf("MSIE 7")>-1);
  this.ie8 = (this.b=="ie" && this.version.indexOf("MSIE 8")>-1);
  this.ie55up = ((this.mac&&this.ie5) || this.ie55 || this.ie6 || this.ie7 || this.ie8);
  this.ie6down = (this.ie4 || this.ie45 || this.ie5 || (this.mac&&this.ie5) || this.ie55 || this.ie6);
  this.ie7up = (this.ie7 || this.ie8);
  this.op = (this.b=="op");
  this.ko = (this.b=="ko");
  this.sa = (this.b=="sa");
  this.min = (this.ns||this.ie||this.op||this.ko||this.sa);

  //Language
  this.lang = ((this.ie)?navigator.browserLanguage:navigator.language).substring(0,2);
}
is = new BrowserCheck();


// Constants
xOffset = 285;
if (is.ie6down) xOffset = 189;
yOffset = 186;


// Get window size
if (!is.ie) {
  winH = window.innerHeight;
  winW = window.innerWidth;
}
function getMsWindowSize() {    //for IE only, call it after <body> tag
  if (is.ie) {
    if (is.ie7up) {
      winH = document.documentElement.offsetHeight;
      winW = document.documentElement.offsetWidth;
    }
    else {
      winH = document.body.offsetHeight-4;
      winW = document.body.offsetWidth;
    }
  }
}


// Inits
function StartInit() {
  if (is.ie) getMsWindowSize();
  contentH = winH-yOffset;
  contentW = winW-xOffset;
}

function EndInit() {
  // Set CSS
  document.body.style.backgroundImage = 'none';
  document.getElementById('wrapper2').style.overflow = 'hidden';
  document.getElementById('basenav').style.height = winH+'px';
  //document.getElementById('content').style.width = contentW+'px';
  document.getElementById('content').style.height = contentH+'px';
}


// On window resize: reload page
function reload() {
  location.href = location.href;
}
window.onresize = reload;


/* misc. Functions */

// Anzeigen/verstecken von Content-Elementen
function showdata(what) {
  if (is.ie) elements = getElementsByClassName('data');
  else elements = document.getElementsByClassName('data');
  for (i=0;i<elements.length;i++) elements[i].style.display = 'none';
  if (elements[what].style.display=='block') elements[what].style.display = 'none';
  else elements[what].style.display = 'block';
}



/* Bobzin stuff */

// Get number from a CSS pixel value
function getValue(obj){
	return ((obj.substr(0, obj.length - 2)) * 1);
}

// Search form animation
function showInput(){
	if(document.getElementById("searchinput").style.display == "none"){
		document.getElementById("searchlegend").style.display = "none";
		document.getElementById("searchinput").style.display = "block";
		sInt = window.setInterval('growInput()',1);
	}else{
		document.getElementById("searchlegend").style.display = "block";
		document.getElementById("searchinput").style.width = "1px";
		document.getElementById("searchinput").style.display = "none";
		document.getElementById("searchsubmit").style.display = "none";
	}
}

function growInput(){
	if(getValue(document.getElementById("searchinput").style.width) >= 160){
		document.getElementById("searchsubmit").style.display = "block";
		window.clearInterval(sInt);
	}else{
		document.getElementById("searchinput").style.width = getValue(document.getElementById("searchinput").style.width) + 5 + 'px';
	}
}

