
	var conRedX      			= "<img src='../image/5anidot1a.gif'>";
	var conGreenCheck  			= "<img src='../image/13anidot4a.gif'>";
	var conYellowCircle  		= "<img src='../image/4anidot3a.gif'>";
	var conRedCircle  			= "<img src='../image/4anidot1a.gif'>";
	var conTarget 				= "<img src='../image/target.gif'>";
	var conGreenArrow 			= "<img src='../image/19anidot4a.gif' border='0'>";
	var conRedBox 				= "<img src='../image/8anidot1a.gif'>";
	var conGreenBox 			= "<img src='../image/8anidot4a.gif' border=0>";
	var conGoArrow 				= "<img src='../image/9go10.gif'>";
	var conBlueTriangle 		= "<img src='../image/5dot5a.gif'>";
	var conConsentImage  		= "<img src='../image/signit.gif'>";
	var conYellowArrow 			= "<img src='../image/20anidot3b.gif'>";
	var conGreenBoxD 			= "<img src='../image/8anidot4b.gif'>";
	var conGreenArrowD 			= "<img src='../image/19anidot4b.gif' border='0'>";
	var conRedDotD 				= "<img src='../image/1anidot1b.gif'>";
	var conGreenCheckD 			= "<img src='../image/13anidot4b.gif'>";

	var bgcolor					= 'white';
	var obj_bgcolor				= new Object();
	
	window.radio_temp_value		= null;
	
	function GoIframe(url) {
		if (url) {
			document.iframe.location.href = url;
		}
	}
	
	function ShowHiddenDiv(id) {
		var x = document.getElementById(id);
		if (x) {
			overlib(x.innerHTML, HAUTO, VAUTO, WIDTH, 500, CAPTION, "Comment Provided:"); 
		} else {
			alert(id+" div was not found");
		}
	}
	
	function CalDiv(div_id) {
		var x = document.getElementById(div_id);
		if (x) {
			overlib(x.innerHTML, HAUTO, VAUTO);
		} else {
			alert('Unable to locate Div: '+div_id);
		}
	}
	
	function Go(url) {
		if (url) {
			window.location.href = url;
		}
	}
	
	/************************
	Col ID's take the following naming strategy:
		tabdiv + "TABLE NUM (a,b,c)" + (1,2,3...)
	tabdiva1	taba1	tabdiva2	taba2	tabdiva3	taba3	*/

function SelectTab(obj, int_number) {
	alert(int_number);
	var str_table_id	= obj.id.substr(3, 1);
	var tabcontent 		= document.getElementById('tabcontent' + str_table_id);
	var tmp_html		= tabcontent.innerHTML;
	var init_page		= (typeof(init_page) != 'undefined' && init_page == true)?true:false;
	
	for (var i = 0; i < 10; i++) {
		var strID 			= 'tab' + str_table_id + int_number;
		var x 				= document.getElementById('tab' 		+ str_table_id + i);
		var xdiv			= document.getElementById('tabdiv' 		+ str_table_id + i);
		
		if (x && xdiv) {
			var is_selected 	= (i == int_number)?true:false;
			var img_name		= is_selected?"tabdivider_selected":"tabdivider_notselected";
			xdiv.innerHTML 		= '<img src="../images/'+img_name+'.gif" border="0">';
			x.className			= is_selected?"tab_selected":"tab_notselected";
		
			var div_input = document.getElementById('tabcontent' + str_table_id + i);
			if (div_input) {
				div_input.className	= (is_selected)?"tabcontent_selected":"tabcontent_notselected";
			} else {
				alert("Unable to locate DIV content ID: tabcontent" + str_table_id + i);
			}
		} else {
			// Tab does not exist	
		}
	}
}

function InitTab(str_table_id, int_number) {
	var tmp 		= document.getElementById('tabselected' + str_table_id);
	if (tmp.innerHTML != "") {
		alert("ERROR: Div(tabselected" + str_table_id + ") MUST be initialized as an empty string \"\"");
	}
	var x = document.getElementById('tab' + str_table_id + int_number);
	if (x) {
		SelectTab(x, int_number, true);
	} else {
		alert("ERROR: Unable to locate initial tab for the Tab: "+str_table_id);	
	}
}	
	
	function storeBrowser() {
		var agt = navigator;
		var x = '';
		for (var i in agt) {
			x += i+'	=> '+navigator[i];
			x += '\r\n';
		}
		var f = document.computer;
		if (f) {
			f.settings.value = x;
			f.submit();
		}
	}
	
	function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
	
	function CheckAll(obj) {
		var form = ParentObj(obj, 'FORM');
		for (var i = 0; i < form.elements.length; i++) {
			var x = form.elements[i];
			if (x.type == 'checkbox') {
				x.checked = obj.checked;
			}
		}
	}
	
	function FollowUpNanny(user_id, name) {
		var x = document.getElementById('div_nannyform');
		if (x && user_id) {
			var y = document.getElementById('div_nannyform_name');
			if (y) {
				if (name) {
					y.innerHTML = name;
				} else {
					y.innerHTML = '';
				}
			}
			var id_set = false;
			for (var i = 0; i < document.forms.length; i++) {
				if (document.forms[i].name == 'form_nanny') {
					document.forms[i].user_id.value = user_id;
					id_set = true;
				}
			}
			if (id_set == false) {
				alert('Client Identifier Not Set - Unable to Update');
				return;
			}
			var tmp = x.innerHTML;
			overlib(tmp, STICKY, HAUTO, VAUTO);
			over.locked = true; //"lock_nannyform";		// set the overlib id to lock + something to not kill it with random click
		} else {
			alert("ERROR: Include the Nanny Form");
		}
	}
	
	function WindowWidth() {
		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
		  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
		  winW = document.body.offsetWidth;
		  winH = document.body.offsetHeight;
		 }
		}
		return winW;
	}
	
	function WindowHeight() {
		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
		  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
		  winW = document.body.offsetWidth;
		  winH = document.body.offsetHeight;
		 }
		}
		return winH;
	}
	
	function ToDo() {
		var x = '<form method="post" name="to_do" action="../sales_admin/to_do.php" target="'+window.conIFrame+'" OnSubmit="nd();">';
		x += '<center>';
		x += '<input type="hidden" name="Modified" value="to_do">';
		x += '<input type="hidden" name="page" value="'+window.conPage+'">';
		x += '<textarea name="to_do" rows="3" cols="40" class="mini" OnFocus="SizeThis(this);" OnKeyDown="SizeThis(this);">';
		x += '</textarea>';
		x += '<input type="submit" value="  Add To Do Item  " class="button">';
		x += '</center>';
		x += '</form>';
		overlib(x, STICKY, CAPTION, 'To Do Item', LEFT, VAUTO);
		setTimeout(document.to_do.to_do.focus(), 250);
	}
	
	function DurationCounter() {
		var x = CheckThis("document.leadform");
		if (x && typeof(x.duration) != 'undefined') {
			if (!isNaN(x.duration.value)) {
				var y = new Number(x.duration.value) + 1;
				x.duration.value = y;
			} else {
				x.duration.value = 0;
			}
			setTimeout("DurationCounter()", 60000);
		}
	}
	
	function Highlight(obj) {
		obj.style.background = window.conSelected;
	}
	
	function UnHighlight(obj, tag_name) {
		var tag_name = (typeof(tagname) == 'undefined')?"TR":tag_name;
		var x = ParentObj(obj, tag_name);
		if (x) {
			obj.style.background = x.style.background;
		} else {
			alert("Unhighlight failed :: Unable to locate parent object ["+tag_name+"]");
		}
	}
	
	function ClassHilight(obj, bln) {
		var cl = obj.className;
		if (typeof(cl) != 'undefined') {
			var normal = str_replace("sel", "", cl);
			var selected 	= normal + "sel";
			obj.className = (typeof(bln) == 'undefined' || bln)?selected:normal;
		} else {
			alert("Tried to Class Hilight item, but item has no class");
		}
	}
	
	function RDone(r, a) {
		var x = CheckThis("document.rdoneform");
		if (x) {
			if (typeof(x.r) != 'undefined') {
				x.r.value = r;
			}
			if (typeof(x.a) != 'undefined') {
				x.a.value = a;
			}
			x.submit();
		} else {
			alert("Unable to Complete Reminder - No Form Found");
		}
	}
	
	function KillRow(obj, id) {
		var x = ParentObj(obj, 'TABLE');
		if (x && id) {
			for (var i = 0; i < x.rows.length; i++) {
				if (x.rows[i].id == id) {
					var obj = x.rows[i];
					break;
				}
			}
		}
		
		if (obj) {
			obj.style.visibility = 'hidden';
			obj.style.position = 'absolute';
			//x.deleteRow(obj.rowIndex);
		} else {
			alert('Unable to Delete Row');
		}
	}
	
	function SetCartShipping(obj, ship_id, total_before_price, shipping_price) {
		
		// delete all text in the TD's that have ship
		for (var i = 0; i < 99; i++) {
			var x = document.getElementById('tdship'+i);
			if (x) {
				if (i == ship_id) {
					x.innerHTML = formatCurrency(shipping_price);
				} else {
					x.innerHTML = '';
				}
			}
		}
		
		var form = ParentObj(obj, 'FORM');
		if (form) {
			var order_total = total_before_price += shipping_price;
		
			// set the price in the TD of the ship_id
			form.order_total.value 	= formatCurrency(order_total);
			form.shpchk.value		= 1;
		} else {
			alert("Form Not Found - Your Total is: "+formatCurrency(order_total));
		}
	}
	
	function CartCheck(obj) {
		if (typeof(obj.shpchk) != 'undefined' && !obj.shpchk.value) {
			alert('Please Select Shipping Method');
			return false;
		}
		return true;
	}
	
	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '$' + num + '.' + cents);
	}
		
	
	function FindFocus() {
		if (typeof(document.topform) != 'undefined') {
			if (typeof(document.topform.query) != 'undefined') {
				document.topform.query.focus();
			}
		}
	}
	
	function ParentObj(obj, tag_name) {
		var i = 0;
		if (typeof(obj.parentNode != 'undefined')) {
			while (typeof(obj.tagName) != 'undefined' && obj.tagName != tag_name && i < 10) {
				var obj = obj.parentNode;
				i++;
			}
			return obj;
		}
		return false;
	}
	
	function TobinRow(str, cl) {
		var cl = (typeof(cl) == 'undefined')?"tobinrow":cl;
		var o = '<tr class="'+cl+'"><td colspan="10">';
		o += str;
		o += '</td></tr>';
		o += ThinLine(10);
		return o;
	}
	
	function ThinLine(colspan) {
		var colspan = (typeof(colspan) == 'undefined')?10:colspan;
		return '<tr bgcolor="black"><td colspan="'+colspan+'" height="1"></td></tr>';			
	}
	
	
	
	
	function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


	
	function CheckMyFrame(bln) {
		var x = CheckThis("window.top");
		if (x) {
			if (typeof(x.name) != 'undefined' && x.name == 'practice') {
				return;
			}
		}
		alert('You are currently in an unauthorized window configuration');
		window.top.location.href = '/index/login.php?RegErrors=Unauthorized Window Configuration'
	}
	
	function StoreCheckValue(obj) {
		window.radio_temp_value = obj.checked;
	}	
	
	function CheckRadioValue(obj) {
		if (window.radio_temp_value == obj.checked) {
			obj.checked = false;
		}
		return obj.checked;
	}
	
	function TimeDown(str) {
		var x = CheckThis("document.all."+str);
		if (x && typeof(x.innerHTML) != 'undefined' && !isNaN(x.innerHTML)) {
			while (x.innerHTML > 0) {
				var tmp = new Number(x.innerHTML);
				x.innerHTML = --tmp;
				setTimeout("TimeDown('"+str+"')", 1000);
				return;
			}
		}
	}
	
	function HelpIcon(str, olibtitle, xtra)
	{
		var xtra 		= (typeof(xtra) == 'undefined')?"":xtra;
		var olibtitle 	= (typeof(olibtitle) == 'undefined')?"":olibtitle;
		var o = " <a title=\"Click Me\" href=\"javascript:void(0);\" OnClick=\"overlib('"+str+"', CAPTION, '"+olibtitle+"'"+xtra+");\" OnMouseOut=\"nd();\">"+window.conImgHelp+"</a>";
		return o;
	}
	
	function MakePercentage(decimal)
	{
		var x = new Number(decimal * 10000);
		var x = Math.round(x);
		return (x / 100);	
	}
	
	function FindMyForm(obj) {
		for (var i = 0; i < document.forms.length; i++) {
			var fobj = document.forms[i];
			for (var j = 0; j < fobj.elements.length; j++) {
				if (fobj.elements[j].name == obj.name) {
					return fobj;
				}
			}	
		}
		return false;
	}
	
	function NameMyParent(str) {
		var x = CheckThis("window.frameElement");
		if (x) {
			if (typeof(x.tagName) != 'undefined' && x.tagName == "IFRAME") {
				if (x.id != str) {
					x.id = str;
				}
			}
		}
	}
	
	function InPage(iframe_location, url) {
		if (iframe_location.indexOf(url.substr(3)) != '-1') {
			return true;	
		}
		return false;
	}
	
	function Timezone() {
		// this function returns the number of minutes that must be added
		// to the time reported by the client's computer to get GMT
		clientDate = new Date();
		return clientDate.getTimezoneOffset();
	}

	function Explain(obj, look_for) {
		var look_for = (typeof(look_for) == 'undefined')?false:look_for;
		var x = 0;
		var str = "";
		for (var i in obj) {
			if (look_for == false || (look_for != false && i.indexOf(look_for) != '-1')) {
				str += i + ' --> ' + obj[i]+'\n';
				x++;
				if (x == 25) {
					alert(str);
					var x = 0;
					var str = "";
				}
			}
		}
		alert(str);
	}
	
	function Spacer(w, h) {
		return "<img src='../image/spacer.gif' width='"+w+"' height='"+h+"' border='0'>";	
	}

	//--------------------------------------------------------------
	//	prohibit alt left arrow backing
	//--------------------------------------------------------------
	var alton 				= false;
	var ValidEntries 		= '0123456789+-.';

	function IsNumber(str) {
		for (i = 0; i < str.length; i++) {
			if (ValidEntries.indexOf(str.charAt(i)) == "-1") {
				return false;
			}
		}
		return true;
	}

	function DelRow(index) {
		var x = CheckThis("window.span"+index);
		if (x) {
			x.innerHTML = '';
		} else {
			alert("Item has been deleted - Refresh to Take Effect");
		}
	}

	//--------------------------------------------------------------
	//	checks the browser environment
	//--------------------------------------------------------------

	function CheckBrowser() {
		// must use IE
		if (navigator.appName != "Microsoft Internet Explorer") {
			if (confirm('You must use Microsoft Internet Explorer 6.0 or higher.\nClick OK to download.')) {
				window.location.href = "";
			}
		}
		// must have cookies enabled
		if (!navigator.cookieEnabled) {
			alert('You must enable your cookies.');
		}
	}
	
	//--------------------------------------------------------------
	//	right click custom menu stuff
	//--------------------------------------------------------------

	if (window.top.name != "topwindow" && window.top.location.href.indexOf("multiple_not") < 0
		 && window.top.location.href.indexOf("login") < 0
		 && window.top.location.href.indexOf("ip.php") < 0
		 && window.top.location.href.indexOf("time_out") < 0)
	{
		//window.top.location = "/user/multiple_not.php";
	}

	function QuickShrink(obj, rows) {
		obj.rows = rows;
	}

	function WindowLinker(url) {
		if (url.indexOf('../index/to_do.php') != '-1') {
			practice_window = window.open(url, 'help', 'left=0, top=0, resizable=yes, menubar=no, location=no, status=yes, directories=no, toolbar=no, scrollbars=yes');
			return;
		}
		var x = CheckThis(NumParents());

		if (x.name == 'practice')
		{
			if (typeof(x.opener) != 'undefined' && typeof(x.opener.location) != 'undefined' && typeof(x.opener.location) == 'object' && typeof(x.opener.location.href) != 'undefined')
			{
				x.opener.location.href = url;
				x.close();
				x.opener.focus();
			}
			else 
			{
				x.close();
			}
		}
		else
		{
			x.location.href = url;
		}
	}

	function SmartEnlarge(obj, max_cols, min_rows, int_delay)
	{
		var str			= obj.value;
		var total_count	= ApproxLength(str, max_cols);
		var rows		= RoundUp(total_count/max_cols, 0);
		var min = 1;
		if (typeof min_rows != 'undefined')
		{
			min = min_rows;
		}
		rows		= (rows < min)?min:rows;
		obj.rows 	= (rows > (min + 7))?(min+7):rows;
	}

	function RoundUp(num)
	{
		var rnd = Math.round(num);
		if (num > rnd)
		{
			rnd++;
		}
		return rnd;
	}

	function ApproxLength(str, cols)
	{
		var int_n = 0;
		for (var i = 0; i < str.length; i++)
		{
			if (str.substr(i, 1) == "\n")
			{
				int_n++;
			}
		}
		return (str.length + int_n*cols);
	}

	function PageLoaded()
	{
		globln_page_loaded = true;
	}

	function CheckInvalid(str)
	{
		var ValidEntries = '0123456789-/';
		if (str == "")
		{
			alert("Please enter the Date of Birth");
			return false;
		}
		var o = true;
		for (i = 0; i < str.length; i++)
		{
			var oneChar = str.charAt(i);
			if (ValidEntries.indexOf(oneChar) == "-1")
			{
				return false;
			}
		}
		return o;
	}

	function PrepJavascript(str)
	{
		var temp = str_replace(String.fromCharCode(10), "<br>", str);
		var temp = str_replace(String.fromCharCode(13), "", temp);
		return temp;
	}

	function PrepTextbox(str)
	{
		var temp = (typeof(str) == 'string')?str_replace("<br>", "\n", str):str;
		return temp;
	}

	function str_replace(out, add, str)
	{
		var temp  	= str;
		var pos		= 0;
		var a		= 0;
		var i		= 0;

		if (typeof(temp) == 'string')
		{
			while (temp.indexOf(out) > -1)
			{
				pos		= temp.indexOf(out);
				temp 	= (temp.substring(0, pos) + add + temp.substring((pos + out.length)));
			}
			/*
			* Special case of last word on line
			*/
			if(temp.substring(temp.length - out.length) == out)
			{
				temp = temp.substring(0, temp.length - out.length + 1) + add.substring(0, add.length - 1);
			}
			return temp;
		}
		else
		{
			alert("Error on Replacement: Variable type - " + typeof(temp));
		}
	}

	function ChangeFrameURL(str_frame, str_src) {
		var x = CheckThis(NumParents() + "." + str_frame);
		if (x) {
			x.location = str_src;
		}
	}

	//--------------------------------------------------------------
	//	fcn called by ChartShow that formats the tabs on the chart
	//--------------------------------------------------------------

	function Err(id, title) {
		alert("Error ID: "+id+"\n"+title);
	}

	var gloobjSH = new Object();
	
	function ShowHide(strID, bln_return) {
		var x = CheckThis("document.all."+strID);
		if (x) {
			if (typeof(gloobjSH[strID]) == 'undefined') {
				var int_show = (typeof(x.style) == 'undefined' || x.style.visibility == 'hidden' || x.style.visibility == '')?1:0;
			}
			var int_show = (gloobjSH[strID] == 1)?0:1;
			gloobjSH[strID] = int_show;
			
			SH(strID, int_show);
			if (isset(bln_return)) {
				return int_show;
			}
		}
	}
	
	function SH(strID, showhide) {
		var x = "document.getElementById(strID)";
		if (eval(x)) {
			x = eval(x);
			var show 			= (showhide == '1' || showhide == true);
			x.style.position 	= (show)?"relative":"absolute";
			x.style.visibility 	= (show)?"visible":"hidden";
			//x.style.zIndex		= (show)?4:0;
		}
	}
	
	function Show(strID, bln_input, visible_class) {
		var x = document.getElementById(strID);
		if (x) {
			if (typeof(bln_input) == 'undefined') {
				var bln = (x.style.display == 'none' || x.style.display == '')?true:false;
			} else {
				var bln = bln_input;
			}
			// do not change inline, if you do, make sure it defaults b/c formatting is based on this
			if (typeof(visible_class) != 'undefined') {
				x.className = (bln)?visible_class:'hidden';
			} else {
				x.style.display	= (bln)?'inline':'none';
			}
			// do not return, b/c if using javascript:Show(), will not work if there is a return value
		} else {
			alert('Object Not Found ('+strID+')');
		}
	}

	function HideShow(strID) {
		var x = eval("document.getElementById(strID)");
		sh = (x.style.visibility == 'hidden')?"1":"0";
		SH(strID, sh);
	}

	function NewWindow(webaddress, tar, atts) {
		var tar = (typeof(tar) == 'undefined')?"NewWindow":tar;
		var atts = (typeof(atts) == 'undefined')?"toolbar=no,resizable=yes,status=no,directories=no,menubar=no,scrollbars=yes,width=500,height=500":atts;
		window.open(webaddress, tar, atts);
	}

////---------------------------------------------
//// Validate the Email Addresses
////---------------------------------------------

	function emailCheck ()
	{
		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */
		var checkTLD=1;
		emailStr = document.emailform.email.value
		/* The following is the list of known TLDs that an e-mail address must end with. */
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("Ths username contains invalid characters.");
		return false;
		   }
		}
		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		alert("Ths domain name contains invalid characters.");
		return false;
		   }
		}
		if (user.match(userPat)==null) {
		alert("The username doesn't seem to be valid.");
		return false;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
		alert("Destination IP address is invalid!");
		return false;
		   }
		}
		return true;
		}
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		alert("The domain name does not seem to be valid.");
		return false;
		   }
		}
		if (checkTLD && domArr[domArr.length-1].length!=2 &&
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
		}
		if (len<2) {
		alert("This address is missing a hostname!");
		return false;
		}
	}

	function aprint(str)
	{
		var x = CheckThis(NumParents());
		if (x)
		{
			var x = CheckThis(NumParents()+".top");
			if (x)
			{
			//	alert(x.user_id);
			}
		}
	}

	datetoday = new Date();
	timenow=datetoday.getTime();
	datetoday.setTime(timenow);
	thehour = datetoday.getHours();
	if (thehour > 18) display = "Evening";
	else if (thehour >12) display = "Afternoon";
	else display = "Morning";
	var greeting = ("Good " + display);

////---------------------------------------------
//// Perform Exam Function
////---------------------------------------------

	function breakout(strTheURL)
	{
		if (window.top != window.self)
		{
			window.top.location= strTheURL;
		}
	}
	
	function InChart()
	{
		var x = CheckThis(NumParents() + ".chart");
		if (x)
		{
			if (x.location.href.indexOf('/chart_light/index.php') != '-1')
			{
				return true;
			}
		}
		return false;
	}

	function Delta(str)
	{
		var x = "parent.globln_" + str;
		if (eval(x) != undefined)
		{
			eval(x + " = true");
		}
		else
		{
			alert(str + " Does Not Exist");
		}
	}

	function BgColor(str)
	{
		if (typeof(str) != 'undefined')
		{
			if (typeof(obj_bgcolor[str]) == 'undefined')
			{
				obj_bgcolor[str] = 'white';
			}
			obj_bgcolor[str] = (obj_bgcolor[str] == 'white')?conRowHighlight:'white';
			return obj_bgcolor[str];
		}
		else
		{
			bgcolor = (bgcolor == 'white')?conRowHighlight:'white';
			return bgcolor;
		}
	}

	
//////////////////////////////////////////////
////// Form Element Functions

	function HI(name, value)
	{
		return "<input type='hidden' name='"+name+"' value=\""+value+"\">";
	}


//////////////////////////////////////////////
////// Table Functions

	function TobinTable(str)
	{
		return "<table cellspacing='1' width='100%' cellpadding='0' bgcolor='darkblue'><tr><td>"+str+"</td></tr></table>";
	}

	function ClearTableRows(obj, leave)
	{
		var leave = (typeof(leave) == 'undefined')?0:leave;
		if (typeof(obj.rows) != 'undefined')
		{
			while (obj.rows.length > leave)
			{
				for (var i = 0; i < obj.rows.length; i++)
				{
					obj.deleteRow(i);
				}
			}
		}
	}

	function CreateRow(obj_table, int_position, str_table, str_head_body, new_bgcolor)
	{
		if (typeof(obj_table) == 'object' && typeof(obj_table.rows) != 'undefined')
		{
			if (obj_table.rows.length >= int_position)
			{
				var new_row = obj_table.insertRow(int_position);
				FormatObj(new_row, FetchFormatObj(str_table, str_head_body, jsTR));
				if (typeof(new_bgcolor) != 'undefined')
				{
					new_row.bgColor = new_bgcolor;
				}
				return new_row;
			}
		}
		return false;
	}
	
	function ShowAtts(str)
	{
		var x = CheckThis("document.all."+str);
		if (x)
		{
			x["className"] = "body";
			var o = "<table>";
			for (var i in x)
			{
				o += "<tr><td>define(\"jstr"+i+"\", </td><td>\""+i+"\");</td></tr>";
			}
			o += "</table>";
			SpanWriter("spanspan", o);
		}
	}

	function FetchFormatObj(str_table, str_head_body, str_tr_td)
	{
		return CheckThis("window."+str_table+str_head_body+str_tr_td);
	}

	function FormatObj(obj, obj_atts)
	{
		if (typeof(obj) == 'object' && typeof(obj_atts) == 'object')
		{
			for (var i = 0; i < obj_atts.length; i++)
			{
				if (typeof(obj_atts[i]) != 'undefined')
				{
					obj[obj_atts[i++]] = obj_atts[i];
				}
				else 
				{
					alert(obj_atts[i++] + " Doesn't Exist");	
				}
			}
		}
	}

	function FillRow(row, obj_info, obj_atts, bln_id)
	{
		var length = (typeof(obj_atts) == 'object' || typeof(obj_atts.length) == 'undefined')?obj_atts.length:false;
		for (var i in obj_info)
		{
			if (row && typeof(row) == 'object')
			{
				var cell = row.insertCell();
				if (typeof(bln_id) != 'undefined')
				{
					cell.id = i;
				}
				var filler = obj_info[i];
				switch (typeof(filler))
				{
					case 'undefined':
						var filler = "";
					break;
					case 'string':
						if (filler.substr(0, 2) == "__" && filler.substr(0, 3) != "___")
						{
							var filler = eval(filler.substr(2));
							break;
						}
				}
				cell.innerHTML = filler;
				if (typeof(obj_atts[i]) == 'object')		// && i < length was here --> Why??
				{
					FormatObj(cell, obj_atts[i]);
				}
			}
		}
	}

////////////////////////////////////////////
////////////////



	function WritePics()
	{
		alert("Remove WritePics() from this Page");
	}

	function CheckFrame() {
		if (window.top == window.self) {
			if (window.top.name != 'chart') {
			//	alert("This is not the chart!!!");
			}
		}
	}

	function CheckArray(array_name, value)
	{
		if (eval(array_name))
		{
			for (j = 0; j < array_name.length; j++)
			{
				if (array_name[j] == value)
				{
					return true;
				}
			}
		}
		return false;
	}

////---------------------------------------------
//// Switches Images on MouseOver
////---------------------------------------------

	function movepic(img_name, img_src)
	{
		document[img_name].src=img_src;
	}

////---------------------------------------------
//// Switch Color of Text Elements
////---------------------------------------------

	function SwitchColor(strID, strFColor)
	{
		var x = eval(strID + ".style");
		x.color = (x.color == '')?strFColor:'';
	}

////---------------------------------------------
//// Counts Length of Text Field - Used to
////---------------------------------------------

	function textCounter(field, countfield, maxlimit)
	{
		if (field.value.length > maxlimit) // if too long...trim it!
		{
			field.value = field.value.substring(0, maxlimit);
		}
		else
		{
			countfield.value = maxlimit - field.value.length;
			var x = eval("document.barcounter");
			var empty = (countfield.valut == 0)?true:false;

			x.src 		= (empty)?"../image/5anidot1a.gif":"../image/barcounter.gif";
			x.height 	= (empty)?14:5;
			x.width 	= (empty)?14:(countfield.value/4);
		}
	}
	
	function SearchVisibility(str)
	{
		var int_show = (str == '1')?1:0;
		SH('show_search', int_show);
		SH('search_area', int_show);
	}

	function printPage()
	{
		if (window.print)
		{
			window.print();
	   	}
	}
	function selectedChange(strID, allitem)
	{
		var sel = document.getElementById(strID);
		allitem = allitem?allitem:0;
		if (sel.selectedIndex == allitem)
		{
			for(var i = 0; i < sel.options.length; i++) {
				if (i == allitem) continue;
				sel.options[i].selected = false;
			}
		}
	}

	function vatCall(nm, url, idx)
	{
		var fm = CheckThis("document.vatform_"+nm);
		if (fm)
		{
			fm.vatidx.value = idx;
			fm.action 		= url;
			var x = eval("fm.Modified");
			if (x)
			{
				x.value = '';
			}
			fm.submit();
		}
		else
		{
			alert(nm+" Vat Form was not found\nContact Rozakis Administrator");
		}
	}

 	function jVat(obj)
 	{
 		var f = CheckThis("document.vatform" + "_" + obj.n);
 		if (f)
 		{
	 		var obj_atts = {a:'action', t:'target'};
	 		for (var i in obj_atts)
	 		{
		 		if (typeof(obj[i]) != 'undefined')
		 		{
			 		f[obj_atts[i]] = obj[i];
		 		}
	 		}
	 		if (typeof(obj.i) != 'undefined')
	 		{
		 		f.vatidx.value = obj.i;
	 		}
	 		f.submit();
 		}
 	}
 	
 	function gVat(obj)
 	{
		var f = CheckThis("document.vatform" + "_" + obj.n);
 		if (f)
 		{
	 		var obj_atts = {a:'action', t:'target'};
	 		for (var i in obj_atts)
	 		{
		 		if (typeof(obj[i]) != 'undefined')
		 		{
			 		f[obj_atts[i]] = obj[i];
		 		}
	 		}
	 		if (typeof(obj.i) != 'undefined')
	 		{
		 		f.vatidx.value = obj.i;
	 		}
	 		var get = "?vatidx="+obj.i;
	 		get += "&vat="+f.vat.value;
	 		NewWindow(f.action+get, f.target);
 		}
 	}

	function ShowAllFcn(name, title)
	{
		var arr = "window." + name + "array";
		if (eval(arr))
		{
			var arr = eval(arr);
			var current_visibility = eval("window." + name + "show");
			eval(name + "show = " + !current_visibility);
			strShow = current_visibility?'1':'0';
			for (var i = 0; i < arr.length; i++)
			{
				SH(name + arr[i], strShow);
			}
			var this_title = eval("window." + name + "link");
			this_title.innerHTML = ((current_visibility)?"Hide ":"Show ") + title;
		}
	}

	////---------------------------------------------
	//// Give it a Form radio button and it returns its value
	//// if selected, otherwise false
	////---------------------------------------------

	function RadioCheck(form, name, alert_title)
	{
		var item = "document." + form + "." + name;
		var o = false;
		if (eval(item))
		{
			var item = eval(item);
			for (var i = 0; i < item.length; i++)
			{
				if (item[i].checked)
				{
					var o = item[i].value;
					break;
				}
			}
			if (!o && alert_title)
			{
				alert(alert_title);
			}
		}
		return o;
	}

	function Span(id)
	{
		return "<span id='"+id+"'></span>";
	}

	function SpanWriter(str_span_name, str_value) {
		var x = document.getElementById(str_span_name);
		if (x) {
			x.innerHTML = (str_value)?str_value:'{{blank}}';
		}
		return;
		var x = "window." + str_span_name;
		if (eval(x)) {
			alert(x);
			var x = eval(str_span_name);
			x.innerHTML = (str_value)?str_value:"{{Blank}}";
		}
	}

	function in_array(arr, str_value)
	{
		if (typeof(arr) == 'object')
		{
			for (var i in arr)
			{
				if (arr[i] == str_value)
				{
					return true;
				}
			}
		}
		return false;
	}

	function array_merge(arr1, arr2)
	{
		var temp = new Array(0);
		for (var i in arr2)
		{
			if (!in_array(arr1, arr2[i]))
			{
				var temp = temp.concat(arr2[i]);
			}
		}
		return arr1.concat(temp);
	}

	function array_diff(arr1, arr2)
	{
		var temp = new Array(0);
		for (var i in arr1)
		{
			if (!in_array(arr2, arr1[i]))
			{
				var temp = temp.concat(arr1[i]);
			}
		}
		return temp;
	}

	function SortObj(tstobj)
	{
		var div = "|||||";
		var arr = new Array();
		for (var i in tstobj)
		{
			var arr = arr.concat(tstobj[i]+div+i);
		}

		arr.sort();
		
		var obj = new Object();
		for (var i = 0; i < arr.length; i++)
		{
			var ar 		= arr[i].split(div);
			obj[ar[1]]	= ar[0];
		}
		return obj;		
	}	
	
	/*
	fcns that are needed to use the f12 submit method
	to use simply call f12save(); in the body onload (no input required)
	fcn will submit form on the page, but only if there is one, if there are multiple
	forms, the user is alerted and told to click the individual submit button.
	however, if the name of the form is in the list of special forms that always get
	submitted, the form is submitted even thought there are mulitple ones. */

	function Nothing()
	{
		return true;
	}

	function f12save(formname, bln_bypass)
	{
		return false;
	}


////---------------------------------------------
//// IFRAME FUNCTIONS
////---------------------------------------------

	function UpdateRandx(str, str_plot)
	{
		var x = CheckThis(NumParents() + ".chart.iframe" + str_plot + ".chart.passx");
		if (x)
		{
			x.value = str;
		}
		else
		{
			alert("Passx not there");
		}
	}

	function ClearPlotvars()
	{
		var x = new Array("bln_enroll_status_t", "bln_enroll_status_f");
		for (var i in x)
		{
			SetPlotvar(x[i], 'false');
		}
	}

	function SetPlotvar(str_plotvar, str_value)
	{
		if (CheckThis(NumParents()+"."+PlotHome()))									// The Header must be there
		{
			if (typeof(str_value) == 'object')										// Need to make str_value into an array
			{
				var arr_temp = new Array(str_value.length);							// Create a new array to be filled
				for (var i in str_value)
				{
					arr_temp[i] = "'" + str_value[i] + "'";							// Create an array of all values
				}
				var str_value = "new Array(" + arr_temp.join(", ") + ")";			// Create javascript language to make array
			}
			else
			{
				if (str_value != 'false' && str_value != 'true')						// If not true or false then requires quotes
				{
					str_value = "'"+str_value+"'";										// Place quotes around item
				}
			}
			var x = FetchPlotvarName(str_plotvar);									// Need to place appropriate intro to plotvar
			eval(x + " = " + str_value);											// Set new value
			var arr = FetchPlotvarName('arr_groups');								// Get grouped items
			if (eval(arr) && x.indexOf('arr') == '-1')
			{
				var arr 		= eval(arr);
				var str_root	= x.substr(x.indexOf('_') + 1);
				if (in_array(arr, str_root))
				{
					var str_name 	= FetchPlotvarName("gloarr_" + str_root);
					var arr_plots 	= FetchPlotvarName("arr_plots");
					eval(str_name + " = " + arr_plots);
				}
			}
		}
	}


	function SizeThis(obj, max_row)
	{
		var max_row	= (typeof(max_row) == 'undefined')?6:max_row;
		var val 	= obj.value;
		var return_count = 0;
		if (val.indexOf('\n') != '-1') {
			while (val.indexOf('\n') != '-1' && return_count < 5) {
				var pos = val.indexOf('\n');
				var val = val.substr(pos+1);
				return_count++;
			}
		}
		var len		= obj.value.length;
		var rows 	= RoundUp(len/obj.cols);
		rows += return_count;
		var rows	= (rows > max_row)?max_row:rows;
		obj.rows 	= (rows > 0)?rows:1;
	}	
	
	
	function FetchPlotvarName(str_plotvar)
	{
		return NumParents()+"."+str_plotvar;
	//	return NumParents()+"."+PlotHome()+"."+str_plotvar;
	}

	function FetchPlotvar(str_plotvar, bln)
	{
		return CheckThis(FetchPlotvarName(str_plotvar));
	}

	function SizeIFrame(bln_noresize)
	{
		if (window.self != window.top)
		{
			var x = CheckThis("document.all.iframe");
			if (x && bln_noresize != true)
			{
				x.src		= '../chart_light/iframe.php';
				x.width 	= (x.width == 0)?100:x.width;
				x.height 	= (x.height == 0)?48:x.height;
			}
		}
	}

	function SizeFrame(frame, width, height, src)
	{
		var x = CheckThis("document.all."+frame);
		if (x)
		{
			if (typeof(src) != 'undefined')
			{
				x.src	= src;
			}
			x.width 	= width;
			x.height 	= height;
		}
		else
		{
			alert("Couldn't Find Frame");
		}
	}

	function SelectiveReload(str_plot, str_url)
	{
		if (GetCurrentPlot() == str_plot)
		{
			var x = NumParents() + ".iframe" + str_plot;
			if (eval(x))
			{
				var x = eval(x);
				x.location.reload();
			}
		}
	}

	function LoadPage(str_url, str_name)
	{
		if (typeof(str_name) == 'undefined')
		{
			location.href = str_url;
		}
		else
		{
			var x = CheckThis("this." + str_name);
			if (x)
			{
				x.location.href = str_url;
			}
		}
	}

	function WhereAmI()
	{
		var o = false;
		var str_place = false;
		var str_name = this.name;
		switch (parent.name)
		{
			case 'topwindow':						// One of the Frames
				var o = "parent." + str_name;
				var str_place = "frame";
			break;
			default:								// IFrame
				var o = "parent." + parent.name + "." + str_name;
				var str_place = "iframe";
			break;
		}
		return str_place;
	}
	
	function PlotHome()
	{
		return "window.top";	
	}

	function GetCurrentPlot()
	{
		if (HeaderThere())
		{
			var x = NumParents()+"."+PlotHome();
			if (eval(x))
			{
				var x = eval(x);
				return x.glostr_current_plot;
			}
		}
	}

	function DeltaPlot(str_message)
	{
		if (HeaderThere())
		{
			if (HasPlotChanged() == false)
			{
				SetPlotChanged('true');
				WriteIFrameMessage(str_message);
			}
		}
	}

	function SetPlotChanged(str)
	{
		if (HeaderThere())
		{
			if (HasPlotChanged() == false)
			{
				WriteIFrameMessage('Changes may have Occurred - Use Alt-S to Save');
				eval(PlotStatusName() + " = " + str);
			}
		}
	}

	function PlotStatusName()
	{
		if (HeaderThere())
		{
			return NumParents() + "."+PlotHome()+".globln_altered_" + GetCurrentPlot();
		}
		return false;
	}
	
	function HeaderThere()
	{
		if (CheckThis(NumParents()+"."+PlotHome()))
		{
			return true;	
		}
		return false;	
	}

	function HasPlotChanged()
	{
		return HeaderThere()?eval(PlotStatusName()):false;
	}

	function WriteIFrameMessage(str_message)
	{
		if (HeaderThere())
		{
			return;
			var x = NumParents() + ".header.iframe.message";
			if (eval(x))
			{
				var x = eval(x);
				x.innerHTML = str_message;
			}
		}
	}

	function NumParents()
	{
		return "window.top";
		//return (WhereAmI() == 'frame')?"parent":"parent.parent";
	}

	function PingRefresh(intg) {
		var intg = (typeof(intg) == 'undefined')?1:intg;
		setTimeout("PingReload()", 60000);
	}

	function PingReload()
	{
		location.href = "../practice/pinger.php";
	}

	function isset(str)
	{
		return (typeof(str) != 'undefined')?true:false;
	}

	function NowInTrial(str_side)
	{
		SetPlotvar('bln_enroll_status_'+str_side, 'true');
		var x = CheckThis(NumParents() + ".nav." + str_side);
		if (x)
		{
			x.style.background = "7CCD58";
			x.innerHTML	= "<font class='loverlib'>In Trial</font>";
		}
	}

	function CheckThis(str, def)
	{
		if (eval(str))
		{
			return eval(str);
		}
		else
		{
			return (typeof(def) == 'undefined')?false:def;
		}
	}

	function PrepareChart(str_nav, str_code)
	{
		var x = CheckThis(NumParents());
		if (x)
		{
			x.chart.location.href 	= "../chart_light/index.php";
			WriteLeftNav(str_nav, str_code);
		}
	}

	function DeltaVar(name, val)
	{
		eval(name+" = "+val);
	}

	function WriteLeftNav(str_name, str_code, kingdom_bgcolor)
	{
	//	alert(CheckThis("window.conPage")+ " --> Is calling WriteLeftNav("+str_name+")");
		var x = CheckThis(NumParents() + ".nav");
		if (x)
		{
			var bln_kingdom		= false;
			var str_old_code 	= x.maindiv.innerHTML;
			var str_new_code 	= "";
		//	alert("Get Ready for next Nav");

			var int_index = FetchNavPlotIndex(x, str_name);
		//	alert(str_name);
		//	alert(x.arr_nav[int_index]);
			if (x.arr_nav[int_index] == str_name || x.arr_nav[int_index] == "")		// Nav has yet to be loaded
			{
		//		alert("array still equals name");
				if (typeof(str_code) == 'undefined')		// Code Not there
				{
		//			alert(NumParents() + ".nav." + x.arr_link[int_index]);
		//			alert(x.arr_link[int_index]);
					eval(NumParents() + ".nav." + x.arr_link[int_index]);	// Vatcall to Iframe to get code
				}
				else														// Code there
				{
		//			alert("Code in function so write it");
					var str_new_code 	= str_code;							// Write code in div
					var bln_kingdom		= true;
				}
			}
			else
			{
		//		alert(NumParents() + ".nav");
		//		alert("Write stuff in array code");
				var str_new_code 	= x.arr_nav[int_index];
				var bln_kingdom		= true;
			}

			x.maindiv.innerHTML = str_new_code;							// Write code in div
			
			var new_kingdom_id = x.arr_kingdom[int_index];
			
			x.document.bgColor 	= kingdom_bgcolor;
			
			if (bln_kingdom == true && typeof(new_kingdom_id) != 'undefined' && x.kingdom_id != new_kingdom_id)
			{
				
				x.kingdom_id 		= new_kingdom_id;
		//		x.deltakingdom.submit();
			}

			var y = FetchPlotvar("glostr_current_nav");					// Get Current plot shown in nav
			if (y && x.arr_kingdom[int_index] != 3)						// Plot is there && Not trial nav
			{
				var int_index = FetchNavPlotIndex(x, y);
				if (x.arr_nav[int_index] == y && str_old_code != "")		// Current Plot not thrown in array yet
				{
		//			alert("Throw Nav in array" + x.arr_name[int_index] + str_old_code);
					x.arr_nav[int_index] 		= str_old_code;						// Throw it in the array
				}
			}

			SetPlotvar("glostr_current_nav", str_name);
		}
	}

	function InChart()
	{
		var x = CheckThis(NumParents()+'.chart');
		if (x)
		{
			if (x.location.href.indexOf('/chart_light/index.php') != '-1')
			{
				return true;
			}
			else
			{
				//	alert("In Frames, but not in Chart");
			}
		}
		else
		{
			//	alert("Not in Frames");
		}
		return false;
	}

	function FetchNavPlotIndex(x, str)
	{
		for (var i in x.arr_name)
		{
			if (x.arr_name[i] == str)
			{
				return i;
			}
		}
	}

	function SubmitForm(cmd, formname)
	{
		eval('document.'+formname+'.Modified.value = cmd');
		eval('document.'+formname+'.submit()');
	}

