var content_breite = 0;
var content_hoehe = 0;
var hoehe_center = 0;

var preloads = new Array();

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i, x, a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){
  	document.MM_sr[j++]=x; 
	if (!x.oSrc) x.oSrc=x.src; 
	x.src=a[i+2];
  }
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { if (args[i+1] != "") { nm=args[i+1]; } else { nm=val.name; } if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine echte E-Mail-Adresse sein.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' muss eine Zahl sein.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Zahl zwischen '+min+' und '+max+' sein.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' ist erforderlich.\n'; }
  }
  document.MM_returnValue = errors;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function zentrieren() {
	var i, obj, breite, hoehe;
	
	
 	if (window.innerWidth) {
		breite = window.innerWidth;
  	} else if (document.body && document.body.offsetWidth) {
    	breite = document.body.offsetWidth;
	} else {
    	breite = 0;
	}	

	if (window.innerHeight) {
		hoehe = window.innerHeight;
  	} else if (document.body && document.body.offsetHeight) {
    	hoehe = document.body.offsetHeight;
	} else {
    	hoehe = 0;
	}
	obj = document.getElementById("center_div");


	if (obj) {
		i = breite - content_breite;
		i = i / 2;
		if (i < 0) i = 0;

		j = hoehe - content_hoehe;
		j = j / 2;
		if (j < 0) j = 0;
	
		obj.style.left = i+"px";
		if (hoehe_center) {
			obj.style.top = j+"px";
		}
	}
}

function zentrierenBreite(breite) {
	var i, obj, tmpBreite;
	
	content_breite = breite;
	
 	if (window.innerWidth) {
		tmpBreite = window.innerWidth;
  	} else if (document.body && document.body.offsetWidth) {
    	tmpBreite = document.body.offsetWidth;
	} else {
    	tmpBreite = 0;
	}	
	
	i = tmpBreite - breite;
	i = i / 2;
	if (i < 0) i = 0;
	
	/*return i;*/
	document.write('<style type="text/css">');
	document.write('#center_div { position: absolute; left: '+i+'px; }');
	document.write('</style>');
}

function zentrierenHoehe(hoehe, vertikal) {
	var i, obj, tmpHoehe;

	content_hoehe = hoehe;
	hoehe_center = vertikal;

	if (window.innerHeight) {
		hoehe = window.innerHeight;
  	} else if (document.body && document.body.offsetHeight) {
    	hoehe = document.body.offsetHeight;
	} else {
    	hoehe = 0;
	}

	j = hoehe - content_hoehe;
	j = j / 2;
	if (j < 0) j = 0;
	
	if (!vertikal) {
		j = 0;
	} 
	
	/*return j;*/
	document.write('<style type="text/css">');
	document.write('#center_div { position: absolute; top: '+j+'px; }');
	document.write('</style>');
}

function preload() {
  var d = document; 
  if (d.images){ 
  	if (!d.MM_p) d.MM_p = new Array();
    var j = d.MM_p.length;
    for (var i = 0; i < preloads.length; i++) {
		if (preloads[i].indexOf("#") != 0) {
			d.MM_p[j] = new Image; 
			d.MM_p[j++].src = preloads[i];
		}
    }
  }
}

function getSel()
{
	var txt = '';
	var foundIn = '';
	if (window.getSelection)
	{
		txt = window.getSelection();
		foundIn = 'window.getSelection()';
	}
	else if (document.getSelection)
	{
		txt = document.getSelection();
		foundIn = 'document.getSelection()';
	}
	else if (document.selection)
	{
		txt = document.selection.createRange().text;
		foundIn = 'document.selection.createRange()';
	}
	else return;
	document.forms[0].selectedtext.value = 'Found in: ' + foundIn + '\n' + txt;
}

function addResizeEvent(func) {
  var old = window.onresize;
  if (typeof window.onresize != 'function') {
    window.onresize = func;
  } else {
    window.onresize = function(e) {
      old(e);
      func(e);
    }
  }
}

function addScrollEvent(func) {
  var old = window.onscroll;
  if (typeof window.onscroll != 'function') {
    window.onscroll = func;
  } else {
    window.onscroll = function(e) {
      old(e);
      func(e);
    }
  }
}

function toggle(wen) {
	var d, e;
	d = document;

	e = d.getElementById(wen);

	if (e) {
		if (e.style.display == 'none') {
			e.style.display = ''
		} else {
			e.style.display = 'none';
		}
	};
}

function togglefaq(wen) {
	toggle(wen);
	toggle(wen+'_pfeil1');
	toggle(wen+'_pfeil2');
}


function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function toggle_navi(id) {
	toggle(id);
	toggle(id+'_in');
}