/**
 Returns the height of the browser window
 */
function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	} else {
		if (document.documentElement&& document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight;
		} else {
			if (document.body&&document.body.clientHeight) {
				windowHeight=document.body.clientHeight;

			}
		}
	}
	return windowHeight;
}

/**
 Sets the footer dynamically.
 */
function setFooter(offset) {
	if (!offset) {
		offset = 0;
	}
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			var contentHeight = document.getElementById('ppn_content').offsetHeight;
			var headerHeight = document.getElementById('ppn_header').offsetHeight;
			contentHeight = contentHeight + headerHeight + offset;
			var footerElement = document.getElementById('ppn_copyright');
			var footerHeight=footerElement.offsetHeight;
			var topDistance = windowHeight-(contentHeight+footerHeight);
			if (topDistance >= 0) {
				footerElement.style.position = 'relative';
				footerElement.style.top = topDistance+'px';
				footerElement.style.left = 0;
			} else {
				footerElement.style.position='static';
			}
		}
	}
}


function Go( selected) {
  if ( selected != null && selected != "nothing" ) {
    i = selected.indexOf( "||");
    x1 = selected.substring( 0, i);
    x2 = selected.substring( i+2, selected.length);
    window.open( x1, x2);
  }
  document.SelectForm.reset();
}

  function europe() {
  doc = open("","_parent");
   wahl1 = document.eu.SelectDoc1.options[document.eu.SelectDoc1.selectedIndex].value;
   doc.location.href=wahl1;
  }

   function northamerica() {
  doc = open("","_parent");
   wahl2 = document.na.SelectDoc2.options[document.na.SelectDoc2.selectedIndex].value;
   doc.location.href=wahl2;
  }

     function latinamerica() {
  doc = open("","_parent");
   wahl3 = document.la.SelectDoc3.options[document.la.SelectDoc3.selectedIndex].value;
   doc.location.href=wahl3;
  }

     function middleeast() {
  doc = open("","_parent");
   wahl4 = document.me.SelectDoc4.options[document.me.SelectDoc4.selectedIndex].value;
   doc.location.href=wahl4;
  }

     function africa() {
  doc = open("","_parent");
   wahl5 = document.af.SelectDoc5.options[document.af.SelectDoc5.selectedIndex].value;
   doc.location.href=wahl5;
  }

     function asia() {
  doc = open("","_parent");
   wahl6 = document.as.SelectDoc6.options[document.as.SelectDoc6.selectedIndex].value;
   doc.location.href=wahl6;
  }

     function australia() {
  doc = open("","_parent");
   wahl7 = document.ao.SelectDoc7.options[document.ao.SelectDoc7.selectedIndex].value;
   doc.location.href=wahl7;
  }

  // Setzen eines Textes
function setText (id, val) {
  if (document.getElementById) {
    document.getElementById(id).firstChild.nodeValue = val;
  }
  else if (document.all) {
    document.all[id].innerText = val;
  }
}


// Holen eines Textes
function getText (id) {
  if (document.getElementById) {
    return document.getElementById(id).firstChild.nodeValue;
  }
  else if (document.all) {
    return document.all[id].innerText;
  }
  return null;
}


// Hole Element
function getElement (id) {
  if (document.getElementById) {
    return (document.getElementById(id));
  }

  if (document.all) {
    return(document.all[id]);
  }

  return null;
}


// Popup-Window
function popupWindow () {
  var win;
  var width;
  var sb = 1;
  var rz = 1;
  var width = 400;

  this.close = function () {
    if (win != null && !win.closed) win.close();
  }

  this.scrollbars = function (flg) {
    sb = (flg) ? 1 :0;
  }

  this.resize = function (flg) {
    rz = (flg) ? 1 :0;
  }

  this.width = function (wth) {
    width = wth;
  }

  this.open =  function (url) {
    this.close();
    win = window.open(url,'PopUp', 'dependent=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+sb+',resizable='+rz+',width='+width+',height=175,top=140,left=300');
    win.focus();
  }
}


//Setzen des Werts eines Cookies fuer vorgegegeben Namen
function setCookie(name, value, lt) {
   var today = new Date();
   today.setTime(today.getTime() + lt);
   document.cookie = name + '=' + value +'; expires=' + today.toGMTString() + ';'
}


//Lesen des Werts eines Cookies fuer vorgegegeben Namen
function getCookie(name) {
   var cookie = document.cookie;
   var bpos;

   if (cookie == '') return ('');
   var bpos = cookie.indexOf(name+'=', bpos);
   if (bpos == -1) return ('');
   bpos+=(name.length+1);

   var epos = cookie.indexOf(';', bpos);
   if (epos == -1) epos = cookie.length;

   return cookie.slice(bpos,epos);
}


//Loeschen des Cookies fuer neue Session
function delCookie(name) {
   var today = new Date();
   var val = getCookie(name);
   today.setTime(today.getTime() - 1);
   document.cookie = name + '=' + val +'; expires=' + today.toGMTString() + ';'
}

function calendarWindow() {
        var win;

        this.close = function() {
          if (win != null && !win.closed) win.close();
        }

        this.open = function(url, left, top) {
          this.close();
          var calHeight = 190;
          var calWidth = 180;
          var calLeft;
          var calTop;
          if (navigator.appName.toLowerCase().indexOf('microsoft') >= 0) {
            var winHeight = window.screen.availHeight;
            var winWidth = window.screen.availWidth;
            //window.blubb();
            //alert('Positionen: ' + winHeight + ', ' + winWidth);
            if (top + calHeight > winHeight) {
              calTop = winHeight - calHeight - 40;
            } else {
              calTop = top;
            }
            if (left + calWidth > winWidth) {
              calLeft = winWidth - calWidth - 40;
            } else {
              calLeft = left;
            }
          } else {
            calTop = top;
            calLeft = left;
          }
          win = window.open(url, 'calendar_popup', 'top=' + calTop + ',left=' + calLeft + ',height=' + calHeight + ',width=' +            calWidth +',dependent=yes,hotkeys=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbars=no');
          //win.moveTo(left, top);
          //win.focus();
        }
      }

      // Einhaengen von Initialisierungsfunktionen in onLoad
      var ifct = new Array();
      function initAll () {
        popup = new popupWindow();
        calendar = new calendarWindow();
        for (var i = 0; i < ifct.length; i++) {
          ifct[i]();
        }
      }


      // Footer setzen
      function setFooterSpace() {
        setFooter(32);
      }