// *** Globale Funktionalitaeten ***

// Imgs laden und sicherstellen
// Browser identifizieren
function detectBrowser() {
	b = new Object;
	with(navigator) {
		// general
		b.name = appName;
		b.version = appVersion;
		b.platform = platform;
		b.fullid = "Name:" + appName + "\nVersion:" + appVersion + "\nPlatform:" + platform;
		b.v = 0;
		// name
		if(appName.indexOf("Microsoft Internet Explorer") > -1) {
			vers = b.version.match(/MSIE (\d+)\.(\d+)/);
			b.ie = true;
			b.id = "ie";
			b.v = vers[1];
		} else if(appName.indexOf("Netscape") > -1) {
			vers = b.version.match(/^(\d+)\.(\d+)/);
			b.v = vers[1];
			if(vers[1] >= 5) {
				b.mz = true;
				b.id = "mz";
			} else {
				b.ns = true;
				b.id = "ns";
			}
		} else {
			b.other = true;
			b.id = "other";
		}
		// platform
		b.os = 'other';
		if(platform == "Win32" || platform == "Win16") {
			b.os = 'win';
			b.win = true;
		} else if(platform.indexOf("Mac") > -1) {
			b.os = 'mac';
			b.mac = true;
		} else {
			b.c64 = true;
		}
	}
	return b;
}
browser = detectBrowser();

var c_width = browser.ns ? 810 : 806;
var c_height = 732;
var c_x = (screen.availWidth / 2) - (c_width / 2);
var c_y = (screen.availHeight / 2) - (c_height / 2);



/* new method for string objects */
function getParameter(parameter) {
	s = this.toString();
	if(s.indexOf('?') == 0) s = s.substr(1);
	if(s == '') return '';
	pairs = s.split(/&/);
	for(i in pairs) {
		pair = pairs[i].split(/=/);
		if(pair[0] == parameter) {
			return (!pair[1] ? '' : pair[1]);
		}
	}
	return '';
}
String.prototype.getParameter = getParameter;

function nul() {
}

//popup (print)
function openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}


//popup (sitemap)

	parent.name = "main";
	function openPopup(URL,winName,features){
	parent.name = "main";
		window.open(URL,winName,features);
	}

// textSizer

function cBtype8() {
 if(document.getElementById)
   document.getElementById("copyBody").style.fontSize = "8pt";
   document.getElementById("copyBody").style.fontFamily = "arial, helvetica"; 
} 
function cBtype10() {
 if(document.getElementById)
   document.getElementById("copyBody").style.fontSize = "10pt"; 
   document.getElementById("copyBody").style.fontFamily = "arial, helvetica";
}
function fBtype8() {
 if(document.getElementById)
   document.getElementById("featureBody").style.fontSize = "8pt";
   document.getElementById("featureBody").style.fontFamily = "arial, helvetica"; 
} 
function fBtype10() {
 if(document.getElementById)
   document.getElementById("featureBody").style.fontSize = "10pt"; 
   document.getElementById("featureBody").style.fontFamily = "arial, helvetica";
}


// streckt den body auf vertikalhoehe
function setHeight(){
	if (window.innerWidth)	{fensterhoehe = window.innerHeight;}
	else {fensterhoehe = document.body.offsetHeight;}
	{ if (fensterhoehe < 718) {changeHeight = "<tr><td colspan='5' height='46'><img src='../lib/img/misc/p.gif' width='1' height='46' alt='' border='0'></td>";}
	else {changeHeight = "<tr><td colspan='5' height='142'><img src='../lib/img/misc/p.gif' width='1' height='142' alt='' border='0'></td>";} return changeHeight;}
		}


// formularvalidierung
function MM_findObj(n, d) { 
  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_validateForm() { 
  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) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- Das Feld  "'+nm+'" muss eine eMailadresse enthalten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- Das Feld "'+nm+'" muss ausgefuellt sein.\n'; }
  } if (errors) alert('Eingabefehler: \n\n'+errors);
  document.MM_returnValue = (errors == '');
}
//imgs wechseln
function findObj(n, d) { 
  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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

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