var here = "trace marker";


var formerror = "Your request could not be submitted. Please enter the following required information and resubmit.\t\t\n\n";



var browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) : navigator.appVersion);
var ie  = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
var ie4 = (document.all)?true:false;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var mac = (navigator.platform.toLowerCase().indexOf("mac") != -1);
var ns  = (navigator.appName.toLowerCase().indexOf("netscape") != -1);
var NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4")
var ns4 = (document.layers)?true:false;
var ns6 = (document.getElementById&&!document.all)?true:false;
var win = (navigator.platform.toLowerCase().indexOf("win") != -1);

//'=============================================================================================
//' FUNCTION: _int( numaric value $num)
//'	PURPOSE: alias to the javascript parseInt function. returns 0 if the value doesn't resulve to a number
//'	
//'	ARGUMENTS: $num as string/int
//'	RETURNS: INT
//' EXAMPLE: _int("123")// 123; _int("abc") // 0
//'	AUTHOR: Scott McDonald : echo@voxecho.com
//'	VERSION: 1.0
//'=============================================================================================
	function _int($num){return (!parseInt($num))?0:parseInt($num);}
//'=============================================================================================

/************************************************************************************
FUNCTION: selectedRadio(Object $obj)
PURPOSE: returns the index of the radio series which is selected

ARGUMENTS: Radio Object
RETURNS: INT
EXAMPLE:
	// HTML radio list
	<input type="radio" name="radio1" value="1" />
	<input type="radio" name="radio1" value="2" />
	<input type="radio" name="radio1" value="3" /> // this one is selected
	<input type="radio" name="radio1" value="4" />
	<input type="radio" name="radio1" value="5" />
	
	selectedRadio(MM_findObj("radio1")) // 2 (remember indexes start counting at 0 so 1 = 0,  2 = 1, 3 = 2
	
AUTHOR: Scott McDonald
VERSION: 1.0
DEPENDENCIES: MM_findObj()
************************************************************************************/
	function selectedRadio($obj){
		for(var $i=0;$i<$obj.length;$i++){
			if($obj[$i].checked) return $i;
		}
		return false;
	}
	
	function radiovalue($obj){
		for(var $i=0;$i<$obj.length;$i++){
			if($obj[$i].checked) return $i;
		}
		return -1;
	}
	
/************************************************************************************/


/*******************************************************************
		FUNCTION:		addValue
		PURPOSE: 		Adds item/value to a select list
		AUTHOR:			Adapted from script found on internet by Scott McDonald
		VERSION: 		1.1
		LAST EDIT:		Wednesday, December 29, 2004
		RETURNS:		bool
		ARGUMENTS: 
			oName:		object name
			fName:		form name
			newText:		display text
			newValue:		tag value
			keepValue:	
						false = will highlight new last item in list
						true 	= will remain highlighted on item selected when this function is called
						
			fillTop:		true will fill in empty top option, best used for selection boxes with multiple listed
			allowDupes	
						false (default) : will not allow duplicate entries (compared on display text)
						true : will allow duplicate entries (compared on display text)
						
			illegalText	[array] array of strings that can not be added to the select list. if only one value
						it may be passed as a string (NOT CASE SENSITIVE)
	*******************************************************************
*/



function addValue(oName,fName,newText,newValue,keepValue,fillTop,allowDupes,illegalText,verbose){ // add a value to a select list.
	var nv = (newValue)?newValue:"-1";
	verbose = (typeof(verbose)=="undefined")?true:verbose;
	var sl = 0;
	if(typeof(illegalText)=="string") {
		if(illegalText.toLowerCase() == newText.toLowerCase()){
			if(verbose) alert("\"" + newText + "\" is invalid.");
			return false;
		}
	} else if(typeof(illegalText)=="object"){
		for(var i = 0;i<illegalText.length;i++){
			if(typeof(illegalText[i])=="string" && illegalText[i].toLowerCase() == newText.toLowerCase()){
				if(verbose) alert("\"" + newText + "\" is invalid.");
				return false;
			}
		}
	}
	
	if(!allowDupes){
		// we're not allowing duplicate entires in the select list, so we need to loop through the 
		// existing items and make sure that none match. This is a case insensitive option, so all 
		// comparisons will be done in lowercase
		for(var i = 0; i < document[fName][oName].length;i++){
			if(document[fName][oName].options[i].text == newText){
				if(verbose) alert("Duplicate entries not allowed");
				return false;
			}				
		}		
	}
	
	if(newText){
		if((document[fName][oName].length>0)&&(fillTop)){
			if(document[fName][oName].options[0].text == ""){
				document[fName][oName].options[0].text = newText;
				document[fName][oName].options[0].value = nv;
			} else {
				document[fName][oName].length ++;
				sl = document[fName][oName].length;
				document[fName][oName].options[sl-1].text = newText;
				document[fName][oName].options[sl-1].value = nv;					
			}
		} else {
			document[fName][oName].length ++;
			sl = document[fName][oName].length;
			document[fName][oName].options[sl-1].text = newText;
			document[fName][oName].options[sl-1].value = nv;
		}
		if(!keepValue){
			document[fName][oName].selectedIndex = sl-1;
		}
		return true;
	} else {
		if(verbose) alert('No value set.');
		return false;
	}
}

	/*
	******************************************************************
		FUNCTION:		deleteSelect
		PURPOSE: 			deletes value from select list
		AUTHOR:			Adapted from script found on internet by Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
			oName:			object name
			fName:			form name
	*******************************************************************
*/

function deleteSelect(oName,fName,$warning) { 
  sl = document[fName][oName].selectedIndex;
  
  
  if (document[fName][oName].options[sl].value==".none"){alert("Please select an Item first.");return false;}
  if ($warning!="NONE") {
	  if(!confirm("CAUTION:\nThis will delete the selected Item." + (($warning)?$warning:""))) {
		  return false;
	  }
  }
  
  if(document[fName][oName].options[sl].text.toUpperCase()!="RECIPES IN CATEGORY"){
	  if (sl != -1 && document[fName][oName].options[sl].value > "") {		
		 if (document[fName][oName].length==1) {
			document[fName][oName].options[0].text="";
			document[fName][oName].options[0].value=".none";
		 } else {
			document[fName][oName].options[sl]=null;
		 } 
		 return true;
	}
  } else {
	 alert("This item cannot be deleted.");
	 return false;	  
  }
}

	/*
	******************************************************************
		FUNCTION:		updateSelect
		PURPOSE: 			Change selected item in select list
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
			oName:			object name
			fName:			form name
			nText:			New text to display
			nVal:				[optional] new value for the <option value=
			EXCLUDE: 	if the passed field has the current value of the $EXCLUDE value, then the
									field cannot be changed
	*******************************************************************
*/

function updateSelect(oName,fName,nText,nVal,$EXCLUDE){ 
	if((nText!="")&&(document[fName][oName].length>0)){
 		sl = document[fName][oName].selectedIndex;
 		if(document[fName][oName].options[sl].text != $EXCLUDE){
			if(nText) document[fName][oName].options[sl].text = nText;
			if(nVal) document[fName][oName].options[sl].value = nVal;
			return true;
		} else {
			 alert("This item cannot be altered.");
			 return false;	  
		}
	} else if(document[fName][oName].length==0){
		alert('There are no items to alter.');
		return false;		
	} else {
		alert('please enter a value.');
		return false;
	}
}


	/*
	******************************************************************
		FUNCTION:		ff_orderSelect
		PURPOSE: 			Moves items in select box list shift possistion as long as the 
										button is pressed.
		SPECIAL INSTRUCTIONS FOR USE:
										When button is pressed, the variable $ff_order is assigned the 
										timeout which loops the function on it'self put in the onmouseout 
										"clearTimeout($ff_order)" which will stop the loop.
										
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
				down: direction of travel in the list
							0: up
							1: down
			oName: object name
			fName: form name
			
		SUPPORTING VARIABLE:
			$ff_order: object pointer which holds the setTimeout while function is looping.
	*******************************************************************
*/

var $ff_order = 1; // sets up the variable for orderSelect.
function ff_orderSelect(down,oName,fName,$EXCLUDE) { // fast forward function for recipemanagement
	sl = document[fName][oName].selectedIndex; // find selected index in list
	if (sl != -1 && document[fName][oName].options[sl].value > "") { // if something is selected, and is not empty
		// call the function which actually does the moving.
		orderSelect(down,oName,fName,$EXCLUDE); 
		// count to 50 milliseconds, and loop
		$ff_order = setTimeout("ff_orderSelect("+down+",'"+oName+"','"+fName+"')",50); 
		return true;
	} else {
		alert('you must select an item to move.');
		return false;
	}
}


	/*
	******************************************************************
		FUNCTION:		orderSelect
		PURPOSE: 			Moves items in select box list once per click
		AUTHOR:			Taken from online form/ modified for use by Scott McDonald
		VERSION: 			2.0
		LAST EDIT:		April 2004
		RETURNS:			bool
		ARGUMENTS: 
				down: direction of travel in the list
							0: up
							1: down
			oName: object name
			fName: form name
	*******************************************************************
*/

function orderSelect($down,$oName,$fName,$EXCLUDE) { 
	// moves Categories, Subcategories, and recipes up and down in a list
	if(typeof($oName)!="object"){var $obj = document[$fName][$oName];} else {$obj = $oName;}
  	$sl = $obj.selectedIndex;
  
  if($obj.options[$sl].text==$EXCLUDE || $obj.options[$sl].value==$EXCLUDE){alert("This item cannot be altered.");return false}
  if ($sl != -1 && $obj.options[$sl].value > "") {
	 $oText = $obj.options[$sl].text;
	 $oValue = $obj.options[$sl].value;
	 if ($obj.options[$sl].value > "" && $sl > 0 && $down == 0) {
		if($obj.options[$sl-1].text==$EXCLUDE){alert("This item cannot be moved into that position.");return false}
		$obj.options[$sl].text = $obj.options[$sl-1].text;
		$obj.options[$sl].value = $obj.options[$sl-1].value;
		$obj.options[$sl-1].text = $oText;
		$obj.options[$sl-1].value = $oValue;
		$obj.selectedIndex--;
	 } else if ($sl < $obj.length-1 && $obj.options[$sl+1].value > "" && $down == 1) {
		if($obj.options[$sl+1].text==$EXCLUDE){alert("This item cannot be moved into that position.");return false}
		$obj.options[$sl].text = $obj.options[$sl+1].text;
		$obj.options[$sl].value = $obj.options[$sl+1].value;
		$obj.options[$sl+1].text = $oText;
		$obj.options[$sl+1].value = $oValue;
		$obj.selectedIndex++;
	 }
	 return true;
  } else {
	 alert("Please select an item first.");
	 return false;
  }
}

/*
******************************************************************
	FUNCTION:		throwStyle
	PURPOSE: 			Sends new value, to a style of an object
	AUTHOR:			Scott McDonald
	VERSION: 			1.0
	LAST EDIT:		Friday, July 19, 2002 
	RETURNS:			none
	ARGUMENTS: 
		throwTo: 			Object to send style value to.
		throwAt:			Name of style that will be changed.	
		throwWhat:		Value to send to style.
		
	EXAMPLE OF USE:	
		throwStyle("divLayer","visibility","hide");
*******************************************************************
*/		
	function throwStyle(throwTo,throwAt,throwWhat,$index){ 
		$index = ($index>=0)?$index:-1;
		// If browser is IE set up document.all to work without locating object
		if (!document.all&&document.getElementById){document.all = document.getElementsByTagName("*")}		
		// setting up location for NN
		if(document.layers) throwObj = ($index>=0)?document.layers[throwTo][$index]:document.layers[throwTo];
		// setting up location for IE
		if(document.all) throwObj = ($index>=0)?document.all[throwTo][$index].style:document.all[throwTo].style;
		// send value to the objects style
		throwObj[throwAt]=throwWhat;	
	}
	
	function moveLayer(strLayerName, intX, intY){
		throwStyle(strLayerName,"top",intY);
		throwStyle(strLayerName,"left",intX);
		return;
	}

	function browser(){
		if (!document.all&&document.getElementById){document.all = document.getElementsByTagName("*")}
		// setting up location for NN
		if(document.layers) return "nn";
		// setting up location for IE
		if(document.all) return "ie";
	}

/*
******************************************************************
	FUNCTION:		getStyle
	PURPOSE: 			gets value from the style of an object
	AUTHOR:			Scott McDonald
	VERSION: 			1.0
	LAST EDIT:		Friday, July 19, 2002 
	RETURNS:			style value
	ARGUMENTS: 
		throwTo: 			Object to send style value to.
		throwAt:			Name of style that will be changed.	
		
	EXAMPLE OF USE:	
		alert(getStyle("divLayer","visibility"));
*******************************************************************
*/	

	function getStyle(throwTo,throwAt){
		if((throwTo)&&(throwAt)){ // insure that all arguments are not null
			if (!document.all&&document.getElementById){document.all = document.getElementsByTagName("*")}
			if(document.layers)throwObj = document.layers[throwTo];
			if(document.all)throwObj = document.all[throwTo].style;
			return throwObj[throwAt];	
		} // --> end if((throwTo)&&(throwAt))
		return false;
	}
	
	/*
	******************************************************************
		FUNCTION:		showHide
		PURPOSE: 			makes a layer visible or invisible
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Friday, July 19, 2002 
		RETURNS:			none
		ARGUMENTS: 
			obj: 			layer name
			objDir:							
				1 = force visible
				2 = force invisible
				0 = toggle vis/invis
			
		EXAMPLE OF USE:	
			showHide("divLayer",1);
	*******************************************************************
*/	

function showHide(obj,objDir) {
	var flipObj;
	if (!document.all&&document.getElementById){document.all = document.getElementsByTagName("*")}
	ns4 = (document.layers)? true:false;
	ie4 = (document.all)? true:false;
	objArray = obj.split(",");
	if (ns4){_hide="hide";_visible="show"}else{_hide="hidden";_visible="visible"}
	for (var i = 0; i < objArray.length; ++i){
		if(ns4){flipObj = document.layers[objArray[i]];}
		if(ie4){
			try {flipObj = document.all[objArray[i]].style;}
			catch(e) {}
		}
		if(flipObj==undefined) {
			alert("Can not find object " + objArray[i]);
			continue;
		}
		
		if(objDir==0) {
			flipObj.visibility=_hide
		} else if(objDir==1){
			flipObj.visibility=_visible
		} else {
			flipObj.visibility==_hide? flipObj.visibility=_visible:flipObj.visibility=_hide;
		}
	}
}
	/*
	******************************************************************
		FUNCTION:		alterText
		PURPOSE: 			will change the content of any name/id DIV
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
			obj:			Object name
			newText:	New text/html to insert into the div
	*******************************************************************
*/
// THIS  MUST HAVE MMSCRIPT.JS INCLUDED TO WORK
function alterText(obj,newText){ 
	if((elem = MM_findObj(obj))!=null){
		elem.innerHTML = newText;
	}
}

	/*
	******************************************************************
		FUNCTION:		getInner
		PURPOSE: 			return the value of any name/id DIV
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			string
		ARGUMENTS: 
			obj:			Object name
	*******************************************************************
*/

function getInner($obj){ // get the value of an DIV
	if((elem = MM_findObj($obj))!=null){
		return(elem.innerHTML);
	}
}

function gi($obj){
	return getInner($obj);
}

/*
	******************************************************************
		FUNCTION:		removeSpaces
		PURPOSE: 			removes multiple spaces and carrage returns from any string
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			string
		ARGUMENTS: 
			$val string value to alter
	*******************************************************************
*/

function removeSpaces($val){ 
	while($val.indexOf('\n')!=-1){$val = $val.replace(/\n/," ");}
	while($val.indexOf('\t')!=-1){$val = $val.replace(/\t/," ");}
	while($val.indexOf('\r')!=-1){$val = $val.replace(/\r/," ");}
	while($val.indexOf('  ')!=-1){$val = $val.replace(/  /," ");}
	return $val;
}

/*
	******************************************************************
		FUNCTION:		numOnly
		PURPOSE: 			remove anything but numbers from the field
		AUTHOR:			Scott McDonald
		VERSION: 			2.1
		Revition History:
			Friday, May 02, 2003
				added support for non numaric return (ie: make function do opposite of designed task)
			Wednesday, January 18, 2006
				added support for default value if return string is null - changed third argument 
				to "args" peram to allow for future additions
			
		RETURNS:			string
		ARGUMENTS: 
			$val 		string value to alter
			$add		any chars to add as allowable. e.g if passing a phone number, you might
							add "-" and/or "()" as allowable.
							
			$args : used to add less used arguments
				returnNoneNumeric true : returns anything that isn't a number instead of the numbers
					note: if $args = "true" this will be assumed				
				default : indicates a value to replace if the value is left empty
	*******************************************************************
*/

function numOnly($val,$add,$args){ // returns string stripped of any none number	
	var $returnNoneNumeric = (argVal($args,"returnNoneNumeric")==true||$args=="true"||$args==true)?true:false;
	var $default = (argVal($args,"default"));

	// $add = any charictors to add to the list.
	if(!$add){$add="";} // if the $add variable is NULL then give it an empty string
	if($val){ // if there is a value... 
		var $allowList = "1234567890"+$add; // define the list of allowable chars. 0-9 and any other chars that's been passed
		for(var $i=0;$i < $val.length;$i++){ // loop from char(0) in the string to the last char
			var $g = $val.charAt($i); // get the value of the current char
			
			if((!$returnNoneNumeric && $allowList.indexOf($g)==-1) || ($returnNoneNumeric && $allowList.indexOf($g)!=-1)){  // if the current char is not found in allowable list then ... 
				$val = $val.replace($g,""); // remove all insences of the offending charictor
				$i=-1; // reset the counter to -1
			} // end if
			
		} // loop 
	} // end if
	
	// check to see if there is a default value, if so, and $val == "" then insert the default value;
	if($default&&$val==""){$val = $default;}
	
	return $val;
} // end function

/*
	******************************************************************
		FUNCTION:		sCase
		PURPOSE: 			alters str $val to as close an approximet to sentence case.
										used to stip out "all caps" or odd caps.
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			string
		ARGUMENTS: 
			$val 		string value to alter
	*******************************************************************
*/

function sCase($val){ 
	if($val){
		var $newValue = markReturns($val,1);
		var $arrThisVal =$newValue.split(" ");
		for(var $i=0;$i<$arrThisVal.length;$i++){
			var $foundFirst = 0;
			var $thisWord = $arrThisVal[$i];
			for(var $ii=0;$ii<$thisWord.length;$ii++){
				if((legalAlpha($thisWord.charCodeAt($ii)))&&($foundFirst)){
					var $thisChar = $thisWord.charAt($ii);
					if(isCap($thisWord.charCodeAt($ii))){
						var $a = $thisWord.substring(0,$ii);
						var $b = $thisWord.substring($ii+1,$thisWord.length);
						$thisWord = $a + $thisChar.toLowerCase() + $b;
					}
				} else if((legalAlpha($thisWord.charCodeAt($ii)))&&(!$foundFirst)) {
					$foundFirst = 1;
				}
			}
			if($thisWord != $arrThisVal[$i]){
				 $arrThisVal[$i] = $thisWord;
			}
		}
		$newString = markReturns($arrThisVal.join(" "),0);
		if ($newString != $val){
			return $newString;
		}
	}
	return $val;
}
/*
	******************************************************************
		FUNCTION:		markReturns
		PURPOSE: 			support function used for sCase, putting in or taking out filler text
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
			$text 	value to alter
			$out		wither to put string in dimil form, or take it out of dilim form.
	*******************************************************************
*/

function markReturns($text,$out){ 
	if($out){
		while($text.indexOf('\n')!=-1){$text = $text.replace(/\n/,"``1");}
		while($text.indexOf('\r')!=-1){$text = $text.replace(/\r/,"``2 ");}
	} else {
		while($text.indexOf('``1')!=-1){$text = $text.replace(/``1/,"\n");}
		while($text.indexOf('``2 ')!=-1){$text = $text.replace(/``2 /,"\r");}
	}
	return $text;
}

/*
	******************************************************************
		FUNCTION:		legalAlpha
		PURPOSE: 			returns if given char as a-zA-Z
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
			$char 		char value to check
	*******************************************************************
*/

function legalAlpha($char){ 
	if((($char>=65)&&($char<=90))||(($char>=97)&&($char<=122))){
		return true;
	} else {
		return false
	}
}

/*
	******************************************************************
		FUNCTION:		isCap
		PURPOSE: 			returns if given char is Upper Case
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 
			$char 		char value to check
	*******************************************************************
*/

function isCap($char){
	if(($char>=65)&&($char<=90)){
		return true;
	} else {
		return false
	}
}

/*
	******************************************************************
		FUNCTION:		stripQuotes
		PURPOSE: 			takes quotes out of text fields
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			string
		ARGUMENTS: 
			$val = string to alter
	*******************************************************************
*/

function stripQuotes($val){
	// loop so long as a quote is still found in the room
	while($val.indexOf('"')!=-1){ 
		// change all quote to single quotes (apos)
		$val = $val.replace(/\"/,"'");
	}
	return $val;
}

/*
	******************************************************************
		FUNCTION:		showProperties
		PURPOSE: 			diag function which will show all of the object properties of an element
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			none
		ARGUMENTS: 
			obj = object to list values of
	*******************************************************************
*/
function showProperties(obj,$return) { 
	$obj = (typeof(obj)!="object")?$obj = MM_findObj(obj):obj;
		
	
	var $result = ""   
	for (var $i in $obj) {
		$result += $obj.name + "." + $i + " = " + $obj[$i] + "\n";
	}
	if($return){
		return $result;
	} else {
		trace($result);
	}
}

/*
	******************************************************************
		FUNCTION:		validPhone
		PURPOSE: 			returns if a phone number is valid, and puts it in database freindly order
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			array(
			.val =	re-formatted phone number.
			.st	=	returns if phone number is valid
		)
		ARGUMENTS: 
				$val = string to look at
	*******************************************************************
*/
function isPhone($val){
	var phone = validPhone($val);
	return phone.st;
}

function validPhone($val){ 
	var $return = new Object();
	$val = numOnly($val);
	if($val.length>0){
		var $good = "0123456789";
		var $l = $val.length;
		for(var $i=0;$i<$l;$i++){
			if(($val.charAt(0)==1)||($val.charAt(0)==0)){
				$val = $val.substr(1,$val.length);
				$i=0;
				$l = $val.length;
				continue;
			}
			var $a = $val.substring(0,$i);
			var $z = $val.substring($i+1,$val.length);
			var $g = $val.charAt($i);
			if($good.indexOf($g)==-1){
				$val = "" + $a + "" + $z;
				$i=0;
				$l = $val.length;
			}
		}
		if($val.length==10){
			var $code 	= 	$val.substr(0,3);
			var $pre		=		$val.substr(3,3);
			var $post		=		$val.substr(6,4);
			$return.val = $code+"-"+$pre+"-"+$post;
			$return.valid = true;
			$return.st = true;
		} else {
			$return.valid = false;
			$return.val = $val;
			$return.st = false;
		}
	} else {
		$return.val = "";
		$return.st = true;
		$return.valid = true;
	}
	return $return;
}

//'=============================================================================================
//' FUNCTION: validEmail/isEmail
//'	PURPOSE: looks at the given email address and ditermins if it is valid. the mask is:
//		####@####.#### <-- it will accept as many .'s in both the start and end... but there must be
// 		at least 1 . in the domain.
// example of acceptable
//	scottmac@typensave.com
//	scott.mcdonald@type.n.save.com
// 	[will not accept] scott@typensave
//'
//'	ARGUMENTS:
//'=============================================================================================

	function validEmail($val){return isEmail($val);}
	function isEmail($val){ // check to see if email address is valid
		// set up a list of valid chars for an email address.. if it's not on this list, it's not valid.
		var $validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-._0123456789";
		if($val.length == 0){return false;} // if the email address is empty, return false. 
		var $arrEmail = $val.split("@"); // split the string into an array, at the @ symble
		if($arrEmail.length==2){ // if the array has 2 parts then we're good, keep going
			if(($arrEmail[0].length==0)||($arrEmail[1].length==0)){return false;} // if either part of the address is empty then return [exit] false
			var $name = $arrEmail[0].split("."); // split the name part on it's .'s
			for(var $name_i=0;$name_i<$name.length;$name_i++){ // cycle through each part of the name 
				if($name[$name_i].length==0){ // if it's empty (meaning there was a . at the beginning which isn't valid) then exit false
					return false;
				} else { // there is a value, lets make sure it doesn't have any invalid chars
					for(var $thisChar=0;$thisChar<=$name[$name_i].length;$thisChar++){ // loop through each char of the string
						if($validChars.indexOf($name[$name_i].charAt($thisChar))=="-1") {return false;} // if it's got illegal chars exit false
					} // loop
				} // end if
			} // loop			
			var $dom = $arrEmail[1].split("."); // split the domain on it's .'s
			if($dom.length==1){ // if there is only one index in the array, then there are no dots in the domain.. which means it's invalid
				return false; // exit false
			} else { // has length, check the chars
				for(var $dom_i=0;$dom_i<$dom.length;$dom_i++){ // loop through the different parts of the domain
					if($dom[$dom_i].length==0){ // if any part is 0 length, then...
						return false; // exit false
					} else { // not 0 length, so let's chack the chars
						for(var $thisChar=0;$thisChar<=$dom[$dom_i].length;$thisChar++){ // loop through the chars
							if($validChars.indexOf($dom[$dom_i].charAt($thisChar))=="-1") {return false;} // if any char isn't in the valid list, exit false
						} // loop
					} // end if
				} // loop
			} // end if
		} else { // lendth of email address split on @ is ! 2... 
			return false; // exit false
		} // end if
		return true; // if we get to this point, nothing's wrong with the email addres.. return true.
		} // end function

/*
	******************************************************************
		FUNCTION:		closeThis
		PURPOSE: 			close this window after $time seconds
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			none
		ARGUMENTS: 	
			$i should be set as 0
			$time time in milliseconds before closing the window
			
	*******************************************************************
*/

function closeThis($i,$time){
	if(($i!=1)&&($time)){
		setTimeout("closeThis(1)",$time);							
	} else {
		window.close();
	}
}

/*
	******************************************************************
		FUNCTION:		isZip
		PURPOSE: 			checks $val to see if it's a valid zip code.
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			bool
		ARGUMENTS: 	
			$val string to check
	*******************************************************************
*/

function isZIP($val){
	var $zip = "1234567890-";
	for(var $i=1;$i < $val.length;$i++){
		var $g = $val.charAt($i);
		if($zip.indexOf($g) == -1){return false}
	}
	if ($val.length < 5 && $val.length > 0){
		return false;
	} else if ($val.length > 5 && $val.charAt(5) != "-"){
		return false;
	}
	return (true);
}
function isZip($val){return isZIP($val)}
function validZip($val){return isZIP($val)}
/*
******************************************************************
	FUNCTION:		echo
	PURPOSE: 			alias to document.write
	AUTHOR:			Scott McDonald
	VERSION: 			1.0
	REVISION:		Friday, August 23, 2002
	RETURNS:			nothing
	ARGUMENTS: 	$text - String to write to screen
*******************************************************************
*/
function echo($text,b){document.write($text);if(b){document.write("<br/>");}}




/*
******************************************************************
	FUNCTION: trace
	PURPOSE: Creates output window and sends text to this window for tracing errors. (immulates FLASH output field)
	AUTHOR: Scott McDonald
	RETURNS: VOID
	ARGUMENTS: [String] Output Text
	CREATED: Thursday, October 20, 2005
	VERSION: 1.0
	REVISIONS:
*******************************************************************
*/
// Variable which will hold the window object., This is declaired globally so that 
// the same window will be used no matter how many times the page is reloaded.
var TraceOutputWindow; 
function trace(){	
	if(!TraceOutputWindow){ // look to see if the window is already there, if not, create it
		TraceOutputWindow = window.open("","TraceOutputWindow","width=500,height=500,scrollbars=true");
		TraceOutputWindow.document.write("<title>Trace Output Window</title>");	
		TraceOutputWindow.document.write("<style type=\"text/css\"><!--body,td,th {font-family: Arial, Helvetica, sans-serif;}--></style>");	
		TraceOutputWindow.document.write("<h1 style=\"font-family:Arial, Helvetica\">Trace Output Window</h1><hr/>");	
		TraceOutputWindow.document.write("<form name=\"trace_form\" id=\"trace_form\"><textarea cols=1 rows=1 style=\"width:480;height:400\" name=\"output\" id=\"output\"></textarea></form>");	
	}
	TraceOutputWindow.focus();// Bring the output window into focus
	for(i=0;i<arguments.length;i++){
		TraceOutputWindow.document.trace_form.output.value+=("• " + arguments[i] +"\n"); // write to the output window
	}
}
/********************************************************************/





function getPage(){
	var $url = new String(document.location);
	var $arrUrl = $url.split("/");
	return $arrUrl[$arrUrl.length-1];
}

function mark_error($obj,$error){
	if($error){
		throwStyle($obj,"border",$errorStyle);
	} else {
		throwStyle($obj,"border",$noErrorStyle);
	}	
}

function markIt_Error($obj,$alt,$text){
	if(((agent().win&&agent().msie) && ($obj!='')) || $alt==''){
		throwStyle($obj,"background","FFFFCC");
	} else if($alt!='') {
		alterText($alt,"<font color=\"red\">" + $text + "</font>");
	}
}

function markIt_Back($obj,$alt,$text){
	if(($browser=="win:ie") && ($obj!='')){
		throwStyle($obj,"background","FFFFFF");
	} else if($alt!='') {
		alterText($alt,$text);
	}
}

function markit($obj,$alt,$text,$error){
	markIt($obj,$alt,$text,$error);
}

function markIt($obj,$alt,$text,$error){	
	var $arrObj = $obj.split(",");
	var $arrAlt = $alt.split(",");
	if((agent().win&&agent().msie) && ($obj!='')){
		for(var i=0;i<$arrObj.length;i++){
			throwStyle($arrObj[i],"background",(($error)?"FFFFCC":"FFFFFF"));
		}
	} else if($alt!='') {
		for(var i=0;i<$arrAlt.length;i++){
			alterText($arrAlt[i],(($error)?"<font color=\"red\">" + $text + "</font>":$text));
		}
	}
}

	/*
	******************************************************************
		CLASS:				Invalid List
		PURPOSE: 			tracks the form objects that do not contain valid information
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Wednesday, October 02, 2002

		
	
	*******************************************************************
*/
	function invalidList(){ // object constructor
		this.list = new Array();
		this.inArray = in_array;
		this.add = addInvalid;
		this.drop = removeInvalid;
		this.free = freeToFlee;
		this.error = show_invalid_error;
	}

	function show_invalid_error(){
		//alert(this.free());
		if(!this.free()) { 
			return window.status = 'One or more errors will prevent this form from submitting.' 
		} else { 
			return window.status = '' 
		}
	}
	
	function in_array($value){
		for($i=0;$i<this.list.length;$i++){
			this.error();
			if(this.list[$i]==$value) return true;
		}
		this.error();
		return false;
		
	}
	
	function addInvalid($name){
		if(!this.inArray($name)){
			this.list[this.list.length] = $name;
		}		
	}

	function removeInvalid($value){
		for($i=0;$i<this.list.length;$i++){
			if(this.list[$i]==$value) {
				this.list[$i]="";
			}
		}
		this.error();
	}
	
	function freeToFlee(){
		for($i=0;$i<this.list.length;$i++){
			if(this.list[$i].length>0) {
				return false;
			}
		}
		return true;
	}
	
	
//=============================================================================================
// 	FUNCTION: removePunc($text)
//	PURPOSE: stips puctuation from a given string. currently only looks for periods and commas
//			and whatever is passed in add. 
//	
//	ARGUMENTS: 
//		[String] $text: text string to strip puctuation from
//		[String] $add: anything to add to the strip out list
//	RETURNS: [String] revised string
// 	EXAMPLE: removePunc("this, is not a test.") // this is not a test
//	AUTHOR: Scott McDonald
//	VERSION: 1.0
//	DEPENDENCIES: None
//=============================================================================================

function removePunc($text,$add){
	if(!$add){$add="";}
	var $killString = ",." + $add;
	for(var $i=0;$i<$killString.length;$i++){
		while($text.indexOf($killString.charAt($i))!=-1){
			$text = $text.replace($killString.charAt($i),"");
		}
	}
	return $text;
}

//=============================================================================================

	/*
	******************************************************************
		FUNCTION:		setSelectValue
		PURPOSE: 			set a select list value as "selected"
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Wednesday, October 02, 2002
		RETURNS:			none
		ARGUMENTS: 
			$list:			Object name
			$val:			value to look for, in order to determan which item to select
	*******************************************************************
*/

function setSelectValue($list,$val){	
	var $obj = ((typeof($list)!="object")?MM_findObj($list):$list);
	var $length = $obj.length;
	for(var $i=0;$i<$length;$i++){
		if($obj[$i].value==$val){
			$obj[$i].selected=1;
		}
	}
}
// *******************************************************************
Array.prototype.inArray =  function($value,$index,$caseinsensitive){
	return(inArray(this,$value,$index,$caseinsensitive));
}

if(!Array.prototype.push){
	Array.prototype.push=function(){
		for(var i=0;i<arguments.length;i++){
			this[this.length]=arguments[i];
		};
	};
};

function inArray($array,$value,$index,$caseinsensitive){
	for(var $i=0;$i<$array.length;$i++){
		if($caseinsensitive){
			if($array[$i].toLowerCase()==$value.toLowerCase()) {return (($index)?$i:true);}			
		} else {
			if($array[$i]==$value) {return (($index)?$i:true);}
		}
	}
	return false;
}

function imgWindow($src,$title,$width,$height,$owidth,$oheight){
	$windowName = validHTTPFileString($title);
	$imgWindow = window.open('',$windowName,'width='+$width+',height='+$height);
	$imgWindow.document.write('<html>');
	$imgWindow.document.write('<title>'+$title+'</title>\n');
	$imgWindow.document.write('<script>');
	$imgWindow.document.write('window.focus();');
	$imgWindow.document.write('</script>');
	$imgWindow.document.write('<body\n');
	$imgWindow.document.write('leftmargin=\"0\"\n');
	$imgWindow.document.write('topmargin=\"0\"\n');
	$imgWindow.document.write('marginwidth=\"0\"\n');
	$imgWindow.document.write('marginheight=\"0\"\n');
	$imgWindow.document.write('><table width=100% height=100%><tr><td align=center valign=middle>');
	
	
	if($src.toLowerCase().indexOf(".swf")!=-1){
		$imgWindow.document.write("<object ");
		$imgWindow.document.write("classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" ");
		$imgWindow.document.write("codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" ");
		$imgWindow.document.write("id=\"imgWindowSWF\" ");
		$imgWindow.document.write("align=\"middle\" ");
		if($owidth>0) $imgWindow.document.write("width=\""+$owidth+"\" ");
		if($oheight>0) $imgWindow.document.write("height=\""+$oheight+"\"");
		$imgWindow.document.write(">");
		$imgWindow.document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
		$imgWindow.document.write("<param name=\"movie\" value=\"" + $src + "\" />");
		$imgWindow.document.write("<param name=\"quality\" value=\"high\" />");
		$imgWindow.document.write("<param name=\"bgcolor\" value=\"#ffffff\" />");
		$imgWindow.document.write("<embed ");
		$imgWindow.document.write("src=\"" + $src + "\"");
		$imgWindow.document.write("quality=\"high\" ");
		$imgWindow.document.write("bgcolor=\"#ffffff\" ");
		$imgWindow.document.write("name=\"imgWindowSWF\" ");
		$imgWindow.document.write("align=\"middle\"");
		$imgWindow.document.write("allowScriptAccess=\"sameDomain\" ");
		$imgWindow.document.write("type=\"application/x-shockwave-flash\" ");
		$imgWindow.document.write("pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ");
		if($owidth>0) $imgWindow.document.write("width=\""+$owidth+"\" ");
		if($oheight>0) $imgWindow.document.write("height=\""+$oheight+"\" ");
		$imgWindow.document.write("/></object>");
	} else {
		$imgWindow.document.write('<a href=\"javascript:window.close();\"><img src=\"'+$src+'\" border=\"0\"></a>\n');
	}
	
	
	
	
	
	
	$imgWindow.document.write('</td></tr></table></body>\n</html>\n');
//  if (navigator.appName == 'Netscape') i=40;
//  if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);
//  self.focus();
}

/*
	******************************************************************
		FUNCTION:		validHTTPFileString
		PURPOSE: 			converst a given string into an acceptable HTTP folderName
		AUTHOR:			Scott McDonald
		VERSION: 			1.0
		LAST EDIT:		Monday, July 22, 2002
		RETURNS:			string
		ARGUMENTS: 
			$val string value to alter
	*******************************************************************
*/

function validHTTPFileString($val,$add){ 
	
	var $strAcceptList = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9";
	if($add!=""){$strAcceptList += "," + $add;}
	
	var $goodArray = $strAcceptList.split(",");
	var $valArray = $val.split("");
	for(var $i=0;$i<$valArray.length;$i++){
		if(!inArray($goodArray,$valArray[$i])){$valArray[$i]="";}
	}
	if($valArray[$valArray.length-1]=="."){$valArray[$valArray.length-1]="";}
	return $valArray.join("");
}


	function reloadSpacer(){
		var $spacer =  document.spacer;
		for(var $i=0;$i<$spacer.length;$i++){
			$spacer[$i].src = $spacer[$i].src
		}
	}
	
	function reloadImageArray($imageName){
		if(!$imageName) return false;
		var $spacer =  document[$imageName];
		for(var $i=0;$i<$spacer.length;$i++){
			$spacer[$i].src = $spacer[$i].src
		}
	}
	
	function mixCase($string){ 	
		/* 
		the purpose of this function will be to check that the given string 
		is not all in caps and not all in lower case. It will ignore any none 
		alpha charictors. 
		
		AUTHOR: Scott McDonald
		DATE: Friday, September 12, 2003
		Version: 1.0
		
		Ex. 
		mixCase("JOHN HANCOCK") // returns: FALSE
		mixCase("JOHN 5 HANCOCK") // returns: FALSE
		mixCase("john hancock") // returns: FALSE
		mixCase("JoHn HaNcOcK") // returns: TRUE
		mixCase("John Hancock") // returns: TRUE	
		*/
		
		if(!$string){return;} // jump out if $string has no content
		var $upper = false;
		var $lower = false;
		for(var $i=0;$i<$string.length;$i++){
			var $thisChar = $string.charCodeAt($i);
			if(($thisChar>=65)&&($thisChar<=90)) { $upper = true; }
			if(($thisChar>=97)&&($thisChar<=122)) { $lower = true; }
		}
		return (($upper)&&($lower))?true:false;
}




function agent(){
	result = new Object();
	result.name = "agent()";
	result.appname = navigator.appName + "\n" + navigator.appVersion;
	result.opera = (navigator.appVersion.indexOf("opera")!=-1);
	result.msie = (navigator.appVersion.indexOf("MSIE")!=-1);
	result.netscape = (navigator.appName.indexOf("Netscape")!=-1);
	result.safari = (navigator.appName.toLowerCase().indexOf("safari")!=-1);	
	result.win = (navigator.platform.toLowerCase().indexOf("win")!=-1);
	result.mac = (navigator.platform.toLowerCase().indexOf("mac")!=-1);
	result.ns4 = (document.layers)? true:false;
	result.ie4 = (document.all)? true:false;
	return result;
}

function diagarea($obj,$return,$depth) { 	
	var $result = "";
	var $depth = (!$depth)?0:$depth;
	if(typeof($obj) == "object"){
		for (var $i in $obj) {
			$result += $obj.name + "." + $i + ": "
			if(typeof($obj[$i])=="object") {
				$result += "[object]"  + "\n" + diagarea($obj[$i],1,$depth++);
			} else {
				$result += $obj[$i] + "\n";
			}
		}
	} else {
		$result = $obj;
	}

	if($return){
		return $result;
	} else {
		newWindow = window.open("","newWindow");
		newWindow.document.write("<textarea style=\"width:100%;height:100%\" rows=1 cols=1>" + $result + "</textarea>");
	}
}

function strpad($string,$len,$padString,$left){
	if(!$len) return $string;
	$string = ($string)?_trim(" " + $string) :"";
	$padString = ($padString)?$padString:" ";
	for(var $i=$string.length;$i < $len;$i++){
		$string = ($left)?$padString + $string:$string + $padString;
		$i = $string.length;
	}
	return $string;
}

function popup($string){
		if(!$string) return 0;
		popupWindow = window.open('','popupWindow','width=700,height=500,scrollbars=yes'); 
		popupWindow.document.write('<textarea rows=\'1\' cols=\'1\' style=\'width:100%;height:100%\'>'); 
		popupWindow.document.write($outString);
		popupWindow.document.write('</textarea>');
}

/**************************************************************


function:  isYelling
purpose: checks a given string and determans if it is an all uppercase
returns: percentage of string which is in uppercase


***************************************************************/
function isYelling($formValue,$threshhold){
	var result = new Object();
	result.name = "isYelling";
	// lets setup a progress bar so that we can show people that something is happening.	
	$threshhold  = ($threshhold)?$threshhold:0;
	if($formValue=='')return false; // return false on empty string
	
	
	result.wordcount = $formValue.split(' ').length;
	result.charcount = $formValue.length;
	result.alphatext = alphaOnly($formValue);

	//and lets find out how many chars in the string 
	// are uppercase and how many lowercase
	result.capcount = 0; // set the counter for the number of cap letters found
	result.lowercount = 0; // set the counter for the number of lowercase letters found
	for(var $i=0;$i<result.alphatext.length;$i++){
		var $char = result.alphatext.charCodeAt($i);		
		if(($char>=65)&&($char<=90)){result.capcount++;}else{result.lowercount++;}
		var $val = ($i>0)?(100-((result.alphatext.length-$i)/result.alphatext.length)*100):0;
		window.status = parseInt($val.toString() + "%");
	}	
	window.status = "";
	result.percentcaps = _int(result.capcount/result.alphatext.length*100);
	result.percentlower = _int(result.lowercount/result.alphatext.length*100);
	result.yelling = result.percentcaps>$threshhold;
	result.whispering = result.percentlower == 100;
	return result;
}





function alphaOnly($val,$add){
	$add = (!$add)?"":$add;
	if($val){
		var $allowList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+$add;
		for(var $i=0;$i < $val.length;$i++){
			var $a = $val.substring(0,$i);
			var $z = $val.substring($i+1,$val.length);
			var $g = $val.charAt($i);
			if($allowList.indexOf($g)==-1){
				$val = "" + $a + "" + $z;
				$i=-1;
			}
		}
	}
	return $val;
}


function validUrl($url){
	if(!$url) {return false;}
	var $arrUrl = $url.split("/");
	if($arrUrl.length<=2){return false;}
	if($arrUrl[0]!="http:" && $arrUrl[0]!="https:"){return false;}
	if($arrUrl[2].split(".").length<=1){return false;}	
	return true;
}

// takes a given url and returns the name of the page, minus any
// addressing and querystring

function pagename($url){
	if(!$url) return ""; // exit function IF url is empty
	$url += " "; // add a blank string to the beginning of the URL so that the object is converted to a string
	var $arr = $url.split("/"); // split the URL on the "/"
	var $page = $arr[$arr.length-1]; // extract the last index of the array
	if($page.indexOf("?")!=-1){
	$arr = $page.split("?"); // split the page on "?" so as to pull the querystring out of the page name
	return _trim($arr[0]); // return the page name
	} else {
		return _trim($page);
	}
}

String.prototype.trim = function(){
	return(_trim(this));
}

function _trim($string){
	if(!$string) return "";
	while($string.charAt(0)==" "){$string = $string.substr(1);}
	while($string.charAt($string.length-1)==" "){$string = $string.substr(0,$string.length-1);}	
	return $string;
}

// ' build function which will loop through the display text and count down the timer
// ' when the timer hits Zero it will reload the page.
function countDownSpan($spanname,$time){
	if( MM_findObj($spanname) == null ) return;
	$time = ($time)?$time:getInner($spanname); // '  get the text value of the given span area
	if($time && parseInt($time)>0){ // '  if the value exists, and is larger then 0 then
		alterText($spanname,Echo_secondsToReadable(parseInt($time)-1)); // ' replace the text of the span with the value minus 1
		setTimeout("countDownSpan('" + $spanname + "'," + (($time)-1) + ");",1000); // ' after 1 second, check again
	} else { // ' if the value is 0 or doesn't exist, reload the window
		window.location.reload();
	} // ' end if
} // ' end function

function Echo_secondsToReadable($seconds){
	var $years = 0;
	var $months = 0;
	var $days = 0;
	var $hours = 0;
	var $mins = 0;
	
	var $secondsInYear = 31536000;
	var $secondsInMonth = 2592000;
	var $secondsInDay = 86400;
	var $secondsInHour = 3600;
	var $secondsInMin = 60;

	if($seconds>$secondsInYear){
		$years = parseInt($seconds/$secondsInYear);
		$seconds = parseInt($seconds%$secondsInYear);
	}

	if($seconds>$secondsInMonth){
		$months = parseInt($seconds/$secondsInMonth);
		$seconds = parseInt($seconds%$secondsInMonth);
	}

	if($seconds>$secondsInDay){
		$days = parseInt($seconds/$secondsInDay);
		$seconds = parseInt($seconds%$secondsInDay);
	}

	if($seconds>$secondsInHour){
		$hours = parseInt($seconds/$secondsInHour);
		$seconds = parseInt($seconds%$secondsInHour);
	}
	
	if($seconds>$secondsInMin){
		$mins = parseInt($seconds/$secondsInMin);
		$seconds = parseInt($seconds%$secondsInMin);
	}
	
	if($seconds<=$secondsInMin){
		$seconds = parseInt($seconds.toString());
	}
	
	$return = "";
	$return += ($years>1)?" " + $years + " years":($years==1)?" " + $years + " year":"";
	$return += ($months>1)?" " + $months + " months":($months==1)?" " + $months + " month":"";
	$return += ($days>1)?" " + $days + " days":($days==1)?" " + $days + " day":"";
	$return += ($hours>1)?" " + $hours + " hours":($hours==1)?" " + $hours + " hour":"";
	$return += ($mins>1)?" " + $mins + " minutes":($mins==1)?" " + $mins + " minute":"";
	$return += ($seconds>1)?" " + $seconds + " seconds":($seconds==1)?" " + $seconds + " second":"";
	
	
	return  $return;
}

function stopOnBackSpace(objEvent) {
  var iKeyCode;
   
  if (IE) {
	 iKeyCode = objEvent.keyCode;
  } else {
	 iKeyCode = objEvent.which;
  }
  //alert(iKeyCode);
  if(iKeyCode==8){
	return false;
  }
  return true;
}

function valid_date($month, $day, $year) {
	return date($month+"-"+$day+"-"+$year);
}

function date($date) {
	var d = new Date($date);	
	if(d == "NaN") {
		// find out what the dilim for the date string is.	
		var $dilim = numOnly($date,"",true);
		var $arrDate = $date.split($dilim.substr(0,1));
		$arrDate.uBound = $arrDate.length-1;
		var $year, $month, $day;
		if($arrDate.uBound==0) { $year = $arrDate[0]; $month = 1; $day = 1; }
		if($arrDate.uBound==1) { 
			if($arrDate[0]<=12) {
				$year = $arrDate[1];
				$month = $arrDate[0];
				$day = 1;
			} else {
				$year = $arrDate[0];
				$month = $arrDate[1];
				$day = 1;
			}
			//alert($year+":"+$month+":"+$day);
		}
		d = new Date($year,$month-1,$day);
	}
	var result = new Object();
	result.name = "date()";
	result.valid = (d!="NaN");
	result.month = d.getMonth() + 1;
	result.day = d.getDate();
	result.year = d.getFullYear();
	result.second = d.getSeconds();
	result.hour = d.getHours();
	result.minute = d.getMinutes();
	result.toString = d.toLocaleString().replace(" 12:00:00 AM","");
	result.date = strpad(result.month,2,"0",true) + "-" + strpad(result.day,2,"0",true) + "-" + result.year;
	result.mysql = result.year + "-" + strpad(result.month,2,"0",true) + "-" + strpad(result.day,2,"0",true);
	result.futuredate = futureDate(result.year,result.month,result.day); 
	return result;	
}

function DaysInMonth(nYear, nMonth){
	nMonth = parseInt(nMonth)-1;
	nYear = parseInt(nYear)
	var nDayLen = 24 * 60 * 60 * 1000;
	return (new Date((new Date(nYear+(nMonth==11?1:0),(nMonth+1)%12,1)).getTime()-nDayLen)).getDate();
}

function futureDate($y,$m,$d){
	var $objD = new Date($y,$m-1,$d);
	var $objT = new Date();
	return ($objD>$objT);
}

String.prototype._replace = function($n,$w){
	return((this.split($n).join($w)));
}

String.prototype.removeBlankLines = function(){
	var t = this.split("\r\n");
	var r = "";var m;
	for(m=0;m<t.length;m++){if(t[m]!=""&&t[m]!=undefined){r = r + ((r!="")?"\r\n":"") + t[m];}}
	return(r);
}


function strReplace($string,$what,$with){
	return ($string.split($what)).join($with);
}


function msgbox($src,$w,$h,$x,$y,$scroll,$resize,$status,$force_as_child_window){	
	if(ie4&&!$force_as_child_window) {	
		window.showModalDialog($src,null,(($h)?"dialogHeight: " + $h + "px;":"") + (($w)?"dialogWidth: " + $w + "px;":"") + (($x)?"dialogLeft: " + $x + "px;":"") + (($y)?"dialogTop: " + $y + "px;":"") + ((!$x&&!$y)?"center: yes;":"center: no;") + (($scroll)?"scroll: yes;":"scroll: no;") + (($resize)?"resizable: yes;":"resizable: no;") + (($status)?"status: yes;":"status: no;") + "help: no;");
	} else {
		var sWidth = screen.availWidth;
		var sHeight = screen.availHeight;
		$sHeight = ($h)?(sHeight*.5)-($h*.5):(sHeight*.5)-100;
		$sWidth = ($w)?(sWidth*.5)-($w*.5):(sWidth*.5)-100;
		top.modless_window = window.open($src,'modless_window',"height=" + (($h)?$h:200) + ",width=" + (($w)?$w:200) + ",screenX="+(($x)?$x:$sWidth)+",screenY="+(($y)?$y:$sHeight)+",scrollbars=" + (($scroll)?"yes":"no") + ",resizable=" + (($resize)?"yes":"no") + "");		
		top.modless_window.moveTo((($x)?$x:$sWidth),(($y)?$y:$sHeight));	
	}
}

function check_msgbox(){
	if(!!top.modless_window&&!top.modless_window.closed){
		top.modless_window.focus();
	}
}


//  Cookie Functions - Second Helping  (21-Jan-96)
//  Written by:  Bill Dortch, hIdaho Design <bdortch@netw.com>
//  The following functions are released to the public domain.

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function setCookie (name, value, oneyear) {
  var argv = setCookie.arguments;
  var argc = setCookie.arguments.length;
  
  nd = new Date();
  nd.setTime (nd.getTime()+(365*24*60*60*1000));
  
  var expires = (!oneyear) ? null : nd;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 4) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain));
}

function DeleteCookie(name){
exp=new Date();
exp.setTime (exp.getTime() - 1);
var cval = getCookie ("name");
document.cookie = name + "=" + cval +"; expires=" + exp.toGMTString();
}

function buildArrayLink($varlist, $linkpattern, $textpattern, $args){
	var $arrList, $c, $i, $rString;
	if($varlist == "" || $linkpattern == "" || $textpattern == "") return; // if any values are empty, then exit function
	$arrList = $varlist.split(","); // break string into array
	$c = $arrList.length; // set $c to = the number of indexes found
	if($c <= 0) return; // if c isn//t greater or equal to 0 then there are no records, exit the function
	$rString = "";
	for($i=0;$i<$c;$i++){ // loop through the array
		// build the link, replacing the %1 with the ID in this loop		
		$target = (argVal($args,"target")!="")?"target=\"" + argVal($args,"target") + "\"":"";	
		$rString += "<a href=\"" + $linkpattern.replace("%1",_trim($arrList[$i])) + "\"  onClick=\"javascript:void(0)\" onFocus=\"this.blur()\" " + $target + ">" + $textpattern.replace("%1",_trim($arrList[$i])) + "</a>";
		// output the comma or ampersign depending on the number of items, and the current possission
		if($i==$c-2){
			$rString += " " +  argVal($args,"andor") + " ";
		} else if($i<$c && $i+1<$c){
			$rString +=  ", ";
		}
	}
	return $rString;
}

//=============================================================================================
//	FUNCTION: 	argVal
//	PURPOSE:		used to split a string list of arguments and return the 
// 								one corrisponding with the passed dilimiter (dilim)
//	
//	ARGUMENTS:
//								ARGLIST 	as string: list of arguments in "var=val var=val var=val" format
//								DILIM			as string: val currently looking for
//
//	RETURNS:		string value attached to the dilim variable
// 	EXAMPLE:
// 								argList = "one=1 two=2 three=3"
//								response.write argValue(argList,"two")
//
//	AUTHOR: Scott McDonald
//	VERSION: 1.1
// LAST EDITED: Thursday, September 18, 2003
//=============================================================================================

function argVal($argList,$dilim){
	var $theList, $thisArg, $thisDilim, $i;
	//first check to see if the arglist is in an array or a string. if it is an array, then pass it on to the array 
	// version of this function, otherwise continue
	if( typeof($argList)=="object"){
		// check to make sure it's not empty
		if($argList.length<=0) return;
		return argListFromArray($argList,$dilim);
	}
	
	//remove leading and trailing spacing, as these would keep anything after the spaces 
	//from being seen
	$argList = _trim($argList);
	//remove any extra spacing in the arg list, there should only be one space between 
	//items in the list. without this line, anything after the double space would be lost
	$argList = $argList.replace("  "," ");
	
	if($argList == "") return; //if the arglist is empty, then exit function

	$theList = $argList.split(" ");  //split the argList into an array on " "
	//loop through the resulting array if there is a uBound value > 0
	for($i=0;$i<$theList.length;$i++){
		$theList[$i] = $theList[$i].split("=");
	}
	return argListFromArray($theList,$dilim);
}

function argListFromArray($arrArgs, $dilim){
	if(typeof($arrArgs)!="object") return "";
	if(!$arrArgs.length) return "";
	for(var $i=0;$i<$arrArgs.length;$i++){
		$thisArg = $arrArgs[$i]
		if($thisArg[0] == $dilim){ return $thisArg[1] }
	}
	return "";
}

function tostring($text){
	$text = escape($text);
	while($text.indexOf('%27')!=-1){$text = $text.replace("%27","\\'");} // '
	while($text.indexOf('%22')!=-1){$text = $text.replace('%22','&quot;');} // "
	return unescape($text);
}

function formEncode($text){
	$text = escape($text);
	while($text.indexOf('%22')!=-1){$text = $text.replace('%22','&quot;');} // "
	return unescape($text);
}

// The function $ is an alias to eval which is reminisent of PHP's $$"variablename"
// form of dynamic variables.
function $($varname){return eval($varname);}


function flash_openwindow(address,width,height){
	window.open(address,"new_window","width=" + width + ",height=" + height);
}

function helptext($obj,$text,$force){
	if(getInner($obj)==""||$force){
		alterText($obj,$text);
	} else {
		alterText($obj,"");
	}
}



function replaceall($string,$what,$with){
	if(!$string) return;
	$string = $string + " ";
	while($string.indexOf($what)!=-1){
		$string = $string.replace($what,$with);
	}
	return $string;
}


// class used to keep track of the values in a given form. 
// this class will init by reading in ALL form elements 
// and building an object of them. when "class_form_changes_compare" 

function class_form_changes($formname){
	if(!$formname || $formname =="") return;
	
	// defining variable members of this class
	this.$form = document[$formname];
	// elems will be an array of objects or type form_elements
	this.elems = new Array();
	
	
	// defining function members of this class
	this.index_elements = class_form_changes_index_elements;	
	this.check_elements = class_form_changes_check_elements;	
	
	this.index_elements(); // init class
}

function class_form_changes_index_elements(){
	for($i=0;$i<this.$form.elements.length;$i++){
		this.elems[this.elems.length] = new class_form_elements(this.$form.elements[$i]);		
	}
}


// returns false if any changes have been made to the form. 
// will not check buttons
function class_form_changes_check_elements(){
	// loop through all of the elements in the form
	for($i=0;$i<this.$form.elements.length;$i++){
		// skip this loop if the object is a button, submit or image
		if(this.$form.elements[$i].type == "button" || this.$form.elements[$i].type == "submit" || this.$form.elements[$i].type == "image") continue;
		// if the element that we are looking at hasn't got the same name as it's mirror 
		// in the element array, then we know that the form has been changed... return false
		if(this.$form.elements[$i].name!=this.elems[$i].name) return false;
		// look at the current element and find it's type. then compare it's value witht he 
		// matching element in the element array
		if((this.elems[$i].type == "text") || (this.elems[$i].type == "textarea") || (this.elems[$i].type == "hidden")) {
			if(this.$form.elements[$i].value!=this.elems[$i].value) return false; // value to value
			//alert(this.$form.elements[$i].value + " : " + this.elems[$i].value);
		} else if ((this.elems[$i].type == "radio") || (this.elems[$i].type == "checkbox")) {
			if(this.$form.elements[$i].checked!=this.elems[$i].value) return false; // checked to value
		} else if (this.elems[$i].type == "select-one") {
			if(this.$form.elements[$i].selectedIndex!=this.elems[$i].value) return false; // selectIndex to value
		} else if (this.elems[$i].type == "select-multiple") {
			if(multiselected(this.$form.elements[$i])!=this.elems[$i].value) return false; // list of selectIndexis to value list
		}
	}	
	return true;
}

// class which will hold the information about the individual form elements
// this class member functions will break up the elements and store them
// will not log buttons as they will only change programatically it is assumed
// that any change made to them will be intentional.

function class_form_elements($obj){
	if(typeof($obj)=="undefined" || !$obj) return false;
	// declairing class properties
	this.type = ""
	this.name = ""
	this.value = ""
	this.length = 0;
	
	
	
	this.name = $obj.name;
	this.type = $obj.type;
	if(this.type == "text" || this.type == "textarea" || this.type == "hidden") {
		this.value = $obj.value;
	} else if (this.type == "radio" || this.type == "checkbox") {
		this.value = $obj.checked;
	} else if (this.type == "select-one") {
		this.value = $obj.selectedIndex;
	} else if (this.type == "select-multiple") {
		this.value = multiselected($obj);		
	}
}






// *************************************************88
// Shockwave Detection
// 

//***************************
// For detecting the shockwave plugin for Netscape.
// This function can return a boolean or a floating point value.
// If you supply a reqVer value (number) it will return true or false
// depending on if that version or higher was found.
// If you don't supply a parameter it will return the found version number.

function shockwaveDetectNsVer(reqVer) {
	if (!navigator.plugins) return (reqVer ? false : 0.0); // IE Mac 4.5 and lower don't have a plugins array.
	// Set these local variables to avoid the Netscape 4 crashing bug.
	thearray = navigator.plugins;
	arraylen = thearray.length;
	
	// Step through each plugin in the array.
	for (i=0; i < arraylen; i++) {
		// Set these local variables to avoid the Netscape 4 crashing bug.
		theplugin = thearray[i];
		thename = theplugin.name;
		thedesc = theplugin.description;
		if(thename.toLowerCase().indexOf("shockwave")!=-1){
			if(!reqVer) {
				return true;
			} else {
				if(thedesc.toLowerCase().indexOf(reqVer+".")!=-1){
					return true;
				}
			}
		}
	}
	return false;
}

function arrayDelete($array, $index){
	$r = new Array();
	if(typeof $array != "object") return $array;
	if(($index<0)||($index>$array.length-1)) return $array;
	for(var $a = 0; $a<$array.length;$a++){
		if($a != $index) $r[$r.length] = $array[$a];
	}	
	return $r;
}

function xmlVal($tag,$val){
	if($tag == ""){ return false; } // no sense going on, we don't have any valid tags
	if(($val!="")||($val==0)){
		return "<"+$tag+">" + $val + "</"+$tag+">\n";
	} else {
		return "<"+$tag+"/>\n";
	}
}


// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version
	for (i=25;i>0;i--) {
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);
		}
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");
			} else {
				versionArray      = versionStr.split(".");
			}
			var versionMajor      = versionArray[0];
			var versionMinor      = versionArray[1];
			var versionRevision   = versionArray[2];
			var versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			var versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if (versionMajor > reqMajorVer) {
				return true;
			} else if (versionMajor == reqMajorVer) {
				if (versionMinor > reqMinorVer)
					return true;
				else if (versionMinor == reqMinorVer) {
					if (versionRevision >= reqRevision)
						return true;
				}
			}
			return false;
		}
	}
}


// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	return flashVer;
}

window.width = function(){
	if(window.innerWidth!=undefined){
		return(window.innerWidth);
	} else if(document.body && document.body.clientWidth!=undefined){
		return(document.body.clientWidth);
	} else if(document.documentElement && document.documentElement.clientWidth != undefined){
		return(document.documentElement.clientWidth);
	} else {
		return(null);
	}
}

window.height = function(){
	if(window.innerHeight!=undefined){
		return(window.innerHeight);
	} else if(document.body && document.body.clientHeight!=undefined){
		return(document.body.clientHeight);
	} else if(document.documentElement && document.documentElement.clientHeight != undefined){
		return(document.documentElement.clientHeight);
	} else {
		return(null);
	}
}

function getVal(me){
	if(typeof(me)=="object"){
		/*
		* hopefully we're looking at a form element. if so
		* we should be able to ask what type it is, and get the value from there.
		*/
		switch(me.type){
			case("text"):{return(me.value);break;}
			case("select-one"):{return(me[me.selectedIndex].value);break;}
			case("select-multiple"):{
				var r = new Array();
				for(i=0;i<me.length;i++){
					if(me[i].selected){r[r.length]=me[i].value;}
				}
				return(r.join(","));
				break;
			}
			case("checkbox"):{return(me.checked);break;}
			case("textarea"):{return(me.value);break;}
			default:{alert("GetVal not set to handle type: " + me.type + " yet. nows a good time to make it work though.");break;}
		}	
	}
}
