	function popupIE(url,fensterName,width,height) {
		x=screen.availWidth/2-width/2;
		y=screen.availHeight/2-height/2;		
		var popWin = window.showModalDialog(url,null,'dialogHeight:'+(height+26)+'px;dialogWidth:'+(width+10)+'px;scroll:no;status:no;help:no');
	}
	
	function popWindow(url,fenster,width,height){
		var n=navigator.appName;
		if (n=="Microsoft Internet Explorer") {
			popupIE(url,fenster,width,height);
		}
		else {
			x=screen.availWidth/2-width/2;
			y=screen.availHeight/2-height/2;
			args='width='+width+',height='+height+',left='+x+',top='+y+',resizable=no,scrollbars=0,dependent=yes,status=no,dialog,modal';
			popWin = window.open(url,fenster,args);
			popWin.focus();
		}
	}	
	
	var pop;
	function popup(url,fenster,width,height,args){
		x=screen.availWidth/2-width/2;
		y=screen.availHeight/2-height/2;
		args=args + ',width='+width+',height='+height+',left='+x+',top='+y+args +',resizable=yes';
		
		pop = window.open(url,fenster,args);
		pop.resizeTo(width+8,height+25);
		pop.moveTo(x,y);
		pop.focus();
	}
	

    function frmSubmit() {
    	
    	var ScrollValue = (document.all)? document.body.scrollTop :window.pageYOffset;
    	//alert(ScrollValue);
    	var theform;
		if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
			theform = document.forms["frm_examination"];}
		else {
			theform = document.frm_examination;}
		alert(theform.name);
		theform.__SCROLLLOC.value = ScrollValue;
		
    }
    
    	
	
	
	
	function isVisible(Parent_Field,Check_Value){
	    var f = document.getElementById(Parent_Field)
	    var vis = "visible";
		var invis = "hidden";
		
		//alert(f.name + f.value);
		
		if(f.value==Check_Value) {
            //alert(vis);
            return vis;
        }
        else
            //alert(invis);
            return invis;
	}
	
	function activateRow(tr)
	{
		tr.className="hover";
		return;
		//alert(tr.childNodes[0].length);
		//alert(tr.innerHTML);
		var url=tr.childNodes[0].href;
		//var url=tr.cells[0].childNodes[0].href;
		url=url.substring(11);
		//tr.onclick=url;
		//alert(tr.onclick);
		
	}
	function resetRow(tr)
	{
		tr.className="";
		//tr.onclick="";
	}
	
    
    function calc_standard_weight()
	{
	    var txt_height;
	    txt_height=document.getElementById('txt_height');
	    var height=txt_height.value;
	    
	    var cmb_sex;
	    cmb_sex=document.getElementById('cmb_sex');
	    var sex=cmb_sex.value;
	    
	    if(isNaN(height) == true) height=0;
	    if(isNaN(sex) == true) sex=0;
	    
	    
	    var standard_weight;
	    standard_weight = height -100;
	    if (sex == 1) standard_weight = standard_weight - ((standard_weight - 52) * 0.4); //weiblich
	    if (sex == 2) standard_weight = standard_weight - ((standard_weight - 52) * 0.2); //männlich
        
        //alert("standard_weight=" + standard_weight);
        
        
        var txt_standard_weight;
	    txt_standard_weight=document.getElementById('disabled_standard_weight');
	    var standard_weight_string;
	    standard_weight_string = Math.round(standard_weight*10)/10; //auf eine Stellen runden
	    standard_weight_string=String(standard_weight_string);
	    standard_weight_string=standard_weight_string.replace(/\./,",");
	    //ctl_standard_weight.value = standard_weight_string;
	    txt_standard_weight.value=standard_weight_string;
	    
	    return standard_weight;
	}
	
	function removeRow(ctl)
	{
		var row=ctl.parentNode.parentNode;
		var tab=row.parentNode;
		if(tab.rows.length>1) {
			var idx=row.rowIndex;
			row.parentNode.deleteRow(row.rowIndex);
		}
		//return false;
	}
	
	
	function calc_pdai()
	{
	    //Errechnet den PDAI (14.04.2008)
	    var pdai = 0;
	    for (var i=1; i<6; i++)
	    {
	        var cmb = document.getElementById('cmb_pdai' + String(i));
	        var result = (cmb.value == - 1) ? 0 : cmb.value;
	        pdai += parseInt(result);
		}
	    
        var txt_pdai=document.getElementById('txt_pdai_score');
	    txt_pdai.value=pdai;
	    return pdai;
	}
	
	
	
	
	
	function calc_bmi()
	{
	    //
	    // Calculates the BMI
	    //
	    
	    // Weight in kg
	    var txt_weight;
	    txt_weight=document.getElementById('txt_weight');
	    
	     if(txt_weight == null)
			return;
	    
	    var w=txt_weight.value.replace(/\,/,"."); // Komma durch Punkt ersetzen
	    
	    // Height in cm
	    var txt_height;
	    txt_height=document.getElementById('txt_height');
	    
	    
	    if(txt_height == null)
			return;
	    
	    var h=txt_height.value;
	    
	    //alert("weight=" + isNaN(w));
	    
	    
	    if(isNaN(w) == true) w=0;
	    if(isNaN(h) == true) h=0;
	    
	    
	    var txt_bmi;
	    txt_bmi=document.getElementById('txt_bmi');
	    
	    var bmi;
	    
	    if(w==0 || h==0)
	    {
			bmi = "0";
	    }
	    else
	    {
			/* 
			* Formel für BMI
			* weight (kg) / (height (m))^2
			*/ 
			
			var wert = w / Math.pow(h/100,2)
			bmi = String(Math.round(wert*10)/10); //auf zwei Stellen runden
			bmi=bmi.replace(/\./,",");
	    }	    
	    txt_bmi.value = bmi;
	    return bmi;
	}
	
	function calc_rcdai()
	{
		
		/*
		* Calculates the points of the rcdai
		*/
		
		var length = parseInt(document.getElementById('cmb_rcdai_length').value);
		var diameter = parseInt(document.getElementById('cmb_rcdai_diameter').value);
		var dilatation = parseInt(document.getElementById('cmb_rcdai_dilatation').value);
		
		if(length<0)
			length=0;
			
		if(dilatation<0)
			dilatation=0;
			
			
		if(diameter<0)
			diameter = 0;
		else
			diameter = 11 - diameter;
			
		var points = length + diameter + dilatation;
		
		document.getElementById('txt_rcdai_score').value = points + "";
		
		return points;
		
		
	}
	
	function calc_hbi()
	{
		
		/*
		* Calculates the Harvey Bradshaw Score
		*/
		
		if(document.getElementById('cmb_hbi1') == null)
			return;
		
		var hbi1 = parseInt(document.getElementById('cmb_hbi1').value);
		
		
		var hbi2 = parseInt(document.getElementById('cmb_hbi2').value);
		
		
		var txt_hbi3 = document.getElementById('txt_hbi3').value;
		
		var hbi3=0;
		
		if(txt_hbi3.length > 0)
		{
			if(isNaN(txt_hbi3) == false)
				hbi3=parseInt(txt_hbi3);
		}
		
		var hbi4 = parseInt(document.getElementById('cmb_hbi4').value);
		
		
		if(hbi1 < 0) hbi1=0;
		if(hbi2 < 0) hbi2=0;
		if(hbi3 < 0) hbi3=0;
		if(hbi4 < 0) hbi4=0;
		
		var hbi5=0;
		var hbi5List = document.getElementsByName('chk_hbi5');
		
		for (var i=0;  i < hbi5List.length; i++)
	    {
			if(hbi5List[i].checked)
				hbi5 += 1;
	    
	    }
	    
	    var hbi = 0;
		
		var hbi = hbi1
				+ hbi2
				+ hbi3
				+ hbi4
				+ hbi5;
						
		document.getElementById('txt_hbi').value = hbi;
		
		return hbi;
		
		
		
	}	
	
	function calc_surface()
	{
	    //
	    // Errechnet die Körperoberfläche
	    //
	    
	    var txt_weight;
	    txt_weight=document.getElementById('txt_weight');
	    var w=txt_weight.value.replace(/\,/,"."); // Komma durch Punkt ersetzen
	    
	    var txt_height;
	    txt_height=document.getElementById('txt_height');
	    var h=txt_height.value;
	    
	    //alert("weight=" + isNaN(w));
	    
	    
	    if(isNaN(w) == true) w=0;
	    if(isNaN(h) == true) h=0;
	    
	    
	    
	    w = Math.pow(w,0.425); 
	    h = Math.pow(h,0.725); 
	    
	    //alert("weight=" + w);
	    //alert("height=" + h);
	    
	    var surface;
        surface = 0.007184 * w * h
        
        //alert("surface=" + surface);
        
        var txt_surface;
	    txt_surface=document.getElementById('txt_surface');
	    var surface_string;
	    surface_string = Math.round(surface*10)/10; //auf zwei Stellen runden
	    surface_string=String(surface_string);
	    surface_string=surface_string.replace(/\./,",");
	    txt_surface.value = surface_string;
	    return surface;
	}
	
	function IsDate(source, args) 
	{
		
		alert("IsDate");
		alert(source);
		args.IsValid = false;
		
		
		
		/*
		var sDate="";
		sDate=ctl.value;
		
		args.IsValid = false;
		
		
		
		if (sDate == ""){return;};
		var nDate = sDate.replace(/\./g, "-"); 
		var parsedDate = nDate.split ("-");
		if (parsedDate.length < 2 || parsedDate.length > 3) // Das Datum besteht nicht aus zwei bzw. drei Teilen
		{ 
			alert('Please enter a date in format dd.MM.yyyy !');
			ctl.select(); 
			return false
		};
		
		
		
		var day, month, year;
		day = parsedDate[0];
		month = parsedDate[1]-1;
		
		if(parsedDate.length != 3)
		{
			
			year = new Date().getFullYear();
			}
		else
			year = parsedDate[2];
			
			
		
		if(isNaN(day) == true) {alert('Please enter a valid day!');return;}
		if(isNaN(month) == true) {alert('Please enter a valid month!');return;}
		if(isNaN(year) == true) {alert('Please enter a valid year!');return;}
		
		//alert(parseInt(year));
		
		if(parseInt(year) < 100)
			if(parseInt(year) < 50)
				year = parseInt(year) + 2000;
			else
				year = parseInt(year) + 1900;
				
		if(parseInt(year) < 1900){alert('Please enter a valid year!');return;}
		
		
		var objDate = new Date (year,month,day); 
		day = objDate.getDate() < 10 ? "0" + objDate.getDate() : objDate.getDate();
		monat = objDate.getMonth()+ 1;
		month = monat < 10 ? "0" + monat : monat;
		year = objDate.getFullYear();
		
		
		ctl.value = day + "." + month + "." + year;
		
		args.IsValid = true;
			
		//return true;
		*/
	}
	
	
	function ReplaceUrl(urlLocation,newPage)
	{
		
		//alert(urlLocation.pathname);
		
		var arr = urlLocation.pathname.split( '/' );
		
		i = arr.length -1;
		arr[i]=newPage;
		
		//alert(arr.join('/'));
		
		urlLocation.pathname = arr.join('/');
		
		
		
		
		//alert("hallo");
		
	
	
	
	}
	
	function ValidateEinAus(source, args)

	{
		args.IsValid = document.getElementById('cbxEinAus').checked;
	}
	
	function SetDisplayKategorie(ddl)
	{
		if(ddl==null)
			return;
		
		classname = ddl.value=="2" ? "show" : "hide";
			
		document.getElementById('divZentrum').className = "zeile " + classname;
		document.getElementById('divAbteilung').className = "zeile " + classname;
		
		//Validator enablen
		val = document.getElementById('rfvZentrum');
		enable = ddl.value=="2";
		
		try
		{
			ValidatorEnable(val, enable);
		}
		catch(ex)
		{
			//alert(ex.description);
		}
		
		
	
	
	}
	
	
	

	
		
