function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns6 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck();
///////////////////////////////////////////////////////////////////////////////////////////////////////
function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
	if(typeof win != "undefined") win.close();
	var win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	return win;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function preload(imgObj,imgSrc) {
	
	if (document.images){
	 	eval(imgObj + ' = new Image();');
		var imgO = eval(imgObj);
	  	imgO.src = imgSrc;
		//alert(imgO);
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function changeImage(imgName, imgObj) {
		document.images[imgName].src = eval(imgObj+".src");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function showDiv (elemId) {
	document.getElementById(elemId).style.display = "block";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function hideDiv (elemId) {
	document.getElementById(elemId).style.display = "none";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function toggleDiv (elemId) {
	
	if (!elemId) return false;
	var mode = document.getElementById(elemId).style.display;
	
	if (mode != "block")
		showDiv(elemId);
	else
		hideDiv(elemId);
		
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function ScreenCenter(){
	var ScreenWidth = 0;
	switch (is.b) {
		case "ie" : 
				ScreenWidth = document.body.clientWidth;
  				break;
		case "ns" : 
				ScreenWidth = window.innerWidth;
				break;
		default : 
				ScreenWidth = false;
				break;
	}
	return ScreenWidth / 2;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function writeToLayer(lay,data) {
  txt=data.replace(/\n/g,'<br>');
  if (is.ie) {
    document.all[lay].innerHTML = txt;
	
  } else if (is.ns4) {//
	//ret='<table width="420" height="25" cellspacing="2" cellpadding="2" border="0"><tr><td>'+txt+'</td></tr></table>';
	document.layers[lay].document.open();
	document.layers[lay].document.writeln(txt);
    document.layers[lay].document.close();
	
  } else if (is.ns6) {
    over = document.getElementById([lay]);
    range = document.createRange();
    range.setStartBefore(over);
    domfrag = range.createContextualFragment(txt);
    while (over.hasChildNodes()) {
      over.removeChild(over.lastChild);
    }
    over.appendChild(domfrag);
  }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function setLayer(LayerId,LayerTop,LayerLeft){
	if(is.ie){if(LayerTop) document.all[LayerId].style.top=LayerTop;
			  if(LayerLeft) document.all[LayerId].style.left=LayerLeft;
			 }
	if(is.ns4){if(LayerTop) document.layers[LayerId].top=LayerTop;
			   if(LayerLeft) document.layers[LayerId].left=LayerLeft;
			  }
	if(is.ns6){if(LayerTop) document.getElementById(LayerId).style.top=LayerTop;
			   if(LayerLeft) document.getElementById(LayerId).style.left=LayerLeft;
			  }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function getDivInfo(dId){
	divId = dId;
						//(top,left,width,height)
	var divData=new Array(false,false,false,false)
	if(is.ie){
		var el = document.all[divId];
		var x = y = 0;
		do {
		 x += el.offsetLeft;
		 y += el.offsetTop;
		 //alert(el.id);
		}
		while ((el = el.offsetParent));
		divData[0]=y;
		divData[1]=x;
		divData[2]=document.all[divId].offsetWidth;
		divData[3]=document.all[divId].offsetHeight;
	}
	if(is.ns4){
		eval("divData[0]=document.layers['"+divId+"'].pageY");
		eval("divData[1]=document.layers['"+divId+"'].pageX");
		eval("divData[2]=document.layers['"+divId+"'].clip.width");
		eval("divData[3]=document.layers['"+divId+"'].clip.height");
	}
	if(is.ns6){
		divData[0]=document.getElementById(divId).offsetTop;
		divData[1]=document.getElementById(divId).offsetLeft;
		divData[2]=document.getElementById(divId).offsetWidth;
		divData[3]=document.getElementById(divId).offsetHeight;
	}
	return divData;
}

function clipDiv(divId,cTop,cRight,cBottom,cLeft){
	if(is.ie){document.all[divId].style.clip='rect('+cTop+'px '+cRight+'px '+cBottom+'px '+cLeft+'px)';}
	if(is.ns4){	eval("document.layers['"+divId+"'].clip.top="+cTop);
				eval("document.layers['"+divId+"'].clip.right="+cRight);
				eval("document.layers['"+divId+"'].clip.bottom="+cBottom);
				eval("document.layers['"+divId+"'].clip.left="+cLeft);
				}
	if(is.ns6){document.getElementById(divId).style.clip='rect('+cTop+'px '+cRight+'px '+cBottom+'px '+cLeft+'px)';}

}

function dump(obj){
  var w=prompt(obj+" ("+typeof obj+")"+"\n");
  if(w==null) window.location.href = window.location.href.replace(/#.*/,"")+"?exit";
}
///////////////////////////////////////////////////////////////////////////////////////////////////

function showmenupoint(elemId)
	{
	var dem = document.getElementById("menuItem_"+elemId);

	dem.style.backgroundColor = '#FFFFFF';
	}


function hidemenupoint(elemId)
	{
	var dem = document.getElementById("menuItem_"+elemId);
	dem.style.backgroundColor = '';
	}

function showpoint(elemId)
	{
	var point = document.getElementById(elemId);
	point.style.visibility='visible';
	}
function hidepoint(elemId)
	{
	var point = document.getElementById(elemId);
	point.style.visibility='hidden';
	}
	
	
	
function formFocus(obj,fvalue){
	if(is.ie||is.ns6){
	  obj.style.backgroundColor='#FFFFFF';
	}
	if(obj.value==fvalue) obj.value='';
}
function formBlur(obj){
	if(is.ie||is.ns6){
		if(obj.value!='')	obj.style.backgroundColor='#D5D0D6';
	  	else obj.style.backgroundColor='#F5F5F6';
	}
}
function checkForm(obj){

	formOK=true;
	ret = "Korrigieren Sie bitte folgende Fehler und klicken Sie anschliessend auf 'senden'.\n\n";

	if (obj.anrede.options[obj.anrede.options.selectedIndex].value==''){
	  ret += "• Waehlen Sie bitte Ihre Anrede.\n\n";
	  formOK=false;
	}
	if (obj.vorname.value.length<2){
	  ret += "• Geben Sie bitte Ihren Vornamen an.\n\n";
	  formOK=false;
	}
	if (obj.name.value.length<2){
	  ret += "• Geben Sie bitte Ihren Namen an.\n\n";
	  formOK=false;
	}
	if (!obj.email.value.match(/^[0-9a-z_]([-_.]{0,1]{0-9a-z])*@[0-9a-z][-.0-9a-z]*\.[a-z]{2,4}$/)){
	  ret += "• Keine gueltige e-mail Adresse.\n\n";
	  formOK=false;
	}
	if(formOK){
	  return true;
	} else {
	  alert(ret);
	  return false;
	}

}
	