<!--

var elem_serum;
var elem_serum_creatinine;
var elem_urine;
var elem_urine_creatinine;
var elem_sel_sodium;
var elem_sel_urea;

function initializePage()
{
	document.getElementById("menu_fractional_excretion").className = "active";
	
	elem_serum=document.getElementById("serum_value");
	elem_serum_creatinine=document.getElementById("serum_creatinine");
	elem_urine=document.getElementById("urine_value");
	elem_urine_creatinine=document.getElementById("urine_creatinine");
	elem_sel_sodium=document.getElementById("electrolyte_sodium");
	elem_sel_urea=document.getElementById("electrolyte_urea");
	
	elem_serum.value = "";
	elem_serum_creatinine.value="";
	elem_urine.value = "";
	elem_serum_creatinine.value="";
	elem_urine_creatinine.value="";
	elem_sel_sodium.checked=true;
	
	elem_serum.focus();
 	calculo();
}

function processKey (code)
{

	switch (code) {
	case code_o:
		elem_serum.select();
		break;
	case code_c:
		elem_serum_creatinine.select();
		break;
	case code_i:
		elem_urine.select();
		break;
	case code_r:
		elem_urine_creatinine.select();
		break;
	case code_s:
		elem_sel_sodium.checked=true;
		calculo();
		break;
	case code_u:
		elem_sel_urea.checked=true;
		calculo();
		break;
	}
}



function calculo()
{
	var ptSerumValue = parseFloat(elem_serum.value);
	var ptSerumCreatinine = parseFloat(elem_serum_creatinine.value);
	var ptUrineValue = parseFloat(elem_urine.value);
	var ptUrineCreatinine = parseFloat(elem_urine_creatinine.value);
  	var lyte;
	var output_notes="";

	var fractional_excretion=-1;
	var values_valid=true;
	
	var recs = "";
	
	if (elem_sel_sodium.checked) {
		lyte="sodium";
	}
	else if (elem_sel_urea.checked) {
		lyte="urea"
	}
	
	if (lyte=="sodium") {
		document.getElementById("serum_value_label").innerHTML="<label for=\"serum_value\">Serum s<span class=\"shortcuthilight\">o</span>dium:&nbsp;</label>";
		document.getElementById("urine_value_label").innerHTML="<label for=\"urine_value\">Ur<span class=\"shortcuthilight\">i</span>ne sodium:&nbsp;</label>";
		document.getElementById("serum_value_units").innerHTML="meq/L";
		document.getElementById("urine_value_units").innerHTML="meq/L";
	}
	if (lyte=="urea") {
		document.getElementById("serum_value_label").innerHTML="<label for=\"serum_value\">Bl<span class=\"shortcuthilight\">o</span>od urea nitrogen:&nbsp;</label>";
		document.getElementById("urine_value_label").innerHTML="<label for=\"urine_value\">Ur<span class=\"shortcuthilight\">i</span>ne urea nitrogen:&nbsp;</label>";
		document.getElementById("serum_value_units").innerHTML="mg/dl";
		document.getElementById("urine_value_units").innerHTML="mg/dl";
	}
	
	if (elem_serum.value=="") {
		values_valid=false;
	}
	if ((elem_serum_creatinine.value < 0) || (elem_serum_creatinine.value=="")) {
		values_valid=false;
	}
	if ((elem_urine.value < 0) || (elem_urine.value=="")) {
		values_valid=false;
	}
	if ((elem_urine_creatinine.value < 0) || (elem_urine_creatinine.value=="")) {
		values_valid=false;
	}
	

	
	if (values_valid) {
		fractional_excretion = (ptUrineValue/ptSerumValue)/(ptUrineCreatinine/ptSerumCreatinine);
		fractional_excretion = fractional_excretion*100;
		fractional_excretion = pseudoRound(fractional_excretion, 1);
	
		document.getElementById("solo_output").innerHTML = fractional_excretion+"%";
		document.getElementById("solo_header").innerHTML = "fractional excretion of "+lyte;
		document.getElementById("solo_header").style.display="block";
    	document.getElementById("solo_output").style.display="block";

		if (lyte=="sodium") {
			if (fractional_excretion < 1) {
			output_notes = "<p><br />In the setting of acute renal failure, a low (&lt;1%) fractional excretion of sodium suggests a pre-renal etiology, although other conditions may also present this way.</p>";
			}
			else if ((fractional_excretion >= 1) && (fractional_excretion <= 2)) {
				output_notes="<p><br />A fractional excretion of sodium between 1% and 2% is borderline and may not be diagnostically helpful.</p>";
			}
			else {
				output_notes="<p><br />In the setting of acute renal failure, a fractional excretion of sodium &gt;2% in suggests of ATN unless diuretics are active.</p>";
			}
		}
		
		if (lyte=="urea") {
				if (fractional_excretion <=35) {
					output_notes = "<p><br />In the setting of acute renal failure, a low (&lt;35%) fractional excretion of urea suggests a pre-renal etiology.</p>";
				}
				else if ((fractional_excretion > 35) && (fractional_excretion <= 50)) {
					output_notes="<p><br />A fractional excretion of urea between 35% and 50% is borderline and may not be diagnostically helpful.</p>";
				}
				else {
					output_notes="<p><br />In the setting of acute renal failure, a fractional excretion of urea &gt;50 in suggests of ATN.</p>";
				}
		}

		
		recs=output_notes;
  	}
	else {
		document.getElementById("solo_header").style.display="none";
    	document.getElementById("solo_output").style.display="none";
		
		
		if ((elem_serum.value=="") || (elem_serum_creatinine.value=="")) {
	      recs += "<p>Enter serum values.</p>"
	    }
	    if ((elem_urine.value=="") || (elem_urine_creatinine.value=="")) {
	      recs += "<p>Enter urine values.</p>";
	    }
	}
	document.getElementById("adviceoutput").innerHTML = recs;
}

-->