

//before events

button_psab.onClick = function(){	
	tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = PSABpage.join("");	
}
button_initial.onClick = function(){	
	tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = ISBpage.join("");	
}
button_initext.onClick = function(){
	tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = EXTBpage.join("");
}
button_repeat.onClick = function(){
	tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = RBpage.join("");
}
button_saturation.onClick = function(){
	tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = SBpage.join("");
}
button_mort120.onClick = function(){
	tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = MORT120page.join("");
}


//------------------------------------------

//bf I events


button_gsu.onClick = function(){	
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = GSUpage.join("");	
}
button_ece.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = ECEpage.join("");
}
button_lsvi.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = LSVIpage.join("");
}
button_lni.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = LNIpage.join("");
}
button_lrmv.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = LRMVpage.join("");
}
button_plnd.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = PLNDpage.join("");
}
button_obt.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = OBTpage.join("");
}


//----------------------------------------------


//bf II events

button_insig.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = INSIGpage.join("");
}
button_tzpz.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = TZPZpage.join("");
}
button_dmar.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = DMARpage.join("");
}
button_ysat.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = YSATpage.join("");
}


//----------------------------------------------

//after surgery events

button_loc.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = LOCpage.join("");
}
button_dis.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = DISpage.join("");
}
button_pcass.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = PCASSpage.join("");
}
button_psa.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = PSApage.join("");
}


//----------------------------------------------

//after psa relapse events

button_meta.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "<b>After PSA Relapse</b>", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = METApage.join("");
}
button_rpht.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "<b>After PSA Relapse</b>", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = RPHTpage.join("");
}
button_prec.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "<b>After PSA Relapse</b>", "Hormone failure"]);
	tabs.refresh();
	container.element().innerHTML = PRECpage.join("");
}

//----------------------------------------------

// hormone failure events

button_aipc.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "<b>Hormone failure</b>"]);
	tabs.refresh();
	container.element().innerHTML = AIPCpage.join("");
}

button_pdt.onClick = function(){
	tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "<b>Hormone failure</b>"]);
	tabs.refresh();
	container.element().innerHTML = PDTpage.join("");
}

//----------------------------------------------

//print button

button_print.onClick = function(){
	window.print();
}


//------------------------------------------

// ISB events


button_isb_calculate.onClick = function(){
	var error = 0;
	var error_age = 0;
	var error_dre = 0;
	var error_psa = 0;
	var error_fpsa = 0;
	if (input_isb_age.getControlText() == "between 10 and 90" || input_isb_age.getControlText() < 10 || input_isb_age.getControlText() > 90 || !isNumeric(input_isb_age.getControlText())){
		error_age = 1;
		error = 1;
	}
	if (input_isb_psa.getControlText() == "up to 50"|| input_isb_psa.getControlText() < 0 || input_isb_psa.getControlText() > 50 || !isNumeric(input_isb_psa.getControlText())){
		error_psa = 1;
		error = 1;
	}
	if ((input_isb_fpsa.getControlText() != "up to 100" && !isNumeric(input_isb_fpsa.getControlText())) || input_isb_fpsa.getControlText() < 0 || input_isb_fpsa.getControlText() > 100){
		error_fpsa = 1;
		error = 1;
	}
	if (combo_isb_dre.getControlText() == "Select"){
		error_dre = 1;
		error = 1;
	}
	
	if (error)
	{
		if (error_age)
			alert("please fill in the age field properly");
		else if (error_dre)
			alert("please fill in the DRE field properly");
		else if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_fpsa)
			alert("please fill in the Free PSA field properly");
	}
	else
	{
		if (input_isb_fpsa.getControlText() == "up to 100") {
						
			var age;
			var dre;
			var psa;
			var p,z, kE;
			age = input_isb_age.getControlText();
			psa = input_isb_psa.getControlText();
			if (combo_isb_dre.getControlText() == "Suspicious")
				dre = 1;
			if (combo_isb_dre.getControlText() == "Normal")
				dre = 0;
				
			kE = 2.718281828459045235360287471352;
			z =  (1.24651 * dre) + (0.05602 * psa) + (0.02058 * age) - 3.0061;
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
			p = roundNumber(p,1);	
				
			result_isb_1.setControlText("<b>The probability of finding prostate cancer");
			result_isb_2.setControlText("during an initial sextant biopsy is </b></font>");
			result_isb_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
			result_isb_3.setControlText("Please discuss this probability with your physician.");
			result_isb_4.setControlText("This percentage needs to be interpreted in context");
			result_isb_5.setControlText("of your age, general health and several other");
			result_isb_6.setControlText("considerations.");
							
			
			
			container.element().innerHTML = ISBpageResult.join("");
			tabs.setSelectedItems([0]);
			tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();	
			
		}
		else {			
			var age;
			var dre;
			var psa;
			var fpsa;
			var p,z, kE;
			age = input_isb_age.getControlText();
			psa = input_isb_psa.getControlText();
			fpsa = input_isb_fpsa.getControlText();
			if (combo_isb_dre.getControlText() == "Suspicious")
				dre = 1;
			if (combo_isb_dre.getControlText() == "Normal")
				dre = 0;
				
			kE = 2.718281828459045235360287471352;
			z = (1.82162 * dre) + (0.02858 * psa) + (0.02436 * age) - (0.0868001 * fpsa) - 1.01469;   
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
			p = roundNumber(p,1);	
				
			 result_isb_1.setControlText("<b>The probability of finding prostate cancer");
			result_isb_2.setControlText("during an initial sextant biopsy is </b></font>");
			result_isb_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
			result_isb_3.setControlText("Please discuss this probability with your physician.");
			result_isb_4.setControlText("This percentage needs to be interpreted in context");
			result_isb_5.setControlText("of your age, general health and several other");
			result_isb_6.setControlText("considerations.");
				
			
			
			container.element().innerHTML = ISBpageResult.join("");
			tabs.setSelectedItems([0]);
			tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();	
			
		}
			
	}
}

question_isb_age.onClick = function(){
	window.open('/local/files/pcat/glossary/Age_at_bopsy.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_isb_dre.onClick = function(){
	window.open('/Tools/local/files/pcat/glossary/DRE.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_isb_psa.onClick = function(){
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_isb_fpsa.onClick = function(){
	window.open('/local/files/pcat/glossary/Percent_free_PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
	
input_isb_age.onControlActivated = function(event){			
	if (input_isb_age.getControlText() == "between 10 and 90")
	{
		input_isb_age.setControlText("");											
	}
		
}	

input_isb_age.onControlDeactivated = function(event){				
	if (input_isb_age.getControlText() == "")
	{
		input_isb_age.setControlText("between 10 and 90");						
	}

}

input_isb_psa.onControlActivated = function(event){			
	if (input_isb_psa.getControlText() == "up to 50")
	{
		input_isb_psa.setControlText("");											
	}
		
}	

input_isb_psa.onControlDeactivated = function(event){				
	if (input_isb_psa.getControlText() == "")
	{
		input_isb_psa.setControlText("up to 50");						
	}

}

input_isb_fpsa.onControlActivated = function(event){			
	if (input_isb_fpsa.getControlText() == "up to 100")
	{
		input_isb_fpsa.setControlText("");											
	}
		
}	

input_isb_fpsa.onControlDeactivated = function(event){				
	if (input_isb_fpsa.getControlText() == "")
	{
		input_isb_fpsa.setControlText("up to 100");						
	}

}

// end of ISB events

//--------------------------------------------------------------

// RB events

button_rb_calculate.onClick = function(){
	var error = 0;
	var error_age = 0;
	var error_dre = 0;
	var error_psa = 0;
	var error_fpsa = 0;
	var error_bxs = 0;
	var error_volsmpl = 0;
	var error_pvol = 0;
	var error_smpld = 0;
	var error_volsmpl2 = 0;
	
	if ( input_rb_age.getControlText() == "between 45 and 85" || input_rb_age.getControlText() < 45 || input_rb_age.getControlText() > 85 || !isNumeric(input_rb_age.getControlText()) ){
		error_age = 1;
		error = 1;
	}
	if ( input_rb_psa.getControlText() == "up to 50"|| input_rb_psa.getControlText() < 0 || input_rb_psa.getControlText() > 50 || !isNumeric(input_rb_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}
	if ( input_rb_fpsa.getControlText() == "up to 100" || input_rb_fpsa.getControlText() < 0 || input_rb_fpsa.getControlText() > 100 || !isNumeric(input_rb_fpsa.getControlText()) ){
		error_fpsa = 1;
		error = 1;
	}
	if ( input_rb_pbx.getControlText() == "between 2 and 7" || input_rb_pbx.getControlText() < 2 || input_rb_pbx.getControlText() > 7 || !isNumeric(input_rb_pbx.getControlText()) ){
		error_bxs = 1;
		error = 1;
	}	
	if ( input_rb_pvol.getControlText() == "up to 220" && input_rb_smpld.getControlText() == "up to 22" ){
		error_volsmpl = 1;
		error = 1;
	}
	if ( input_rb_pvol.getControlText() < 0 || input_rb_pvol.getControlText() > 220 || (input_rb_pvol.getControlText() != "up to 220" && !isNumeric(input_rb_pvol.getControlText()) ) ){
		error_pvol = 1;			
	}		
	if ( input_rb_smpld.getControlText() < 0 || input_rb_smpld.getControlText() > 22 || ( input_rb_smpld.getControlText() != "up to 22" && !isNumeric(input_rb_smpld.getControlText()) ) ){
		error_smpld = 1;		
	}	
	if (combo_rb_dre.getControlText() == "Select"){
		error_dre = 1;
		error = 1;
	}	
	if ( ( input_rb_pvol.getControlText() >= 0 && input_rb_pvol.getControlText() <= 220 & isNumeric(input_rb_pvol.getControlText()) != 0 ) && ( input_rb_smpld.getControlText() >= 0 && input_rb_smpld.getControlText() <= 22 && isNumeric(input_rb_smpld.getControlText()) != 0 ) ){
		error_volsmpl2 = 1;
		error = 1;
	}
	
	if ( (error_pvol || error_smpld)  )
		error = 1;
	
	
	
	if (error)
	{
		if (error_age)
			alert("please fill in the age field properly");
		else if (error_dre)
			alert("please fill in the DRE field properly");
		else if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_fpsa)
			alert("please fill in the Free PSA field properly");
		else if (error_bxs)
			alert("please fill in the Prev. Bx Sessions field properly");
		else if (error_volsmpl)
			alert("please fill in either Prost. Vol field or Sampl. D field");
		else if (error_volsmpl2)
			alert("please fill in either Prost. Vol field or Sampl. D field, not both");
		else if (error_smpld)
			alert("please fill in Sampl. D field properly");
		else if (error_pvol)
			alert("please fill in Prost. Vol field properly");
		
	}
	else
	{
			var age;
			var dre;
			var psa;
			var freepsa;
			var prevbx;
			var prostvol;
			var smpld;
			var p,z, kE;
			age = input_rb_age.getControlText();
			psa = input_rb_psa.getControlText();
			freepsa = input_rb_fpsa.getControlText();
			prevbx = input_rb_pbx.getControlText();
			prostvol = input_rb_pvol.getControlText();
			smpld = input_rb_smpld.getControlText();
			if (combo_rb_dre.getControlText() == "Suspicious")
				dre = 1;
			if (combo_rb_dre.getControlText() == "Normal")
				dre = 0;
				
			kE = 2.718281828459045235360287471352;
			if (smpld == "up to 22")
			{
				z =  (0.04337257 * age) + (1.00489803 * dre) + (0.03408701 * psa) - (0.06800965 * freepsa) - (0.39847122 * prevbx) - (0.01951768 * prostvol) - 0.47394105;
				p = 100 * (1 / (1 + Math.pow(kE,-z)));
				
			}
			
			if (prostvol == "up to 220")
			{
				z =  (0.04889477 * age) + (1.04009098 * dre) + (0.03372980 * psa) - (0.06700937 * freepsa) - (0.47164745 * prevbx) - (0.22066932 * smpld) - 0.57824062;
				p = 100 * (1 / (1 + Math.pow(kE,-z)));
				
			}			 
			
			p = roundNumber(p,1);	
				
			result_rb_1.setControlText("<b>Your probability of finding prostate cancer ");
			result_rb_2.setControlText("during a repeat biopsy is </b></font>");
			result_rb_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
			result_rb_3.setControlText("Please discuss this probability with your physician.");
			result_rb_4.setControlText("This percentage needs to be interpreted in context");
			result_rb_5.setControlText("of your age, general health and several other");
			result_rb_6.setControlText("considerations.");
				
			
			
			container.element().innerHTML = RBpageResult.join("");
			tabs.setSelectedItems([0]);
			tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();	
	}
}

question_rb_age.onClick = function(){
	window.open('/local/files/pcat/glossary/Age_at_biopsy.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_rb_dre.onClick = function(){
	window.open('/local/files/pcat/glossary/DRE.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_rb_psa.onClick = function(){
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_rb_fpsa.onClick = function(){
	window.open('/local/files/pcat/glossary/Percent_free_PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_rb_pbx.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_rb_pvol.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_rb_smpld.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_rb_age.onControlActivated = function(event){			
	if (input_rb_age.getControlText() == "between 45 and 85")
	{
		input_rb_age.setControlText("");											
	}
		
}	

input_rb_age.onControlDeactivated = function(event){				
	if (input_rb_age.getControlText() == "")
	{
		input_rb_age.setControlText("between 45 and 85");						
	}

}

input_rb_psa.onControlActivated = function(event){			
	if (input_rb_psa.getControlText() == "up to 50")
	{
		input_rb_psa.setControlText("");											
	}
		
}	

input_rb_psa.onControlDeactivated = function(event){				
	if (input_rb_psa.getControlText() == "")
	{
		input_rb_psa.setControlText("up to 50");						
	}

}

input_rb_fpsa.onControlActivated = function(event){			
	if (input_rb_fpsa.getControlText() == "up to 100")
	{
		input_rb_fpsa.setControlText("");											
	}
		
}	

input_rb_fpsa.onControlDeactivated = function(event){				
	if (input_rb_fpsa.getControlText() == "")
	{
		input_rb_fpsa.setControlText("up to 100");						
	}

}

input_rb_pbx.onControlActivated = function(event){			
	if (input_rb_pbx.getControlText() == "between 2 and 7")
	{
		input_rb_pbx.setControlText("");											
	}
		
}	

input_rb_pbx.onControlDeactivated = function(event){				
	if (input_rb_pbx.getControlText() == "")
	{
		input_rb_pbx.setControlText("between 2 and 7");						
	}

}

input_rb_pvol.onControlActivated = function(event){			
	if (input_rb_pvol.getControlText() == "up to 220")
	{
		input_rb_pvol.setControlText("");											
	}
		
}	

input_rb_pvol.onControlDeactivated = function(event){				
	if (input_rb_pvol.getControlText() == "")
	{
		input_rb_pvol.setControlText("up to 220");						
	}

}

input_rb_smpld.onControlActivated = function(event){			
	if (input_rb_smpld.getControlText() == "up to 22")
	{
		input_rb_smpld.setControlText("");											
	}
		
}	

input_rb_smpld.onControlDeactivated = function(event){				
	if (input_rb_smpld.getControlText() == "")
	{
		input_rb_smpld.setControlText("up to 22");						
	}

}

// end of RB events

//--------------------------------------------------------------

// SB events

button_sb_calculate.onClick = function(){
	var error = 0;
	var error_age = 0;
	var error_fpsa = 0;
	var error_pvol = 0;
	var error_bphvol = 0;
	
	if ( input_sb_age.getControlText() == "between 40 and 80" || input_sb_age.getControlText() < 40 || input_sb_age.getControlText() > 80 || !isNumeric(input_sb_age.getControlText()) ){
		error_age = 1;
		error = 1;
	}
	if ( input_sb_fpsa.getControlText() == "up to 45" || input_sb_fpsa.getControlText() < 0 || input_sb_fpsa.getControlText() > 45 || !isNumeric(input_sb_fpsa.getControlText()) ){
		error_fpsa = 1;
		error = 1;
	}
	if ( input_sb_pvol.getControlText() == "between 20 and 220" || input_sb_pvol.getControlText() < 20 || input_sb_pvol.getControlText() > 220 || !isNumeric(input_sb_pvol.getControlText()) ){
		error_pvol = 1;
		error = 1;
	}
	if ( input_sb_bphvol.getControlText() == "up to 130" || input_sb_bphvol.getControlText() < 0 || input_sb_bphvol.getControlText() > 130 || !isNumeric(input_sb_bphvol.getControlText()) ){
		error_bphvol = 1;
		error = 1;
	}
	
	
	
	if (error)
	{
		if (error_age)
			alert("please fill in the age field properly");
		else if (error_fpsa)
			alert("please fill in the Free PSA field properly");
		else if (error_pvol)
			alert("please fill in Prost. Vol field properly");
		else if (error_bphvol)
			alert("please fill in BPH. Vol field properly");
		
	}
	else
	{
			var age;			
			var freepsa;
			var prostvol;
			var bphvol;
			var p,z, kE;
			age = input_sb_age.getControlText();
			freepsa = input_sb_fpsa.getControlText();
			bphvol = input_sb_bphvol.getControlText();
			prostvol = input_sb_pvol.getControlText();
			
			
				
			kE = 2.718281828459045235360287471352;
			
			z =  (0.06011152 * age) - (0.07949234 * freepsa) + (0.04101865 * prostvol)  - (0.07919255 * bphvol) - 2.49258330;
			
			
			p = 100 * (1 / (1 + Math.pow(kE,-z)));		
			
			
			
			p = roundNumber(p,1);	
				
			result_sb_1.setControlText("<b>The probability of finding prostate cancer ");
			result_sb_2.setControlText("during a saturation biopsy is </b></font>");
			result_sb_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
			result_sb_3.setControlText("Please discuss this probability with your physician.");
			result_sb_4.setControlText("This percentage needs to be interpreted in context");
			result_sb_5.setControlText("of your age, general health and several other");
			result_sb_6.setControlText("considerations.");
				
			
			
			container.element().innerHTML = SBpageResult.join("");
			tabs.setSelectedItems([0]);
			tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();	
		
	}
}

question_sb_age.onClick = function(){
	window.open('/local/files/pcat/glossary/Age_at_biopsy.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_sb_fpsa.onClick = function(){
	window.open('/local/files/pcat/glossary/Percent_free_PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_sb_pvol.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_sb_bphvol.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_sb_age.onControlActivated = function(event){			
	if (input_sb_age.getControlText() == "between 40 and 80")
	{
		input_sb_age.setControlText("");											
	}
		
}	

input_sb_age.onControlDeactivated = function(event){				
	if (input_sb_age.getControlText() == "")
	{
		input_sb_age.setControlText("between 40 and 80");						
	}

}

input_sb_fpsa.onControlActivated = function(event){			
	if (input_sb_fpsa.getControlText() == "up to 45")
	{
		input_sb_fpsa.setControlText("");											
	}
		
}	

input_sb_fpsa.onControlDeactivated = function(event){				
	if (input_sb_fpsa.getControlText() == "")
	{
		input_sb_fpsa.setControlText("up to 45");						
	}

}

input_sb_pvol.onControlActivated = function(event){			
	if (input_sb_pvol.getControlText() == "between 20 and 220")
	{
		input_sb_pvol.setControlText("");											
	}
		
}	

input_sb_pvol.onControlDeactivated = function(event){				
	if (input_sb_pvol.getControlText() == "")
	{
		input_sb_pvol.setControlText("between 20 and 220");						
	}

}

input_sb_bphvol.onControlActivated = function(event){			
	if (input_sb_bphvol.getControlText() == "up to 130")
	{
		input_sb_bphvol.setControlText("");											
	}
		
}	

input_sb_bphvol.onControlDeactivated = function(event){				
	if (input_sb_bphvol.getControlText() == "")
	{
		input_sb_bphvol.setControlText("up to 130");						
	}

}


//--------------------------------------------------------------

// INSIG events

button_insig_calculate.onClick = function(){
	var error = 0;
	var error_psa = 0;
	var error_ct = 0;
	var error_ppc = 0;
	
	var error_cs = 0;
	var error_pribg = 0;
	var error_secbg = 0;
	
	
	
	if ( input_insig_psa.getControlText() == "up to 50"|| input_insig_psa.getControlText() < 0 || input_insig_psa.getControlText() > 50 || !isNumeric(input_insig_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}
	if ( input_insig_ct.getControlText() == "up to 70" || input_insig_ct.getControlText() < 0 || input_insig_ct.getControlText() > 70 || !isNumeric(input_insig_ct.getControlText()) ){
		error_ct = 1;
		error = 1;
	}
	if ( input_insig_ppc.getControlText() == "between 12.5 and 100" || input_insig_ppc.getControlText() < 12.5 || input_insig_ppc.getControlText() > 100 || !isNumeric(input_insig_ppc.getControlText()) ){
		error_ppc = 1;
		error = 1;
	}	
	if (combo_insig_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_insig_pribg.getControlText() == "Select"){
		error_pribg = 1;
		error = 1;
	}	
	if (combo_insig_secbg.getControlText() == "Select"){
		error_secbg = 1;
		error = 1;
	}	
	
	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage field properly");
		else if (error_pribg)
			alert("please fill in the Pri. Bx. Gl field properly");
		else if (error_secbg)
			alert("please fill in the Sec. Bx. Gl  field properly");
		else if (error_ct)
			alert("please fill in the Cancer tissue (mm) field properly");
		else if (error_ppc)
			alert("please fill in % + Cores field properly");		
		
	}
	else
	{
			//window.location.href = "calc_insig.php?psa=" + input_insig_psa.getControlText() + "&cs=" + combo_insig_cs.getControlText() + "&pribg=" + combo_insig_pribg.getControlText() + "&secbg=" + combo_insig_secbg.getControlText() + "&ct=" + input_insig_ct.getControlText() + "&ppc=" + input_insig_ppc.getControlText() + "&radio=" + radio_insig.getSelectedItems();
			var psa;
			var cs;
			var pribg;
			var secbg;
			var ct;
			var ppc;
			var radio;
			var c_label;
			
			var p,z, kE;
			psa = input_insig_psa.getControlText();
			ct = input_insig_ct.getControlText();
			ppc = input_insig_ppc.getControlText();
			radio = radio_insig.getSelectedItems(); 
			
			if (radio == 0)
			{
				c_label = "insignificant prostate cancer";
				radio_insig.setSelectedItems([0]);
			
				if (combo_insig_pribg.getControlText() == "2")
					pribg = 0;
				if (combo_insig_pribg.getControlText() == "3")
					pribg = -0.17759;
				if (combo_insig_pribg.getControlText() == "4")
					pribg = -6.85195; 
					
				if (combo_insig_secbg.getControlText() == "2")
					secbg = 0;
				if (combo_insig_secbg.getControlText() == "3")
					secbg = -0.67703;
				if (combo_insig_secbg.getControlText() == "4")
					secbg = -2.92992; 
				if (combo_insig_secbg.getControlText() == "5")
					secbg = -1.04925; 	
					
				if (combo_insig_cs.getControlText() == "T1")
					cs = 0;
				if (combo_insig_cs.getControlText() == "T2A")
					cs = -0.45425;
				if (combo_insig_cs.getControlText() == "T2B")
					cs = 0.17469; 
				if (combo_insig_cs.getControlText() == "T2C")
					cs = 1.32017;
				if (combo_insig_cs.getControlText() == "T3")
					cs = 2.19734; 	
			
				z =  - (0.09943 * psa) - (0.32956 * ct) - (0.05521 * ppc) + pribg + secbg + cs + 1.49285;	
			}
			
			if (radio == 1)
			{
				c_label = "meaningful prostate cancer >0.5 cc";
				radio_insig.setSelectedItems([1]);
			
				if (combo_insig_pribg.getControlText() == "2")
					pribg = 0;
				if (combo_insig_pribg.getControlText() == "3")
					pribg = 0.02765;
				if (combo_insig_pribg.getControlText() == "4")
					pribg = 6.93932; 
					
				if (combo_insig_secbg.getControlText() == "2")
					secbg = 0;
				if (combo_insig_secbg.getControlText() == "3")
					secbg = 0.51451;
				if (combo_insig_secbg.getControlText() == "4")
					secbg = 1.79698; 
				if (combo_insig_secbg.getControlText() == "5")
					secbg = 0.68623; 	
					
				if (combo_insig_cs.getControlText() == "T1")
					cs = 0;
				if (combo_insig_cs.getControlText() == "T2A")
					cs = 0.51112;
				if (combo_insig_cs.getControlText() == "T2B")
					cs = 0.05379; 
				if (combo_insig_cs.getControlText() == "T2C")
					cs = -1.18277;
				if (combo_insig_cs.getControlText() == "T3")
					cs = -1.95859; 	
			
				z =  + (0.09725 * psa) + (0.28493 * ct) + (0.05949 * ppc) + pribg + secbg + cs - 1.30842;	
			}
			
			if (radio == 2)
			{
				c_label = "meaningful prostate cancer >1.0 cc";
				radio_insig.setSelectedItems([2]);
			
				if (combo_insig_pribg.getControlText() == "2")
					pribg = 0;
				if (combo_insig_pribg.getControlText() == "3")
					pribg = -0.27829;
				if (combo_insig_pribg.getControlText() == "4")
					pribg = -0.16070;
					
				if (combo_insig_secbg.getControlText() == "2")
					secbg = 0;
				if (combo_insig_secbg.getControlText() == "3")
					secbg = -0.31675;
				if (combo_insig_secbg.getControlText() == "4")
					secbg = 0.11459;  
				if (combo_insig_secbg.getControlText() == "5")
					secbg = 5.40152;	
					
				if (combo_insig_cs.getControlText() == "T1")
					cs = 0;
				if (combo_insig_cs.getControlText() == "T2A")
					cs = 0.33086;
				if (combo_insig_cs.getControlText() == "T2B")
					cs = 0.27690;  
				if (combo_insig_cs.getControlText() == "T2C")
					cs = -1.22432;
				if (combo_insig_cs.getControlText() == "T3")
					cs = -1.80861; 	
			
				z =  + (0.12827 * psa) + (0.21219 * ct) + (0.05066 * ppc) + pribg + secbg + cs - 0.93113;	
			}
	
			if (radio == 3)
			{
				c_label = "meaningful prostate cancer >2.0 cc";
				radio_insig.setSelectedItems([3]);
			
				if (combo_insig_pribg.getControlText() == "2")
					pribg = 0;
				if (combo_insig_pribg.getControlText() == "3")
					pribg = 0.09782;
				if (combo_insig_pribg.getControlText() == "4")
					pribg = 0.27303; 
					
				if (combo_insig_secbg.getControlText() == "2")
					secbg = 0;
				if (combo_insig_secbg.getControlText() == "3")
					secbg =0.67758;
				if (combo_insig_secbg.getControlText() == "4")
					secbg = 0.03964; 
				if (combo_insig_secbg.getControlText() == "5")
					secbg = 6.24452; 	
					
				if (combo_insig_cs.getControlText() == "T1")
					cs = 0;
				if (combo_insig_cs.getControlText() == "T2A")
					cs = 0.18334;
				if (combo_insig_cs.getControlText() == "T2B")
					cs = 0.64859; 
				if (combo_insig_cs.getControlText() == "T2C")
					cs = -0.89448;
				if (combo_insig_cs.getControlText() == "T3")
					cs = -0.86074; 
			
				z =  + (0.16386 * psa) + (0.07631 * ct) + (0.03051 * ppc) + pribg + secbg + cs - 1.57516;	
			}
	
	
					
				
			kE = 2.718281828459045235360287471352;
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
			p = roundNumber(p,1);
			
			
			
			result_insig_1.setControlText("<b>Your probability of having ");
			result_insig_2.setControlText(c_label + "  is </b></font>");
			result_insig_2b.setControlText("<b><font color=blue size=3>" + p + "%</b></font>");
			result_insig_3.setControlText("Please discuss this probability with your physician.");
			result_insig_4.setControlText("This percentage needs to be interpreted in context");
			result_insig_5.setControlText(" of your age, general health and several other");
			result_insig_6.setControlText(" considerations.");
			
		
			
			
			container.element().innerHTML = INSIGpageResult.join("");
			tabs.setSelectedItems([2]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();

			
	}
}

question_insig_psa.onClick = function(){
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_insig_cs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_insig_pribg.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_insig_secbg.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_insig_ct.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_insig_ppc.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_insig_psa.onControlActivated = function(event){			
	if (input_insig_psa.getControlText() == "up to 50")
	{
		input_insig_psa.setControlText("");											
	}
		
}	

input_insig_psa.onControlDeactivated = function(event){				
	if (input_insig_psa.getControlText() == "")
	{
		input_insig_psa.setControlText("up to 50");						
	}

}

input_insig_ct.onControlActivated = function(event){			
	if (input_insig_ct.getControlText() == "up to 70")
	{
		input_insig_ct.setControlText("");											
	}
		
}	

input_insig_ct.onControlDeactivated = function(event){				
	if (input_insig_ct.getControlText() == "")
	{
		input_insig_ct.setControlText("up to 70");						
	}

}

input_insig_ppc.onControlActivated = function(event){			
	if (input_insig_ppc.getControlText() == "between 12.5 and 100")
	{
		input_insig_ppc.setControlText("");											
	}
		
}	

input_insig_ppc.onControlDeactivated = function(event){				
	if (input_insig_ppc.getControlText() == "")
	{
		input_insig_ppc.setControlText("between 12.5 and 100");						
	}

}
// end of INSIG events

//--------------------------------------------------------------


// TZPZ events

button_tzpz_calculate.onClick = function(){
	
	var error = 0;
	var error_psa = 0;
	var error_bgs = 0;
	var error_cmo = 0;
	var error_cb = 0;
	var error_cvc = 0;
	
	if ( input_tzpz_psa.getControlText() == "up to 80" || input_tzpz_psa.getControlText() < 0 || input_tzpz_psa.getControlText() > 80 || !isNumeric(input_tzpz_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}
	if ( input_tzpz_cvc.getControlText() == "up to 90" || input_tzpz_cvc.getControlText() < 0 || input_tzpz_cvc.getControlText() > 90 || !isNumeric(input_tzpz_cvc.getControlText()) ){
		error_cvc = 1;
		error = 1;
	}
	if (combo_tzpz_bgs.getControlText() == "Select"){
		error_bgs = 1;
		error = 1;
	}
	if (combo_tzpz_cmo.getControlText() == "Select"){
		error_cmo = 1;
		error = 1;
	}
	if (combo_tzpz_cb.getControlText() == "Select"){
		error_cb = 1;
		error = 1;
	}
	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_bgs)
			alert("please fill in Bx. Gleason sum field properly");
		else if (error_cmo)
			alert("please fill in # + Cores Mid only field properly");
		else if (error_cb)
			alert("please fill in # + Cores Base field properly");
		else if (error_cvc)
			alert("please fill in % Ca Volume / Cores field properly");
		
	}
	else
	{					
			var psa;
			var bgs;
			var cmo;
			var cb;
			var cvc;
			
			var p,z, kE;
			psa = input_tzpz_psa.getControlText();
			cvc = input_tzpz_cvc.getControlText();
			cmo = combo_tzpz_cmo.getControlText();
			cb = combo_tzpz_cb.getControlText();
			
				
			if (combo_tzpz_bgs.getControlText() == "4 or 5")
				bgs = 0;
			if (combo_tzpz_bgs.getControlText() == "6")
				bgs = -1.80140552;
			if (combo_tzpz_bgs.getControlText() == "7 (3 + 4)")
				bgs = -1.60910362; 	
			if (combo_tzpz_bgs.getControlText() == "7 (4 + 3)")
				bgs = -2.10102085;
			if (combo_tzpz_bgs.getControlText() == "8+")
				bgs = -2.80120490; 
			
			
				
			kE = 2.718281828459045235360287471352;
			z =  (0.09519106 * psa) + bgs - (1.40357614 * cmo)  - (0.98239301 * cb) - (0.04770012 * cvc) - 0.09698167;	
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
			p = roundNumber(p,1);	
		
			
			result_tzpz_1.setControlText("<b>The probability that your tumour is in the");
			result_tzpz_2.setControlText("transition zone is </b></font>");
			result_tzpz_2b.setControlText("<b><font color=blue size=3>" + p + "%</b></font>");
			result_tzpz_3.setControlText("Please discuss this probability with your physician.");
			result_tzpz_4.setControlText("This percentage needs to be interpreted in context");
			result_tzpz_5.setControlText(" of your age, general health and several other");
			result_tzpz_6.setControlText(" considerations.");
			
			
			container.element().innerHTML = TZPZpageResult.join("");
			tabs.setSelectedItems([2]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();
			
	}
}


question_tzpz_psa.onClick = function(){
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_tzpz_bgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_tzpz_cmo.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_tzpz_cb.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_tzpz_cvc.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_tzpz_psa.onControlActivated = function(event){			
	if (input_tzpz_psa.getControlText() == "up to 80")
	{
		input_tzpz_psa.setControlText("");											
	}
		
}	

input_tzpz_psa.onControlDeactivated = function(event){				
	if (input_tzpz_psa.getControlText() == "")
	{
		input_tzpz_psa.setControlText("up to 80");						
	}

}

input_tzpz_cvc.onControlActivated = function(event){			
	if (input_tzpz_cvc.getControlText() == "up to 90")
	{
		input_tzpz_cvc.setControlText("");											
	}
		
}	

input_tzpz_cvc.onControlDeactivated = function(event){				
	if (input_tzpz_cvc.getControlText() == "")
	{
		input_tzpz_cvc.setControlText("up to 90");						
	}

}



//--------------------------------------------------------------


// gleason sum upgrading events

button_gsu_calculate.onClick = function(){
	var error = 0;
	var error_psa = 0;
	var error_cs = 0;
	var error_pribg = 0;
	var error_secbg = 0;
	
	
	
	if ( input_gsu_psa.getControlText() == "up to 120"|| input_gsu_psa.getControlText() < 0 || input_gsu_psa.getControlText() > 120 || !isNumeric(input_gsu_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}		
	if (combo_gsu_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_gsu_pribg.getControlText() == "Select"){
		error_pribg = 1;
		error = 1;
	}	
	if (combo_gsu_secbg.getControlText() == "Select"){
		error_secbg = 1;
		error = 1;
	}	
	
	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage field properly");
		else if (error_pribg)
			alert("please fill in the Pri. Bx. Gl field properly");
		else if (error_secbg)
			alert("please fill in the Sec. Bx. Gl  field properly");
	
		
	}
	else
	{			
			var psa;
			var cs;
			var pribg;
			var secbg;
			
			var p,z, kE;
			psa = input_gsu_psa.getControlText();
			
			if (combo_gsu_pribg.getControlText() == "1 ~ 2")
				pribg = 0;
			if (combo_gsu_pribg.getControlText() == "3")
				pribg = -1.75909187;
			if (combo_gsu_pribg.getControlText() == "4 ~ 5")
				pribg = -3.73810052;
				
			if (combo_gsu_secbg.getControlText() == "1 ~ 2")
				secbg = 0;
			if (combo_gsu_secbg.getControlText() == "3")
				secbg = -1.23190822;
			if (combo_gsu_secbg.getControlText() == "4 ~ 5")
				secbg = -4.44965261;	
				
			if (combo_gsu_cs.getControlText() == "T1C")
				cs = 0;
			if (combo_gsu_cs.getControlText() == "T2A")
				cs = 0.49024674;
			if (combo_gsu_cs.getControlText() == "T2B")
				cs = 0.85812447;	
			if (combo_gsu_cs.getControlText() == "T2C")
				cs = 0.69658742;
			if (combo_gsu_cs.getControlText() == "T3")
				cs = 0.43080512;	
			
			
		
				
			kE = 2.718281828459045235360287471352;
			z =  + (0.02940016 * psa) + cs + pribg + secbg + 2.01316871;	
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
			p = roundNumber(p,1);	
			
			
			
			result_gsu_1.setControlText("<b>Your probability of having Gleason sum");
			result_gsu_2.setControlText("upgrading is </b></font>");
			result_gsu_2b.setControlText("<b><font color=blue size=3>" + p + "%</b></font>");
			result_gsu_3.setControlText("Please discuss this probability with your physician.");
			result_gsu_4.setControlText("This percentage needs to be interpreted in context");
			result_gsu_5.setControlText(" of your age, general health and several other");
			result_gsu_6.setControlText(" considerations.");
			
			
		
			container.element().innerHTML = GSUpageResult.join("");
			tabs.setSelectedItems([1]);
			tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();

			
	}
}

question_gsu_psa.onClick = function(){
	alert("blah");
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_gsu_cs.onClick = function(){
	alert("blah");
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_gsu_pribg.onClick = function(){
	alert("blah");
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_gsu_secbg.onClick = function(){
	alert("blah");
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_gsu_psa.onControlActivated = function(event){			
	if (input_gsu_psa.getControlText() == "up to 120")
	{
		input_gsu_psa.setControlText("");											
	}
		
}	

input_gsu_psa.onControlDeactivated = function(event){				
	if (input_gsu_psa.getControlText() == "")
	{
		input_gsu_psa.setControlText("up to 120");						
	}

}


// end of gleason sum  upgrading events

//--------------------------------------------------------------


// ECE events

button_ece_calculate.onClick = function(){
	var error = 0;
	var error_cs = 0;
	var error_bgs = 0;
	var error_ppc = 0;
	var error_pc = 0;
	var error_psa = 0;
	
	
	
	if ( input_ece_psa.getControlText() == "up to 80"|| input_ece_psa.getControlText() < 0 || input_ece_psa.getControlText() > 80 || !isNumeric(input_ece_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}	
	if ( input_ece_ppc.getControlText() == "up to 100"|| input_ece_ppc.getControlText() < 0 || input_ece_ppc.getControlText() > 100 || !isNumeric(input_ece_ppc.getControlText()) ){
		error_ppc = 1;
		error = 1;
	}	
	if ( input_ece_pc.getControlText() == "up to 100"|| input_ece_pc.getControlText() < 0 || input_ece_pc.getControlText() > 100 || !isNumeric(input_ece_pc.getControlText()) ){
		error_pc = 1;
		error = 1;
	}	
	if (combo_ece_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_ece_bgs.getControlText() == "Select"){
		error_bgs = 1;
		error = 1;
	}	
		
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PPSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage  field properly");
		else if (error_bgs)
			alert("please fill in the Bx. Gleason sum field properly");
		else if (error_ppc)
			alert("please fill in the % + Cores field properly");
		else if (error_pc)
			alert("please fill in the % Cancer field properly");			
	}
	else
	{			
			var psa;
			var cs;
			var bgs;
			var ppc;
			var pc;
			
			var p,z, kE;
			psa = input_ece_psa.getControlText();
			pc = input_ece_pc.getControlText();
			ppc = input_ece_ppc.getControlText();
			
			if (combo_ece_bgs.getControlText() == "0")
				bgs = 0;
			if (combo_ece_bgs.getControlText() == "4 or 5")
				bgs = -0.67268947;
			if (combo_ece_bgs.getControlText() == "6")
				bgs = 0.10406123;
			if (combo_ece_bgs.getControlText() == "7 (3 + 4)")
				bgs = 1.13404358; 
			if (combo_ece_bgs.getControlText() == "7 (4 + 3)")
				bgs = 1.26818981;
			if (combo_ece_bgs.getControlText() == "8 or 9")
				bgs = 0.80463625; 
				
					
			if (combo_ece_cs.getControlText() == "T1C")
				cs = 0;
			if (combo_ece_cs.getControlText() == "T2A")
				cs = 0.95120051;
			if (combo_ece_cs.getControlText() == "T2B")
				cs = 3.88165367; 	
			if (combo_ece_cs.getControlText() == "T2C")
				cs = 1.97360182;
			if (combo_ece_cs.getControlText() == "T3")
				cs = 1.51289427; 
		

				
			kE = 2.718281828459045235360287471352;
			z =  (0.05715431 * psa) + bgs + cs + (0.00138832 * ppc) + (0.02150559 * pc) - 3.33032634;
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
			p = roundNumber(p,1);
			
			result_ece_1.setControlText("<b>The probability that your cancer has spread beyond");
			result_ece_2.setControlText("the confines of the prostate is</b></font>");
			result_ece_2b.setControlText("<b><font color=blue size=3>" + p + "%</b></font>");
			result_ece_3.setControlText("Please discuss this probability with your physician.");
			result_ece_4.setControlText("This percentage needs to be interpreted in context");
			result_ece_5.setControlText(" of your age, general health and several other");
			result_ece_6.setControlText(" considerations.");
			
			container.element().innerHTML = ECEpageResult.join("");
			tabs.setSelectedItems([1]);
			tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();
			
	}
}


question_ece_psa.onClick = function(){
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_ece_cs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_ece_bgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_ece_ppc.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_ece_pc.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_ece_psa.onControlActivated = function(event){			
	if (input_ece_psa.getControlText() == "up to 80")
	{
		input_ece_psa.setControlText("");											
	}
		
}	

input_ece_psa.onControlDeactivated = function(event){				
	if (input_ece_psa.getControlText() == "")
	{
		input_ece_psa.setControlText("up to 80");						
	}

}

input_ece_ppc.onControlActivated = function(event){			
	if (input_ece_ppc.getControlText() == "up to 100")
	{
		input_ece_ppc.setControlText("");											
	}
		
}	

input_ece_ppc.onControlDeactivated = function(event){				
	if (input_ece_ppc.getControlText() == "")
	{
		input_ece_ppc.setControlText("up to 100");						
	}

}

input_ece_pc.onControlActivated = function(event){			
	if (input_ece_pc.getControlText() == "up to 100")
	{
		input_ece_pc.setControlText("");											
	}
		
}	

input_ece_pc.onControlDeactivated = function(event){				
	if (input_ece_pc.getControlText() == "")
	{
		input_ece_pc.setControlText("up to 100");						
	}

}


// end of ECE events

//--------------------------------------------------------------


// LOCAL REC events

button_loc_calculate.onClick = function(){
	
	var error = 0;
	var error_pts = 0;
	var error_psm = 0;
	var error_pgs = 0;
	var error_lnd = 0;
	var error_adj = 0;
	
	
	if (combo_loc_pts.getControlText() == "Select"){
		error_pts = 1;
		error = 1;
	}
	if (combo_loc_psm.getControlText() == "Select"){
		error_psm = 1;
		error = 1;
	}
	if (combo_loc_pgs.getControlText() == "Select"){
		error_pgs = 1;
		error = 1;
	}
	if (combo_loc_lnd.getControlText() == "Select"){
		error_lnd = 1;
		error = 1;
	}	
	if (combo_loc_adj.getControlText() == "Select"){
		error_adj = 1;
		error = 1;
	}
	
	
	
	
	if (error)
	{
		if (error_pts)
			alert("please fill in the Path T stage field properly");
		else if (error_psm)
			alert("please fill in + SM field properly");
		else if (error_pgs)
			alert("please fill in Path Gl. sum field properly");
		else if (error_lnd)
			alert("please fill in LN Dissection field properly");
		else if (error_adj)
			alert("please fill in Adjuvant XRT field properly");
		
	}
	else
	{					
			var pts;
			var psm;
			var pgs;
			var lnd;
			var adj;
			
			var p5y, p10y, p15y, p20y, z, kE;
			
			if (combo_loc_pts.getControlText() == "T2b/c")
				pts = -0.21265001695048;
			if (combo_loc_pts.getControlText() == "T2a")
				pts = 0; 
			if (combo_loc_pts.getControlText() == "T3")
				pts = 0.53389470410897;
		
			if (combo_loc_psm.getControlText() == "Yes")
				psm = 0.50531876689382;
			if (combo_loc_psm.getControlText() == "No")
				psm = 0; 
			
			if (combo_loc_pgs.getControlText() == "2 - 5")
				pgs = 0;
			if (combo_loc_pgs.getControlText() == "6")
				pgs = 1.65136777602632; 
			if (combo_loc_pgs.getControlText() == "7")
				pgs = 0.90302583544791; 
			if (combo_loc_pgs.getControlText() == "8 - 10")
				pgs = 2.10509004906015;

			if (combo_loc_lnd.getControlText() == "Yes")
				lnd = -0.51322385026542;
			if (combo_loc_lnd.getControlText() == "No")
				lnd = 0; 
			
			if (combo_loc_adj.getControlText() == "Yes")
				adj = -1.27790265948538;
			if (combo_loc_adj.getControlText() == "No")
				adj = 0; 
			



				
			kE = 2.718281828459045235360287471352;
			z =  pts + psm + pgs + lnd + adj - 0.96925819242613;
			
			p5y  = 100 * Math.pow(kE, Math.pow(kE, z - 0.4282914988575) * Math.log(0.9527533239802) ); 
			p10y = 100 * Math.pow(kE, Math.pow(kE, z - 0.4136022881803) * Math.log(0.9122689612292) );
			p15y = 100 * Math.pow(kE, Math.pow(kE, z - 0.4111214326715) * Math.log(0.8963814840358) );
			p20y = 100 * Math.pow(kE, Math.pow(kE, z - 0.4242354585820) * Math.log(0.8779834001633) ); 

			p5y = roundNumber(p5y,1);
			p10y = roundNumber(p10y,1);
			p15y = roundNumber(p15y,1);
			p20y = roundNumber(p20y,1);
			
			
			result_loc_1.setControlText("<b>Your probability of NOT having");
			result_loc_2.setControlText("local recurrence after radical prostatectomy is</b>");
			result_loc_3.setControlText("<b>at 5 years &nbsp;&nbsp;=  <font color=blue size=3>" + p5y + "%</font></b>");
			result_loc_4.setControlText("<b>at 10 years = <font color=blue size=3>" + p10y + "%</font></b>");
			result_loc_5.setControlText("<b>at 15 years = <font color=blue size=3>" + p15y + "%</font></b>");
			result_loc_6.setControlText("<b>at 20 years = <font color=blue size=3>" + p20y + "%</font></b>");


			result_loc_7.setControlText("Please discuss this probability with your physician.");
			result_loc_8.setControlText("This percentage needs to be interpreted in context");
			result_loc_9.setControlText("of your age, general health and several other");
			result_loc_10.setControlText("considerations.");
			
			
			
			container.element().innerHTML = LOCpageResult.join("");
			tabs.setSelectedItems([3]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();
		
	}
}

question_loc_pts.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_loc_psm.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_loc_pgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_loc_lnd.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_loc_adj.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}


// end of Local Recurrence


//--------------------------------------------------------------


// DISTANT REC events

button_dis_calculate.onClick = function(){
	
	var error = 0;
	var error_pts = 0;
	var error_pgs = 0;
	var error_cor = 0;
	var error_adj = 0;
	
	
	if (combo_dis_pts.getControlText() == "Select"){
		error_pts = 1;
		error = 1;
	}
	if (combo_dis_pgs.getControlText() == "Select"){
		error_pgs = 1;
		error = 1;
	}
	if (combo_dis_cor.getControlText() == "Select"){
		error_cor = 1;
		error = 1;
	}
	if (combo_dis_adj.getControlText() == "Select"){
		error_adj = 1;
		error = 1;
	}
	
	if (error)
	{
		if (error_pts)
			alert("please fill in the Path T stage field properly");
		else if (error_pgs)
			alert("please fill in Path Gl. sum field properly");
		else if (error_cor)
			alert("please fill in Cormobidity field properly");
		else if (error_adj)
			alert("please fill in Adjuvant XRT field properly");
		
	}
	else
	{		
			var pts;
			var pgs;
			var cor;
			var adj;
			
			var p5y, p10y, p15y, p20y, z, kE;
			
			if (combo_dis_pts.getControlText() == "T2b/c")
				pts = 0.13826729885457;
			if (combo_dis_pts.getControlText() == "T2a")
				pts = 0; 
			if (combo_dis_pts.getControlText() == "T3")
				pts = 0.81019265035119;
		
			if (combo_dis_pgs.getControlText() == "2 - 5")
				pgs = 0;
			if (combo_dis_pgs.getControlText() == "6")
				pgs = 1.24749375515049; 
			if (combo_dis_pgs.getControlText() == "7")
				pgs = 1.23187348542196; 
			if (combo_dis_pgs.getControlText() == "8 - 10")
				pgs = 1.94219683078794; 

			if (combo_dis_cor.getControlText() == "0")
				cor = 0;
			if (combo_dis_cor.getControlText() == "1+")
				cor = -1.0831008077362; 
			
			if (combo_dis_adj.getControlText() == "Yes")
				adj = 0.67189352135731;
			if (combo_dis_adj.getControlText() == "No")
				adj = 0; 
			

				
			kE = 2.718281828459045235360287471352;
			
			z =  pts + pgs + cor + adj - 1.35654713930177;
			
			
			p5y  = 100 * Math.pow(kE, Math.pow(kE, z - 0.4017061472304) * Math.log(0.9594600133537) );
			p10y = 100 * Math.pow(kE, Math.pow(kE, z - 0.3673716434017) * Math.log(0.9054296719078) );
			p15y = 100 * Math.pow(kE, Math.pow(kE, z - 0.3108802570177) * Math.log(0.8483076036185) );
			p20y = 100 * Math.pow(kE, Math.pow(kE, z - 0.2899121311401) * Math.log(0.8050509006682) );

			p5y = roundNumber(p5y,1);
			p10y = roundNumber(p10y,1);
			p15y = roundNumber(p15y,1);
			p20y = roundNumber(p20y,1);
			
			
			result_dis_1.setControlText("<b>Your probability of NOT having distant recurrence");
			result_dis_2.setControlText("after radical prostatectomy is</b>");
			result_dis_3.setControlText("<b>at 5 years &nbsp;&nbsp;=  <font color=blue size=3>"+p5y+"%</font></b>");
			result_dis_4.setControlText("<b>at 10 years = <font color=blue size=3>"+p10y+"%</font></b>");
			result_dis_5.setControlText("<b>at 15 years = <font color=blue size=3>"+p15y+"%</font></b>");
			result_dis_6.setControlText("<b>at 20 years = <font color=blue size=3>"+p20y+"%</font></b>");
			
			result_dis_7.setControlText("Please discuss this probability with your physician.");
			result_dis_8.setControlText("This percentage needs to be interpreted in context");
			result_dis_9.setControlText("of your age, general health and several other");
			result_dis_10.setControlText("considerations.");
			
						
			container.element().innerHTML = DISpageResult.join("");
			tabs.setSelectedItems([3]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();
		
	}
}
question_dis_pts.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_dis_pgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_dis_cor.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_dis_adj.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}


// end of distant Recurrence


//--------------------------------------------------------------


//  PCA SS events

button_pcass_calculate.onClick = function(){
	
	var error = 0;
	var error_age = 0;
	var error_pts = 0;
	var error_pgs = 0;
	var error_lnd = 0;
	var error_xrt = 0;
	
	if (combo_pcass_age.getControlText() == "Select"){
		error_age = 1;
		error = 1;
	}
	if (combo_pcass_pts.getControlText() == "Select"){
		error_pts = 1;
		error = 1;
	}	
	if (combo_pcass_pgs.getControlText() == "Select"){
		error_pgs = 1;
		error = 1;
	}
	if (combo_pcass_lnd.getControlText() == "Select"){
		error_lnd = 1;
		error = 1;
	}
	if (combo_pcass_xrt.getControlText() == "Select"){
		error_xrt = 1;
		error = 1;
	}
	
	
	
	
	if (error)
	{
		if (error_age)
			alert("please fill in Age at biopsy field properly");
		else if (error_pts)
			alert("please fill in the Path T stage field properly");		
		else if (error_pgs)
			alert("please fill in Path Gl. sum field properly");
		else if (error_lnd)
			alert("please fill in LN Dissection field properly");
		else if (error_xrt)
			alert("please fill in XRT field properly");
		
	}
	else
	{	
			var age;
			var pts;
			var pgs;
			var lnd;
			var xrt;
			
			var p5y, p10y, p15y, p20y, z, kE;
			
			if (combo_pcass_age.getControlText() == "< or equal to 64.6")
				age = 0;
			if (combo_pcass_age.getControlText() == "> 64.6")
				age = -0.86941469372128; 
		
			
			if (combo_pcass_pts.getControlText() == "T2b/c")
				pts = 0.12389399574710;
			if (combo_pcass_pts.getControlText() == "T2a")
				pts = 0; 
			if (combo_pcass_pts.getControlText() == "T3")
				pts = 1.00137727534106;
		
			if (combo_pcass_pgs.getControlText() == "2 - 5")
				pgs = 0;
			if (combo_pcass_pgs.getControlText() == "6")
				pgs = 0.85898774647245; 
			if (combo_pcass_pgs.getControlText() == "7")
				pgs = 1.09507673260222; 
			if (combo_pcass_pgs.getControlText() == "8 - 10")
				pgs = 2.28655312152840; 

			if (combo_pcass_lnd.getControlText() == "Yes")
				lnd = -0.40425878795810 ;
			if (combo_pcass_lnd.getControlText() == "No")
				lnd= 0; 
			
			if (combo_pcass_xrt.getControlText() == "Yes")
				xrt = 1.16551019283589;
			if (combo_pcass_xrt.getControlText() == "No")
				xrt = 0; 
			
				
			kE = 2.718281828459045235360287471352;
			
			
			z =  pts + age + pgs + lnd  + xrt - 0.96040093464059;
			
			
			p5y  =100 * Math.pow(kE, Math.pow(kE, z - 0.8082111411259) * Math.log(0.9898029995373) );
			p10y =100 * Math.pow(kE, Math.pow(kE, z - 0.7428804134374) * Math.log(0.9550082348093) );
			p15y =100 * Math.pow(kE, Math.pow(kE, z - 0.7387986000491) * Math.log(0.9090022006615) );
			p20y =100 * Math.pow(kE, Math.pow(kE, z - 0.7576736113857) * Math.log(0.8571339710996) );
			
			
			p5y = roundNumber(p5y,1);
			p10y = roundNumber(p10y,1);
			p15y = roundNumber(p15y,1);
			p20y = roundNumber(p20y,1);
			
			result_pcass_1.setControlText("<b>Your probability of NOT dying of prostate cancer");
			result_pcass_2.setControlText("after a radical prostatectomy is</b>");
			result_pcass_3.setControlText("<b>at 5 years &nbsp;&nbsp;=  <font color=blue size=3>"+p5y+"%</font></b>");
			result_pcass_4.setControlText("<b>at 10 years = <font color=blue size=3>"+p10y+"%</font></b>");
			result_pcass_5.setControlText("<b>at 15 years = <font color=blue size=3>"+p15y+"%</font></b>");
			result_pcass_6.setControlText("<b>at 20 years = <font color=blue size=3>"+p20y+"%</font></b>");
		
			result_pcass_7.setControlText("Please discuss this probability with your physician.");
			result_pcass_8.setControlText("This percentage needs to be interpreted in context");
			result_pcass_9.setControlText("of your age, general health and several other");
			result_pcass_10.setControlText("considerations.");
			
			
			
			container.element().innerHTML = PCASSpageResult.join("");
			tabs.setSelectedItems([3]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();
		
	}
}

question_pcass_age.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_pcass_pts.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_pcass_pgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_pcass_lnd.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_pcass_xrt.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}


// end of  PCA SS

//--------------------------------------------------------------


// AIPC events

button_aipc_calculate.onClick = function(){
	var error = 0;
	var error_psaadt = 0;
	var error_psadt = 0;
	var error_npsaadt = 0;
	var error_tinme = 0;

	
	
	
	if ( input_aipc_psaadt.getControlText() == "up to 2400"|| input_aipc_psaadt.getControlText() < 0 || input_aipc_psaadt.getControlText() > 2400 || !isNumeric(input_aipc_psaadt.getControlText()) ){
		error_psaadt = 1;
		error = 1;
	}	
	if ( input_aipc_psadt.getControlText() == "up to 30"|| input_aipc_psadt.getControlText() < 0 || input_aipc_psadt.getControlText() > 30 || !isNumeric(input_aipc_psadt.getControlText()) ){
		error_psadt = 1;
		error = 1;
	}	
	if ( input_aipc_npsaadt.getControlText() == "up to 110"|| input_aipc_npsaadt.getControlText() < 0 || input_aipc_npsaadt.getControlText() > 110 || !isNumeric(input_aipc_npsaadt.getControlText()) ){
		error_npsaadt = 1;
		error = 1;
	}	
	if ( input_aipc_time.getControlText() == "up to 90"|| input_aipc_time.getControlText() < 0 || input_aipc_time.getControlText() > 90 || !isNumeric(input_aipc_time.getControlText()) ){
		error_time = 1;
		error = 1;
	}	

		
	
	if (error)
	{
		if (error_psaadt)
			alert("please fill in the PSA at ADT init. field properly");
		else if (error_psadt)
			alert("please fill in the PSA doubling time field properly");
		else if (error_npsaadt)
			alert("please fill in the Nadir PSA on ADT field properly");
		else if (error_time)
			alert("please fill in the Time ADT >= AIPC(M) field properly");
		
	}
	else
	{			
			var psaadt = input_aipc_psaadt.getControlText();
			var psadt = input_aipc_psadt.getControlText();
			var npsaadt = input_aipc_npsaadt.getControlText();
			var time = input_aipc_time.getControlText();
			
			

			var pk1 = 8.247; 
			var pk2 = 54.35; 
			var pk3 = 356.62; 
			var pkd = Math.pow((pk3 - pk1),(2/3)); 
			
			
			var psaadt_prime =   Math.pow(Math.max(((psaadt - pk1) / pkd), 0), 3) + (pk2 - pk1) / (pk3 - pk2) * Math.pow(Math.max(((psaadt - pk3) / pkd),0), 3) + (pk1 - pk3) / (pk3 - pk2) * Math.pow(Math.max(((psaadt - pk2) / pkd), 0), 3);
							 
			var tk1 = 7.496667; 
			var tk2 = 18.1; 
			var tk3 = 40.55;
			var tkd = Math.pow((tk3 - tk1),(2/3));                   
			
			var time_prime = Math.pow(Math.max(((time - tk1) / tkd), 0), 3) + (tk2 - tk1) / (tk3 - tk2) * Math.pow(Math.max(((time - tk3) / tkd), 0), 3) + (tk1 - tk3) / (tk3 - tk2) * Math.pow(Math.max(((time - tk2) / tkd), 0), 3);
							 
							   
							   
			var kE = 2.718281828459045235360287471352;				   
			var z = 2.93383019486184 + (psaadt * 0.00403885813034) + (psaadt_prime * (-0.01107482460102)) + (psadt * (-0.22864165982598)) + (npsaadt * 0.01753418423331) + (time * (-0.09668625059793)) + (time_prime * 0.11431915737335);



			var p1y =100 * Math.pow(kE, Math.pow(kE, z - 0.8161442346207) * Math.log(0.8493316129764) );
			var p2y =100 * Math.pow(kE, Math.pow(kE, z - 0.5085346438741) * Math.log(0.7237977272461) );
			var p3y =100 * Math.pow(kE, Math.pow(kE, z - 0.3424189146943) * Math.log(0.6479944353772) );
			var p4y =100 * Math.pow(kE, Math.pow(kE, z - 0.1808011324429) * Math.log(0.5511230226183) );
			var p5y =100 * Math.pow(kE, Math.pow(kE, z + 0.0182228100478) * Math.log(0.4380005861031) );
			
			p1y  = roundNumber(p1y,1);
			p2y  = roundNumber(p2y,1);
			p3y  = roundNumber(p3y,1);
			p4y  = roundNumber(p4y,1);
			p5y  = roundNumber(p5y,1);
			
			
			
			result_aipc_1.setControlText("<b>The probabilities of NOT dying  at the following");
			result_aipc_2.setControlText("points in time after the diagnosis of");
			result_aipc_3.setControlText ("hormone refractory prostate cancer are:</b>");
			result_aipc_4.setControlText("<b>12 months after diagnosis = <font color=blue size=3>"+p1y+"%</font></b>");
			result_aipc_5.setControlText("<b>24 months after diagnosis = <font color=blue size=3>"+p2y+"%</font></b>");
			result_aipc_6.setControlText("<b>36 months after diagnosis = <font color=blue size=3>"+p3y+"%</font></b>");
			result_aipc_7.setControlText("<b>48 months after diagnosis= <font color=blue size=3>"+p4y+"%</font></b>");
			result_aipc_8.setControlText("<b>60 months after diagnosis= <font color=blue size=3>"+p5y+"%</font></b>");
			
			result_aipc_9.setControlText("Please discuss these probabilities with your physician.");
			result_aipc_10.setControlText("Thess percentages need to be interpreted in context");
			result_aipc_11.setControlText("of your age, general health and several other");
			result_aipc_12.setControlText("considerations.");
			
						
			container.element().innerHTML = AIPCpageResult.join("");
			
			tabs.setSelectedItems([5]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "<b>Hormone failure</b>"]);
			tabs.refresh();
			
	}
}

			
			
			
			
			
	

question_aipc_psaadt.onClick = function(){
	window.open('/local/files/pcat/glossary/PSA.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_aipc_psadt.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_aipc_npsaadt.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

question_aipc_time.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}

input_aipc_psaadt.onControlActivated = function(event){			
	if (input_aipc_psaadt.getControlText() == "up to 2400")
	{
		input_aipc_psaadt.setControlText("");											
	}
		
}	

input_aipc_psaadt.onControlDeactivated = function(event){				
	if (input_aipc_psaadt.getControlText() == "")
	{
		input_aipc_psaadt.setControlText("up to 2400");						
	}

}
input_aipc_psadt.onControlActivated = function(event){			
	if (input_aipc_psadt.getControlText() == "up to 30")
	{
		input_aipc_psadt.setControlText("");											
	}
		
}	

input_aipc_psadt.onControlDeactivated = function(event){				
	if (input_aipc_psadt.getControlText() == "")
	{
		input_aipc_psadt.setControlText("up to 30");						
	}

}
input_aipc_npsaadt.onControlActivated = function(event){			
	if (input_aipc_npsaadt.getControlText() == "up to 110")
	{
		input_aipc_npsaadt.setControlText("");											
	}
		
}	

input_aipc_npsaadt.onControlDeactivated = function(event){				
	if (input_aipc_npsaadt.getControlText() == "")
	{
		input_aipc_npsaadt.setControlText("up to 110");						
	}

}
input_aipc_time.onControlActivated = function(event){			
	if (input_aipc_time.getControlText() == "up to 90")
	{
		input_aipc_time.setControlText("");											
	}
		
}	

input_aipc_time.onControlDeactivated = function(event){				
	if (input_aipc_time.getControlText() == "")
	{
		input_aipc_time.setControlText("up to 90");						
	}

}



// end of AIPC events

//--------------------------------------------------------------

//--------------------------------------------------------------


// PSA REC (reduce) events

button_psa_calculate.onClick = function(){
	
	var error = 0;
	var error_pts = 0;
	var error_psm = 0;
	var error_pgs = 0;
	var error_pt = 0;
	var error_adj = 0;
	
	
	if (combo_psa_pts.getControlText() == "Select"){
		error_pts = 1;
		error = 1;
	}
	if (combo_psa_psm.getControlText() == "Select"){
		error_psm = 1;
		error = 1;
	}
	if (combo_psa_pgs.getControlText() == "Select"){
		error_pgs = 1;
		error = 1;
	}
	if (combo_psa_pt.getControlText() == "Select"){
		error_pt = 1;
		error = 1;
	}
	if (combo_psa_adj.getControlText() == "Select"){
		error_adj = 1;
		error = 1;
	}
	
	
	
	
	if (error)
	{
		if (error_pts)
			alert("please fill in the Path T stage field properly");
		else if (error_psm)
			alert("please fill in + SM field properly");
		else if (error_pgs)
			alert("please fill in Path Gl. sum field properly");
		else if (error_pt)
			alert("please fill in Procedure type field properly");
		else if (error_adj)
			alert("please fill in Adjuvant XRT field properly");
		
	}
	else
	{					
			var pts;
			var psm;
			var pgs;
			var pt;
			var adj;
			
			var p5y, p10y, p15y, p20y, z, kE;
			
			if (combo_psa_pts.getControlText() == "T2b/c")
				pts = 0.35542880901744;
			if (combo_psa_pts.getControlText() == "T2a")
				pts = 0; 
			if (combo_psa_pts.getControlText() == "T3")
				pts = 0.76461973648260;
		
			if (combo_psa_psm.getControlText() == "Yes")
				psm = 0.54493944278091;
			if (combo_psa_psm.getControlText() == "No")
				psm = 0; 
			
			if (combo_psa_pgs.getControlText() == "2 - 5")
				pgs = 0;
			if (combo_psa_pgs.getControlText() == "6")
				pgs = 0.84126608570529; 
			if (combo_psa_pgs.getControlText() == "7")
				pgs = 1.39552249085300; 
			if (combo_psa_pgs.getControlText() == "8 - 10")
				pgs = 1.61353574498900; 

			if (combo_psa_pt.getControlText() == "Perineal")
				pt = 0;
			if (combo_psa_pt.getControlText() == "Retropubic")
				pt = 0.41075439367260; 
			
			if (combo_psa_adj.getControlText() == "Yes")
				adj = -0.43589790494138;
			if (combo_psa_adj.getControlText() == "No")
				adj = 0; 
			
				
			kE = 2.718281828459045235360287471352;
			z =  pts + psm + pgs + pt + adj - 1.62255792871118;

			p5y  = 100 * Math.pow(kE, Math.pow(kE, z + 2.5172604075150) * Math.log(0.9898029995373) ); 
			p10y = 100 * Math.pow(kE, Math.pow(kE, z + 1.8479013968464) * Math.log(0.9550082348093) );
			p15y = 100 * Math.pow(kE, Math.pow(kE, z + 1.5670320100118) * Math.log(0.9090022006615) );
			p20y = 100 * Math.pow(kE, Math.pow(kE, z + 1.1908998920795) * Math.log(0.8571339710996) );
			
			p5y = roundNumber(p5y,1);
			p10y = roundNumber(p10y,1);
			p15y = roundNumber(p15y,1);
			p20y = roundNumber(p20y,1);
			
			
			result_psa_1.setControlText("<b>Your probability of NOT having a PSA recurrence");
			result_psa_2.setControlText("after radical prostatectomy is</b>");
			result_psa_3.setControlText("<b>at 5 years&nbsp;&nbsp;=  <font color=blue size=3>"+p5y+"%</font></b>");
			result_psa_4.setControlText("<b>at 10 years = <font color=blue size=3>"+p10y+"%</font></b>");
			result_psa_5.setControlText("<b>at 15 years = <font color=blue size=3>"+p15y+"%</font></b>");
			result_psa_6.setControlText("<b>at 20 years = <font color=blue size=3>"+p20y+"%</font></b>");
				
			result_psa_7.setControlText("Please discuss this probability with your physician.");
			result_psa_8.setControlText("This percentage needs to be interpreted in context");
			result_psa_9.setControlText("of your age, general health and several other");
			result_psa_10.setControlText("considerations.");
			
			
			container.element().innerHTML = PSApageResult.join("");
			tabs.setSelectedItems([3]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "<b>After Surgery</b>", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();

		
	}
}


question_psa_pts.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_psa_psm.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_psa_pgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_psa_pt.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_psa_adj.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}


// end of PSA Recurrence (reduced)


//--------------------------------------------------------------



// META events

button_meta_calculate.onClick = function(){
	
	var error = 0;
	var error_age = 0;
	var error_pgs = 0;
	var error_time = 0;
	var error_adj = 0;
	
	if (combo_meta_age.getControlText() == "Select"){
		error_age = 1;
		error = 1;
	}
	if (combo_meta_pgs.getControlText() == "Select"){
		error_pgs = 1;
		error = 1;
	}
	if (combo_meta_time.getControlText() == "Select"){
		error_time = 1;
		error = 1;
	}
	if (combo_meta_adj.getControlText() == "Select"){
		error_adj = 1;
		error = 1;
	}
	

	if (error)
	{
		if (error_age)
			alert("please fill in Age at BCR field properly");
		else if (error_pgs)
			alert("please fill in Path Gl. sum field properly");	
		else if (error_xrt)
			alert("please fill in Adjuvant XRT field properly");
		else if (error_time)
			alert("please fill in Time Surg to BCR field properly");
		
	}
	else
	{		
			var age;			
			var pgs;
			var time;
			var adj;
			
			var p5y, p10y, p15y, p20y, z, kE;
			
			if (combo_meta_age.getControlText() == "< or equal to 62.4")
				age = 0;
			if (combo_meta_age.getControlText() == "between 62.4 and 67.9")
				age = 0.88894866052600;
			if (combo_meta_age.getControlText() == "> 67.9")
				age = -0.91904948914545;
			
			if (combo_meta_pgs.getControlText() == "2 - 6")
				pgs = 0;
				if (combo_meta_pgs.getControlText() == "7")
				pgs = 0.70670904635702; 
			if (combo_meta_pgs.getControlText() == "8 - 10")
				pgs = 1.30055013328041; 

			if (combo_meta_time.getControlText() == "< or equal to 98 months")
				time = 0;
			if (combo_meta_time.getControlText() == "> 98 months")
				time = -0.91924443513307;
			
			if (combo_meta_adj.getControlText() == "Yes")
				adj = 1.54753727307060;
			if (combo_meta_adj.getControlText() == "No")
				adj = 0; 
			
				
			kE = 2.718281828459045235360287471352;
					
			z =  age + pgs + time  + adj - 0.58253515405702;
			
			p2y  = 100 * Math.pow(kE, Math.pow(kE, z - 0.5829811193465) * Math.log(0.9128209977258) );
			p5y  = 100 * Math.pow(kE, Math.pow(kE, z - 0.4707913032542) * Math.log(0.8196650749803) );
			p10y = 100 * Math.pow(kE, Math.pow(kE, z - 0.3047375670078) * Math.log(0.7524784392226) );

			
			p2y = roundNumber(p2y,1);
			p5y = roundNumber(p5y,1);
			p10y = roundNumber(p10y,1);
			
			
			result_meta_1.setControlText("<b>Your probability of NOT having distant metastases");
			result_meta_2.setControlText("after radical prostatectomy and PSA recurrence is</b>");
			result_meta_4.setControlText("<b>at 2 years after PSA recurrence= <font color=blue size=3>"+p2y+"%</font></b>");
			result_meta_5.setControlText("<b>at 5 years after PSA recurrence= <font color=blue size=3>"+p5y+"%</font></b>");
			result_meta_6.setControlText("<b>at 10 years after PSA recurrence= <font color=blue size=3>"+p10y+"%</font></b>");

			result_meta_7.setControlText("Please discuss this probability with your");
			result_meta_8.setControlText("physician. This percentage needs to be");
			result_meta_9.setControlText("interpreted in contextof your age, general");
			result_meta_10.setControlText("health and several other considerations.");

			
			container.element().innerHTML = METApageResult.join("");
			tabs.setSelectedItems([4]);
			tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "<b>After PSA Relapse</b>", "Hormone failure"]);
			tabs.refresh();
		
	}
}


question_meta_age.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_meta_pgs.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_meta_time.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}
question_meta_adj.onClick = function(){
	window.open('/local/files/pcat/glossary/.htm','name','height=750, width=550,toolbar=no,directories=no,status=no, menubar=no,scrollbars=yes,left=525,top=70,resizable=yes'); return false;
}


// end of  META

//--------------------------------------------------------------




//--------------------------------------------------------------

// EXT B events

button_extb_calculate.onClick = function(){
	var error = 0;
	var error_age = 0;
	var error_dre = 0;
	var error_psa = 0;
	var error_fpsa = 0;
	var error_smpld = 0;
	
	
	if ( input_extb_age.getControlText() == "between 35 and 95" || input_extb_age.getControlText() < 35 || input_extb_age.getControlText() > 95 || !isNumeric(input_extb_age.getControlText()) ){
		error_age = 1;
		error = 1;
	}
	if ( input_extb_psa.getControlText() == "up to 50"|| input_extb_psa.getControlText() < 0 || input_extb_psa.getControlText() > 50 || !isNumeric(input_extb_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}
	if ( input_extb_fpsa.getControlText() == "up to 90" || input_extb_fpsa.getControlText() < 0 || input_extb_fpsa.getControlText() > 90 || !isNumeric(input_extb_fpsa.getControlText()) ){
		error_fpsa = 1;
		error = 1;
	}
	if ( input_extb_smpld.getControlText() == "up to 32" || input_extb_smpld.getControlText() < 0 || input_extb_smpld.getControlText() > 32 || !isNumeric(input_extb_smpld.getControlText()) ){
		error_smpld = 1;
		error = 1;
	}
	
	if (combo_extb_dre.getControlText() == "Select"){
		error_dre = 1;
		error = 1;
	}	
	
	
	if (error)
	{
		if (error_age)
			alert("please fill in the age field properly");
		else if (error_dre)
			alert("please fill in the DRE field properly");
		else if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_fpsa)
			alert("please fill in the Free PSA field properly");
		else if (error_smpld)
			alert("please fill in Sample Density field properly");	
	}
	else
	{
			var age;
			var dre;
			var psa;
			var freepsa;
			var smpld;
			var p,z, kE;
			age = input_extb_age.getControlText();
			psa = input_extb_psa.getControlText();
			freepsa = input_extb_fpsa.getControlText();
			smpld = input_extb_smpld.getControlText();
			if (combo_extb_dre.getControlText() == "Suspicious")
				dre = 1;
			if (combo_extb_dre.getControlText() == "Normal")
				dre = 0;
				
			kE = 2.718281828459045235360287471352;
			z =  (0.04860701 * age) + (1.05402953 * dre) + (0.07223122 * psa) - (0.06300559 * freepsa) - (0.17744213 * smpld) - 1.69408031;
			p = 100 * (1 / (1 + Math.pow(kE,-z)));
								
			p = roundNumber(p,1);	
				
			result_extb_1.setControlText("<b>Your probability of having prostate cancer ");
			result_extb_2.setControlText("at initial extended biopsy is </b></font>");
			result_extb_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
			result_extb_3.setControlText("Please discuss this probability with your physician.");
			result_extb_4.setControlText("This percentage needs to be interpreted in context");
			result_extb_5.setControlText("of your age, general health and several other");
			result_extb_6.setControlText("considerations.");
					
			
			container.element().innerHTML = EXTBpageResult.join("");
			tabs.setSelectedItems([0]);
			tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
			tabs.refresh();	
	
		
	}
}


input_extb_age.onControlActivated = function(event){			
	if (input_extb_age.getControlText() == "between 35 and 95")
	{
		input_extb_age.setControlText("");											
	}
		
}	

input_extb_age.onControlDeactivated = function(event){				
	if (input_extb_age.getControlText() == "")
	{
		input_extb_age.setControlText("between 35 and 95");						
	}

}

input_extb_psa.onControlActivated = function(event){			
	if (input_extb_psa.getControlText() == "up to 50")
	{
		input_extb_psa.setControlText("");											
	}
		
}	

input_extb_psa.onControlDeactivated = function(event){				
	if (input_extb_psa.getControlText() == "")
	{
		input_extb_psa.setControlText("up to 50");						
	}

}

input_extb_fpsa.onControlActivated = function(event){			
	if (input_extb_fpsa.getControlText() == "up to 90")
	{
		input_extb_fpsa.setControlText("");											
	}
		
}	

input_extb_fpsa.onControlDeactivated = function(event){				
	if (input_extb_fpsa.getControlText() == "")
	{
		input_extb_fpsa.setControlText("up to 90");						
	}

}


input_extb_smpld.onControlActivated = function(event){			
	if (input_extb_smpld.getControlText() == "up to 32")
	{
		input_extb_smpld.setControlText("");											
	}
		
}	

input_extb_smpld.onControlDeactivated = function(event){				
	if (input_extb_smpld.getControlText() == "")
	{
		input_extb_smpld.setControlText("up to 32");						
	}

}

// end of EXT B events

//--------------------------------------------------------------

//--------------------------------------------------------------

// MORT 120 events

button_mort120_calculate.onClick = function(){
	var error = 0;
	var error_age = 0;
	var error_cormo = 0;
	var error_freq = 0;

	
	if ( input_mort120_age.getControlText() == "between 35 and 105" || input_mort120_age.getControlText() < 35 || input_mort120_age.getControlText() > 105 || !isNumeric(input_mort120_age.getControlText()) ){
		error_age = 1;
		error = 1;
	}
	
	if (combo_mort120_cormo.getControlText() == "Select"){
		error_cormo = 1;
		error = 1;
	}	
	if (combo_mort120_freq.getControlText() == "Select"){
		error_freq = 1;
		error = 1;
	}	
	
	
	if (error)
	{
		if (error_age)
			alert("please fill in the age field properly");
		else if (error_cormo)
			alert("please fill in the Cormobidity field properly");
		else if (error_freq)
			alert("please fill in the Bx. Frequency field properly");
	}
	else
	{
		var age;
		var cormo;
		var freq;
		var p,z, kE;
		age = input_mort120_age.getControlText();
		if (combo_mort120_cormo.getControlText() == "0")
			cormo = 0;
		if (combo_mort120_cormo.getControlText() == "1 - 2")
			cormo = 0.36090247;				
		if (combo_mort120_cormo.getControlText() == "3 - 4")
			cormo = 0.78638491;
		if (combo_mort120_cormo.getControlText() == "5 - 6")
			cormo = 0.97606376;
		if (combo_mort120_cormo.getControlText() == "7+")
			cormo = 1.50752169;
			
		if (combo_mort120_freq.getControlText() == "1")
			freq = 0;
		if (combo_mort120_freq.getControlText() == "2")
			freq = -0.68893618;
		if (combo_mort120_freq.getControlText() == "3+")
			freq = -0.71251382;
			
		kE = 2.718281828459045235360287471352;
		var k1 = 57;
		var k2 = 66;
		var k3 = 72;
		var k4 = 82;
		var kd = Math.pow((k4 - k1),(2/3));
		
		
		var age_prime  = Math.pow(Math.max((age - k1)/kd, 0),3) + (   (k3 - k1) * Math.pow(Math.max((age - k4)/kd, 0),3) - (k4 - k1) * (Math.pow(Math.max((age - k3)/kd, 0),3))   )/(k4 - k3);
						  
						  
		var age_dprime = Math.pow(Math.max((age - k2)/kd, 0),3) + (   (k3 - k2) * Math.pow(Math.max((age - k4)/kd, 0),3) - (k4 - k2) * (Math.pow(Math.max((age - k3)/kd, 0),3))   )/(k4 - k3);
		 
		
		z = - 9.54588705 + (age * 0.05574103) + (age_prime * 0.18662372) - (age_dprime * 0.60133524) + cormo + freq;
		
				
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
			
				
		p = roundNumber(p,1);	
			
		result_mort120_1.setControlText("<b>Your probability of dying (of any cause)");
		result_mort120_2.setControlText("within 120 days of a biopsy is </b></font>");
		result_mort120_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_mort120_3.setControlText("Please discuss this probability with your physician.");
		result_mort120_4.setControlText("This percentage needs to be interpreted in context");
		result_mort120_5.setControlText("of your age, general health and several other");
		result_mort120_6.setControlText("considerations.");
			
		
		
		container.element().innerHTML = MORT120pageResult.join("");
		tabs.setSelectedItems([0]);
		tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}


input_mort120_age.onControlActivated = function(event){			
	if (input_mort120_age.getControlText() == "between 35 and 105")
	{
		input_mort120_age.setControlText("");											
	}
		
}	

input_mort120_age.onControlDeactivated = function(event){				
	if (input_mort120_age.getControlText() == "")
	{
		input_mort120_age.setControlText("between 35 and 105");						
	}

}



// end of MORT 120 events



//--------------------------------------------------------------

// LRM SVI events

button_lsvi_calculate.onClick = function(){
	var error = 0;
	var error_psa = 0;
	var error_cs = 0;
	var error_gsm = 0;
	var error_ppc = 0;
	
	
	
	if ( input_lsvi_psa.getControlText() == "up to 45" || input_lsvi_psa.getControlText() < 0 || input_lsvi_psa.getControlText() > 45 || !isNumeric(input_lsvi_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}
	
	if (combo_lsvi_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_lsvi_gsm.getControlText() == "Select"){
		error_gsm = 1;
		error = 1;
	}	
	if (combo_lsvi_ppc.getControlText() == "Select"){
		error_ppc = 1;
		error = 1;
	}	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage field properly");
		else if (error_gsm)
			alert("please fill in the Gleason Sum field properly");
		else if (error_ppc)
			alert("please fill in the % + Cores field properly");
		
	}
	else
	{
		var psa;
		var cs;
		var gsm;
		var ppc;
		var p,z, kE;
		psa = input_lsvi_psa.getControlText();
		
		if (combo_lsvi_cs.getControlText() == "T1c")
			cs = 0;
		if (combo_lsvi_cs.getControlText() == "T2")
			cs = 0.83668658;				
		if (combo_lsvi_cs.getControlText() == "T3")
			cs = 0.92830462;
			
		if (combo_lsvi_gsm.getControlText() == "2 - 5")
			gsm = 0;
		if (combo_lsvi_gsm.getControlText() == "6")
			gsm = 0.53250137;
		if (combo_lsvi_gsm.getControlText() == "7")
			gsm = 1.75672090;
		if (combo_lsvi_gsm.getControlText() == "8 - 10")
			gsm = 2.23626344;
			
			
		if (combo_lsvi_ppc.getControlText() == "< or equal to 59")
			ppc = 0;
		if (combo_lsvi_ppc.getControlText() == "> 59")
			ppc = 0.93588923;
			
		kE = 2.718281828459045235360287471352;
		
		z =  (0.04917794 * psa) + cs + gsm + ppc - 4.50246266 ;
		
		
		
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
			
		
		
		
		p = roundNumber(p,1);	
			
		result_lsvi_1.setControlText("<b>The probability that your cancer has");
		result_lsvi_2.setControlText("spread into the seminal vesicles is </b></font>");
		result_lsvi_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_lsvi_3.setControlText("Please discuss this probability with your physician.");
		result_lsvi_4.setControlText("This percentage needs to be interpreted in context");
		result_lsvi_5.setControlText("of your age, general health and several other");
		result_lsvi_6.setControlText("considerations.");
			
		
		
		container.element().innerHTML = LSVIpageResult.join("");
		tabs.setSelectedItems([1]);
		tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
	
		
	}
}


input_lsvi_psa.onControlActivated = function(event){			
	if (input_lsvi_psa.getControlText() == "up to 45")
	{
		input_lsvi_psa.setControlText("");											
	}
		
}	

input_lsvi_psa.onControlDeactivated = function(event){				
	if (input_lsvi_psa.getControlText() == "")
	{
		input_lsvi_psa.setControlText("up to 45");						
	}

}


// end of LRM SVI events


//--------------------------------------------------------------

// LRM RMV events

button_lrmv_calculate.onClick = function(){
	var error = 0;
	var error_psa = 0;
	var error_cs = 0;
	var error_gsm = 0;
	var error_nodes = 0;
	
	
	
	if ( input_lrmv_psa.getControlText() == "up to 50" || input_lrmv_psa.getControlText() < 0 || input_lrmv_psa.getControlText() > 50 || !isNumeric(input_lrmv_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}
	if ( input_lrmv_nodes.getControlText() == "up to 40" || input_lrmv_nodes.getControlText() < 0 || input_lrmv_nodes.getControlText() > 40 || !isNumeric(input_lrmv_nodes.getControlText()) ){
		error_nodes = 1;
		error = 1;
	}
	
	if (combo_lrmv_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_lrmv_gsm.getControlText() == "Select"){
		error_gsm = 1;
		error = 1;
	}	
	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage field properly");
		else if (error_gsm)
			alert("please fill in the Gleason Sum field properly");
		else if (error_nodes)
			alert("please fill in the Total Nodes field properly");
		
	}
	else
	{
		var psa;
		var cs;
		var gsm;
		var nodes;
		var p,z, kE;
		psa = input_lrmv_psa.getControlText();
		nodes = input_lrmv_nodes.getControlText();
		
		if (combo_lrmv_cs.getControlText() == "T1c")
			cs = 0;
		if (combo_lrmv_cs.getControlText() == "T2")
			cs = 0.27208988;		
		if (combo_lrmv_cs.getControlText() == "T3")
			cs = 2.00503629; 
			
		if (combo_lrmv_gsm.getControlText() == "2 - 5")
			gsm = 0;
		if (combo_lrmv_gsm.getControlText() == "6")
			gsm = 0.29248698; 
		if (combo_lrmv_gsm.getControlText() == "7")
			gsm = 1.80978177; 
		if (combo_lrmv_gsm.getControlText() == "8 - 10")
			gsm = 2.41874491; 
			
			
				
		kE = 2.718281828459045235360287471352;
		
		z =  (0.02014919 * psa) + cs + gsm + (0.05390611 * nodes) - 4.73990958;
		
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
			
		
		
		
		p = roundNumber(p,1);	
			
		result_lrmv_1.setControlText("<b>Your probability of having LNI using the total ");
		result_lrmv_2.setControlText("number of nodes removed and examined is</b></font>");
		result_lrmv_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_lrmv_3.setControlText("Please discuss this probability with your physician.");
		result_lrmv_4.setControlText("This percentage needs to be interpreted in context");
		result_lrmv_5.setControlText("of your age, general health and several other");
		result_lrmv_6.setControlText("considerations.");
			
		
		
		container.element().innerHTML = LRMVpageResult.join("");
		tabs.setSelectedItems([1]);
		tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}


input_lrmv_psa.onControlActivated = function(event){			
	if (input_lrmv_psa.getControlText() == "up to 50")
	{
		input_lrmv_psa.setControlText("");											
	}
		
}	

input_lrmv_psa.onControlDeactivated = function(event){				
	if (input_lrmv_psa.getControlText() == "")
	{
		input_lrmv_psa.setControlText("up to 50");						
	}

}

input_lrmv_nodes.onControlActivated = function(event){			
	if (input_lrmv_nodes.getControlText() == "up to 40")
	{
		input_lrmv_nodes.setControlText("");											
	}
		
}	

input_lrmv_nodes.onControlDeactivated = function(event){				
	if (input_lrmv_nodes.getControlText() == "")
	{
		input_lrmv_nodes.setControlText("up to 40");						
	}

}


// end of LRM RMV events

//--------------------------------------------------------------


// LRM PLND events

button_plnd_calculate.onClick = function(){
	var error = 0;
	var error_psa = 0;
	var error_cs = 0;
	var error_gsm = 0;

	
	
	
	if ( input_plnd_psa.getControlText() == "up to 50" || input_plnd_psa.getControlText() < 0 || input_plnd_psa.getControlText() > 50 || !isNumeric(input_plnd_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}

	
	if (combo_plnd_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_plnd_gsm.getControlText() == "Select"){
		error_gsm = 1;
		error = 1;
	}	
	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage field properly");
		else if (error_gsm)
			alert("please fill in the Gleason Sum field properly");
		
	}
	else
	{
		var psa;
		var cs;
		var gsm;
		var p,z, kE;
		psa = input_plnd_psa.getControlText();
		
		
		if (combo_plnd_cs.getControlText() == "T1c")
			cs = 0;
		if (combo_plnd_cs.getControlText() == "T2")
			cs = 0.24215941; 
		if (combo_plnd_cs.getControlText() == "T3")
			cs = 1.95725270; 
			
		if (combo_plnd_gsm.getControlText() == "2 - 5")
			gsm = 0;
		if (combo_plnd_gsm.getControlText() == "6")
			gsm = 0.44515743; 
		if (combo_plnd_gsm.getControlText() == "7")
			gsm = 1.89585633; 
		if (combo_plnd_gsm.getControlText() == "8 - 10")
			gsm = 2.52844780; 
			
			
				
		kE = 2.718281828459045235360287471352;
		
		z =  (0.01638081  * psa) + cs + gsm  - 3.73692396;
		
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
			
		
		
		
		p = roundNumber(p,1);	
			
		result_plnd_1.setControlText("<b>Your probability of having LNI at extended ");
		result_plnd_2.setControlText("lymph node dissection is </b></font>");
		result_plnd_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_plnd_3.setControlText("Please discuss this probability with your physician.");
		result_plnd_4.setControlText("This percentage needs to be interpreted in context");
		result_plnd_5.setControlText("of your age, general health and several other");
		result_plnd_6.setControlText("considerations.");
			
		
		
		container.element().innerHTML = PLNDpageResult.join("");
		tabs.setSelectedItems([1]);
		tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}


input_plnd_psa.onControlActivated = function(event){			
	if (input_plnd_psa.getControlText() == "up to 50")
	{
		input_plnd_psa.setControlText("");											
	}
		
}	

input_plnd_psa.onControlDeactivated = function(event){				
	if (input_plnd_psa.getControlText() == "")
	{
		input_plnd_psa.setControlText("up to 50");						
	}

}




// end of LRM PLND events

//--------------------------------------------------------------

//--------------------------------------------------------------


// obturator events

button_obt_calculate.onClick = function(){
	var error = 0;
	var error_psa = 0;
	var error_cs = 0;
	var error_gsm = 0;

	
	
	
	if ( input_obt_psa.getControlText() == "up to 140" || input_obt_psa.getControlText() < 0 || input_obt_psa.getControlText() > 140 || !isNumeric(input_obt_psa.getControlText()) ){
		error_psa = 1;
		error = 1;
	}

	
	if (combo_obt_cs.getControlText() == "Select"){
		error_cs = 1;
		error = 1;
	}	
	if (combo_obt_gsm.getControlText() == "Select"){
		error_gsm = 1;
		error = 1;
	}	
	
	
	
	if (error)
	{
		if (error_psa)
			alert("please fill in the PSA field properly");
		else if (error_cs)
			alert("please fill in the Clinical Stage field properly");
		else if (error_gsm)
			alert("please fill in the Gleason Sum field properly");
		
	}
	else
	{
		var psa;
		var cs;
		var gsm;
		var p,z, kE;
		psa = input_obt_psa.getControlText();
		
		
		if (combo_obt_cs.getControlText() == "T1c")
			cs = 0;
		if (combo_obt_cs.getControlText() == "T2")
			cs = -0.01964474; 
		if (combo_obt_cs.getControlText() == "T3")
			cs = 0.83539179; 
			
		if (combo_obt_gsm.getControlText() == "2 - 6")
			gsm = 0;
		if (combo_obt_gsm.getControlText() == "7")
			gsm = 1.73338296; 
		if (combo_obt_gsm.getControlText() == "8 - 10")
			gsm = 3.14729676; 
			
			
				
		kE = 2.718281828459045235360287471352;
		
		z =  (0.01613545  * psa) + cs + gsm - 4.99685216;
		
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
			
		
		
		
		p = roundNumber(p,1);	
			
		result_obt_1.setControlText("<b>Your probability of having LNI beyond");
		result_obt_2.setControlText("the obturator nodes is </b></font>");
		result_obt_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_obt_3.setControlText("Please discuss this probability with your physician.");
		result_obt_4.setControlText("This percentage needs to be interpreted in context");
		result_obt_5.setControlText("of your age, general health and several other");
		result_obt_6.setControlText("considerations.");
			
		
		
		container.element().innerHTML = OBTpageResult.join("");
		tabs.setSelectedItems([1]);
		tabs.setItemText(["Before Diagnosis", "<b>Before Treatment I</b>", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}


input_obt_psa.onControlActivated = function(event){			
	if (input_obt_psa.getControlText() == "up to 140")
	{
		input_obt_psa.setControlText("");											
	}
		
}	

input_obt_psa.onControlDeactivated = function(event){				
	if (input_obt_psa.getControlText() == "")
	{
		input_obt_psa.setControlText("up to 140");						
	}

}




// end of obturator events

//--------------------------------------------------------------



// DMAR events

button_dmar_calculate.onClick = function(){
	var error = 0;
	var error_cormo = 0;
	var error_age = 0;
	var error_aasv = 0;

	
	
	
	if ( input_dmar_cormo.getControlText() == "up to 11" || input_dmar_cormo.getControlText() < 0 || input_dmar_cormo.getControlText() > 11 || !isNumeric(input_dmar_cormo.getControlText()) ){
		error_cormo = 1;
		error = 1;
	}

	
	if (combo_dmar_age.getControlText() == "Select"){
		error_age = 1;
		error = 1;
	}	
	if (combo_dmar_aasv.getControlText() == "Select"){
		error_aasv = 1;
		error = 1;
	}	
	
	
	
	if (error)
	{
		if (error_cormo)
			alert("please fill in the Cormobidity field properly");
		else if (error_age)
			alert("please fill in the Age at RP field properly");
		else if (error_aasv)
			alert("please fill in the Avg. An.. Surg. Vol. field properly");
		
	}
	else
	{
		var cormo;
		var age;
		var aasv;
		var p,z, kE;
		cormo = input_dmar_cormo.getControlText();
		
		
		if (combo_dmar_age.getControlText() == "40 - 68")
			age = 0;
		if (combo_dmar_age.getControlText() == "69+")
			age = 1.1516306; 
		
		if (combo_dmar_aasv.getControlText() == "0.2 - 27.0")
			aasv = 0;
		if (combo_dmar_aasv.getControlText() == "27.1+")
			aasv = -1.9748448;
	
				
		kE = 2.718281828459045235360287471352;
		
		z =  (0.2459623  * cormo) + age + aasv - 5.8656661;
		
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
			
		
		
		
		p = roundNumber(p,1);	
			
		result_dmar_1.setControlText("<b>The odds of dying from any cause within 30");
		result_dmar_2.setControlText("days of surgery are:</b></font>");
		result_dmar_2b.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_dmar_3.setControlText("Please discuss this probability with your physician.");
		result_dmar_4.setControlText("This percentage needs to be interpreted in context");
		result_dmar_5.setControlText("of your age, general health and several other");
		result_dmar_6.setControlText("considerations.");
			
		
		
		container.element().innerHTML = DMARpageResult.join("");
		tabs.setSelectedItems([2]);
		tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}


input_dmar_cormo.onControlActivated = function(event){			
	if (input_dmar_cormo.getControlText() == "up to 11")
	{
		input_dmar_cormo.setControlText("");											
	}
		
}	

input_dmar_cormo.onControlDeactivated = function(event){				
	if (input_dmar_cormo.getControlText() == "")
	{
		input_dmar_cormo.setControlText("up to 11");						
	}

}




// end of DMAR events

//--------------------------------------------------------------



// YSAT events

button_ysat_calculate.onClick = function(){
	var error = 0;
	var error_cormo = 0;
	var error_age = 0;


	
	
	
	if ( input_ysat_cormo.getControlText() == "up to 12" || input_ysat_cormo.getControlText() < 0 || input_ysat_cormo.getControlText() > 12 || !isNumeric(input_ysat_cormo.getControlText()) ){
		error_cormo = 1;
		error = 1;
	}
	
		if ( input_ysat_age.getControlText() == "between 55 and 95" || input_ysat_age.getControlText() < 55 || input_ysat_age.getControlText() > 95 || !isNumeric(input_ysat_age.getControlText())  || !isInt(input_ysat_age.getControlText()) ){
		error_age = 1;
		error = 1;
	}


	
	
	
	if (error)
	{
		if (error_cormo)
			alert("please fill in the Cormobidity field properly");
		else if (error_age)
			alert("please fill in the Age at Therapy field properly");
		
		
	}
	else
	{
		var cormo;
		var age;
		var p,z, kE;
		cormo = input_ysat_cormo.getControlText();
		age = input_ysat_age.getControlText();
	
				
		kE = 2.718281828459045235360287471352;
		
		z =  -4.26868908118702 + (age * 0.06107070266617) + (cormo * 0.14581304661238);
		
		var p10yRRP;
		var p10yXRT;

		p10yRRP = 100 * Math.pow( kE, Math.pow(kE,z+0.1489045385791) * Math.log(0.8198370562007) );
		p10yXRT = 100 * Math.pow( kE, Math.pow(kE,z-0.3590188104580) * Math.log(0.3158026905329) );
		   
			
		p10yRRP = roundNumber(p10yRRP,1);	
		p10yXRT = roundNumber(p10yXRT,1);	
			
		result_ysat_1.setControlText("<b>Your probability of 10-year survival:</b>");
		result_ysat_3.setControlText("<b>with surgery is= <font color=blue size=3>"+p10yRRP+"%</b></font>");
		result_ysat_4.setControlText("<b>with radiation is = <font color=blue size=3>"+p10yXRT+"%</b></font>");
		result_ysat_5.setControlText("Please discuss this probability with your physician.");
		result_ysat_6.setControlText("This percentage needs to be interpreted in context");
		result_ysat_7.setControlText("of your age, general health and several other");
		result_ysat_8.setControlText("considerations.");
			
		
		
		container.element().innerHTML = YSATpageResult.join("");
		tabs.setSelectedItems([2]);
		tabs.setItemText(["Before Diagnosis", "Before Treatment I", "<b>Before Treatment II</b>", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}


input_ysat_cormo.onControlActivated = function(event){			
	if (input_ysat_cormo.getControlText() == "up to 12")
	{
		input_ysat_cormo.setControlText("");											
	}
		
}	

input_ysat_cormo.onControlDeactivated = function(event){				
	if (input_ysat_cormo.getControlText() == "")
	{
		input_ysat_cormo.setControlText("up to 12");						
	}

}

input_ysat_age.onControlActivated = function(event){			
	if (input_ysat_age.getControlText() == "between 55 and 95")
	{
		input_ysat_age.setControlText("");											
	}
		
}	

input_ysat_age.onControlDeactivated = function(event){				
	if (input_ysat_age.getControlText() == "")
	{
		input_ysat_age.setControlText("between 55 and 95");						
	}

}



// end of YSAT events

//--------------------------------------------------------------



// RPHT events

button_rpht_calculate.onClick = function(){
	var error = 0;
	var error_pt3 = 0;
	var error_rpgl = 0;
	var error_psm = 0;
	var error_age = 0;
	var error_rec = 0;
	
	

	if ( input_rpht_age.getControlText() == "between 45 and 95" || input_rpht_age.getControlText() < 45 || input_rpht_age.getControlText() > 95 || !isNumeric(input_rpht_age.getControlText()) ){
		error_age = 1;
		error = 1;
	}

	
	if (combo_rpht_rpgl.getControlText() == "Select"){
		error_rpgl = 1;
		error = 1;
	}	
	
	if (combo_rpht_psm.getControlText() == "Select"){
		error_psm = 1;
		error = 1;
	}	
	
	if (combo_rpht_pt3.getControlText() == "Select"){
		error_pt3 = 1;
		error = 1;
	}	
	
	if (combo_rpht_rec.getControlText() == "Select"){
		error_rec = 1;
		error = 1;
	}	
	
	
	if (error)
	{
		if (error_pt3)
			alert("please fill in the pT3 field properly");
		else if (error_rpgl)
			alert("please fill in the RP. Gl. 8-10 field properly");
		else if (error_psm)
			alert("please fill in the +SM field properly");
		else if (error_age)
			alert("please fill in the Age at HT field properly");
		else if (error_rec)
			alert("please fill in Rec. Type field properly");	
	}
	else
	{
		var pt3;
		var rpgl;
		var psm;
		var age;
		var rec;
		var z, kE;
		age = input_rpht_age.getControlText();
		
		
		if (combo_rpht_pt3.getControlText() == "Yes")
			pt3 = 0.89356720028427;
		if (combo_rpht_pt3.getControlText() == "No")
			pt3 = 0; 
			
		if (combo_rpht_rpgl.getControlText() == "Yes")
			rpgl = 0.42900090658587;
		if (combo_rpht_rpgl.getControlText() == "No")
			rpgl = 0; 
			
		if (combo_rpht_psm.getControlText() == "Yes")
			psm = -0.75996995905313;
		if (combo_rpht_psm.getControlText() == "No")
			psm = 0; 
		
		if (combo_rpht_rec.getControlText() == "PSA Recurrance")
			rec = 0;
		if (combo_rpht_rec.getControlText() == "Loc Recurrance")
			rec = -0.07655341723188; 
		if (combo_rpht_rec.getControlText() == "Dis Recurrance")
			rec = 0.89029717625269; 	
		
		
				
		kE = 2.718281828459045235360287471352;
		
		z =  pt3 + rpgl + psm + rec - (0.04454821527397 * age) + 2.416862486016 ;

		var p2y = 100 * Math.pow( kE, Math.pow(kE, z-0.3003652718780) * Math.log(0.8900360258488) ); 
		var p3y = 100 * Math.pow( kE, Math.pow(kE, z-0.2801426075930) * Math.log(0.7930717534326) ); 
		var p4y = 100 * Math.pow( kE, Math.pow(kE, z-0.2531713961291) * Math.log(0.7216477172177) );
		var p5y = 100 * Math.pow( kE, Math.pow(kE, z-0.2424504470484) * Math.log(0.6829880180810) ); 

		
		
		p2y = roundNumber(p2y,1);	
		p3y = roundNumber(p3y,1);	
		p4y = roundNumber(p4y,1);	
		p5y = roundNumber(p5y,1);	
			
		result_rpht_1.setControlText("<b>Odds of NOT dying of prostate cancer at");
		result_rpht_2.setControlText("following times after starting hormone therapy:</b>");
		result_rpht_3.setControlText("<b>2 years = <font color=blue size=3>"+p2y+"%</font></b>");
		result_rpht_4.setControlText("<b>3 years = <font color=blue size=3>"+p3y+"%</font></b>");
		result_rpht_5.setControlText("<b>4 years = <font color=blue size=3>"+p4y+"%</font></b>");
		result_rpht_6.setControlText("<b>5 years = <font color=blue size=3>"+p5y+"%</font></b>");

		result_rpht_7.setControlText("Please discuss this probability with your");
		result_rpht_8.setControlText("physician. This percentage needs to be");
		result_rpht_9.setControlText("interpreted in context of your age, general");
		result_rpht_10.setControlText("health and several other considerations.");
			
		
		
		container.element().innerHTML = RPHTpageResult.join("");
		tabs.setSelectedItems([4]);
		tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "<b>After PSA Relapse</b>", "Hormone failure"]);
		tabs.refresh();	
		
	}
}



input_rpht_age.onControlActivated = function(event){			
	if (input_rpht_age.getControlText() == "between 45 and 95")
	{
		input_rpht_age.setControlText("");											
	}
		
}	

input_rpht_age.onControlDeactivated = function(event){				
	if (input_rpht_age.getControlText() == "")
	{
		input_rpht_age.setControlText("between 45 and 95");						
	}

}



// end of RPHT events

//--------------------------------------------------------------





// PREC events

button_prec_calculate.onClick = function(){
	var error = 0;
	var error_gsm = 0;
	var error_adj = 0;


	if (combo_prec_adj.getControlText() == "Select"){
		error_adj = 1;
		error = 1;
	}	
	if (combo_prec_gsm.getControlText() == "Select"){
		error_gsm = 1;
		error = 1;
	}	
	
	
	
	if (error)
	{
		if (error_gsm)
			alert("please fill in the Path Gl. Sum field properly");
		else if (error_adj)
			alert("please fill in the Adjuvant XRT field properly");
		
		
	}
	else
	{
		var gsm;
		var adj;
		var  z, kE;
		
		
		if (combo_prec_adj.getControlText() == "Yes")
			adj = 1.77188558111711;
		if (combo_prec_adj.getControlText() == "No")
			adj = 0; 
			
		if (combo_prec_gsm.getControlText() == "2 - 6")
			gsm = 0;
		if (combo_prec_gsm.getControlText() == "7")
			gsm = 0.94314408309415; 
		if (combo_prec_gsm.getControlText() == "8 - 10")
			gsm = 2.24769079377347; 
		
		
				
		kE = 2.718281828459045235360287471352;
		
		z =  -1.01082483825502 + adj + gsm;

		var p2y =  100 * Math.pow( kE, Math.pow(kE, z-3.1991681059088) * Math.log(0.9128209977258) ); 
		var p5y =  100 * Math.pow( kE, Math.pow(kE, z-1.8816561869930) * Math.log(0.8196650749803) );  
		var p10y = 100 * Math.pow( kE, Math.pow(kE, z-1.1514922458081) * Math.log(0.7524784392226) );
	
		
		p2y = roundNumber(p2y,1);	
		p5y = roundNumber(p5y,1);	
		p10y = roundNumber(p10y,1);	
			
		result_prec_1.setControlText("<b>Your probability of NOT dying of prostate cancer");
		result_prec_2.setControlText("after surgery and PSA recurrence is:</b>");
		
		result_prec_4.setControlText("<b>after 2 years = <font color=blue size=3>"+p2y+"%</font></b>");
		result_prec_5.setControlText("<b>after 5 years = <font color=blue size=3>"+p5y+"%</font></b>");
		result_prec_6.setControlText("<b>after 10 years = <font color=blue size=3>"+p10y+"%</font></b>");

		result_prec_7.setControlText("Please discuss this probability with your physician.");
		result_prec_8.setControlText("This percentage needs to be interpreted in context");
		result_prec_9.setControlText("of your age, general health and several other");
		
		result_prec_10.setControlText("considerations.");
			
		
		
		container.element().innerHTML = PRECpageResult.join("");
		tabs.setSelectedItems([4]);
		tabs.setItemText(["Before Diagnosis", "Before Treatment I", "Before Treatment II", "After Surgery", "<b>After PSA Relapse</b>", "Hormone failure"]);
		tabs.refresh();	
		
	}
}



// end of PREC events

//--------------------------------------------------------------





// end of PDT events

//--------------------------------------------------------------


function roundNumber(number,decimal_points) {
	if(!decimal_points) return Math.round(number);
	if(number == 0) {
		var decimals = "";
		for(var i=0;i<decimal_points;i++) decimals += "0";
		return "0."+decimals;
	}

	var exponent = Math.pow(10,decimal_points);
	var num = Math.round((number * exponent)).toString();
	return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)
}



function isNumeric(x) {
// I use this function like this: if (isNumeric(myVar)) { }
// regular expression that validates a value is numeric
var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; // Note: this WILL allow a number that ends in a decimal: -452.
// compare the argument to the RegEx
// the 'match' function returns 0 if the value didn't match
var result = x.match(RegExp);
return result;
}

function isInt(x) {
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
 } 
 
function sortit(a,b){
	return(a[0]-b[0])
}

function date_diff(day0,month0,year0,dayi,monthi,yeari){	
	

	var day_result;
	var month_result;
	var year_result;
	var N;
	var result;
	
	switch(monthi)
	{
	case 1:
	  N = 31;
	  break    
	case 2:
	  N = 28;
	  break
	case 3:
	  N = 31;
	  break
	case 4:
	  N = 30;
	  break
	case 5:
	  N = 31;
	  break
	case 6:
	  N = 30;
	  break
	case 7:
	  N = 31;
	  break
	case 8:
	  N = 31;
	  break
	case 9:
	  N = 30;
	  break
	case 10:
	  N = 31;
	  break
	case 11:
	  N = 30;
	  break
	case 12:
	  N = 31;
	  break
	
	}
	
	if (dayi <= day0){
		day_result = day0 - dayi;
	}
	if (dayi > day0){		
		day_result = N + day0 - dayi ;
		monthi++;
	}
	
	if (monthi <= month0){		
		month_result = month0 - monthi;
	}
	
	if (monthi > month0){
	   month_result = 12 + month0 - monthi;
	   yeari++;
	}
	
	year_result = year0 - yeari;
	
	result = day_result + (30 * month_result) + (365 * year_result);
	return result;
		
}

//--------------------------------------------------------------



// psab events

button_psab_calculate.onClick = function(){
	var error = 0;
	var error_dre = 0;
	var error_fpsa = 0;


	
	
	
	
		if ( input_psab_fpsa.getControlText() == "between 3.33 and 85" || input_psab_fpsa.getControlText() < 3.33 || input_psab_fpsa.getControlText() > 85 || !isNumeric(input_psab_fpsa.getControlText()) ){
		error_fpsa = 1;
		error = 1;
	}

	if (combo_psab_dre.getControlText() == "Select"){
		error_dre = 1;
		error = 1;
	}	
	
	
	
	if (error)
	{
		if (error_dre)
			alert("please fill in the DRE field properly");
		else if (error_fpsa)
			alert("please fill in the % Free PSA field properly");
		
		
	}
	else
	{
		var age;
		var dre;
		var fpsa;
		var p,z, kE;
		fpsa = input_psab_fpsa.getControlText();
		
		if (combo_psab_dre.getControlText() == "Suspicious")
			dre = 1;
		if (combo_psab_dre.getControlText() == "Normal")
			dre = 0;
			
		kE = 2.718281828459045235360287471352;
		
		z = -0.004483058 - (fpsa * 0.056679137) + (dre * 0.724297143);
		
		p = 100 * (1 / (1 + Math.pow(kE,-z)));
		p = roundNumber(p,1);	
			
		result_psab_1.setControlText("<b>The probability of finding prostate cancer");
		result_psab_2.setControlText("during biopsy is</b></font>");
		result_psab_3.setControlText("<b><font color=blue size=3>"+p+"%</b></font>");
		result_psab_5.setControlText("Please discuss this probability with your physician.");
		result_psab_6.setControlText("This percentage needs to be interpreted in context");
		result_psab_7.setControlText("of your age, general health and several other");
		result_psab_8.setControlText("considerations.");
			
		
		
		container.element().innerHTML = PSABpageResult.join("");
		tabs.setSelectedItems([0]);
		tabs.setItemText(["<b>Before Diagnosis</b>", "Before Treatment I", "Before Treatment II", "After Surgery", "After PSA Relapse", "Hormone failure"]);
		tabs.refresh();	
		
	}
}




input_psab_fpsa.onControlActivated = function(event){			
	if (input_psab_fpsa.getControlText() == "between 3.33 and 85")
	{
		input_psab_fpsa.setControlText("");											
	}
		
}	

input_psab_fpsa.onControlDeactivated = function(event){				
	if (input_psab_fpsa.getControlText() == "")
	{
		input_psab_fpsa.setControlText("between 3.33 and 85");						
	}

}



// end of psab events

//--------------------------------------------------------------

button_back1.onClick = function(){container.element().innerHTML = page1.join("");}
button_back2.onClick = function(){container.element().innerHTML = page1.join("");}
button_back3.onClick = function(){container.element().innerHTML = page1.join("");}
button_back4.onClick = function(){container.element().innerHTML = page1.join("");}
button_back5.onClick = function(){container.element().innerHTML = page1.join("");}
button_back6.onClick = function(){container.element().innerHTML = page1.join("");}

button_back7.onClick = function(){container.element().innerHTML = page2.join("");}
button_back8.onClick = function(){container.element().innerHTML = page2.join("");}
button_back9.onClick = function(){container.element().innerHTML = page2.join("");}

button_back10.onClick = function(){container.element().innerHTML = LNIpage.join("");}
button_back11.onClick = function(){container.element().innerHTML = LNIpage.join("");}
button_back12.onClick = function(){container.element().innerHTML = LNIpage.join("");}

button_back13.onClick = function(){container.element().innerHTML = page3.join("");}
button_back14.onClick = function(){container.element().innerHTML = page3.join("");}
button_back15.onClick = function(){container.element().innerHTML = page3.join("");}
button_back16.onClick = function(){container.element().innerHTML = page3.join("");}

button_back17.onClick = function(){container.element().innerHTML = page4.join("");}
button_back18.onClick = function(){container.element().innerHTML = page4.join("");}
button_back19.onClick = function(){container.element().innerHTML = page4.join("");}
button_back20.onClick = function(){container.element().innerHTML = page4.join("");}

button_back21.onClick = function(){container.element().innerHTML = page5.join("");}
button_back22.onClick = function(){container.element().innerHTML = page5.join("");}
button_back23.onClick = function(){container.element().innerHTML = page5.join("");}
button_back25.onClick = function(){container.element().innerHTML = page5.join("");}

button_back24.onClick = function(){container.element().innerHTML = page6.join("");}

button_back26.onClick = function(){container.element().innerHTML = page2.join("");}


