/* Author: Mario Harnisch \*/
/* 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);
}

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("header"))
          if (img[currHeaderPic] != "")
            //--- START Addition for small header by MM 08.06. ----
            {
              if(!smallHead) {
            //--- END Addition ---
                document.getElementById("header").style.backgroundImage='url('+img[currHeaderPic]+')';
            //--- START Addition for small header by MM 08.06. ----
            }
            //--- END Addition ---
          }
            
      } catch (e) {}
    }
    else {
      try {
        setCookie("picture", currHeaderPic);
        currHeaderPic = zufall(imgCount);
		   //--- START Addition for small header by MM 08.06. ----
        if(!smallHead) {
        //--- END Addition ---
          document.getElementById("header").style.backgroundImage='url('+img[currHeaderPic]+')';
        //--- START Addition for small header by MM 08.06. ----
        }
        //--- END Addition --- 
          
      } catch (e) {}
    }
}
