<!--




//BEGIN FUNCTION
//findScrollTop() takes 0 arguments, uses the DOM to find the distance scrolled and return it<!--

function findScrollTop() {
	
		if (window.pageYOffset) {

			var blah = window.pageYOffset;
			return (blah);
		}
		else if (document.body.scrollTop) {
			return document.body.scrollTop;
		}
		else {
		return(100);
	}
	
}


//Functions added by Craig McCoy 1/10/06
//BEGIN FUNCTION
//checkstring(field,error) takes 2 arguments, the current field usually passed as (this)
//and an error to output




function checkstring (field, error)
{

if (!field.value) return false;

   var iChars = "*|,\":<>[]_/;{}`\';()=+&$#%";

   for (var i = 0; i < field.value.length; i++) {
      if (iChars.indexOf(field.value.charAt(i)) != -1){
         alert( error );
    	field.focus();
    	field.select();
    	return false;
    	}
   }
   return true;
}
function checknumber (field, error)
{
if (!field.value) return false;
var iChars = "*|,\":/<>[]{}`\';()=_+&$#%-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";

   for (var i = 0; i < field.value.length; i++) {
      if (iChars.indexOf(field.value.charAt(i)) != -1){
         alert( error );
    	field.focus();
    	field.select();
    	return false;
    	}
   }
   return true;
}
//END FUNCTION






function validateEmail(objField) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (!objField.value.match(re)) {
		alert("Invalid email address");
		objField.focus();
		objField.select();
		return (false);
	} else {
		return true;
	}
}

// No rightclick script v.2.5
// (c) 1998 barts1000
// barts1000@aol.com
// Don't delete this header!
var message="Sorry. The images and code on this page are protected by copyright."; // Message for the alert box

// Don't edit below!

function click(e) {
	if (document.all) {
		if (event.button == 2) {
			alert(message);
			return false;
		}
	}
	
	if (document.layers) {
		if (e.which == 3) {
			alert(message);
			return false;
		}
	}
}

/*
	Right-click prevention currently disabled
	10/10/2003
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;
*/

// These Functions should be assigned
// to the onFocus() and onBlur() methods,
// respectively. GH_Highlight() creates
// a red border around the selected object,
// and GH_Obscure returns the object to
// its original state, as defined by the 
// style class .textbox (located in 
// "/include/sitestyle.css"

function addToFavorites(argVal) {
	var bookData = new Array();
	bookData = argVal.split("|");

	if (document.all) {
		window.external.AddFavorite(bookData[0], bookData[1]);
	} else {
		alert("Sorry. Netscape users must bookmark the pages manually by hitting <Ctrl-D>");
	}
}


function testAlert(strText) {
	alert(strText);
}

function GH_openFrames(strMenu, strContent) {
	parent.submenu.location.href=strMenu;
	parent.content.location.href=strContent;
}

function GH_Highlight(objName) {
	objName.style.borderColor = "#FF0000";
	objName.style.borderStyle = "solid";
	objName.style.borderWidth = "4px";
}

function GH_Obscure(objName) {
	objName.style.borderColor = "#000000";
	objName.style.borderStyle = "solid";
	objName.style.borderWidth = "1px";
}


// Looks to drop-down list, for planid to jump to
// creates URL and jumps
function quickJumpPlanEdit() {
	var strURL = "/admin/plan_edit.php?planid=";
	var intIndex = document.form1.selQuickjump.selectedIndex;
	var planID = document.form1.selQuickjump.options[intIndex].value;
	strURL = strURL + planID;
	location.href=strURL;
}

// Form Checking Functions

/*
	function: GH_checkLength
	parameters: form name, field name, descriptive name for field, required length
	action: checks to see if value of field length meets
	requirements. 
	returns: onSuccess() - blank string
			onError() - descriptive text.
*/
function GH_checkLength(frmName, objName, strFieldName, intMinLength) {
	oField = eval("document." + frmName + "." + objName);
	strFieldValue = new String(oField.value);
	if ((strFieldValue.length < intMinLength) || ((intMinLength == -1) && (strFieldValue.length == 0))) {
		if (intMinLength == -1) {
			strError = strFieldName + " cannot be left blank.\n";
		} else {
			strError = strFieldName + " must be at least " + intMinLength + " characters in length.\n";
		}
		
		return strError;
	} else {
		return "";
	}
}

function GH_addToFavorites(planid) {
	strURL = "/admin/addtofavorites.php?planid=" + planid;
	MM_openBrWindow(strURL, 'wndAddFav', 'width=150,height=95');
}

function GH_prevClicked() {
	document.form1.intStartAt.value = document.form1.tempPrevStartAt.value;
	document.form1.submit();
}

function GH_nextClicked() {
	document.form1.intStartAt.value = document.form1.tempNextStartAt.value;
	document.form1.submit();	
}

/*
// Popup Image Handler, form step through handler
function GH_prevClicked() {
	document.form1.intPos.value = document.form1.tempPrevStartAt.value;
	document.form1.submit();
}

function GH_nextClicked() {
	document.form1.intPos.value = document.form1.tempNextStartAt.value;
	document.form1.submit();	
}
*/

// function and code to enable popup image display
var imgDynamic = new Image();
imgDynamic.src = "/images/themes/vendor_root/clearbox.gif";

function GH_printImage() {
	// retrieve info from image
	var strImgSrc = document.imgDynamic.src;
	var intImgWidth = document.imgDynamic.width;
	var intImgHeight = document.imgDynamic.height;
	
	var strURL = "/printImage.php?imgurl=" + strImgSrc;
	
	MM_openBrWindow(strURL,'imgPrint','scrollbars=auto,width=' + intImgWidth + ',height=' + intImgHeight);
	MM_showHideLayers('popupImg','','hide');
}

function GH_loadImage(strImgURL) {
	// update image src
	document.imgDynamic.src = strImgURL;
	
	// reset position to default
	var oImg = MM_findObj('popupImg');
	oImg.style.left = '0px';

	oImg.style.top = findScrollTop() + "px";
	
	// show image layer
	MM_showHideLayers('popupImg','','show');
}

function GH_moveObject(objName, intLeft, intTop) {
	// get object
	oObj = MM_findObj(objName);
	
	// set left, right
	oObj.style.left = intLeft;
	oObj.style.top = intTop;
}

// A Function to give focus to the passed
// object

function GH_GiveFocus(frmName, objName) {
//	objForm = eval("document." + frmName);
	objElement = eval("document." + frmName + "." + objName);
	objElement.focus();
}

// GH modified to auto-center the popup window

function MM_openBrWindow(theURL,winName,features) { //v2.0
	var startpos, endpos, intWidth, intHeight, top, left, length;
	
	// Get Width
	startpos = features.indexOf("width=") + 6;
	endpos = startpos;
	
	while ((features.charCodeAt(endpos) >= 48) && (features.charCodeAt(endpos) <= 57)) {
		endpos++;
	}

	intWidth = features.substring(startpos, endpos);

	// Get Height
	startpos = features.indexOf("height=") + 7;
	endpos = startpos;
	
	while ((features.charCodeAt(endpos) >= 48) && (features.charCodeAt(endpos) <= 57)) {
		endpos++;
	}
	
	intHeight = features.substring(startpos, endpos);
	
	// Now determine top and left positions (centering) based on height and width
	top = (screen.height - intHeight) / 2;
	left = (screen.width - intWidth) / 2;
	
	features += ", top=" + top + ", left=" + left;
	
  	return window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Retrieves Parent URL,
// refreshes it and closes the current window
function GH_RefreshOpener(page) {

		// Refresh Opener
		var newURL = page;
		opener.location.href = newURL;
		
		// Close Current Window
		window.close();	
}

function GH_CheckPass(field1, field2, frmName) {
	// Get Values of Objects and compare
	objElement1 = eval("document." + frmName + "." + field1);
	objElement2 = eval("document." + frmName + "." + field2);
	
	objVal1 = objElement1.value;
	objVal2 = objElement2.value;
	
	if (objVal1 == objVal2) {
		objForm = eval("document." + frmName);
		objForm.submit();
	} else { 
		alert("Password Fields Don't Match");
		GH_GiveFocus(frmName, field1);
	} 
}

function GH_setText(frmName, frmField, strText) {
	objTarget = eval("document." + frmName + "." + frmField);
	
	objTarget.value = strText;
}

/* 	
	Function: Formats the following fields:
	social; dob; state; email; 
	
	If lnLglGuard == "yes", then requires that
	grdFname && grdLname != ""
	
	Action: If everything's fine, submits the form,
	otherwise, displays popup with details
*/
 
 function GH_ValidateAddUser(frmName) {
	var blnError, strError, strSocial, strDOB, strState, strEmail;
	var strBlnLglGuard, strGrdFname, strGrdLname;
	var intSelected, intValue;
	
	blnError = 0;
	strError = "";
	
	// get form object
	objForm = eval("document." + frmName);
	
	// Determine User Type and Proceed
	intSelected = objForm.userlevel.selectedIndex;
	intValue = objForm.userlevel[intSelected].value;
	
	switch (parseInt(intValue)) {
		case 5 :	// Client User
		
			
			
			// get needed values
				strSocial = new String(objForm.social.value);
				strDOB = new String(objForm.dob.value);
				strState = new String(objForm.state.value);
				strEmail = new String(objForm.email.value);
				strGrdFname = new String(objForm.grdFname.value);
				strGrdLname = new String(objForm.grdLname.value);
				
				
				// Format Social
					// 	first, remove all non-numeric characters
					var	strSocialTemp = new String();
					strSocialTemp = "";
					// alert("strSocial.length: " + strSocial.length);
					for (i = 0; i < strSocial.length; i++) {
						if ((strSocial.charCodeAt(i) <= 57) && (strSocial.charCodeAt(i) >= 48)) {
							// alert("strSocial.charCodeAt(" + i + "): " + strSocial.charCodeAt(i));
							strSocialTemp += strSocial.substr(i,1);
							// alert("strSocialTemp: " + strSocialTemp);
						}
					}
					
					// now Check length
					if (strSocialTemp.length != 9) {
						strError = strError + "Social Security Number not formatted properly: xxx-xx-xxxx\n";
						blnError = 1;
					} else {
						// length ok, now format it and assign it to the form field
						objForm.social.value = strSocialTemp.substr(0,3) + "-" + strSocialTemp.substr(3,2) + "-" + strSocialTemp.substr(5,4);
					}
					
					
				// Format DOB
					// 	first, remove all non-numeric characters
					var	strDOBTemp = new String();
					strDOBTemp = "";
					for (i = 0; i < strDOB.length; i++) {
						if ((strDOB.charCodeAt(i) <= 57) && (strDOB.charCodeAt(i) >= 48)) {
							strDOBTemp += strDOB.substr(i,1);
						}
					}
					
					// now Check length
					if (strDOBTemp.length != 8) {
						strError = strError + "DOB not formatted properly: xx/xx/xxxx\n";
						blnError = 1;
					} else {
						// length ok, now format it and assign it to the form field
						objForm.dob.value = strDOBTemp.substr(0,2) + "/" + strDOBTemp.substr(2,2) + "/" + strDOBTemp.substr(4,4);
					}
					
				// Format State
					if (strState.length != 2) {
						strError = strError + "You must enter a two-character state code.\n";
						blnError = 1;
					} else {
						objForm.state.value = strState.toUpperCase();
					}
				
				// Check Legal Guardian Status
			
					if (objForm.blnLglGuard[0].checked) {
						// First name and last name can't be null
						if ((strGrdFname.length == 0) || (strGrdLname.length == 0)) {
							strError = strError + "Legal Guardian first name and last name must be completed.\n";
							blnError = 1;
						}
					}		
					
			 	
				// Check length on all of these fields to make sure they're not blank
				var arrFields = new Array("Fname", "Lname", "address", "city", "state", "zip");
										  // "phone1", "phone2", "phone3");
										  
				for (i = 0; i < arrFields.length; i++) {
					objField = eval("document." + frmName + "." + arrFields[i]);
					strField = new String(objField.value);
					if (strField.length == 0) {
						strError = strError + arrFields[i] + " cannot be left blank.\n";
						blnError = 1;
					}
				}
			
				// Make sure one of two radio buttons is checked in the following fields
				var arrFields = new Array("gender", "blnSMI", "blnActive");
				for (i = 0; i < arrFields.length; i++) {
					objField = eval("document." + frmName + "." + arrFields[i]);
					if (!objField[0].checked && !objField[1].checked) {
						strError = strError + arrFields[i] + ": must select either 'yes' or 'no'.\n";
						blnError = 1;
					}
				}
				
			break;		
				
		
		case 4 :	// FMH User, email required
		
			// Check length on all of these fields to make sure they're not blank
			var arrFields = new Array("Fname", "Lname", "username", "password", "email");
									  
			for (i = 0; i < arrFields.length; i++) {
				objField = eval("document." + frmName + "." + arrFields[i]);
				strField = new String(objField.value);
				if (strField.length == 0) {
					strError = strError + arrFields[i] + " cannot be left blank.\n";
					blnError = 1;
				}
			}		
		
			break;
			
		default :	// All Other Users

			// Check length on all of these fields to make sure they're not blank
			var arrFields = new Array("Fname", "Lname", "username", "password");
									  
			for (i = 0; i < arrFields.length; i++) {
				objField = eval("document." + frmName + "." + arrFields[i]);
				strField = new String(objField.value);
				if (strField.length == 0) {
					strError = strError + arrFields[i] + " cannot be left blank.\n";
					blnError = 1;
				}
			}		

			break;
	}
	
	
		
	// Check to see if error flag has been set and prompt or submit accordingly
	
		if (blnError == 1) {
			alert(strError);
		} else {
			objForm.submit();
		}
			
}

/* 
	Used on Form 1
*/

function GH_updateLayout() {

	// look at current usertype, then display or hide 
	// appropriate sections
	
	// retrieve selected index of iv_reviewtype
	var intSelected, intValue;
	blnShowVIII = '0';
	intSelected = document.form1.userlevel.selectedIndex;
	intValue = document.form1.userlevel[intSelected].value;
	
	switch (parseInt(intValue)) {
		// alert(blnSMI);
		case 5 :
			// Client Level User
			MM_showHideLayers('layerLogin', '', 'hide');
			MM_showHideLayers('layerAddInfo', '', 'show');
			break;

		default :
			// All other users
			MM_showHideLayers('layerLogin', '', 'show');
			MM_showHideLayers('layerAddInfo', '', 'hide');
			break;
			
	}	
}


function ActiveBG(srcElement, Type) {
	if (Type == 0)
	{
	   if(srcElement.bgColor == "#CCCCCC")
	  {
   	   srcElement.bgColor = "#999999";
	  }else{
   	   srcElement.bgColor = "#CCCCCC";
	  }
	}else{
	   if(srcElement.bgColor == "#CCCCCC")
	  {
   	   srcElement.bgColor = "#999999";
	  }else{
   	   srcElement.bgColor = "#CCCCCC";
	  }	
	}
}

// *************************************
// MENU FUNCTIONS
// *************************************
	function layer_enter (id, parentid)
	{
		if (parentid == -1) { // Not a Sub-Menu
			on_layer_id = id;
		} else {	// Sub-Menu
			on_layer_id = parentid;
			on_sublayer_id = id;
		}
	}
	
	function layer_exit (id, parentid)
	{
		if (parentid == -1) { // Not a Sub-Menu
			on_layer_id = - 1;
			setTimeout("hide(\"" + id + "\")", delay/5);	
		} else {
			on_sublayer_id = - 1;
			setTimeout("hidesub(\"" + id + "\")", delay/5);
			buff_id = parentid;
			on_layer_id = -1;
			setTimeout("hide(\"" + parentid + "\")", delay);
		}
	}
	function menu_enter (id, parentid)
	{
		// Immediately Hides another menu and submenu if they're visible
		if (buff_id != -1)
			hide (buff_id);
		if (buff_sub_id >= 0)
			hidesub (buff_sub_id);
	
		// Displays Menu That We've just entered
		if (parentid == -1) {
			show (id);
			active_layer_id = id;
		} else {
			// Show Sub-menu
			show (id);
			active_sublayer_id = id;
			
			// Show Main Menu
			show (parentid);
			active_layer_id = parentid;
		}
	}
	function menu_exit (id, parentid)
	{
		
		
		if (parentid == -1) { // Not a Sub-Menu
			// setTimeout ('hide('+ id +')', delay);
			// setTimeout (hide("'" + id + "'"), delay);
			setTimeout("hide(\"" + id + "\")", delay);
			buff_id = active_layer_id;
			active_layer_id = -1;	
		} else { // Sub-Menu
			setTimeout ("hide(\"" + id + "\")", delay);
			buff_sub_id = active_sublayer_id;
			active_sublayer_id = -1;
			
			// Handle Parent Menu
			setTimeout ("hide(\"" + parentid + "\")", delay);
			buff_id = active_layer_id;
			active_layer_id = -1;
			
		}
		
		
	
	}
	function show (id)
	{
		MM_showHideLayers(id,'','show');
	} 
	function hide (id)
	{
		if (active_layer_id != id && on_layer_id != id)
		{
			// alert("id: " + id);
			MM_showHideLayers(id,'','hide');
		}
	}
	
	
	function hidesub (id)
	{
		if (active_sublayer_id != id && on_sublayer_id != id)
		{
			MM_showHideLayers(id,'','hide');
		}
	}
	
// *************************************
// NEW MENU FUNCTIONS
// *************************************	
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function tdBGEnter(target) {
	target.style.backgroundColor='#D5904B'
}

function tdBGExit(target) {
	target.style.backgroundColor='#F2EED3';
}

function tdEnter(target) {
	target.style.backgroundColor = "#E3DFC3";
	target.style.border = "1px solid #50441F";
	target.style.color = "#000000";
}

function tdExit(target) {
	target.style.backgroundColor = "";
	target.style.border = "1px solid #666632";
	target.style.color = "#F2EED3";
}

// Define menu object
function menuObj(layerName) {
	this.name = layerName;
	this.parent = -1;
	this.arrChildren = new Array();
	this.blnDisplayed = false;
	this.blnOnChild = false;
	this.blnOnLayer = false;
	this.delay = 500;
	this.headerCell = null;
}

// Add child to menu object
menuObj.prototype.addChild = function(childObj) {
	this.arrChildren.push(childObj);
	childObj.parent = this;
}

// Show this item
menuObj.prototype.show = function(targetCell) {
	MM_showHideLayers(this.name,'','show');
	this.blnDisplayed = true;
	
	if (targetCell != null) {
		this.headerCell = targetCell;
		tdEnter(this.headerCell);
	}
	
	// Hide Siblings
	if (this.parent != -1) {
		for (var i = 0; i < this.parent.arrChildren.length; i++) {
			if (this.parent.arrChildren[i] != this) {
				this.parent.arrChildren[i].hide();
			}
		}
	}
}

// Hide this item
menuObj.prototype.hide = function() {
	// Hide Self and children if not on layer
	if (!this.blnOnLayer && !this.blnOnChild) {
		MM_showHideLayers(this.name,'','hide');
		this.blnDisplayed = false;	
		
		if (this.headerCell != null) {
			tdExit(this.headerCell);
		}
		
		// hide all children
		// alert("arrChildren.length: " + this.arrChildren.length);
		
		for (var i = 0; i < this.arrChildren.length; i++) {
			// alert("hide[" + i + "]: " + this.arrChildren[i].name);
			this.arrChildren[i].hide();
		}		
	}	
}

// Mark layer as entered
menuObj.prototype.enter = function() {
	this.blnOnLayer = true;
	this.parent.blnOnChild = true;
}

function hideMenuObj(targetName) {
	// alert("hideMenuObj(" + targetName + ")");
	for (var i = 0; i < mnuObjTop.arrChildren.length; i++) {
		if (mnuObjTop.arrChildren[i].name == targetName) {
			mnuObjTop.arrChildren[i].hide();
		}
	}
}

// Note layer as exited
menuObj.prototype.exit = function() {
	this.blnOnLayer = false;
	this.parent.blnOnChild = false;
	// alert("this.delay: " + this.delay);
	// alert("this.name: " + this.name);
		
	setTimeout("hideMenuObj('" + this.name + "')", this.delay);
	setTimeout("hideMenuObj('" + this.parent.name + "')", this.delay);
}

// Trace menu object

menuObj.prototype.trace = function(intLevel) {
	if (intLevel == null)
		intLevel = 0;
	
	var strOutput = "";
	
	for (var i = 0; i < intLevel; i++) {
		strOutput += '    ';
	}
	strOutput += '>' + this.name + '\n';
	for (var i = 0; i < this.arrChildren.length; i++) {
		strOutput += this.arrChildren[i].trace(intLevel +1);	
	}
	
	if (this.parent == -1) {
		alert(strOutput);
	} else {
		return strOutput;
	}
}
// *************************************
// END NEW MENU FUNCTIONS
// *************************************	


	
// -->
