/* segments.js (Cross-browser)
* Copyright (c) 1999-2000 internet.com Corp.  To receive the right to license
* this code to use on your site the original code must be copied from
* Webreference.com. License is granted if and only if this entire copyright 
* notice is included, and you link from the page on which the code is used 
* to Webreference at http://webreference.com/dhtml/ for the latest version.
* By Peter Belesis. v1.0 980311 - column 16.
*/

isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all && !isMac) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

function showSegment(where) {
  location.href = "#" + where;
}

// assign your own parameter values to the variables below: 

if (ver4) {
  prefix = "seg"
  firstSeg = "Intro";

  footerEl = "end";   // if no footer, assign null
  footerElSpace = 150; // overlooked if above is null

  leftPos = null;  // if option 1 or 3, above, assign null
  topPos = null;  // if option 1 or 3, above, assign null

  margRight = 20; // for NO right margin, assign 0

  padding = 5;       // for NO padding, assign 0
  backCol = "#ccccff"; // for transparent, assign null

  borWid = null;         // for no border, assign null
  borCol = "#993366"; // overlooked if borWid is null
  borSty = "solid";   // overlooked if borWid is null
}

function nextStep() {
	var po = document.periop;
	
	//  Check for major criteria
	for (var i=1; i < 5; i++) {
		if (eval("po.major" + i + ".checked")) {showSegment('major'); return;}
	}
	
	//  Check for intermediate criteria
	for (var i=1; i < 5; i++) {
		if (eval("po.mid" + i + ".checked")) {showSegment('mid1'); return;}
	}
	
	//  Check for minor criteria
	for (var i=1; i < 7; i++) {
		if (eval("po.minor" + i + ".checked")) {showSegment('minor1'); return;}
	}
	
	alert ("Please select applicable clinical predictors.");
	return false;
}

function midNextStep() {
	var po = document.periop;
	
	if (!po.funcCap[0].checked && !po.funcCap[1].checked) {
		alert ("What is the patient\'s functional capacity (in METs)?");
		return false;
	}
	if (!po.risk[0].checked && !po.risk[1].checked & !po.risk[2].checked) {
		alert ("Please select the appropriate surgical risk.");
		return false;
	}
	if (po.funcCap[0].checked || po.risk[0].checked) {showSegment('mid2'); return;}
		else {showSegment('Intro2'); return;}
}

function goBack() {
	var where1, where2, len, backStep;
	var prevStep = document.periop.prevStep.value;
	
	for (var i=1; i <= 2; i++) {
		len = prevStep.length;
		where1 = prevStep.lastIndexOf(";", len-2);

		if (where1 == -1) {
			document.periop.prevStep.value = "";
			showSegment("Intro");
			return;}
		backStep = prevStep.substring(where1+1,len-1);
		prevStep = prevStep.slice(0,where1-len+1);
	}
	document.periop.prevStep.value = prevStep;
	
/*	alert ("length = " + len +
		"\nwhere1 = " + where1 +
		"\nbackStep = " + backStep +
		"\nnew prevStep = " + document.periop.prevStep.value);
	*/
	showSegment(backStep);
	return;
}

//  Pop-Up Text
var less4mets = "<b>&lt; 4 METs</b><br><span style=\"font-size=8pt;\"><li>Can you take care of yourself?<li>Eat, dress, or use the toilet?<li>Walk indoors around the house?<li>Walk a block or two on level ground at 2-3 mph or 3.2-4.8 km/h?<li>Do light work around the house like dusting or washing dishes?</span>";
var more4mets = "<b>&gt; 4 METs</b><br><span style=\"font-size=8pt;\"><li>Climb a flight of stairs or walk up a hill?<li>Walk on level ground at 4 mph or 6.4 km/h?<li>Run a short distance?<li>Do heavy work around the house like scrubbing floors or lifing or moving heavy furniture?<li>Participate in moderate recreational activities like golf, bowling, dancing, doubles tennis, or throwing a baseball or football?<li>Participate in strenuous sports like swimming, singles tennis, football, basketball, or skiing?</span>";

var highrisk = "<b>High Surgical Risk Procedures:</b><br><span style=\"font-size=8pt;\">(Reported cardiac risk often &gt;5%)<br><li>Emergent major operations, particularly in the elderly<li>Aortic and other major vascular<li>Peripheral vascular<li>Anticipated prolonged surgical procedures assoc with large fluid shifts and/or blood loss</span>";
var midrisk = "<b>Intermed Surgical Risk Procedures:</b><br><span style=\"font-size=8pt;\">(Reported cardiac risk generally &lt; 5%)<br><li>Carotid endarterectomy<li>Head and neck<li>Intraperitoneal and intrathoracic<li>Orthopedic<li>Prostate</span>";
var lowrisk = "<b>Low Surgical Risk Procedures:</b><br><span style=\"font-size=8pt;\">(Reported cardiac risk generally &lt; 1%,<br>further preop cardiac testing not generally required)<br><li>Endoscopic procedures<li>Superficial procedures<li>Cataract<li>Breast</span>";
