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_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) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='  - '+nm+' enthält keine gültige E-Mail Adresse\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='  - '+nm+' enthählt keine Ziffern\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+'. beinhalten\n';
    } } } else if (test.charAt(0) == 'R') errors += '  - '+nm+' fehlt\n'; }
  } if (errors) alert('Bitte folgende Eingaben ausbessern:    \n-------------------------------------------\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*
function CookieCheck(){
	 if(navigator.cookieEnabled == true)
   document.write("Cookies erlaubt");
 else if(navigator.cookieEnabled == false) document.write("Cookies verboten.");
      else document.write("Verrate ich nicht.");
}
*/
function BenutzerAusgeben() {
	if(document.cookie) {
		//gespeichert = document.cookie;
		//return gespeichert;
		return getCookie("user");
	}
	else return "";
}
function AbmeldenAusgeben() {
	if(document.cookie) return "<a href=\"/cgi-bin/WebObjects/ixbau.woa/wa/logout\">[Abmelden...]</a>";
	else return "";
}
/*
function setCookie(){
	var ablauf = new Date();
	var inxTagen = ablauf.getTime() + (1 * 24 * 60 * 60 * 1000);
	ablauf.setTime(inxTagen);
	//document.cookie = "Andreas Niederer, modulor; expires=" + ablauf.toGMTString();
	document.cookie = "user=Andreas Niederer, modulor; expires=" + ablauf.toGMTString();
}

function setCookie (name, value, expires, path, domain, secure){  
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "")      
	+((path) ? "; path=" + path : "") +     
	((domain) ? "; domain=" + domain : "") +  
	((secure) ? "; secure" : "");
	  document.cookie = curCookie;  
}
*/
function getCookie(name){  
	var dc = document.cookie;  
	var prefix = name + "=";  
	var begin = dc.indexOf("; " + prefix);  
	if (begin == -1) {    
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
		}
	else begin += 2;  
		var end = document.cookie.indexOf(";", begin);  
	if (end == -1)    end = dc.length;  
	return unescape(dc.substring(begin + prefix.length, end));
} 

function deleteCookie(name,path,domain){
	if (getCookie(name)) {
		document.cookie = name + "=" +
//		((path) ? "; path=" + path : "") +   
//		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";  		
	}
} 
function openGlossar(theURL) { //v2.0
  window.open(theURL,'GlossarPopup','scrollbars=yes, resizable=no, width=420, height=250');
}