//----------------------------------------------------------------
//***START*JAVSCRIPT*TOOLS****************************************
//----------------------------------------------------------------

//FINDS A NAMED OBJECT FOR ANY BROWSER, RETURNS THE OBJECT INSTANCE
	//FINDS THE OBJECT ON THE CURRENT PAGE
		function findDOM(objectId) {
			if (document.getElementById) {return (document.getElementById(objectId));}
			else if (document.all) {return (document.all[objectId]);}
			else if (document.layers) {return (document.layers[objectId]);}
			else {return (document.getElementById(objectId));}
			}

	//FINDS THE OBJECT ON THE OPENER PAGE
		function findParentDOM(objectId) {
			if (window.opener.document.getElementById) {return (window.opener.document.getElementById(objectId));}
			else if (window.opener.document.all) {return (window.opener.document.all[objectId]);}
			else if (window.opener.document.layers) {return (window.opener.document.layers[objectId]);}
			else {return (window.opener.document.getElementById(objectId));}
		}

	//RETURNS THE OBJ FOR THE PASSED IN STUFF. CAN PASS IN OBJECT OR ID.
	function $DOM(obj) {
		if (typeof(obj)=="string") obj=findDOM(obj);
		return obj;
	}
	
	function $Exists(obj) {
		try {
			if (typeof(obj)=="string") {
				try {
					var obj = document.getElementById(obj);
					return true;
				} catch (e) {
					return false;
				}
			}
			return true;
		} catch (e) {
			return false;
		}
	}
//END FIND A NAMED OBJECT


//EXTEND OTHER BROWSERS TO INCLUDE SOME IE COMPATABILITY
	try {
		if (!HTMLElement.innerText && HTMLElement.textContent) {
			HTMLElement.prototype.__defineGetter__("innerText", function () { return(this.textContent); });

			HTMLElement.prototype.__defineSetter__("innerText", function (txt) { this.textContent = txt; });
		}
	} catch (e) {}

	//NOTE: "obj.children" in IE doesn't have text nodes.
	try {
		if (!HTMLElement.children && HTMLElement.childNodes) {
			HTMLElement.prototype.__defineGetter__("children", function () { return(this.childNodes); });
		}
	} catch (e) {}

	try {
		if (!HTMLElement.attachEvent) {
			HTMLElement.prototype.attachEvent = function (eventName, functionHandler) {
				functionHandler._wrapHandler = function (e) {
					window.event = e;
					functionHandler();
					return (e.returnValue);
				};
				this.addEventListener(eventName.substr(2), functionHandler._wrapHandler, false);
			};
		}
	} catch (e) {}

	try {
		if (!HTMLElement.detachEvent) {
			HTMLElement.prototype.detachEvent = function (eventName, functionHandler) {
				if (functionHandler._wrapHandler != null)
					this.removeEventListener(eventName.substr(2), functionHandler._wrapHandler, false);
			};
		}
	} catch (e) {}

	try {
		if (!Event.srcElement) {
			Event.prototype.__defineGetter__("srcElement", function () {
				var node = this.target;
				while (node.nodeType != 1)
					node = node.parentNode;
				if (node != this.target) alert("Unexpected event.target!")
					return node;
			});
		}

	} catch (e) {}
//END EXTEND FIREFOX ABILITIES



//FUNCTION TO OPEN A NEW WINDOW
	var _thepopupwindow;

	function openWindow(theURL,winName,features) {
	//FEATURE LIST:
	//alwaysLowered,alwaysRaised,dependent,directories,height,hotkeys,
	//innerHeight,innerWidth,location,menubar,outerHeight,outerWidth,resizable,
	//screenX,screenY,scrollbars,status,titlebar,toolbar,width,z-lock

		_thepopupwindow = window.open(theURL,winName,features);

		TestTheNewPopupWindow();
	}

	function TestTheNewPopupWindow() {
		if (hasPopupBocker()) {
			alert("An ATM popup window has been blocked by your popup blocker." +
				  "\n\nThe window is not an advertisement. Try pressing the " + 
				  "\n'Ctrl' key when clicking or disable your popup blocker." +
				  "\nThank you.");
		}
	}
	
	function hasPopupBocker(){
		var test = window.open("", "test","width=1,height=1,scrollbars=no,left=5000,top=5000");
		if(test==null || typeof(test)=="undefined" || test.closed==true){
			return true;
		}
		try{
    		test.close();
	    }catch(vEx){
    		return true;
	    }
		return false;
	}
		
	function AlreadyPopped() {
		try { 
			if (opener) 
				return true
			else
				return false;
		} catch (e) {
			return false
		}
	}
//END OPEN NEW WINDOW

//JUMPS TO THE URL
	function GoTo(url) {
		window.location.href=url;
	}
//END GOTO

//JAVASCRIPT COOKIE FUNCTIONS - CREATE, READ, ERASE
//**********************************************
//name:= name of the cookie
//value:= the value for the cookie to hold
//days:= how long, in days you want the cookie to last
	function createCookie(name,value,days) {
		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

//name:= name of the cookie to retrieve
//getex:= for simplicity, leave this blank
	function readCookie(name,getex) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		if (getex=="yes") {return document.cookie;}
		else
		{
			for(var i=0;i < ca.length;i++)
			{
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
		}
		return "";
	}

//name:= name of the cookie to erase
	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	}
//*********************************************


//CHECKS AN OBJECTS VALUE TO SEE IF ITS A VALID NUMBER, PRODUCES AN ERROR IF NOT
    function numValidate(obj) {
	var num;
	num = findDOM(obj);
        if (isNaN(num.value) == true) {
            num.value="";
			if (!isEmpty(num.name))
				alert("The value of "+num.name+" is not a valid number.")
			else
				alert("The value of "+num.id+" is not a valid number.");
        }
    }

//MAKES SURE THE USER WANTS TO DELETE A RECORD AND REDIRECTS TO A URL IF SO
	function delConfirm(url) {
		var answer;
		answer = confirm ("Delete this record?")
		if (answer)
		window.location.href=url
	}

//AJAX FUNCTIONS
//*************************************
	//pass in the url to get the info from, and the object name of where to output results
	// also you can pass in the 'After Post Function', which runs after the get completes
	function getAJAXResult(url, obj, apf) {
		if (typeof(obj)=="string") obj = $DOM(obj);

		var xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null) {
			alert("Your browser does not support this action.\nIf using IE, ActiveX Objects may not be allowed.");
			return;
		}
		
		xmlHttp.onreadystatechange = function() {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
				obj.innerHTML = "";
				obj.innerHTML = xmlHttp.responseText;
				if (apf) eval(apf);
			}
		};
		
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

	function postAJAXResult(url, parms, obj, apf) {
		if (typeof(obj)=="string") obj = $DOM(obj);

		var xmlHttp = GetXmlHttpObject();
		if (xmlHttp==null) {
			alert("Your browser does not support this action.\nIf using IE, ActiveX Objects may not be allowed.");
			return;
		}
		
		xmlHttp.onreadystatechange = function() {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
				obj.innerHTML = "";
				obj.innerHTML = xmlHttp.responseText;
				if (apf) eval(apf);
			}
		};
		
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", parms.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(parms);
	}

	function GetXmlHttpObject() {
		var objXMLHttp=null;
		try {// Firefox, Opera 8.0+, Safari
			objXMLHttp=new XMLHttpRequest();
		}
		catch (e) {// Internet Explorer
			try { objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e) {
				try { objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
				catch (e) { return null; }
			}
		}
		return objXMLHttp;
	}

	//TAKES A DELIMITED LIST OF OBJECT NAMES AND RETURNS A QUERYSTRING OF THOSE OBJECT VALUES
	function BuildParamString(objList,delimiter) {
		var poststr = "";
		if (!delimiter)
			objList = objList.split(",")
		else
			objList = objList.split(delimiter);

		for (var i=0;i<objList.length;i++) {
			objList[i] = trim(objList[i]);
 			poststr += objList[i] + "=" + encodeURIComponent(getDOMValue(objList[i])) + "&";
		}

		return poststr;
	}
//END AJAX FUNCTIONS*****************


//THIS FUNCTIONS RETURNS THE VALUE OF THE PASSED IN KEY
	function QueryString(key,url) {
		if (url)
			var mainHREF = url.substring(url.indexOf("?")+1,url.length);
		else
			var mainHREF = self.location.href.substring(self.location.href.indexOf("?")+1,self.location.href.length);

		if (mainHREF.length>1) {
			var sets = mainHREF.split("&");
			for (x=0;x<sets.length;x++) {
				if (sets[x].indexOf(key+"=")==0) {
					var pair = sets[x].split("=");
					var str = "";
					for (z=1;z<pair.length;z++) {
						if (str=="") {str = pair[z];}
						else {str += "=" + pair[z];}
					}
					return unescape(str);
				}
			}
		}
		return false;
	}
//END QUERYSTRING


//RESIZES A POPUP WINDOW TO THE SIZE OF THE IMAGE
	function adjust_popup() {
        	var w, h, fixedW, fixedH, diffW, diffH;
        	if (document.documentElement && document.body.clientHeight==0) {     // Catches IE6 and FF in DOCMODE
                	fixedW = document.documentElement.clientWidth;
                	fixedH = document.documentElement.clientHeight;
                	window.resizeTo(fixedW, fixedH);
                	diffW = fixedW - document.documentElement.clientWidth;
                	diffH = fixedH - document.documentElement.clientHeight;
                	w = fixedW + diffW + 16; // Vert Scrollbar Always On in DOCMODE.
                	h = fixedH + diffH;
                	if (w >= screen.availWidth) h += 16;
        	} else if (document.all) {
                	fixedW = document.body.clientWidth;
                	fixedH = document.body.clientHeight;
                	window.resizeTo(fixedW, fixedH);
                	diffW = fixedW - document.body.clientWidth;
                	diffH = fixedH - document.body.clientHeight;
                	w = fixedW + diffW;
                	h = fixedH + diffH;
                	if (h >= screen.availHeight) w += 16;
                	if (w >= screen.availWidth)  h += 16;
        	} else {
                	fixedW = window.innerWidth;
                	fixedH = window.innerHeight;
                	window.resizeTo(fixedW, fixedH);
                	diffW = fixedW - window.innerWidth;
                	diffH = fixedH - window.innerHeight;
                	w = fixedW + diffW;
                	h = fixedH + diffH;
                	if (w >= screen.availWidth)  h += 16;
                	if (h >= screen.availHeight) w += 16;
        	}
        	w = Math.min(w,screen.availWidth);
        	h = Math.min(h,screen.availHeight);
        	window.resizeTo(w,h);
        	window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
	}
//END RESIZE POPUP WINDOW


//COUNTS THE NUMBER OF CHARACTERS IN A FIELD, AND SHORTENS IT IF IT IS TOO LONG
//  RETURNS THE NUMBER OF CHARACTERS REMAINING TO A SPECIFIED OBJECT.
// YOU PASS IN THE 'field' YOU WANT TO COUNT, THE 'element' TO PASS THE NUMBER
//  OF CHARS LEFT, AND THE 'maxlimit' NUMBER OF CHARACTERS ALOWED.
//THIS FUNCTION CAN BE ASSIGNED TO A ONKEYUP OBJECT EVENT AND/OR ONBLUR
	function textCounter(field, element, maxlimit) {
		if (typeof(field)=="string") field = findDOM(field);
		if (typeof(element)=="string") element = findDOM(element);

  		if (field.value.length > maxlimit)
    		field.value = field.value.substring(0, maxlimit);
  		else
    		$SetValue(element, maxlimit - field.value.length);
	}
//END TEXT COUNTER


//RETURNS THE HEIGHT OR WIDTH OF THE BROWSER WINDOW
	function WindowSize(dimension) {
		var x,y;

		if (self.innerHeight) { // all except Explorer
			x = self.innerWidth;
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {// Explorer 6 Strict Mode
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}

		if ((dimension.toUpperCase()=="W")||(dimension.toUpperCase()=="WIDTH")) {
			return x;
		} else if ((dimension.toUpperCase()=="H")||(dimension.toUpperCase()=="HEIGHT")) {
			return y;
		}
	}

	function WindowSizeHeight() { return WindowSize("h")}

	function WindowSizeWidth() { return WindowSize("w")}
//END WINDOW HEIGHT


//RETURNS THE HEIGHT OR WIDTH OF THE BROWSER DOCUMENT
	function DocumentSize(dimension) {
		var x,y;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) {// all but Explorer Mac
			x = document.body.scrollWidth;
			y = document.body.scrollHeight;
		} else {// Explorer Mac, would also work in Explorer 6 Strict, Mozilla and Safari
			x = document.body.offsetWidth;
			y = document.body.offsetHeight;
		}

		if ((dimension.toUpperCase()=="W")||(dimension.toUpperCase()=="WIDTH")) {
			return x;
		} else if ((dimension.toUpperCase()=="H")||(dimension.toUpperCase()=="HEIGHT")) {
			return y;
		}
	}

	function DocumentSizeHeight() { return DocumentSize("h")}

	function DocumentSizeWidth() { return DocumentSize("w")}
//END DOCUMENT HEIGHT

//RETURNS HOW MUCH THE PAGE HAS SCROLLED
	function ScrollOffset(dimension) {
		var x,y;
		if (self.pageYOffset) {// all except Explorer
			x = self.pageXOffset;
			y = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}

		if ((dimension.toUpperCase()=="L")||(dimension.toUpperCase()=="LEFT")) {
			return x;
		} else if ((dimension.toUpperCase()=="T")||(dimension.toUpperCase()=="TOP")) {
			return y;
		}
	}
	
	function ScrollOffsetHorizontal() {
		return ScrollOffset("Left");
	}
	
	function ScrollOffsetVertical() {
		return ScrollOffset("Top");
	}
	
	function SetScrollPosition(val, LeftToRight) {
		val = val * 1;
		if (self.pageYOffset) {// all except Explorer
			if (LeftToRight) self.pageXOffset = val
			else self.pageYOffset = val;
		} else if (document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
			if (LeftToRight) document.documentElement.scrollLeft = val
			else document.documentElement.scrollTop = val;
		} else if (document.body) {// all other Explorers
			if (LeftToRight) document.body.scrollLeft = val
			else document.body.scrollTop = val;
		}
	}
//END SCROLL OFFSET

//FUNCTIONS FOR GETTING AN ELEMENTS X/Y COORDINATES
	function getXfromLeft(imgID) {
		try {
			if (HTMLElement.x) {
				return document.getElementById(imgID).x
			} else {
				return getRealLeft(imgID);
			}
		} catch (e) {
			return getRealLeft(imgID);
		}
	}

	function getYfromTop(imgID) {
		try {
	  		if (HTMLElement.y) {
				return document.getElementById(imgID).y;
			} else {
				return getRealTop(imgID);
			}
		} catch (e) {
			return getRealTop(imgID);
		}
	}

	function getRealLeft(imgElem) {
    	xPos = document.getElementById(imgElem).offsetLeft;
    	tempEl = document.getElementById(imgElem).offsetParent;
      	while (tempEl != null) {
          	xPos += tempEl.offsetLeft;
          	tempEl = tempEl.offsetParent;
      	}
    	return xPos;
	}

	function getRealTop(imgElem) {//
    	yPos = document.getElementById(imgElem).offsetTop;
    	tempEl = document.getElementById(imgElem).offsetParent;
    	while (tempEl != null) {
          	yPos += tempEl.offsetTop;
          	tempEl = tempEl.offsetParent;
      	}
    	return yPos;
	}
//END X/Y COORDINATES FUNCTIONS


//FUNCTION RETURNS THE ID OR NAME OF THE OBJECT THAT LAST TRIGGERED A DOCUMENT EVENT
	function eventTrigger(e) {
		//get the element that triggered the event
		var targ;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) // workaround Safari bug
			targ = targ.parentNode;
		//end get element

		if ((!targ.id) || (isEmpty(targ.id)))
			return targ.name
		else
			return targ.id;
	}
//END EVENT TRIGGER


//STRING RELATED FUNCTIONS
	//THIS FUNCTIONS ADDS TEXT INTO A FIELD WHERE THE CURSOR IS
		//insertAtCursor("fieldName", "some string");
		function insertAtCursor(myField, myValue) {
			var obj = findDOM(myField);
			if (document.selection) {	//IE support
				obj.focus();
				var sel = document.selection.createRange();
				sel.text = myValue;
			}
			else if (obj.selectionStart || obj.selectionStart == "0") {	//MOZILLA/NETSCAPE support
				var startPos = obj.selectionStart;
				var endPos = obj.selectionEnd;
				obj.value = obj.value.substring(0, startPos) + myValue + obj.value.substring(endPos, obj.value.length);
			} else {
				myField.value += myValue;
			}
		}
	//end insert at cursor


	//TRIM FUNTIONS
		// Removes leading whitespaces
		function LTrim(value) {
			var re = /\s*((\S+\s*)*)/;
			return value.replace(re, "$1");
		}

		// Removes ending whitespaces
		function RTrim(value) {
			var re = /((\s*\S+)*)\s*/;
			return value.replace(re, "$1");
		}

		// Removes leading and ending whitespaces
		function trim(value) {
			if (value)
				return LTrim(RTrim(value))
			else
				return "";
		}
	//END TRIM FUNCTIONS


	//COPY AND PASTE FUNCTIONS
		function Copy(obj) {
			var _t = findDOM(obj);
			var Copied = _t.createTextRange();
			Copied.execCommand("Copy");
		}

		function Paste(obj) {
			var _m = findDOM(obj);
			_m.value = "";
   			_m.focus();
   			var PastedText = _m.createTextRange();
   			PastedText.execCommand("Paste");
		}
	//END COPY AND PASTE FUNCTIONS


	//REPLACES ALL OCCURANCES OF A STRING WITHIN A STRING WITH A STRING
		function replaceAll(value,oldStr,newStr,matchCase) {
			var options = "g";
			if (matchCase) options+="i";
			var val = new RegExp(oldStr, options);
			return value.replace(val,newStr);
		}
	//END REPLACE ALL


	//SIMPLY RETURNS TRUE IF STRING IS = "" or is just spaces
		function isEmpty(str) {
			str = trim(str);
			if ((!str) || (str=="") || (str=="undefined")) return true
			else return false;
		}
	//END EMPTY TEST


	//COMPARES TWO STRINGS TO SEE IF THEY ARE EQUAL, THE ADVANTAGE
	// TO THIS FUNCTION IS THE CASE SENSITIVITY FLAG.
		function isEqual(str1,str2,cs) {
			if (cs) {
				if (str1==str2) return true
				else return false;
			} else {
				if (str1.toUpperCase()==str2.toUpperCase()) return true
				else return false;
			}
		}
	//END ISEQUAL


	//START: CREATE A NEW OBJECT FOR STRING VALIDATION
		//OBJECT REQUIRES A STRING. ALSO ACCEPTS OPTIONAL CUSTOM LIST AS A STRING OR AN ARRAY OF VALUES
		function StringValidator(_string,_customlist) {

			this.string = (_string)?_string:"";
			this.customlist = _customlist;

			//CHECK TO SEE IF THE STRING CONTAINS ONLY LETTERS, WHITESPACE IS OK, SEE 'nospace' PROPERTY
			this.lettersonly = TestLettersOnly(this.string);
			this.lettersonlyError = TestLettersOnly(this.string,true);

			//CHECK TO SEE IF THE STRING CONTAINS ONLY LETTERS AND NUMBERS
			this.textonly = TestTextOnly(this.string);
			this.textonlyError = TestTextOnly(this.string,true);

			//CHECK TO SEE IF THE STRING WOULD QUALIFY AS A VALID EMAIL ADDRESS
			this.email = TestIfEmail(this.string);
			this.emailError = TestIfEmail(this.string,true);

			//AN ARRAY OF VALUES OR A STRING OF CHARACTERS CAN BE PASSED IN FOR THIS CHECK
			//IF NOTHING IS PASSED IN, THE VALUE IS FALSE AND THE ERROR IS BLANK
			if (this.customlist) {
				this.custom = TestCustom(this.string,this.customlist);
				this.customError = TestCustom(this.string,this.customlist,true);;
			} else {
				this.custom = false;
				this.customError = "";
			}

			//CHECK TO SEE IF THE STRING CONTAINS A SPACE
			if (this.string!="")this.nospace = (_string.indexOf(" ")==-1)
			else this.nospace = true;

			//CHECK TO SEE IF THE STRING IS ONLY NUMBERS
			this.numbersonly = (!isNaN(_string));

			//CREATE LENGTH PROPERTY
			if (this.string!="")this.length = this.string.length
			else this.length = 0;
		}

		function TestLettersOnly(str,err) {
			if(str==""){return (err)?"Value is empty":false;}
			else{var list = "`~!@#$%^&*()-_+=\\\t\"';:<,>.?/[{]}|0123456789";for(i=0;i<list.length;i++)
			{if(str.indexOf(list.charAt(i))>-1){return (err)?"Value contains the invaild character \""+list.charAt(i)+"\"":false;}}}
			return (err)?"":true;
		}

		function TestTextOnly(str,err) {
			if(str==""){return (err)?"Value is empty":false;}
			else{var list="\\\t\"<>";for(i=0;i<list.length;i++){if (str.indexOf(list.charAt(i))>-1)
			{return (err)?"Value contains the invaild character \""+list.charAt(i)+"\"":false;}}}
			return (err)?"":true;
		}

		function TestIfEmail(str,err) {
			if(str==""){return (err)?"Value is empty":false;
			}else{
				var list = " `~!#$%^&*()+=\\\t\"';:<,>?/[{]}|";
				var _arr = str.split("@");
				if(str.length<6){return (err)?"Invalid email: not long enough.":false;}
				if(_arr.length!=2){return (err)?"Invalid email address.":false;}
				if((_arr[0].length<2)||(_arr[1].length<4)||
				   	(_arr[1].indexOf(".")==-1)||(_arr[1].indexOf(".")>=(_arr[1].length-2)))
					{return (err)?"Invalid email address.":false;}
				for(i=0;i<list.length;i++) {if (str.indexOf(list.charAt(i))>-1){return (err)?"Value contains the invaild character \""+list.charAt(i)+"\"":false;}}
			}
			return (err)?"":true;
		}

		function TestCustom(str,list,err) {
			if(str==""){return (err)?"Value is empty":false;
			}else{
				if(isArray(list)){for (i=0;i<list.length;i++) {if(str.indexOf(list[i])>-1){return (err)?"Contains an invaild character => "+list[i]+" <=":false;}}
				}else{for (i=0;i<list.length;i++) {if (str.indexOf(list.charAt(i))>-1) {return (err)?"Contains an invaild character => "+list.charAt(i)+" <=":false;}}}
			}
			return (err)?"":true;
		}

		function isArray(obj) {
			return (obj.constructor.toString().toLowerCase().indexOf("array")==-1)?false:true;
		}
	//END: CREATE A NEW OBJECT FOR STRING VALIDATION

	//FOMATS A STRING IN PROPER CASE
	function toProperCase(str) {
		if (!isEmpty(str)) {
			var i;
			var s = trim(str).split(" ");
			str = "";

			for (i=0;i<s.length;i++) {
				if (s[i].length==0) {
					str += " ";
				} else if (s[i].length==1) {
					str += s[i].toUpperCase() + " ";
				} else {
					str += s[i].charAt(0).toUpperCase();
					str += s[i].substring(1,s[i].length).toLowerCase() + " ";
				}
			}
		}

		return str;
	}

	//THIS EXTENDS THE STRING CLASS TO INCLUDE A replaceAll METHOD
	String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}

	//THIS EXTENDS THE STRING CLASS TO INCLUDE A SIMPLER UPPER CASE METHOD
	String.prototype.UCase=function() {return this.toUpperCase()}

	//THIS EXTENDS THE STRING CLASS TO INCLUDE A SIMPLER LOWER CASE METHOD
	String.prototype.LCase=function() {return this.toLowerCase()}

	//THIS EXTENDS THE STRING CLASS TO INCLUDE A SIMPLER TRIM METHOD
	String.prototype.trim = function() {return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))}

	//THIS EXTENDS THE STRING CLASS TO INCLUDE A FUNCTION THAT RETURNS WHETHER A STRING CONTAINS ANOTHER STRING
	String.prototype.contains=function(s1) {return this.toString().indexOf(s1)>-1}

	//THIS EXTENDS THE STRING CLASS TO INCLUDE A FUNCTION THAT RETURNS WHETHER A STRING CONTAINS ANOTHER STRING
	String.prototype.empty=function() {return isEmpty(this)}


	//THIS EXTENDS THE STRING CLASS TO INCLUDE A FUNCTION THAT RETURNS WHETHER A STRING CONTAINS ANOTHER STRING
	String.prototype.insertAfterIndex=function(index,txt) {
		return this.substring(0,index+1) + txt + this.substring(index+1,this.length);
	}

//END STRING RELATED FUNCTIONS


//PARSES A STRING WITH STYLE INFO AND APPLIES THE STYLES TO THE OBJECT PASSED IN
	function ApplyStyles(obj, styles) {
		var x=0, pv;
		if ($Exists(obj)) {
			if (typeof(obj)=="string") obj = findDOM(obj);
			var sty = styles.split(";");

			for (x=0;x<sty.length;x++) {
				if (trim(sty[x])!="") {
					pv = sty[x].split(":");
					try {
						eval("obj.style."+JStyle(trim(pv[0]))+" = \""+trim(pv[1])+"\"");
					} catch(e) {}
				}
			}
		}
	}

	//JScript is picky about the names of its style properties
	function JStyle(_s) {
		while (_s.indexOf("-")>0) {
			_s = _s.substring(0,_s.indexOf("-")) +
			 	_s.charAt(_s.indexOf("-")+1).toUpperCase() +
				_s.substring(_s.indexOf("-")+2,_s.length);
			_s = _s.replace("-","");
		}

		return _s;
	}
//END APPLY STYLES FUNCTIONS

//CHANGE THE BACKGROUND COLOR FUNCTION
	function changeBGColor(obj,from,to) {
		if (typeof(obj)=="string") obj = findDOM(obj);
		if (obj.style) {
			var bgc = obj.style.backgroundColor.replace("#","").toUpperCase();
			if (bgc.indexOf("RGB")>=0) {
				if (RGB2HEX(bgc)==RGB2HEX(from)) {
					obj.style.backgroundColor=HEX2RGB(to);
				} else {
					obj.style.backgroundColor=HEX2RGB(from);
				}
			} else {
				if (RGB2HEX(bgc)==RGB2HEX(from)) {
					obj.style.backgroundColor=RGB2HEX(to);
				} else {
					obj.style.backgroundColor=RGB2HEX(from);
				}
			}
		}
	}
//END CHANGE BACKGROUND COLOR FUNCTION

//HEX TO RGB AND RGB TO HEX COLOR CONVERSIONS
	//NOTE: these 2 functions will convert whatever you give to the specified value
	//      ie., if you input a HEX value into the rgb2hex it will return what you passed in.
	//      if you send a RGB then it will be converted.
	//      its helpful if you don't know which value your getting from the browser, and saves time
	//      trying to determine which one it is.

	function RGB2HEX(rgb) {
		if (rgb.toUpperCase().indexOf("RGB")>=0) {
			var c = rgb.split(",");
			return d2h(parseInt(trim(c[0].replace("RGB(","")))).toString() + d2h(parseInt(c[1])).toString() + d2h(parseInt(c[2])).toString();
		} else {
			return rgb.replace("#","");
		}
	}

	function HEX2RGB(hex) {
		var c = hex.replace("#","");
		if (c.toUpperCase().indexOf("RGB")>=0) {
			return c;
		} else {
			if (hex.length==3) {
				var c1 = c.substring(0,1);
				var c2 = c.substring(1,1);
				var c3 = c.substring(2,1);
			} else {
				var c1 = c.substring(0,2);
				var c2 = c.substring(2,4);
				var c3 = c.substring(4,6);
			}
			return "RGB(" + h2d(c1) + "," + h2d(c2) + "," + h2d(c3) + ")";
		}
	}

	function d2h(d) {return d.toString(16).toUpperCase();}

	function h2d(h) {return parseInt(trim(h),16);}
//END H2D & D2H CONVERSIONS

//HANDY IMAGE FUNCTIONS
	//pass in as long an image list as you want, they will be preloaded into var plImg0-(argument list length-1)
	var _preloadImgFlag = false;
	function MM_preloadImages() {
		if (document.images) {
			for (var i=0; i<MM_preloadImages.arguments.length; i++) {
				eval("var plImg"+i+" = newImage(\""+MM_preloadImages.arguments[i]+"\")");
			}
			_preloadImgFlag = true;
		}
	}

	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}

	//SWITCHES THE IMAGES, 1 WITH 2, 3 WITH 4, 5 WITH 6, ETC.
	function changeImages() {
		if (document.images && (_preloadImgFlag == true)) {
			for (var i=0; i<changeImages.arguments.length; i+=2) {
				document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
			}
		}
	}
//END HANDY IMAGE FUNCTIONS

//RANDOM NUMBER GENERATOR
	function randomInt(lower,upper)	{
		if (upper) {
    		var ranNum= Math.floor((Math.random()*(upper-lower))+lower);
		} else {
			var ranNum= Math.floor(Math.random()*lower);
		}
    	return ranNum;
	}
//END RANDOM NUMBER GENERATOR

//ADD A LINK TO YOUR FAVORITES
	//Adds the current page to your favorites. If no values are passed in,
	// the current location is used.
	function addfav(url,favname) {
		if (document.all){
			if (isEmpty(url)) url=window.location.href;
			if (url.toLowerCase().indexOf("http://")==-1) url = "http://" + url;
			if (isEmpty(favname)) favname=window.location.href;

			window.external.AddFavorite(url,favname);
		}else{
			alert("Your browser may not support this operation.");
		}
	}
//END FAVORITES

//DISPLAYS OR HIDES THE OBJECT PASSED IN
	function ToggleDisplay(obj) {
		ShowOrHideObject(obj);
	}
	
	function ShowOrHideObject(obj,onoff) {
		var d = "", v = "";
		if (!onoff) var onoff="";
		obj=$DOM(obj);
		
		if (onoff=="on") {
			v="visible";
			d="block";
		} else if (onoff=="off") {
			v="hidden";
			d="none";
		} else {
			if ((obj.style.display.toLowerCase()=="none") || (obj.style.visibility.toLowerCase()=="hidden")) {
				v="visible";
				d="block";
			} else {
				v="hidden";
				d="none";
			}
		}
		
		//do some better setting here
		try {
			if (d == "block") {
				switch (obj.nodeName.toUpperCase()) {
					case "TR": d = "table-row"; break;
					case "TD": d = "table-cell"; break;
					case "TABLE": d = "table"; break;
				}
			}
		} catch(e) { }
		obj.style.visibility = v;
		obj.style.display    = d;
	}

	function ShowObject(obj) {ShowOrHideObject(obj,"on");}

	function HideObject(obj) {ShowOrHideObject(obj,"off");}
	
	function isHidden(obj) {
		obj = $DOM(obj);
		try {
			if (obj.style) {
				if (obj.style.display.LCase().contains("none") || obj.style.visibility.LCase().contains("hidden")) {
					return true;
				} 
			}
			return false;
		} catch(e) {
			return false;
		}
	}
//END ShowOrHideObject

//SHOWS AN ALT MESSAGE FOR ANY DOCUMENT ELEMENT
	function alt(obj,txt,offsetX,offsetY) {
		if (!txt) var txt="";
		if (!offsetX) var offsetX=20;
		if (!offsetY) var offsetY=12;

		if (!document.getElementById("alt_div")) {
			var nme = document.createElement("div");
  			nme.setAttribute("id","alt_div");
  			document.body.appendChild(nme);
  			var styles="position:absolute;width:8px;height:16px;display:none;visibility:hidden;" +
  						   "top:0px;left:0px;z-index:100;background-color:#FFFFE1;border:black 1px solid;" +
  						   "text-align:center;font-family:arial;font-size:11px;color:black;font-weight:400;"
  			ApplyStyles(nme,styles);
		}

		if(!nme)var nme = findDOM("alt_div");

		if (nme.style.display=="none") {
			nme.style.width=((txt.length*7)+4) + "px";
			nme.style.left=(getXfromLeft(obj)+offsetX) + "px";
			nme.style.top=(getYfromTop(obj)+offsetY) + "px";
			nme.innerHTML=txt;
			nme.style.display="block";
			nme.style.visibility="visible";
		} else {
			nme.style.display="none";
			nme.style.visibility="hidden";
		}
	}
//END ALT MESSAGE

//SETS THE CURRENT FRAME TO BE THE TOP FRAME
	function SetParent(){
		if(top.location!=location)top.location.href=document.location.href;
	}
//END SETPARENT

//FADE AN OBJECTS COLOR FROM ONE TO THE OTHER
//START RGB => sr,sg,sb : END RGB => er,eg,eb : # OF STEPS => step : OBJECT ID => obj : DOES OR DOESN'T CYCLE => fstop;
	var _fadeForward;

	//fade the foreground color
	function fadeF(sr,sg,sb,er,eg,eb,step,obj,fstop,at) {
		if (!at) var at = 1;
		if (!fstop) var fstop = false;
		if (at==1) _fadeForward = true;
		if (at==step) _fadeForward = false;

		findDOM(obj).style.color = "#" +
					ConvertHex(Math.floor(sr * ((step-at)/step)  + er * (at/step)))+
					ConvertHex(Math.floor(sg * ((step-at)/step) +  eg * (at/step)))+
					ConvertHex(Math.floor(sb * ((step-at)/step) +  eb * (at/step)));

		if ((at==step)&&(fstop)) {
			//stop fading
		} else {
			if (_fadeForward) {
				at++;
				setTimeout("fadeF("+sr+","+sg+","+sb+","+er+","+eg+","+eb+","+step+",\""+obj+"\","+fstop+","+at+")",1);
			} else {
				at--;
				setTimeout("fadeF("+sr+","+sg+","+sb+","+er+","+eg+","+eb+","+step+",\""+obj+"\","+fstop+","+at+")",1);
			}
		}
	}

	//fade the background color
	function fadeB(sr,sg,sb,er,eg,eb,step,obj,fstop,at) {
		if (!at) var at = 1;
		if (!fstop) var fstop = false;
		if (at==1) _fadeForward = true;
		if (at==step) _fadeForward = false;

		findDOM(obj).style.backgroundColor = "#" +
					ConvertHex(Math.floor(sr * ((step-at)/step)  + er * (at/step)))+
					ConvertHex(Math.floor(sg * ((step-at)/step) +  eg * (at/step)))+
					ConvertHex(Math.floor(sb * ((step-at)/step) +  eb * (at/step)));

		if ((at==step)&&(fstop)) {
			//stop fading
		} else {
			if (_fadeForward) {
				at++;
				setTimeout("fadeB("+sr+","+sg+","+sb+","+er+","+eg+","+eb+","+step+",\""+obj+"\","+fstop+","+at+")",1);
			} else {
				at--;
				setTimeout("fadeB("+sr+","+sg+","+sb+","+er+","+eg+","+eb+","+step+",\""+obj+"\","+fstop+","+at+")",1);
			}
		}
	}

	function ConvertHex(i) {
		if (i < 0) return "00";
		else if (i > 255) return "ff";
		else return "" + d2h(Math.floor(i/16)) + d2h(i%16);
	}
//END OBJECT COLOR FADER

//HISTORY CONTROLS
	function Back() {
		history.back();
	}

	function Forward() {
		history.forward();
	}
//END HISTORY


//OTHER HELPFUL DOM FUNCTIONS
	//A COUPLE OF FUNCTIONS TO GET VALUES FROM OBJECTS
		function $Value(obj) {
			return getDOMValue(obj);
		}
		
		function $SetValue(obj,value,UseIndexListForOptionSelect) {
			setDOMValue(obj,value,UseIndexListForOptionSelect);
		}
		
		function getDOMValue(obj) {
			if (typeof(obj)=="string") 
				var valid = $Exists(obj)
			else
				var valid = true;

			if (valid) {
				obj = $DOM(obj);
				
				if (getNodeName(obj)=="input") {
					if (getInputType(obj)=="checkbox") {
						if (!obj.checked) {
							return false;
						} else {
							if (!isEmpty(obj.value))
								return obj.value
							else
								return true;
						}
					} else if (getInputType(obj)=="radio") {
						return GetCheckedRadioValue(obj);
					} else {
						return obj.value;
					}
				} else {
					if (getNodeName(obj)=="select") {
						return GetSelectedOptionValues(obj);
					} else if (getNodeName(obj)=="textarea") {
						return obj.value;
					} else {
						if (obj.innerHTML)
							return obj.innerHTML
						else if (obj.innerText)
							return obj.innerText
						else if (obj.textContent)
							return obj.textContent
						else
							return "";
					}
				}
			}

			return "";
		}
		
		function setDOMValue(obj,value,UseIndexListForOptionSelect) {
			if (typeof(obj)=="string") 
				var valid = $Exists(obj)
			else
				var valid = true;

			if (valid) {
				obj = $DOM(obj);
				
				if (getNodeName(obj)=="input") {
					if (getInputType(obj)=="checkbox") {
						if (value.toString().LCase()=="checked" || value.toString().LCase()=="selected" || 
						   value==true || value.toString().LCase()=="on") {
							obj.checked = true;
						} else {
							obj.checked = false;
						}
					} else if (getInputType(obj)=="radio") {
						SetCheckedRadioValue(obj,value);
					} else {
						obj.value = value;
					}
				} else {
					if (getNodeName(obj)=="select") {
						if (!UseIndexListForOptionSelect) {
							value = GetOptionIndexByValue(obj,value);
						}
						SetSelectedOptionValues(obj,value);
					} else if (getNodeName(obj)=="textarea") {
						obj.value = value;
					} else {
						obj.innerHTML = value;
						
						if (obj.innerHTML.empty() && !value.empty()) {
							obj.innerText = value;
						}
					}
				}
			}
		}


		//RETURNS THE VALUE SELECTED IN A SELECT OBJECT. SUPPORTS MULTI-SELECTS
		//RETURNS COMMA DELIMITED FOR MULTI-SELECTS. GETS INNERTEXT IF VALUE NOT AVAILABLE.
		function GetSelectedOptionValues(obj) {
			obj=$DOM(obj);
			var s = "";

			if (obj.nodeName.toLowerCase()=="select") {
				if (obj.selectedIndex!=-1) {
					for (var i=0;i<obj.options.length;i++) {
						if (obj.options[i].selected) {
							if (obj.options[i].value!="")
								s+=obj.options[i].value+","
							else if (obj.options[i].innerText)
								s+=obj.options[i].innerText+","
							else if (obj.options[i].text)
								s+=obj.options[i].text+","
							else 
								s+=",";
						}
					}
					if(s.charAt(s.length-1)==",")s=s.substring(0,s.length-1);
				}
			}

			return s;
		}
		
		function GetSelectedOptionTexts(obj) {
			obj=$DOM(obj);
			var s = "";

			if (obj.nodeName.toLowerCase()=="select") {
				if (obj.selectedIndex!=-1) {
					for (var i=0;i<obj.options.length;i++) {
						if (obj.options[i].selected) {
							if (obj.options[i].innerText)
								s+=obj.options[i].innerText+","
							else if (obj.options[i].text)
								s+=obj.options[i].text+","
							else 
								s+=obj.options[i].value+",";
						}
					}
					if(s.charAt(s.length-1)==",")s=s.substring(0,s.length-1);
				}
			}

			return s;
		}
		
		function GetOptionIndexByValue(obj,value) {
			obj=$DOM(obj);

			if (obj.nodeName.LCase()=="select") {
				for (var i=0;i<obj.options.length;i++) {
					if (obj.options[i].value==value || obj.options[i].innerText==value) {
						return i;
					}
				}
			}
			
			return -1
		}
		
		function SetSelectedOptionValues(obj,CommaSepIndices) {
			obj=$DOM(obj);
			var s = CommaSepIndices.toString().split(",");
			var l = obj.options.length-1;

			if (obj.nodeName.LCase()=="select") {
				for (var i=0;i<s.length;i++) {
					s[i] = s[i].trim();
					if (!s[i].empty()) {
						if (!isNaN(s[i])) {
							if ((s[i].trim()*1)>-1 && (s[i].trim()*1)<=l) {
								obj.options[s[i]*1].selected = true;
							}
						}
					}
				}
			}
		}
		//END OptionSelectValues

		//GET THE VALUE OF THE SELECTED RADIO BUTTON FROM A RADIO GROUP. IF THE VALUE
		// IS NOT AVAILABLE, IT GETS THE INDEX OF THE SELECTED BUTTON. OTHERWISE IT
		// RETURNS AN EMPTY STRING.
		function GetCheckedRadioValue(obj) {
			var radio_group, radio_checked, x;
			var val = "";

			if(typeof(obj)!="string") {
				(obj.name=="")?obj=obj.id:obj=obj.name;
			}

			if (!isEmpty(obj)) {
				radio_checked = false;
				radio_group = document.getElementsByName(obj);

				for (x=0;x<radio_group.length;x++) {
					if (radio_group[x].checked) {
						val = radio_group[x].value;
						if(isEmpty(val))val=x*1;
					}
				}
			}

			return val;
		}
		
		function SetCheckedRadioValue(obj,value) {
			obj = getObjName(obj);
			var els = document.getElementsByName(obj);
			for (var e=0;e<els.length;e++) {
				if (els[e].value==value) els[e].checked = true;
			}
		}
		
		function ClearRadioGroup(group_name) {
			var radio_group = document.getElementsByName(group_name);
			for (var x=0;x<radio_group.length;x++) {
				radio_group[x].checked = false;
			}
		}
	//END GET OBJECT VALUES FUNCTION


	function getNodeName(obj) {
		if (typeof(obj)=="string") obj = findDOM(obj);
		if (!obj.nodeName)
			return ""
		else
			return obj.nodeName.toLowerCase();
	}

	function getInputType(obj) {
		if (typeof(obj)=="string") obj = findDOM(obj);
		if (!obj.type)
			return ""
		else
			return obj.type.toLowerCase();
	}

	function getObjName(obj) {
		if (typeof(obj)=="string") {
			return obj;
		}

		if (obj.id) {
			if (trim(obj.id)!="") return obj.id;
		}

		if (obj.name) {
			if (trim(obj.name)!="") return obj.name;
		}

		return "";
	}

	function ApplyClassName(obj,clsNm) {
		if (document.createTextNode) {
  			$DOM(obj).className=clsNm;
		}
	}
	
	function GetClassName(obj) {
		if (document.createTextNode) 
  			return $DOM(obj).className
		else
			return "";
	}
	
	function AddClassName(obj, className) {
		if (document.createTextNode) {
  			$DOM(obj).className = ($DOM(obj).className + " " + className).trim().replaceAll("  ", " ");
		} 
	}
	
	function RemoveClassName(obj, className) {
		if (document.createTextNode) {
			var classes = $DOM(obj).className.split(" ");
			var cname = "";
			className = className.trim();
			
			for (var x = 0; x < classes.length; x++) {
				if (classes[x]!="" && classes[x]!=className)
					cname += classes[x] + " ";
			}
			
  			$DOM(obj).className = cname.trim().replaceAll("  ", " ");
		} 
	}
	
	function HasClassName(obj, className) {
		if (document.createTextNode) {
			var classes = $DOM(obj).className.split(" ");
			className = className.trim();
			
			for (var x = 0; x < classes.length; x++) {
				if (classes[x]==className)
					return true;
			}
		}
		return false;
	}
	
	//Sets the value of a style in a class defined in one of the documents style sheets
	//ClassName => If ClassName is found anywhere in the selector of the definition, it is matched
	//JSStyleName => The camel-cased JavaScript name of the style attribute to edit
	//Value => The new value of the style
	//ReplaceAll => If set, continues searching all stylesheets for matches. Otherwise, does the first one.
	function SetCSSClassStyle(ClassName, JSStyleName, Value, ReplaceAll) {
		var ss = document.styleSheets, s;
		var rules, r;
		
		for (s=0; s<ss.length; s++) {
			rules = null;
			if (ss[s].cssRules) rules = ss[s].cssRules
			else if (ss[s].rules) rules = ss[s].rules;
			
			if (rules) {
				for (r=0; r<rules.length; r++) {
					if (rules[r].selectorText.indexOf(ClassName) >= 0) {
						try {
							eval("rules[r].style." + JSStyleName + "= Value");
							if (!ReplaceAll) return true;
						} catch(e) {}
					}
				}
			}
		}
	}
	
	//DOM STUFF, THESE ADD AND REMOVE ITEMS FROM A OPTION SELECT
		//before is the index number of the option the new one will preceed
		function appendOption(obj,txt,val,before) {
			if (!val) var val = txt;
			if (typeof before == "undefined") var before = null;

	  		var elSel = $DOM(obj);

	  		var elOptNew = document.createElement('option');
	  		elOptNew.text = txt;
	  		elOptNew.value = val;

			if (isNaN(before) || (before>=elSel.options.length) || (before<0))
				before = null
			else
				before = elSel.options[before];

	  		try {
	    		elSel.add(elOptNew, before); // standards compliant; doesn't work in IE
	  		}
	  		catch(ex) {
				if (before==null)
	    			elSel.add(elOptNew) // IE only
				else
	    			elSel.add(elOptNew, before); // IE only
	  		}
		}

		//index is the index number of the one to remove, if index is -1, it removes all
		//removes the last one by default
		function removeOption(obj,index) {
	  		var elSel = $DOM(obj);
			
			if (typeof index == "undefined") var index = elSel.options.length-1;
			
	  		for (var i = elSel.options.length - 1; i>=0; i--) {
				if ((i==index) || (index==-1)) {
	      			elSel.remove(i);
	    		}
	  		}
		}
		
		function removeAllOptions(obj) {
			obj = $DOM(obj);
			
			if (obj.options) {
				for (var i = obj.options.length - 1; i>=0; i--) {
					removeOption(obj,i);
				}
			}
		}
		
		function selectAllOptions(obj) {
			obj = $DOM(obj);
			obj.multiple = "multiple";
			for (var i=0;i<obj.options.length;i++) obj.options[i].selected=true;
		}
		
		function deselectAllOptions(obj) {
			obj = $DOM(obj);
			for (var i=0;i<obj.options.length;i++) obj.options[i].selected=false;
		}
		
		function selectedOptionIndex(obj) {
			obj = $DOM(obj);
			for (var i=0;i<obj.options.length;i++) {
				if (obj.options[i].selected) return i;
			}
			return -1;
		}
		
		//A negative MoveNumber will move the item further down the list
		//A positive MoveNumber will move the item further up the list
		function selectedOptionMove(obj, MoveNumber, ReSelect) {
			try {
				if (typeof MoveNumber == "undefined") var MoveNumber = 0;
				if (MoveNumber==0) return false;
				
				var obj = $DOM(obj);
				var index = selectedOptionIndex(obj);
				var count = obj.options.length-1
				
				if (index > -1) {
					var el = obj.options[index];
					removeOption(obj, index);
					
					if ((index+(MoveNumber*-1)) < 0) {
						MoveNumber = index;
					} else if ((index+(MoveNumber*-1)) >= count) {
						appendOption(obj, el.value, el.innerText);
						if (ReSelect) 
							obj.options[count].selected = true;
						return true;
					}
					
					appendOption(obj, el.value, el.innerText, index+(MoveNumber*-1));
					
					if (ReSelect) 
						obj.options[index+(MoveNumber*-1)].selected = true;
				}
			} catch (e) {}
		}
		
		function selectedOptionMoveUp(obj, ReSelect) {
			selectedOptionMove(obj, 1, ReSelect);
		}
		
		function selectedOptionMoveDown(obj, ReSelect) {
			selectedOptionMove(obj, -1, ReSelect);
		}
	//END DOM OPTION SELECT FUNCTIONS
	
	function isElement(obj,ElementType) {
		obj = $DOM(obj);
		var type = getNodeName(obj).toString().LCase();
		
		if (type==ElementType.toString().LCase()) {
			return true;
		} else if (type=="input") {
			type = obj.type;
			return (type==ElementType.LCase())
		} else {
			return false;
		}
	}
//END OTHER HELPFUL DOM FUNCTIONS


//GETS ALL ATTRIBUTES OF A GIVEN OBJECT
	function GetAttributes(obj,delimiter) {
		if (typeof(obj)=="string") obj = $DOM(obj);
		var res = "";
		if (!delimiter) var delimiter = "\n";

		for (var i=0;i<obj.attributes.length;i++) {
			res += obj.attributes[i].name + "=" + obj.attributes[i].value + delimiter;
		}

		return res;
	}
//END GET ALL ATTRIBUTES


//PRINTS THE CURRENT PAGE
	function PrintThisPage() {printArticle();}
	
	function printArticle() {
		if (window.printPreview) {
			setTimeout('window.printPreview();',200);
		} else if (window.print) {
			setTimeout('window.print();',200);
		} else {
			alert("Print function not working. Click file, Print.")
		}
	}
//END PRINT PAGE


//PASS IN A NUMBER OF ARGUMENTS, THIS LOOPS THROUGH AND ALERTS THE VALUE
	function aE() {
		var str = "";
		for (var i=0;i<aE.arguments.length;i++) {
			str += "<" + aE.arguments[i] + ">\n";
		}
		alert(str)
	}
//END aE()


//CHECKS THE URL OF THE PAGE TO SEE IF IT IS THE PASSED IN ONE
function isPage(page,useCase) {
	var url = window.location.href;
	if (!useCase) {
		page = page.LCase();
		url = url.LCase();
	}
	return (url.contains(page));
}
//END CHECK PAGE

//MAKES THE BORDER OF AN OBJECT OR ITS PARENT BLINK
var BorderBlink_border_settings = [];
var BorderBlink_Save_The_Border_Info = true;
function BorderBlink(obj, count, speed, BlinkParent) {
//SPEED := fast, medium, slow
	var t,el;
	if (!BlinkParent) BlinkParent=false;
	
	if (BlinkParent) el = $DOM(obj).parentNode
	else el = $DOM(obj);
	
	if (BorderBlink_Save_The_Border_Info) {
		BorderBlink_border_settings[0] = el.style.borderBottomColor;
		BorderBlink_border_settings[1] = el.style.borderBottomStyle;
		BorderBlink_border_settings[2] = el.style.borderBottomWidth;
		BorderBlink_border_settings[3] = el.style.borderLeftColor;
		BorderBlink_border_settings[4] = el.style.borderLeftStyle;
		BorderBlink_border_settings[5] = el.style.borderLeftWidth;
		BorderBlink_border_settings[6] = el.style.borderRightColor;
		BorderBlink_border_settings[7] = el.style.borderRightStyle;
		BorderBlink_border_settings[8] = el.style.borderRightWidth;
		BorderBlink_border_settings[9] = el.style.borderTopColor;
		BorderBlink_border_settings[10] = el.style.borderTopStyle;
		BorderBlink_border_settings[11] = el.style.borderTopWidth;
		
		BorderBlink_Save_The_Border_Info = false;
	}
	
	switch (speed.LCase()) {
		case "slow":
			t=750;
			break;
		case "medium":
			t=500;
			break;
		case "fast":
			t=100;
	}
	
	if (count == 0) {
		el.style.borderBottomColor = BorderBlink_border_settings[0];
		el.style.borderBottomStyle = BorderBlink_border_settings[1];
		el.style.borderBottomWidth = BorderBlink_border_settings[2];
		el.style.borderLeftColor = BorderBlink_border_settings[3];
		el.style.borderLeftStyle = BorderBlink_border_settings[4];
		el.style.borderLeftWidth = BorderBlink_border_settings[5];
		el.style.borderRightColor = BorderBlink_border_settings[6];
		el.style.borderRightStyle = BorderBlink_border_settings[7];
		el.style.borderRightWidth = BorderBlink_border_settings[8];
		el.style.borderTopColor = BorderBlink_border_settings[9];
		el.style.borderTopStyle = BorderBlink_border_settings[10];
		el.style.borderTopWidth = BorderBlink_border_settings[11];
		
		BorderBlink_Save_The_Border_Info = true;
		
	} else if ((count % 2) == 0) {
		count--;
		
		el.style.borderWidth="2px";
		el.style.borderColor="red";
		el.style.borderStyle="solid";
		
		setTimeout("BorderBlink(\"" + obj + "\"," + count + ",\"" + speed + "\"," +BlinkParent + ")",t);
		
	} else {
		count--;		
		el.style.borderWidth="0px";
		el.style.borderColor="red";
		el.style.borderStyle="solid";
		
		setTimeout("BorderBlink(\"" + obj + "\"," + count + ",\"" + speed + "\"," +BlinkParent + ")",t);
	}
}


//A JAVASCRIPT COLLECTION
	function Collection() {
		var items = [];
		var keys = [];
	}

	Collection.prototype.add = function(item, key) {
		this.items.push(item);
		this.keys.push(key);
	}

	Collection.prototype.count = function() {
		return items.length - 1;
	}

	Collection.prototype.item = function(index) {
		if (typeof index=="integer") {
			return items[index];
		} else {
			for (var i=0; i<this.items.length; i++) {
				if (this.items[i]==index) return this.items[i];
			}
		}
		return null;
	}
//END COLLETION

function isTopPage() {
	return (self.parent.location.href==self.location.href)
}

