function show(cont_id) {
    target = document.getElementById(cont_id);
	if (target && typeof target.style != "undefined"
    && typeof target.style.display != "undefined"){
    target.style.display = ""; 
	}
}
function hide(cont_id) {
    target = document.getElementById(cont_id);
	if (target && typeof target.style != "undefined"
    && typeof target.style.display != "undefined"){
    target.style.display = "none"; 
	}
}
function toggle(what,targetId) {
    target = document.getElementById(targetId);
	target.style.display = (what.checked)?'':'none';
}
function toggleDiv(targetId) {
	target = document.getElementById(targetId);
	target.style.display = (target.style.display)?'':'none';
}
function clearSymp() {
	document.forms["form1"].elements["symptomatic"].checked=false;
}
function clearSympLeft() {
	clearBut('symp_regionl',5);
	document.forms["form1"].elements["symptoml"][0].checked=true;	
}
function clearSympRight() {
	clearBut('symp_regionr',5);	
	document.forms["form1"].elements["symptomr"][0].checked=true;		
}
function resetSymp() {
	document.forms["form1"].elements["symp_brl"].checked=false;
	document.forms["form1"].elements["symp_brr"].checked=false;	
	clearSympLeft();
	clearSympRight();
}
function clearP1P6L() {
	document.forms["form1"].elements["left_vein_temp"].value = " ";
	document.forms["form1"].elements["right_vein_comp"].value = " ";	
	clearBut('left_vein_region',5);
}
function clearP1P6R() {
	document.forms["form1"].elements["right_vein_temp"].value = "";
	document.forms["form1"].elements["left_vein_comp"].value = "";	
	clearBut('right_vein_region',5);
}								
function clearBut(suffix,count) {
	var i=0;
	while (i < count) {
	window.document.form1.elements[suffix+(i)].checked=false;
	i++;}	
}
function clearP7Left () {
	clearBut('left_p7_region',4);
	document.forms["form1"].elements["left_hyper_temp"].value = "";
	document.forms["form1"].elements["right_hyper_comp"].value = "";	
}
function clearP7Right () {
	clearBut('right_p7_region',4);
	document.forms["form1"].elements["right_hyper_temp"].value = "";
	document.forms["form1"].elements["left_hyper_comp"].value = "";	
}
function clearP8Left () {
	clearBut('left_p8_region',4);
	document.forms["form1"].elements["left_hypo_temp"].value = "";
}
function clearP8Right () {
	clearBut('right_p8_region',4);
	document.forms["form1"].elements["right_hypo_temp"].value = "";
}
function hidel() {
	hide('div2l');
	hide('div3l');
}
function hider() {
	hide('div2r');
	hide('div3r');
}
var symptoms = [
	'non-specified',
	'burning',
	'pain',
	'numbness',
	'palpable mass',
	'distorted contour'
];
var veins = [
   'uniform thermal pattern',
   'regular thermovascular pattern',
   'thermovascular network',
   'irregular thermovascular pattern',
   'distorted thermovascular pattern',
   'anarchic thermovascular pattern'
];
var hyper = [
   '0',
   '20',
   '21'
];
var hypo = [
	'0',
   '15',
   '16'
];
var vHyper = [
	'0',
	'10',
	'20',
	'25',
	'40',
	'60'
];	
// Enter with (button array name, placeholder ID's, which string array)
function checkRadio(what,target,target2,whatId) {
	if (whatId == 'veins') {output_str = veins;}
	else if (whatId == 'symptoms') {output_str = symptoms;}
	for(var i=0; i < what.length; i++) {
	if(what[i].checked) {
	document.getElementById(target).innerHTML = output_str[i];
	document.getElementById(target2).innerHTML = output_str[i];
	}
	}
	return; 
}
function checkP16(what,target) {
	var mValue = 0;
	for(var i=0; i < what.length; i++) {
	if(what[i].checked) {mValue = vHyper[i];}
 	}
	document.getElementById(target).innerHTML = "<input type=hidden name="+target+" value="+mValue+">";
}
var p7region = new Array();
	p7region["11"]="the upper-outer quadrant";
	p7region["13"]="the upper-inner quadrant";
	p7region["15"]="the lower-outer quadrant";
	p7region["19"]="the lower-inner quadrant";
	p7region["24"]="the upper half";
	p7region["34"]="the lower half";
	p7region["26"]="the outer half";
	p7region["28"]="the upper-outer diagonal";
	p7region["30"]="the upper-inner diagonal";
	p7region["32"]="the inner-half";
	p7region["58"]="all quadrants";			
	p7region["65"]="three of four quadrants";		
	p7region["100"]="periareolar region";
	p7region["0"]="an unspecified region";
	
var region = new Array();
	region["11"]="the upper-outer quadrant";
	region["13"]="the upper-inner quadrant";
	region["15"]="the lower-outer quadrant";
	region["19"]="the lower-inner quadrant";
	region["24"]="the upper half";
	region["34"]="the lower half";
	region["26"]="the outer half";
	region["28"]="the upper-outer diagonal";
	region["30"]="the upper-inner diagonal";
	region["32"]="the inner-half";
	region["58"]="all quadrants";			
	region["65"]="three of four quadrants";		
	region["100"]="the nipple/areola";
	region["0"]="an unspecified region";

 function regionScore(regionName,n,target) {
    var mValue = 0;
	if (regionName === "" || regionName == 'undefined' || regionName > 158) {
	document.getElementById(target).innerHTML = "<input type=text name="+target+" value=0 >";}
    for(var i=0; i<n; i++) {
    if (window.document.form1.elements[regionName+(i)].checked) {
    mValue = mValue + 1*window.document.form1.elements[regionName+i].value;
	}
 }	
 	if (mValue == 'undefined') {mValue = 0;}
	mV = mValue;
	document.getElementById(target).innerHTML = "<input type=hidden name="+target+ " value="+mV+">";
}
function getMenuValue(menuName,n,target1,target2) {
    var mValue = 0;
    for(var i=0; i<n; i++) {
    if (window.document.form1.elements[menuName+(i)].checked) {
    mValue = mValue + 1*window.document.form1.elements[menuName+i].value;}
 }	
 	if (mValue == 'undefined') {mValue = 0;}
	if (mValue > 34 && mValue <49) {mValue = 65;} 
	mV = mValue.toString(10);
	if (menuName == 'right_p7_region' || menuName == 'left_p7_region') {
	document.getElementById(target1).innerHTML = p7region[mV];
  	document.getElementById(target2).innerHTML = p7region[mV];
	}
	else {
  	document.getElementById(target1).innerHTML = region[mV];
  	document.getElementById(target2).innerHTML = region[mV];
	}
  	return;
}
	var keys = document.all?true:false;
function keyHandler(e) {
 	var _ret=true;
 	var _char=keys?window.event.keyCode:e.which;
 	if(_char==13) {_ret=false;}
	return _ret;
}
	/* onkeypress="return onlyDigits(event,'decOK');"
	Code: decOK = decimal point OK; all = allow all except 13; slash=allow / only  */
	var kStroke = document.all?true:false;
function onlyDigits(e,decReq) {
	var _ret=true;
	var key = kStroke?window.event.keyCode:e.which;
	if(key==13) {_ret=false;return _ret;}
	if (decReq == 'all') {return true;}
	var obj = kStroke?event.srcElement:e.target;
	isNum = (key > 47 && key < 58) ? true:false;
	if (decReq == 'slash') {isNum = (key >= 47 && key < 58) ? true:false;}
	if (decReq == 'dash') {isNum = (key == 45 || (key >= 48 && key< 58)) ? true:false;}
	var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length===0)) ? true:false;
	if(key < 32) {return true;}   
	return (isNum || dotOK);
}
function chkNum(cell,target) {
	var tmin = 20;
	var tmax = 45;
	var str = cell.value;
	if ((str < tmin || str > tmax)) {document.getElementById(target).innerHTML = "Data out of Range";if (cell.focus) {cell.focus();return false;}
	document.getElementById(target).innerHTML = " ";return;
}
}
function setCookie(c_name,value) {
document.cookie = c_name+'='+escape(value)+';path=/;expires='+cookieTime(1);
}
function cookieTime(days){
	var now = new Date();
 	var exp = new Date();
 	var x   = Date.parse(now) + days*24*60*60*1000;
	exp.setTime(x);
	str = exp.toUTCString();
	re = '/(\d\d)\s(\w\w\w)\s\d\d(\d\d))/';
	return str.replace(re,"$1-$2-$3");
 }
 function setLogin (username) {
	counter=+0;pt_id="";examDate="";subCnt=+0;
	lValue=counter+"}"+pt_id+"}"+examDate+"}"+username+"}"+subCnt+"}";
	setCookie('login',lValue);
}
function getCookieValue(c_name) {
	if (document.cookie.length>0) {
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1) { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(",",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null
}
function killAll() {
	cookies = document.cookie.split(";");
	for (i=0;i<cookies.length;i++) {
	indCookie = cookies[i].indexOf("=");
	cName=cookies[i].substring(0,indCookie);
	document.cookie=cName+"=;expires=Fri, 1 Jan 2000 00:00:00 UTC; path=/"
	}
}
function killCookie(cName) {
	document.cookie=cName+"=;expires=Fri, 1 Jan 2000 00:00:00 UTC; path=/"
}
function killLogin () {
	document.cookie="login=;expires=Fri, 1 Jan 2000 00:00:00 UTC; path=/"
}
function checkRegID () {
	passError = '<span style="color:red;"><b>&nbsp;PASSWORD ERROR!</b></span>';
	document.getElementById('errorMsg').innerHTML = " ";
	pwBad = getCookieValue('pwNG');
	if (!pwBad) {return;}
	else {document.getElementById('errorMsg').innerHTML = passError;
	killCookie ('pwNG');
	}
}
function getCkieData (who) {
if (navigator.cookieEnabled) {hide('cookiesOff');show('cookiesOn');}
	else {show('cookiesOff');hide('cookiesOn');}
	hide('commentDiv');
	l_value = getCookieValue('login');
	q_value = getCookieValue('pt_query');	//why allow entry if no login???
	if (!l_value) {
	if (q_value) {
	c_value = document.form1.clientValue.value;
	username = document.form1.username.value;
	setCookie(username,c_value);
	lValue = 0+'}}}'+username+'}'+0+'}';
	setCookie('login',lValue);
	}
	else {alert("GCData error");}
	}
	l_value = getCookieValue('login');
	l_array = l_value.split("}");
	username=l_array[3];
	c_value = getCookieValue(username);
	tal=getCookieValue('tal');
	if (!username) {alert("No username");
	if (tal=='tal') {window.location="../cgi-bin/lab.pl";}
	else {window.location="../index.html";}
	}
    if (!c_value) {c_value=null;}
    if (c_value!=null) { 
    c_array = c_value.split("{");
	if (username!=c_array[0]) {alert("Conflict brca-304: username("+username+")!=array[0]: "+c_array[0]);return false;}
	else {
	document.getElementById('docName').innerHTML = c_array[2];
	document.getElementById('clinic').innerHTML = c_array[1];
	}
  }
  	if (who != 'mod6a') {getDrComment ();}
}
function getDrComment () {
	ptValue=getCookieValue('ptCookie');
	if (!ptValue) {return;}
	ptArray = ptValue.split("{");
	drComment = ptArray[18];
	if (drComment != '' && drComment != '-') {
	show('commentDiv');
	document.getElementById('comment').innerHTML = "<b>Examiner's comments:</b> "+drComment;
	}
}
function updateActivity () {	//On entry to mod7 increment login counter, add pt to list: Updates lValue
	q_value = getCookieValue('pt_query');
	if (q_value) {return true;}
	l_value=getCookieValue('login');
	l_array=l_value.split("}");
	if (l_array[3] == 'guest') {
	document.forms['form1'].action="brca_mod7.pl";
	document.forms['form1'].submit();
	}
	patient_id = document.form1.patient_id.value;
	xmDate = document.form1.exam_date.value;
	l_array[0]++;
	l_array[4]--;
	l_array[1]=l_array[1]+patient_id+":";	//Add pt ID to cookie list
	l_array[2]=l_array[2]+xmDate+":";		//Add exam date to cookie list
	newValue=l_array[0]+"}"+l_array[1]+"}"+l_array[2]+"}"+l_array[3]+"}"+l_array[4]+"}"; 
	setCookie('login',newValue);	//Set login cookie with new value
}
function updateCookie() {
	if (getCookieValue('tal')) {return;}
	finalize();
}	
function finalize () {
	q_value = getCookieValue('pt_query');
	if (q_value) {return true;}
	new_c_value = '';
	l_value=getCookieValue('login');
	l_array=l_value.split("}");
	username = l_array[3];	
	c_value=getCookieValue(username);
	c_array = c_value.split("{");
	c_array[14] = c_array[14]*1;
	l_array[0] = l_array[0]*1;
	c_array[14]= c_array[14] + l_array[0];
	c_array[24] = '1,1' ;
	for (i=0;i<25;i++) {
	new_c_value = c_array[24-i] + "{" + new_c_value;}
	setCookie(username,new_c_value);
}
function abortPt() {

	if (getCookieValue('edit')) {
	eValue=getCookieValue('edit');
	edit_array=eValue.split(",");
	whichMod = edit_array[0];
	getCData(whichMod);
	document.forms['form1'].action="brca_mod6a.pl";
	document.forms['form1'].submit();
	}
	
	else {
	killCookie('pt_query');
	killCookie('edit');
	talValue = getCookieValue('tal');
	ptValue = getCookieValue('ptCookie');
	pwCheck = getCookieValue('pwMatch');
	l_value = getCookieValue('login');
   if (l_value) {
 	l_array=l_value.split("}");
	if (l_array[3] == 'guest') {window.location = "../brth_usermenu.html";return;}

  if (l_array[0] == 0) {
	if (!talValue) {
	if (pwCheck) {window.location = "../index.html";return;
	}
	else {window.location = "../brth_usermenu.html";return;}
	}
	
	else if (talValue) {
	if (ptValue) {window.location = "../cgi-bin/brca_backlog.pl";return;}
	else if (getCookieValue('acctg')) {
	killCookie('acctg');
	window.location="../brth_accounting.shtml";return;
	}
	else {window.location="../cgi-bin/lab.pl";return;}
	}
  }
  
	else {	//  l_array[0] != 0
	hide('goahead');show('abortbox');
	return;
	}
 }	//end of if l_value
	else if (talValue) {window.location="../cgi-bin/lab.pl";}
	else {window.location="../index.html";}
	}
}
function abortFinalize() {
	finalize();
	window.location='./brca_activity.pl';
}
function returnToEval() {
	show('goahead');hide('abortbox');
}
function checkGate(who) {
	if (!navigator.cookieEnabled) {alert("Cookies Not Enabled Error:"+who+".");window.location="../index.html";}
	
	l_value=getCookieValue('login');
	if (!l_value) {		//alert("Error:"+who+" Not properly logged in.");window.location="../brth_login.html";}
	steerOut(who,'0');
	}
	l_array=l_value.split("}");
	username = l_array[3]		//Get username from login cookie
	if (username == '') {	//alert("Error:"+who+" Not properly logged in.");
	steerOut(who,'1');
	}
	c_value=getCookieValue(username);
    if (!c_value) {
	steerOut(who,'2');
	}
    c_array = c_value.split("{");
	if (username!=c_array[0]) {		//alert("Cookies Error Um1");
	steerOut(who,'3');
	}
}
function steerOut (who,what) {
	alert("Error"+what+" in "+who+". Not properly logged in.");
	t_value=getCookieValue("tal");
	if (!t_value) {window.location="../index.html";}
	else {window.location="../cgi-bin/lab.pl";}
}
function goEdit (who) {
	cname='edit';cvalue=who;
	setCookie(cname,cvalue);
if (who=='mod1') {
	pt = document.forms["form1"].elements["patient_id"].value;
	xm = document.forms["form1"].elements["exam_date"].value;
	symp_brr = document.forms["form1"].elements["symp_brr"].value;
	if (symp_brr != 1) {document.forms["form1"].elements["symptomr"].value = 0;
	document.forms["form1"].elements["symp_right_region"].value = 0;}
	symptomr = document.forms["form1"].elements["symptomr"].value;
	symp_right_region = document.forms["form1"].elements["symp_right_region"].value;
	symp_brl = document.forms["form1"].elements["symp_brl"].value;
	if (symp_brl != 1) {document.forms["form1"].elements["symptoml"].value = 0;
	document.forms["form1"].elements["symp_left_region"].value = 0;}
	symptoml = document.forms["form1"].elements["symptoml"].value;
	symp_left_region = document.forms["form1"].elements["symp_left_region"].value;
	cbt = document.forms["form1"].elements["cbt"].value;
	proto0 = document.forms["form1"].elements["proto0"].value;
	proto1 = document.forms["form1"].elements["proto1"].value;
	proto2 = document.forms["form1"].elements["proto2"].value;
	proto3 = document.forms["form1"].elements["proto3"].value;
	exam_time = document.forms["form1"].elements["examTime"].value;
	room_temp = document.forms["form1"].elements["roomTemp"].value;
	equil = document.forms["form1"].elements["equilibration"].value;
	anLog = document.forms["form1"].elements["anLog"].value;
	cvalue = who + ',' + pt + ',' +xm + ',' + symp_brr + ',' + symptomr + ',' + symp_right_region + ',' + symp_brl + ',' + symptoml + ',' + symp_left_region + ',' +cbt + ',' + proto0 + ',' + proto1 + ',' + proto2 + ',' + proto3 + ',' + exam_time + ',' + room_temp + ',' + equil + ',' + anLog;
	setCookie(cname,cvalue);
	document.forms['form1'].action="brca_mod1.pl";
	}
if (who=='mod2') {
	pt = document.forms["form1"].elements["patient_id"].value;
	xm = document.forms["form1"].elements["exam_date"].value;
	p9 = document.forms["form1"].elements["p9"].value;
	if (p9 == 15) {p9 = 1;} else {p9 = 0;}
	p10_right = document.forms["form1"].elements["p10_right"].value;
	if (p10_right == 45) {p10_right = 1;} else {p10_right = 0;}
	right_p10_region = document.forms["form1"].elements["right_p10_region"].value;
	p10_left = document.forms["form1"].elements["p10_left"].value;
	if (p10_left == 45) {p10_left = 1;} else {p10_left = 0;}
	left_p10_region = document.forms["form1"].elements["left_p10_region"].value;
	anLog = document.forms["form1"].elements["anLog"].value;
	cvalue = who + ',' + pt + ',' +xm + ',' + p9 + ',' + p10_right + ',' + right_p10_region + ',' + p10_left + ',' + left_p10_region + ',' + anLog;
	setCookie(cname,cvalue);
	document.forms['form1'].action="brca_mod2.pl";
	}
if (who=='mod3') {
	right_mean = document.forms["form1"].elements["right_mean_temp"].value;
	right_nipple = document.forms["form1"].elements["right_nipple_temp"].value;
	left_mean = document.forms["form1"].elements["left_mean_temp"].value;
	left_nipple = document.forms["form1"].elements["left_nipple_temp"].value;
	sternal = document.forms["form1"].elements["sternal_temp"].value;
	anLog = document.forms["form1"].elements["anLog"].value;
	cvalue = who +','+ right_mean +','+ right_nipple +','+ left_mean +','+ left_nipple +','+ sternal +','+ anLog;

	setCookie(cname,cvalue);
	document.forms['form1'].action="brca_mod3.pl";
	}
if (who=='mod4') {
	var vBut = new Array();
	vBut["0"]="0";vBut["10"]="1";vBut["20"]="2";vBut["25"]="3";vBut["40"]="4";vBut["60"]="5";
	pt = document.forms["form1"].elements["patient_id"].value;
	xm = document.forms["form1"].elements["exam_date"].value;
	var elems = document.forms["form1"].elements;
	p1p6R = vBut[elems["p1_p6_right"].value];	
	rightRegion = elems["right_region"].value;
	rightVeinT = elems["right_vein_temp"].value;
	leftVeinC = elems["left_vein_comp"].value;
	p1p6L = vBut[elems["p1_p6_left"].value];	
	leftRegion = elems["left_region"].value;
	leftVeinT = elems["left_vein_temp"].value;
	rightVeinC = elems["right_vein_comp"].value;
	anLog = elems["anLog"].value;
	cvalue = who + ',' + pt + ',' +xm + ',' + p1p6R + ',' + rightRegion + ',' + rightVeinT + ',' + leftVeinC + ',' + p1p6L + ',' + leftRegion + ',' + leftVeinT + ',' + rightVeinC + ',' + anLog;
	setCookie(cname,cvalue);
	document.forms['form1'].action="brca_mod4.pl";
	}
if (who=='mod5') {
	pt = document.forms["form1"].elements["patient_id"].value;
	xm = document.forms["form1"].elements["exam_date"].value;
	p7_right = document.forms["form1"].elements["p7_right"].value;
	if (p7_right == 20) {p7_right = 1;} else {p7_right = 0;}
	right_p7_region = document.forms["form1"].elements["right_p7_region"].value;
	right_p7_clock = document.forms["form1"].elements["right_p7_clock"].value;
	right_hyper_temp = document.forms["form1"].elements["right_hyper_temp"].value;
	left_hyper_comp = document.forms["form1"].elements["left_hyper_comp"].value;
	p7_left =  document.forms["form1"].elements["p7_left"].value;
	if (p7_left == 20) {p7_left = 1;} else {p7_left = 0}
	left_p7_region = document.forms["form1"].elements["left_p7_region"].value;
	left_p7_clock = document.forms["form1"].elements["left_p7_clock"].value;
	left_hyper_temp = document.forms["form1"].elements["left_hyper_temp"].value;
	right_hyper_comp = document.forms["form1"].elements["right_hyper_comp"].value;
	anLog = document.forms["form1"].elements["anLog"].value;
	cvalue = who + ',' + pt + ',' +xm +','+ p7_right +','+ right_p7_region +','+ right_hyper_temp +','+ left_hyper_comp +','+ p7_left +','+ left_p7_region +','+ left_hyper_temp +','+ right_hyper_comp +','+ right_p7_clock +','+ left_p7_clock +','+ anLog;
	setCookie(cname,cvalue);
	document.forms['form1'].action="brca_mod5.pl";
	}
if (who=='mod6') {
	pt = document.forms["form1"].elements["patient_id"].value;
	xm = document.forms["form1"].elements["exam_date"].value;
	p8_right = document.forms["form1"].elements["p8_right"].value;
	if (p8_right == 15) {p8_right = 1;} else {p8_right = 0;}
	right_p8_region = document.forms["form1"].elements["right_p8_region"].value;
	right_hypo_temp = document.forms["form1"].elements["right_hypo_temp"].value;
	left_hypo_comp = '';
	p8_left =  document.forms["form1"].elements["p8_left"].value;
	if (p8_left == 15) {p8_left = 1;} else {p8_left = 0;}
	left_p8_region = document.forms["form1"].elements["left_p8_region"].value;
	left_hypo_temp = document.forms["form1"].elements["left_hypo_temp"].value;
	anLog = document.forms["form1"].elements["anLog"].value;
	right_hypo_comp = '';
	cvalue = who + ',' + pt + ',' +xm +','+ p8_right +','+ right_p8_region +','+ right_hypo_temp +','+ left_hypo_comp +','+ p8_left +','+ left_p8_region +','+ left_hypo_temp +','+ right_hypo_comp +','+ anLog;
	setCookie(cname,cvalue);
	document.forms['form1'].action="brca_mod6.pl";
	}
	document.forms['form1'].submit();
}
function newRegLogin () {
	killCookie ('tal');
	killCookie ('demo');
	killCookie ('edit');
	l_value=getCookieValue('login');
    if (!l_value) {setCookie ('login','',-3650);window.location="../brth_login.html";}
    else {window.location="../cgi-bin/brca_mod1.pl";}
}
function makeList(who) {
	document.forms["form1"].elements["usrnm"].value = who;
	setLogin(who);
	document.forms['form1'].submit();
}
function initDemo () {
	testGuest = getCookieValue('guest');
	if (testGuest) {show('isGuest');return;}
}
function initInstr() {
	lValue = getCookieValue('login'); 
	if (!lValue) {window.location='error.html';}
	l_array = lValue.split("}");
	username=l_array[3];
	if (username == 'visitor') {
	show('visitor');hide('guest');
	} 
	else {
	show('guest');hide('visitor');
	}
}
function initContactus() {
	if (navigator.cookieEnabled) {
	lValue = getCookieValue('login');
	if (!lValue) {return;}
	hide('noJsCookies');
	l_array = lValue.split("}");
	username=l_array[3];
	if (!username) {window.location='error.html';}
	
	show('theForm');
	if (username == 'visitor') {show('visitorHeader');show('guestForm');
	document.forms["form1"].elements["directIt"].value = 'visitor';
	}
	else if (username == 'guest') {;show('guestHeader');show('guestForm');show('guest2');
	document.forms["form1"].elements["directIt"].value = 'guest';
	}
	else if (username != '') {
	cValue = getCookieValue(username);
	if (!cValue) {window.location='error.html';}
	c_array = cValue.split("{");
	document.getElementById('clientName').innerHTML = c_array[2];
	document.forms["form1"].elements["regName"].value = c_array[2];
	document.forms["form1"].elements["refer_clinic"].value = c_array[1];
	document.forms["form1"].elements["email"].value = c_array[3];
	document.forms["form1"].elements["directIt"].value = 'regClient';
	show('clientHeader');username='client'
	}
	else {window.location='error.html';}
	username = username+"&#64;&#98;&#114;&#101;&#97;&#115;&#116;&#116;&#104;&#101;&#114;&#109;&#111;&#103;&#114;&#97;&#112;&#104;&#121;&#101;&#118;&#97;&#108;&#117;&#97;&#116;&#105;&#111;&#110;&#46;&#99;&#111;&#109;";
	document.getElementById('prefix').innerHTML = username;
	document.forms["form1"].elements['regName'].focus();
}
}
function commonLogin(fromTo) {
	document.getElementById('errorMsg').innerHTML = '';
	empty = '<span style="background-color:red;color:white;"><strong> EMPTY </strong></span>';
	
	username = document.forms["form1"].elements["username"].value;
 	if (username == '') {document.getElementById('errorMsg').innerHTML = empty;return;}
	document.forms["form1"].elements["directIt"].value = fromTo;
	document.forms['form1'].submit();
}
function initReview() {
	testGuest = getCookieValue('guest');
	if (testGuest) {show('isGuest');return;}
	qValue = getCookieValue('pt_query');
	if (!qValue) {  //1st visit to page, so there's no query cookie - 
	show('getQuery');return;
	}
	else {
	q_array = qValue.split("}");
	record = q_array[1];
	document.forms["form1"].elements["qRecord"].value = q_array[1];
	show('showRecords');	
	}
}
function makeSession() {
	pt_query = document.forms["form1"].elements["pt_query"].value;
	record=+0;
	qValue=pt_query+"}"+record;
	setCookie('pt_query',qValue);
	window.location = "./brca_review.pl";
}
function whichRecd (which) {
	qValue = getCookieValue('pt_query');
	q_array = qValue.split("}");
	pt_query = q_array[0];
	qValue=pt_query+"}"+which;
	setCookie('pt_query',qValue);
	window.location = "./brca_review.pl";
}	
function retryQuery () {
	killCookie ('pt_query');
	window.location = "./brca_review.pl";
}
function goBack (){
	killCookie ('pt_query');
	tal=getCookieValue('tal');
	if (tal) {window.location="../cgi-bin/lab.pl";}
	else {window.location="../brth_usermenu.html";}
}
function isItProto () {
	var elems = document.forms["form1"].elements;
	cbtValueY = elems["cbt"][0].checked;
	cbtValueN = elems["cbt"][1].checked;
	if (cbtValueY && !cbtValueN) {
	for (i=0;i<4;i++) {elems["proto"+i][0].checked = true;}
	l_value=getCookieValue('login');
	l_array=l_value.split("}");
	username = l_array[3]
	c_value=getCookieValue(username);
    c_array = c_value.split("{");
	elems["examTime"][c_array[9]-1].checked=true;
	elems["roomTemp"][c_array[10]-1].checked=true;
	elems["equilibration"][c_array[11]-1].checked=true;
	}
	else if (!cbtValueY && cbtValueN) {
	for (i=0;i<4;i++) {elems["proto"+i][0].checked = false;}
	elems["examTime"][0].checked=false;
	elems["examTime"][1].checked=false
	for (i=0;i<3;i++) {document.form1.roomTemp[i].checked=false;}
	for (i=0;i<4;i++) {document.form1.equilibration[i].checked=false;}
}
}
var regions = [];
	regions[0] = [0,0,0,0,0];
	regions[11] = [1,0,0,0,0];
	regions[13] = [0,1,0,0,0];
	regions[15] = [0,0,1,0,0];
	regions[19] = [0,0,0,1,0];
	regions[24] = [1,1,0,0,0];
	regions[26] = [1,0,1,0,0];
	regions[28] = [0,1,1,0,0];
	regions[30] = [1,0,0,1,0];
	regions[32] = [0,1,0,1,0];
	regions[34] = [0,0,1,1,0];
	regions[39] = [1,1,1,0,0];
	regions[43] = [1,1,0,1,0];
	regions[45] = [1,0,1,1,0];
	regions[47] = [0,1,1,1,0];
	regions[58] = [1,1,1,1,0];			
	regions[100] = [0,0,0,0,1];
	regions[111] = [1,0,0,0,1];
	regions[113] = [0,1,0,0,1];
	regions[115] = [0,0,1,0,1];
	regions[119] = [0,0,0,1,1];
	regions[124] = [1,1,0,0,1];
	regions[126] = [1,0,1,0,1];
	regions[128] = [0,1,1,0,1];
	regions[130] = [1,0,0,1,1];
	regions[132] = [0,1,0,1,1];
	regions[134] = [0,0,1,1,1];
	regions[139] = [1,1,1,0,1];
	regions[143] = [1,1,0,1,1];
	regions[145] = [1,0,1,1,1];
	regions[147] = [0,1,1,1,1];
	regions[158] = [1,1,1,1,1];
//
function resetLog(which) {		//same
	killAll();
	if (which == 1) {
	window.location = '../cgi-bin/lab.pl';
	}
	else if (which == 2) {
	setCookie ('tal','tal');window.location = '../brth_accounting.shtml';
	}
}
function load(file){		//same
	unloadFrame();
	iframe = document.getElementById('frame1');
	if (file == '../brcalg/activity.html' || file == './cgi-bin/brca_transaction.pl' || file == './brca_examrecords.pl') {
	iframe.height = '390px';} 
	iframe.src = file; 
}
function unloadFrame() {		//same
	x = window.frames["frame1"];
	x.document.body.innerHTML = "";
}
function mustLoginMsg() {		//same
	document.getElementById('mustMsg').innerHTML = "<span style='color:red;'><strong>LOGIN ERROR</strong></span> ";
}
function resetLoginMsg() {		//same
	document.getElementById('mustMsg').innerHTML = "";
}
function doExams(who) {
	if (who == 'lab') {
	hide('cookiesOn');show('framebox');show('menuButton');
	document.getElementById('banner').innerHTML = 'Examinations Interpreted';
	load('./brca_examrecords.pl'); return false;
	}
	else if (who == 'acctg') {
	pageReady();hide('loginPage');
	document.getElementById('banner').innerHTML = 'Raw Examination Records';
	load('./cgi-bin/brca_examrecords.pl'); return false;
	}
}
function getNewDate() {
	hide('menuLine3');show('getDateMsg');
}
