function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	var obj = document.getElementById(szDivID);
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (i=0; i < alltags.length;i++){
		if (alltags[i].className=="hidden"){
			alltags[i].style.visibility="hidden";
			alltags[i].style.display="none";
			alltags[i].value=obj.value;
		}
	}
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
        document.layers[szDivID].display = iState ? "inline" : "none";
  
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
        obj.style.display = iState ? "inline" : "hidden";
        
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "show" : "hide";
    	document.all[szDivID].style.display = iState ? "inline" : "none";
    }
    
}
function SetBox(elm) // 1 visible, 0 hidden
{
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (i=0; i < alltags.length;i++){
		if (alltags[i].className=="hidden"){
			alltags[i].value=elm.value;
		}
	}
   
}
/*
<SCRIPT LANGUAGE="javascript">
<!--Hide JavaScript from Java-Impaired Browsers
*/


function selectJump(selObj){
  eval("parent.location='"+selObj.options[selObj.selectedIndex].value+"'");
}
/*

// End Hiding -->
</SCRIPT>
*/
/*
<SCRIPT LANGUAGE="javascript">
<!--
*/function openCAL(field) {
    mywin = window.open("/templates/calendar.php?field="+field,"cal",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=212,height=192');
}
function openhelp(str)
{
    help = window.open("/templates/help.php" + str,"helpscreen","location=yes,toolbar=yes,scrollbars=yes,resizeable=yes,width=525,height=400");
    help.focus();
}
function confirmSubmit(text){
    var OK = confirm(text);

    if(OK){
    	return true;
    } else {
        return false;
    }
}
function checkRange (element,description,range){
	name=element.name;
	value=element.value;
	first=0;
	last=0;
	
	first = range.indexOf("-");
    last = range.lastIndexOf("-");
    low=range.substring(0,first);
    high=range.substring(first + 1,range.length);
	if (parseFloat(value) < low || parseFloat(value) > high){
		alert ("Your " + description + " range "+ value + " is not correct it must be within the range of " + low + " to " + high);
		element.focus();
		element.select();
	} 
}
function checkLabRange (element,description,labtype){
	var lab=new Array(9);
	range='';
	lab[1]="0.0-99.9";
	lab[2]="3.2-22.0";
	lab[3]="6.0-70.0";
	lab[4]="0-1000";
	lab[5]="0-300";
	lab[6]="3-160";
	lab[7]=".4-12.0";
	lab[8]="0-10000";
	lab[9]=".5-15.0";
	
	
	range=lab[labtype];
	value=element.name;
	value=element.value;
	first=0;
	last=0;
	
	first = range.indexOf("-");
    last = range.lastIndexOf("-");
    low=range.substring(0,first);
    high=range.substring(first + 1,range.length);
	if (parseFloat(value) < low || parseFloat(value) > high){
		alert ("Your " + description + " range "+ value + " is not correct it must be within the range of " + low + " to " + high);
		element.focus();
		element.select();
	} 
}

function lessionSuccess (grafts,attempts,success,failure){
	
	var unsuccessful = (parseInt(attempts) - parseInt(success));
	document.form.Lessions_w_Grafts_incomp.value=unsuccessful;
	
	if (parseInt(success) == parseInt(attempts) ){
		document.form.Lession_Successful.value=1;
		alert("This was an successful procedure");
	}
	if (parseInt(attempts) > parseInt(success) && parseInt(success)!=0){
		document.form.Lession_Successful.value=3;
		alert("This was an incomplete procedure");
	}
	if (parseInt(success) == 0){
		document.form.Lession_Successful.value=2;
		alert("This was an unsuccessful procedure");

	}
	
	return;
}
function roundNumber(numberField,rlength) {
	var rnum = numberField.value;
	if (rnum > 8191 && rnum < 10485) {
		rnum = rnum-5000;
		var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
		//newnumber = newnumber+5000;
	} else {
		var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
	}
	if (newnumber==0){
		newnumber='';
	}
	numberField.value = newnumber;
}
function BMICalculation(height,weight){
	if (height >0  && weight >0 ){
		
		var bmi=( parseInt(weight) / Math.pow(parseInt(height),2));
		bmi=(bmi * 703);;
		document.form.calculated_BMI.value=Math.round(bmi*100)/100
		
	} else {
		document.form.calculated_BMI.value='';
	}
	return;
}
function m1()
{
    window.status = 'Click here for Definitions and Explanations!';
}
function navChange(sect){
	document.form.Section.value=sect;
	document.form.submit();
}
function m1e()
{
    window.status = '';
}
function openPT(field) {
    mywin = window.open("/registry/templates/peripheraltree.php?field="+field,"cal",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=500,height=680');
}
function DateValidation(field,type)
{
    strDay="";strMonth="";strDate="";strYear="";
    month=0;day=0;year=0;
    strDate=field.value;
    firstslash = 0;lastslash = 0;
    valid = true;
    if (isallwhite(field.value) == false)
    {
        firstslash = strDate.indexOf("/");
        lastslash = strDate.lastIndexOf("/");
        strMonth=strDate.substring(0,firstslash);
        strDay=strDate.substring(firstslash + 1,lastslash);
        strYear=strDate.substring(lastslash + 1,strDate.length);
        if (isNaN(month=parseInt(strMonth, 10)))
        {
            alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " +type+".");
            valid = false;
        }
        if ((isNaN(day=parseInt(strDay, 10))) && (valid == true))
        {
            alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " +type+".");
            valid = false;
        }
        if ((isNaN(year=parseInt(strYear,10))) && (valid == true))
        {
            alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " +type+".");
            valid = false;
        }
        if (((month < 1) || (month > 12) || (year < 1000) || (year > 9999)) && (valid == true))
        {
            alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " +type+".");
            valid = false;
        }
        if ((((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12))) && ((day < 1) || (day > 31)) && (valid == true))
        {
            alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " +type+".");
            valid = false;
        }
        if ((((month == 4) || (month == 6) || (month == 9) || (month == 11)) && ((day < 1) || (day > 30))) && (valid == true))
        {
            alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " + type +".");
            valid = false;
        }
        if ((month == 2) && (valid == true))
        {
            if(((year % 4) == 0) && (((year % 100) != 0) || ((year % 400) == 0)))
            {
                if((day < 1) || (day > 29))
                {
                    alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " + type +".");
                    valid = false;
                }
            }
            else
            {
                if((day < 1) || (day > 28))
                {
                    alert(field.value + " is not a valid date. Please use the format MM/DD/YYYY when entering a date. Please re-enter " + type +".");
                    valid = false;
                }
            }
        }
        if(valid == false)
        {
            field.focus();
            field.select();
        }
        else if (valid == true)
        {

            if(strMonth.length == 1)
                strMonth = "0" + strMonth;
            if(strDay.length == 1)
                strDay = "0" + strDay;
            field.value = strMonth + "/" + strDay + "/" + strYear;
        }
    }
    else
        field.value = "";
}
/*
-->
</SCRIPT>
*/