/* Author: Mario Melzer \*/
/* LastChangedDate: 2008-01-10 \*/
/* LastChangedBy: MM \*/

function onLoadFunctionsSpecial() {
// add function calls here
  getHeaderPic();
}

if (window.addEventListener) {
	window.addEventListener("load", onLoadFunctionsSpecial, true); 
} else if (window.attachEvent) {
	window.attachEvent("onload", onLoadFunctionsSpecial);
}

function set_bookmark(title, url)
{
  if ( window.opera ) 
    alert('Leider unterstützt Ihr Browser nicht das automatische Setzen von Lesezeichen!\n\nKlicken Sie bitte auf [OK] und drücken dann [Strg] + T.');
  else if ( document.all )
    window.external.AddFavorite(url, title);
  else if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
  else
    alert('Leider unterstützt Ihr Browser nicht das automatische Setzen von Lesezeichen!\n\nKlicken Sie bitte auf [OK] und drücken dann [Strg] + D.');

  return;
}

function showListe(x) {
	for (var i=1; i<document.forms[1].elements.length; i++) {
		document.forms[1].elements[i].style.display = "none";
	}
	if (x == "100") {
		document.forms[1].reset();
		document.forms[1].elements[1].style.display = "inline";
		return;
	}
	else {
		document.forms[1].elements[x].style.display = "inline";
	}
}

function Go(y) {
	if (y == "200") {
		return;
	}
	if(y.substr(0, 4) == "http" && y.substr(0, 21) != "https://www.schufa.de") {
		var fenster = window.open(y, 'pop','');
		fenster.focus();
		return;
	}
	else {
		window.location.href = y;
	}
}


var currHeaderPic = "1";

function zufall(b)
{
  var a = 0;
  a = Math.random();
  a *= b;               // hier Limit ändern (b)
  a = Math.ceil(a);
  
  return a;
}

function setCookie(item,value)
{
  if (document.cookie=item+'='+value+';')
    return true;
  else
    return false;
}

function getCookie()
{
  var value = document.cookie;
  value = value.substring(value.indexOf("=")+1, value.search(';'));

  return value;
}

function cookieSet()
{
  var value = document.cookie;
  value = value.substring(0, value.search('='));

  if (value == "picture")
    return true;
  else
    return false;
}

function getHeaderPic()
{
  
    if(cookieSet())
    {
      try {
        var cImg = getCookie();
        currHeaderPic = cImg;
        while (currHeaderPic == cImg)
          currHeaderPic = zufall(imgCount);
    
        setCookie("picture", currHeaderPic);
        if (document.getElementById("div_header"))
          if (img[currHeaderPic] != "")
            document.getElementById("div_header").style.backgroundImage='url('+img[currHeaderPic]+')';
      }
      catch (e) {}
    }
    else
    {
      try {
        setCookie("picture", currHeaderPic);
        currHeaderPic = zufall(imgCount);
        document.getElementById("div_header").style.backgroundImage='url('+img[currHeaderPic]+')';
      }
      catch (e) {}
    }
}

function click (e) {
  if (!e)
    e = window.event;
  if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) {
    if (window.opera)
      window.alert("Sorry: Diese Funktion ist deaktiviert.");
    return false;
  }
}

function clickme(e) {
  if (document.layers) e.captureEvents(Event.MOUSEDOWN);
  e.onmouseup = click;
  e.oncontextmenu = click;
}
