 
// JavaScript Document
var testpicked = "Complete 8-test pack selected"; 

function doSQL(sql){
	url = "ajax.php?method=sql&sql=" + sql;

	//var ret = false;
	$.ajax({
    	type: "GET",
        url: url,
		async: false,
        success: function(rvalue) {
			if (rvalue == 1){
				ret = true;
			}else{
				ret = false;
			}
		}
	});
	return ret;
}

function showPleaseWait(left, top){
	/*
	if (window.event) {
		x = window.event.clientX + document.documentElement.scrollLeft
        		+ document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop +
			+ document.body.scrollTop;
	}
	else {
			alert("in else");

		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;
	}
	y-=200;
	alert(x + ' ' + y);
	document.getElementById("pleasewait").style.left = x + "px";
	document.getElementById("pleasewait").style.top = y + "px";
	*/
//	document.getElementById("pleasewait").style.left = "475px";
//	document.getElementById("pleasewait").style.top = "700px";
	document.getElementById("pleasewait").style.left = left;
	document.getElementById("pleasewait").style.top = top;
	
    document.getElementById("pleasewait").style.display = "block";
}

function hidePleaseWait(){
    document.getElementById("pleasewait").style.display = "none";
}


function checklogin(){
	pin = document.getElementById('loginfld').value;
	if(pin == "wrong"){
		alert("You will receive a confidential login code after you've paid for your tests. If you lose this code, please call 800 xxx xxxx.");
	}else{
		document.loginform.submit();
	}	
}
function showbox(id){
	document.getElementById(id).className = "open";
}
function hidebox(id){
	document.getElementById(id).className = "closed";
}
function assignPosition(d, id) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
	} else if(document.documentElement && document.documentElement.scrollTop) {
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
	} else if(document.body) {
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
	}
	if(document.all) {
		cX += rX; 
		cY += rY;
	}	
	popY = cY;
	d.style.left = (15) + "px";
	d.style.top = (popY - 100) + "px";
}
function showContent(d) {
	document.getElementById(d).className = "open";
	/// open requested container	
	var dd = document.getElementById(d);
	assignPosition(dd, d);	
}

function opnlogin(){
	document.getElementById("aboutbx").className = "closed";
	document.getElementById("contactbx").className = "closed";
	document.getElementById("pressbx").className = "closed";
	
	document.getElementById("loginbx").className = "open";	
}

function opnabout(){
	document.getElementById("loginbx").className = "closed";
	document.getElementById("contactbx").className = "closed";
	document.getElementById("pressbx").className = "closed";
	
	document.getElementById("aboutbx").className = "open";	
}

function opncontact(){
	document.getElementById("loginbx").className = "closed";
	document.getElementById("aboutbx").className = "closed";
	document.getElementById("pressbx").className = "closed";	
	
	document.getElementById("contactbx").className = "open";	
}

function opnpress(){
	document.getElementById("loginbx").className = "closed";
	document.getElementById("aboutbx").className = "closed";
	document.getElementById("contactbx").className = "closed";
	
	document.getElementById("pressbx").className = "open";	
}

function closeme(id){
	document.getElementById(id).className = "closed";
}

function calculatePrice(testsFound) 
{
  var discountPerc = document.testform.discountPerc.value;
  var discountAmount = document.testform.discountAmount.value;
	switch(testsFound)
	{
		case 1:
			finalprice=90;
			break;
		case 2:
			finalprice=150;
			break;
		case 3:
		case 4:
			finalprice=195;
			break;
		case 5:
		case 6:
			finalprice=225;
			break;
		case 7:
		case 8:
			finalprice=245;
			break;
		default:
			finalprice=0;
	}
	
	if(finalprice > 0)
  {
		if (discountPerc > 0)
    {
			finalprice = finalprice - (finalprice * (discountPerc/100));
		}
    if (discountAmount > 0)
    {
			finalprice = finalprice - discountAmount;
		}	
	}
	return finalprice;
}

function testChoice(target,locationSet) {
	testsFound = 0;
	finalprice = 0.00;
	testpicked = "";
   var pageURLSecure = document.testform.pageURLSecure.value;
   var labID = document.testform.labID.value;
   var mailingZip = document.testform.mailingZip.value;
   var orderURL = pageURLSecure+'order.php';
	if(target == "home")
  {
    document.testform.athome.value = 'true';
    add=document.testform.homeTests;
		clear=document.testform.centerTests;	
		document.testform.action="testing-location-home.php";
	}
  else
  {
		if (labID>=1) locationSet=1;
		else  locationSet=0;
		document.testform.athome.value = 'false';
    clear=document.testform.homeTests;
		add=document.testform.centerTests;
		if (locationSet) document.testform.action=orderURL;
		else document.testform.action="testing-location.php";
	}

	//clear other values
	if(target != ""){
		for (i = 0; i < clear.length; i++){
			clear[i].checked=false;
		}
	}
	
	//add total of selected values
	for (i = 0; i < add.length; i++){
		if(add[i].checked){
			testpicked = testpicked + add[i].value + ",";
			testsFound++;
		}
	}
	
	//this is here for the backbutton - counts both checkboxes
	if(testsFound==0){
		for (i = 0; i < clear.length; i++){
			if(clear[i].checked){
				testpicked = testpicked + clear[i].value + ",";
				testsFound++;
			}
		}
		document.testform.action="testing-location-home.php";
		target="home";
	}

	//calculate the price
	finalprice=calculatePrice(testsFound);
	
	
	//add shipping if home
	if(target == "home" && finalprice > 0)
		finalprice+=15.00;
	//update price
	document.getElementById('price').innerHTML= finalprice.toFixed(2);
	//update tests selected
	document.testform.testselected.value = testpicked;
}

function testChoice2(target) {
	testsFound = 0;
	finalprice = 0.00;
	testpicked = "";
   var pageURLSecure = document.testform.pageURLSecure.value;
   var labID = document.testform.labID.value;
   var mailingZip = document.testform.mailingZip.value;
   var orderURL = pageURLSecure+'order.php';
	if(target == "home")
  {
    document.testform.athome.value = 'true';
    add=document.testform.homeTests;
		clear=document.testform.centerTests;	
		document.testform.action="testing-location-home.php";
	}
  else
  {
		if (labID>=1) locationSet=1;
		else  locationSet=0;
		document.testform.athome.value = 'false';
    clear=document.testform.homeTests;
		add=document.testform.centerTests;
		if (locationSet) document.testform.action=orderURL;
		else document.testform.action="testing-location.php";
	}

	//clear other values
	if(target != "")
  {
		//for (i = 0; i < clear.length; i++)
    //{
			//clear[i].checked=false;
		//}
	}
	
	//add total of selected values
	for (i = 0; i < add.length; i++){
		if(add[i].checked){
			testpicked = testpicked + add[i].value + ",";
			testsFound++;
		}
	}
	
  //calculate the price
	finalprice=calculatePrice(testsFound);
	
	
	//add shipping if home
	if(target == "home" && finalprice > 0)
		finalprice+=15.00;
	//update price
	if (target == "center")
	{
	   if (finalprice>1) document.getElementById('priceCenter').innerHTML = '$' + finalprice.toFixed(2);
	   else document.getElementById('priceCenter').innerHTML= 'Select Your Tests';
	   //document.getElementById('priceHome').innerHTML= 'Select Your Tests';
  }
  else
  {
     if (finalprice>1) document.getElementById('priceHome').innerHTML = '$' + finalprice.toFixed(2);
	   else document.getElementById('priceHome').innerHTML= 'Select Your Tests';
     //document.getElementById('priceCenter').innerHTML= 'Select Your Tests'; 
  }
	
	//update tests selected
	document.testform.testselected.value = testpicked;
}

function choosethissite(locCopy)
{
	return true;	
}

function setFormFields(name, address, city, state, zip, labid, phone, hours){

	document.finalform.labname.value = name;
	document.finalform.labaddress.value = address;
	document.finalform.labcity.value = city;
	document.finalform.labstate.value = state;
	document.finalform.labzip.value = zip;
	document.finalform.labid.value = labid;
	document.finalform.labphone.value = phone;
	document.finalform.hours.value = hours;
	athome = document.finalform.athome.value;

	selectdLocation = 1;
	
	var tests = document.finalform.testselected.value;
	var pageURLSecure = document.finalform.pageURLSecure.value;
	var orderURL = pageURLSecure+'order.php';
	if (tests.length > 1 && athome!='true') document.finalform.action=orderURL;
	else document.finalform.action = 'get-std-tested.php';
	document.finalform.submit();
	
	return true;
}

function swapDivs(id, id2){
    ulElement = document.getElementById(id);
	ulElement2 = document.getElementById(id2);
    if (ulElement){
		if (ulElement.className == 'closed'){
			ulElement.className = "open";
			ulElement2.className = "closed";
			
		}else{
			ulElement.className = "closed";
			ulElement2.className = "open";
		}
	}
}

// Toggle: Xpand and Collapse divs
function showHide(id, imgID){
    ulElement = document.getElementById(id);
	imgElement = document.getElementById(imgID);
    if (ulElement){
		if (ulElement.className == 'closed'){
			ulElement.className = "open";
			imgElement.src = "imgs/min.gif";		
		}else{
			ulElement.className = "closed";
			imgElement.src = "imgs/max.gif";
		}
	}
}


// Toggle: Xpand and Collapse divs
function toggleShowHideImg (id, imgID){
    ulElement = document.getElementById(id);
	imgElement = document.getElementById(imgID);
    if (ulElement){
		if (ulElement.className == 'hide'){
			ulElement.className = "show";
			imgElement.src = "imgs/bplus.gif";		
		}else{
			ulElement.className = "hide";
			imgElement.src = "imgs/bminus.gif";
		}
	}
}
function preloadImgs() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImgs.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function restore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function roImg() { //v3.0
  var i,j=0,x,a=roImg.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function popupwin(theURL) { //v2.0
  window.open(theURL,'getSTDtested','resizable=yes,width=520,height=500,scrollbars');
}

function setVisible(obj)
{
	myDiv = document.getElementById(obj);
	myDiv.style.visibility = (myDiv.style.visibility == 'visible') ? 'hidden' : 'visible';
	placeIt(obj);
}
function placeIt(obj)
{
	x = 200; 
	y = 25;
	var theLeft;
	var theTop;
	
	obj = document.getElementById(obj);
	if (document.documentElement){
		theLeft = document.documentElement.scrollLeft;
		theTop = document.documentElement.scrollTop;
	}else if (document.body){
		theLeft = document.body.scrollLeft;
		theTop = document.body.scrollTop;
	}
	theLeft += x;
	theTop += y;
	
	obj.style.left = theLeft + "px";
	obj.style.top = theTop + "px";
}

function showIt(obj, x, y) {
	myDiv = document.getElementById(obj);
	myDiv.style.display = 'block';
	placeIt(obj, x, y);
}

function hideIt(obj) {
	myDiv = document.getElementById(obj);
	myDiv.style.display = 'none';
}

function showFlashDiv(){
		var so = new SWFObject("flash/testkit.swf", "hometestkit", "400", "320", "8");
		so.addParam("wmode", "transparent");
		so.write("flashstarburst");
	    document.getElementById("flashstarburst").className = "show";
	  }
function hideFlashDiv(){
	    document.getElementById("flashstarburst").className = "hide";
		var so = new SWFObject("", "hometestkit", "0", "0", "8");
		so.write("flashstarburst");
	  }
	  
function gohere(page){
	window.location.href=page;
}

//HOME PAGE FUNCTIONS
function stopAutoPlay(){
  	clearTimeout(t);
}

var uid = new Date().getTime();
function resetFld(id, msg){
	if(id.value == "" || id.value == " ")
		id.value = msg;
}

//var t
//var curStage = 0;
function timedCount(){
	doNext();
	t=setTimeout("timedCount()",10000);
}

/*
function optOneselected(tests){
	document.getElementById("opt1").checked=true;
	document.getElementById("opt2").checked=false;
	
	for (i = 0; i < tests.length; i++){
		if(tests[i].checked){
			tests[i].checked = false;
		}
	}	
	//testpicked = "17303,498,37677,3636,3640,37694,17304,799";
	testpicked = "8-pack";
	document.getElementById('testedSelectedCopy').innerHTML= "Complete 8-test pack selected";
	document.getElementById('price').innerHTML= "245.00";
	document.getElementById('price2').innerHTML= "245.00";	

	document.finalform.testselected.value = testpicked;
	document.finalform.totalcharge.value="245";
	document.finalform.pack.value = "8-test";
	
}
*/
/*
function optTwoselected(tests){
	document.getElementById("opt1").checked=false;
	document.getElementById("opt2").checked=true;
	
	testpicked = "";
	testsFound = 0;
	finalprice = 0;
	
	if(tests[5].checked == false){
		tests[1].disabled = "";
		tests[3].disabled = "";
	}
	if(tests[6].checked == false){
		tests[2].disabled = "";
		tests[4].disabled = "";
	}
	
	for (i = 0; i < tests.length; i++){
		if(tests[i].checked){
			testsFound++;
			testpicked = testpicked + tests[i].value + ",";
			
			if(tests[i].value == "17303" || tests[i].value == "37694" || tests[i].value == "498" ){
				finalprice = finalprice + 90;
			}else if (tests[i].value == "17304"){
				if(tests[1].checked){
					finalprice = finalprice - 90;
					tests[1].disabled = "disabled";
					tests[1].checked = false;
					tests[3].disabled = "disabled";
					tests[3].checked = false;
					tests[5].checked = true;
				}else{
					finalprice = finalprice + 90;
				}
			}else if (tests[i].value == "37677"){
				
				if(tests[2].checked){
					finalprice = finalprice - 90;
					tests[2].disabled = "disabled";
					tests[2].checked = false;
					tests[4].disabled = "disabled";
					tests[4].checked = false;
					tests[6].checked = true;
				}else{
					finalprice = finalprice + 90;
				}
				
				
			}else if(tests[i].value == "17305") {
				if(tests[1].checked){
					finalprice = finalprice - 90;
				}
				if(tests[3].checked){
					finalprice = finalprice - 90;
				}
				tests[1].disabled = "disabled";
				tests[1].checked = false;
				tests[3].disabled = "disabled";
				tests[3].checked = false;
				finalprice = finalprice + 150;				
			}else if(tests[i].value == "3636,3640") {
				finalprice = finalprice + 135;
			}else if(tests[i].value == "799") {
				finalprice = finalprice + 75;
			}else if(tests[i].value == "498,37677") {
				if(tests[2].checked){
					finalprice = finalprice - 90;
				}
				if(tests[4].checked){
					finalprice = finalprice - 90;
				}
				tests[2].disabled = "disabled";
				tests[2].checked = false;
				tests[4].disabled = "disabled";
				tests[4].checked = false;
				finalprice = finalprice + 150;
			}
		}
	}
	
	if(testsFound < 1){
		testpicked = "Please select a test first.";
	}
	
	document.getElementById('testedSelectedCopy').innerHTML= "Customized Tests Selected";
	document.getElementById('price').innerHTML= finalprice + ".00";	
	document.getElementById('price2').innerHTML= finalprice + ".00";	
		
	document.finalform.testselected.value = testpicked;
	document.finalform.totalcharge.value = finalprice + ".00";
	document.finalform.pack.value = "custom";

}

function chlGonSelected(tests, selectedTest){
	document.getElementById("opt1").checked=false;
	document.getElementById("opt2").checked=true;
	
	if(selectedTest.checked ==  true){
		if(selectedTest.value == "Chlamydia"){
			tests[3].checked = true;	
		}
		if(selectedTest.value == "Gonorrhea"){
			tests[0].checked = true;
		}
	}else{
		if(selectedTest.value == "Chlamydia"){
			tests[3].checked = false;	
		}
		if(selectedTest.value == "Gonorrhea"){
			tests[0].checked = false;
		}
	}
	optTwoselected(tests);
}

function hepSelected(tests, selectedTest){
	document.getElementById("opt1").checked=false;
	document.getElementById("opt2").checked=true;
	
	if(selectedTest.checked ==  true){
		if(selectedTest.value == "Hepatitis B"){
			tests[5].checked = true;	
		}
		if(selectedTest.value == "Hepatitis C"){
			tests[2].checked = true;
		}
	}else{
		if(selectedTest.value == "Hepatitis B"){
			tests[5].checked = false;	
		}
		if(selectedTest.value == "Hepatitis C"){
			tests[2].checked = false;
		}
	}
	optTwoselected(tests);
}
*/

function validateResultsForm()
{
	if (!document.loginForm.lastName.value) 
	{
		alert ('Please Enter Your Last Name');
		return false;
	}
	if (!document.loginForm.confCode.value) 
	{
		alert ('Please Enter Your Confirmation Code');
		return false;
	}
	
	if (!document.loginForm.agree.checked)
	{
		alert ('Please Confirm You Have Read and Understand The Presented Information');
		return false;
	}
	
}


function validateSHRAForm()
{
	
	var fieldsAllGood = true;
	
	//Get Positive Tests Value
	//var posTestsValue = false;
	//for (var i=0; i < document.SHRAForm.posTests.length; i++)
   // {
   	//	if (document.SHRAForm.posTests[i].checked) posTestsValue = true;
   // }
	  // if (!posTestsValue) fieldsAllGood = false;
	
	//Get Gender Radio Button Value
	var genderValue = false;
	for (var i=0; i < document.SHRAForm.gender.length; i++)
    {
   		if (document.SHRAForm.gender[i].checked) genderValue = true;
    }
	if (!genderValue) 
  {
    document.getElementById("genderLbl").style.color = 'red';
    fieldsAllGood = false;
  }
  else  document.getElementById("genderLbl").style.color = 'black';
	
	if (!document.SHRAForm.ageGroup.selectedIndex) 
  {
      fieldsAllGood = false;
      document.getElementById("ageGroupLbl").style.color = 'red';
  }
  else  document.getElementById("ageGroupLbl").style.color = 'black';
	
	if (!document.SHRAForm.zipcode.value) 
  {
    fieldsAllGood = false;
    document.getElementById("zipcodeLbl").style.color = 'red'; 
  }
  else  document.getElementById("zipcodeLbl").style.color = 'black';
	

	//Get Sex Partners Value
	var partnersValue = false;
	for (var i=0; i < document.SHRAForm.partners.length; i++)
    {
   		if (document.SHRAForm.partners[i].checked) partnersValue = true;
    }
	if (!partnersValue) 
  {
    fieldsAllGood = false;
    document.getElementById("partnersLbl").style.color = 'red';
  }
	else  document.getElementById("partnersLbl").style.color = 'black';
	
	//STD In Past Value
	//var stdPastValue = false;
	//for (var i=0; i < document.SHRAForm.stdPast.length; i++)
  //  {
  // 		if (document.SHRAForm.stdPast[i].checked) stdPastValue = true;
  //  }
	//if (!stdPastValue) fieldsAllGood = false;
	
	//New Partners Value
	var newPartnersValue = false;
	for (var i=0; i < document.SHRAForm.newPartners.length; i++)
    {
   		if (document.SHRAForm.newPartners[i].checked) newPartnersValue = true;
    }
	if (!newPartnersValue) 
  {
    fieldsAllGood = false;
    document.getElementById("newPartnersLbl").style.color = 'red';
  }
  else  document.getElementById("newPartnersLbl").style.color = 'black';
	
	//Last Test Value
	var lastTestValue = false;
	for (var i=0; i < document.SHRAForm.lastTest.length; i++)
    {
   		if (document.SHRAForm.lastTest[i].checked) lastTestValue = true;
    }
	if (!lastTestValue) 
  {
    fieldsAllGood = false;
    document.getElementById("lastTestLbl").style.color = 'red'; 
  }
  else  document.getElementById("lastTestLbl").style.color = 'black';
	
	//Concerned Partner Value
	var concernedPartnerValue = false;
	for (var i=0; i < document.SHRAForm.concernedPartner.length; i++)
    {
   		if (document.SHRAForm.concernedPartner[i].checked) concernedPartnerValue = true;
    }
	if (!concernedPartnerValue) 
  {
    fieldsAllGood = false;
    document.getElementById("concernedPartnerLbl").style.color = 'red';
  }
  else  document.getElementById("concernedPartnerLbl").style.color = 'black';
	
	//Concerned Herpes Value
	var concernedHerpesValue = false;
	for (var i=0; i < document.SHRAForm.concernedHerpes.length; i++)
    {
   		if (document.SHRAForm.concernedHerpes[i].checked) concernedHerpesValue = true;
    }
	if (!concernedHerpesValue) 
  {
    document.getElementById("concernedHerpesLbl").style.color = 'red';
    fieldsAllGood = false;
  }
  else  document.getElementById("concernedHerpesLbl").style.color = 'black';
	
	
	//Get HepB Value
	var hepBValue = false;
	var hepBValueReal;
	for (var i=0; i < document.SHRAForm.hepB.length; i++)
    {
   		if (document.SHRAForm.hepB[i].checked) 
       {
          hepBValue = true;
          hepBValueReal = document.SHRAForm.hepB[i].value;
      }
    }
	if (!hepBValue) 
  {
    fieldsAllGood = false;
    document.getElementById("hepBLbl").style.color = 'red';
  }
  else  document.getElementById("hepBLbl").style.color = 'black';
	
  if (hepBValueReal == 'no' || hepBValueReal == 'dontKnow')
  {
     var hepBStatusValue = false;
     for (var i=0; i < document.SHRAForm.hepBStatus.length; i++)
    {
   		if (document.SHRAForm.hepBStatus[i].checked) hepBStatusValue = true;
    }
  	if (!hepBStatusValue) 
    {
      fieldsAllGood = false;
      document.getElementById("hepBStatusLbl").style.color = 'red';
    }
    else  document.getElementById("hepBStatusLbl").style.color = 'black';
      
  }
	
	//Get IV Radio Button Value
	var IVValue = false;
	for (var i=0; i < document.SHRAForm.IV.length; i++)
    {
   		if (document.SHRAForm.IV[i].checked) IVValue = true;
    }
	if (!IVValue) 
  {
    fieldsAllGood = false;
    document.getElementById("IVLbl").style.color = 'red'; 
  }
  else  document.getElementById("IVLbl").style.color = 'black';
	
	
	
	if (fieldsAllGood == false)
	{
		alert ('Please fill in all required fields before proceeding');
		return false;
	}
	else
  {
     document.SHRAForm.submit(); 
  }
	
}
function openit(sURL,windowname,width,height)
{
  newwindow=open(sURL,windowname,"scrollbars=yes,toolbar=no,directories=no,menubar=no,title=no,resizable=yes,status=no,top=25,left=25,width="+width+",height="+height);
}

function togglePayDisplay(declinedPost) 
{   
	
	//Get Pay Later Button Value
	var payTypeVal;
	for (var i=0; i < document.orderfrm.payType.length; i++)
    {
   		if (document.orderfrm.payType[i].checked) 
		{
			payTypeVal = document.orderfrm.payType[i].value;
		}
    }
    
    if (declinedPost == 1) payTypeVal='now';
	
	tbl = document.getElementById('payNowSection');
	tbl2 = document.getElementById('payLaterSection');
	
	if (payTypeVal == 'now') 
	{
		var tblRows = tbl.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (false) ? "none" : "";      
			}   
		}
		
		var tblRows = tbl2.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (true) ? "none" : "";      
			}   
		}
	}
	
	if (payTypeVal == 'later') 
	{
		var tblRows = tbl.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (true) ? "none" : "";      
			}   
		}
		
		var tblRows = tbl2.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (false) ? "none" : "";      
			}   
		}
	}
	
	if (!payTypeVal)
	{
		var tblRows = tbl.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (true) ? "none" : "";      
			}   
		}
		
		var tblRows = tbl2.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (true) ? "none" : "";      
			}   
		}
	}
}

function changeto(highlightcolor,tableObj)
{ 
  tableObj.style.backgroundColor=highlightcolor;
}

function checkTestForm(location) 
{
    if (location == 'home') checkField = document.testform.homeTests;
    if (location == 'center') checkField = document.testform.centerTests;
    var labID = document.testform.labID.value;
    var pageURLSecure = document.testform.pageURLSecure.value;
    var sourceID = document.testform.sourceID.value;
    var orderURL = pageURLSecure+'order.php';
    
    if (location == 'cdc')
    {
        if (labID>=1) locationSet=1;
		    else  locationSet=0;
		    document.testform.athome.value = 'false';
		    if (locationSet) document.testform.action=orderURL;
		    else document.testform.action="testing-location.php";
        
        if (sourceID == "mhc") testpicked = "37694,17303,17304,3640,36126,";
        else testpicked = "37694,17303,17304,3640,";
        document.testform.testselected.value = testpicked;
        document.testform.submit();
        return true;  
    }
    
    if (location == 'complete')
    {
        if (labID>=1) locationSet=1;
		    else  locationSet=0;
		    document.testform.athome.value = 'false';
		    if (locationSet) document.testform.action=orderURL;
		    else document.testform.action="testing-location.php";
        
        testpicked = "37694,17303,17304,36126,3636,3640,498,37677,";
        document.testform.testselected.value = testpicked;
        document.testform.submit();
        return true;  
    }
    
    checkVal = 0;
    for (i = 0; i < checkField.length; i++)
    {
		  if(checkField[i].checked) checkVal++; 
	  }
	  
	  if (!checkVal)
	  {
      alert ('Please select at least one test before proceeding');
      return false;
    }
    else document.testform.submit();
}

function toggleHepB() 
{   
	tbl = document.getElementById('hepB2');
	
	var hepBVal;
	for (var i=0; i < document.SHRAForm.hepB.length; i++)
    {
   		if (document.SHRAForm.hepB[i].checked) 
		{
			hepBVal = document.SHRAForm.hepB[i].value;
		}
    }
    
	
	if (hepBVal == 'no' || hepBVal == 'dontKnow') 
	{
		var tblRows = tbl.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (false) ? "none" : "";      
			}   
		}
	}
	else
	{
     var tblRows = tbl.rows;   
		for (i = 0; i < tblRows.length; i++) 
		{      
			if (tblRows[i].className != "headerRow") 
			{         
				tblRows[i].style.display = (true) ? "none" : "";      
			}   
		} 
  }
}
  