/*******************************************************************
		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 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:		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:		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:		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:		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 getPage(){
	var $url = new String(document.location);
	var $arrUrl = $url.split("/");
	return $arrUrl[$arrUrl.length-1];
}

	/*
	******************************************************************
		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;
		}
	}
}

if(!Array.prototype.push){
	Array.prototype.push=function(){
		for(var i=0;i<arguments.length;i++){
			this[this.length]=arguments[i];
		};
	};
};
	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 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 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 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);
	}
}

// ' 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 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 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();
}



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 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,"");
	}
}






// 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;
}

function CatchOut(e){
	var r = '';
	for(i in e){
		r += i + ': ' + e[i] + '\n';
	};
}


function getObjectByName(text){
	for(stuff in this){
		try {
			if(this[stuff].name==text || this[stuff].id==text){return(this[stuff]);}
		} catch(e){}
	}
}

