/* --------------------------------------------------------------------------------------------------------------
	Name				: 	dom_methods.js
	Purpose				:	This script contains an object for accessing and traversing the DOM and testing objects
	Created				:	02/23/2006
	Modified			:	12/07/2007 Added some bug fixes for coordinate matching
	Author				:	Charles Taylor 
	Version				:   1.0
	Comments			:	Works in all major browsers (FireFox 1.x, IE 5+, Netscape 6+ and Safari 1.x)
							With tweaks and additions, it mimics some of the work of Kenan Banks on Zoozio.com.
							Unlike his, I also wanted to wrap all the function in a an object for that OO touch :)

--------------------------------------------------------------------------------------------------------------- */

//Create a new Singleton Object called DOM
var DomObj = new Object(); 
	
	var browserName = navigator.userAgent.toLowerCase(); 	
	DomObj.isKonqueror   = (browserName.indexOf('konqueror') != -1); 
   	DomObj.isSafari      = (browserName.indexOf('safari') != - 1);
	DomObj.isOpera       = (browserName.indexOf('opera') != -1); 
	DomObj.isIE 		 = (!this.isOpera && browserName.indexOf('msie') != -1);
	DomObj.isFireFox     = (browserName.indexOf('firefox') != -1); 
	DomObj.isNS 		 = (browserName.indexOf('gecko') != -1 && browserName.indexOf('netscape') != -1);	
	
	//Grab a reference to the top level body DOM element 
	DomObj.domRoot = function(){		
		return ((document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body);	
	};
	/* ------------------------- DEALING WITH DOM ELEMENTS (NODES) --------------------------------------------------
	* These first functions deal with creating and retrieving and setting attributes for
	* the DOM elements like Div, span, table body etc...	
	---------------------------------------------------------------------------------------------------------------*/

	/*------- getElementByID ----------------------
	 *Get an element by ID. If an existing element is 
	 *passed,just return the element unchanged
    ------------------------------------------------*/
	DomObj.getById = function(elementID) {		
		//Guard clause to immediately return the newly created element if an ID was passed
		if (typeof elementID == 'string'){
			return ((document.all && !document.getElementById) ? document.all[elementID] : document.getElementById(elementID));      		
	   };	   
	   	return elementID; //This will be used if the elementid passed in was actually the element itself. Just return it back.
	
	}; //end getElementByID function
	
	
	/* -------- getElementByName shorthand function -----
	* Gets and element by tag name	
	* EXample: DomObj.getByName("table")
	* Example2: DomObj.getByName("li", "idOfUnorderedList")
	--------------------------------------------------*/
	DomObj.getByName = function(elementName, optionalStartingRootElementId){
		//return the element retrieved by tag name
		var elementArray;
		if (optionalStartingRootElementId){
		    var rootElem = DomObj.getById(optionalStartingRootElementId);
		    elementArray = rootElem.getElementsByTagName(elementName);			
		}else{
		    elementArray = document.getElementsByTagName(elementName);
		};
		return elementArray;
	}; /* end getElementByName function */
	
	
	/*
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
	Modified slightly by Charles Taylor (internetmandude1@hotmail.com)
	*/
	/* The 1st parameter is the element you want to search within. Could be document or some other lower element
		2nd parameter is the type of HTML tag to search for such as "a" or "div"
		3rd parameter is the className you are looking for
	*/
	DomObj.getByClassName = function(rootElement, htmlTagName, strClassName){
		var arrElements = (htmlTagName == "*" && rootElement.all)? rootElement.all : rootElement.getElementsByTagName(htmlTagName);
		var arrReturnElements = new Array();
		strClassName = strClassName.replace(/-/g, "\-");
		var regex = new RegExp("(^|\s)" + strClassName + "(\s|$)");
		var oElement;
		for(var i=0; i<arrElements.length; i++){
			oElement = arrElements[i];
			if(regex.test(oElement.className)){
				arrReturnElements.push(oElement);
			};
		};
		return (arrReturnElements)
	};
	
	/* Slightly modified function from WebWonder (www.webbedwonder.com) */
	DomObj.isValidUrl = function(urlStr){
	    if (urlStr.indexOf(" ")!=-1){alert("Spaces are not allowed in a URL");return false;}if(urlStr==""||urlStr==null){return false;}urlStr=urlStr.toLowerCase();var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";var validChars="\[^\\s" + specialChars + "\]";var atom=validChars + '+';var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;var matchArray=urlStr.match(urlPat);if (matchArray==null){alert("The URL seems incorrect");return false;}var user=matchArray[2];var domain=matchArray[3];for (i=0; i<user.length; i++) {if (user.charCodeAt(i)>127) {alert("This domain contains invalid characters.");return false;}}for (i=0; i<domain.length; i++) {if (domain.charCodeAt(i)>127) {alert("This domain name contains invalid characters.");return false;}}var atomPat=new RegExp("^" + atom + "$");var domArr=domain.split(".");var len=domArr.length;for (i=0;i<len;i++) {if (domArr[i].search(atomPat)==-1) {alert("The domain name does not seem to be valid.");return false;}}if (domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(atomPat)==-1) {alert("The address must end in a well-known domain or two letter " + "country.");return false;}return true;
	};
	
	
	/*----- Create an Element function ---*/
	DomObj.create = function(elem){
			return document.createElement(elem);
	}; /*End createElement function*/
	
	/*----- Create a Text Node function ---
	* Example: DomObj.createText("the lazy dog jumped over the moon");
	--------------------------------------*/
	DomObj.createText = function(textString){
			return document.createTextNode(textString);			
	}; /* End createElement function */
	
	
	DomObj.writeText = function(elem, textString){
		var theElem = DomObj.getById(elem);
		theElem.innerHTML = textString;	
	}; /* end function writeText() */
	
	
	/* ------- Creating elements with attributes ------	
	* The first parameter is the name of the element to create.
	* The second parameter is a Javascript object literal used to
	* initialize the elements once created.
	*
	* Returns the DOM Element created
	* 
	* Example:
	*   var newDiv = createWithAttribs("DIV", {onmouseover:doHighlight, onmouseout:stopHighlight, id:'coolDiv'});
	*/
	DomObj.createWithAttribs = function(domObject, listOfAttributes){
		var newDomObject = DomObj.create(domObject); //create the new object		
	   	//Now append each attribute to this element		
			for (attrib in listOfAttributes){				
				newDomObject = DomObj.setAttrib(newDomObject, attrib, listOfAttributes[attrib]);			
			}; //end for
					
	   return newDomObject;
	}; //end function Create with attributes	 
	
	
	/* --- Append child function -----------
	* Appends 2nd element to the first element	
	* Example: DomObj.ac(myTable, "TR")
	--------------------------------------*/
	DomObj.ac = function(parentObject, childObject){
		return parentObject.appendChild(childObject);
	}; //end appendChild function
	
	/* --- Element.setAttribute function -----------
	* Sets an attribute on an element
	* Uses the non W3C syntax that seems to work better for IE
	* Example: DomObj.setAttrib(myTable, "border", "2");
	--------------------------------------*/
	DomObj.setAttrib = function(element, attributeName, attributeValue){
			//var elem = DomObj.getById(element);
		    element[attributeName] = attributeValue;			
			return element;
			//Proper W3C commented out for now
		// return element.setAttribute(attributeName,attributeValue);
	}; //end setAttribute function
	
	
	//Totally removes an element from the DOM tree
	DomObj.removeElement = function(elementId){
		var elem = DomObj.getById(elementId); //Grab the element
		var elemParent = elem.parentNode; //Get the parent of this element	
		elemParent.removeChild(elem);//remove the element
		elem = elemParent = null; //dereference the elements	
	}; //end function removeElement()
	
	
	/* --- Sets the CSS class for this element -----*
	* IE uses classname instead of class for setting the class for an element.
	* This function takes that quirk into account
	*/
	DomObj.setClass = function(theElement, theCssClass){	
	    var element = DomObj.getById(theElement); //make sure we have reference to a DOM element before attaching attributes		
		return ((document.all)? DomObj.setAttrib(element, "className", theCssClass) : DomObj.setAttrib(element, "class", theCssClass));								
	}; //end function set class
	
	
	DomObj.getExternalCssStyle = function(theElement, ieProperty, mozProperty){
		var element = DomObj.getById(theElement); //make sure we have reference to a DOM element
		if (element.currentStyle) {//if IE5+
			return element.currentStyle[ieProperty];
		} else if (window.getComputedStyle){ //if NS6+
			var elstyle=window.getComputedStyle(element, "");
			return elstyle.getPropertyValue(mozProperty);
		}; //end if
	}; //end function getExternalCssStyle()
	
	
	/* This function removes style sheet entries and rules from style sheet entries */
	DomObj.removeCssStyle = function(styleRule){	   
		var curStyleSheet, rules, deleteRule;	
		outOfLoop:
		for (var i=0; i<document.styleSheets.length; i++){
			curStyleSheet = document.styleSheets[i];
			rules = (curStyleSheet.cssRules) ? curStyleSheet.cssRules : curStyleSheet.rules;
			curStyleSheet.deleteEntry = (curStyleSheet.deleteRule) ? curStyleSheet.deleteRule : curStyleSheet.removeRule;		
			for (var g=0; g<rules.length; g++){
				if (rules[g].selectorText.toLowerCase().indexOf(styleRule) != -1){
					curStyleSheet.deleteEntry(g);
					break outOfLoop;
				};
			};		
		};			
	};


    /* Working with Cookies (Just reads for now)*/
    
    DomObj.getCookieValue = function(offset){    
        var endstr = document.cookie.indexOf (";", offset); 
        if (endstr == -1) 
        endstr = document.cookie.length; 
        return unescape(document.cookie.substring(offset, endstr));
    };
    
    DomObj.getCookie = function(cookieName){
         var theCookie = cookieName + "="; 
            var alen = theCookie.length; 
            var clen = document.cookie.length; 
            var i = 0; 
            while (i < clen) { 
            var j = i + alen; 
                if (document.cookie.substring(i, j).toUpperCase() == theCookie.toUpperCase()) {
                    return DomObj.getCookieValue(j); 
                };
                i = document.cookie.indexOf(" ", i) + 1; 
                if (i == 0) break; 
            } ;
            return null;
    
    };	//end function getCookie
    
    DomObj.setCookie = function(name, value, expires, path, domain, secure) {        document.cookie = name + "=" + escape (value) +        ((expires) ? "; expires=" + expires : "") +        ((path) ? "; path=" + path : "") +        ((domain) ? "; domain=" + domain : "") +        ((secure) ? "; secure" : "");    };
    
    
    DomObj.getExpDate = function(days, hours, minutes) {        var expDate = new Date();        if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {            expDate.setDate(expDate.getDate() + parseInt(days));            expDate.setHours(expDate.getHours() + parseInt(hours));            expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));            return expDate.toGMTString();        };    };      
    
    //This function grabs a cookie value from a cookie with multiple values delimited by some character(s)
    DomObj.getFromCArray = function(cookieName, arrayIndexName, cookiesDelimiter, nameValuePairDelimiter){
        var cookieDelim = (cookiesDelimiter) ? cookiesDelimiter : "**";
        var nameValDelim = (nameValuePairDelimiter) ? nameValuePairDelimiter : "*";
        var theCookieValue = unescape(DomObj.getCookie(cookieName)); //Get the cookie value
        var cookieArray = theCookieValue.split(cookieDelim); //Split up the cookies
        var curCookie = "";
        for (var i=0; i<cookieArray.length; i++){ //Loop through the cookies array to find the one to retrieve
            curCookie = cookieArray[i].split(nameValDelim);    
            if (curCookie[0] == arrayIndexName){
                return curCookie[1]; //Return the value of this cookie
            };       
        };       
        return null; //Return null if it somehow reaches this point              
    
    };
    
     /* Name of cookie, name of property within cookie, delimiter between properties, delimiter between property and value */
    DomObj.SetCookieValueInList = function(cookieName, cookiePropertyName, cookieValue, cookiesDelimiter, nameValuePairDelimiter){
        var cookieDelim = (cookiesDelimiter) ? cookiesDelimiter : "**";
        var nameValDelim = (nameValuePairDelimiter) ? nameValuePairDelimiter : "*";
        var theCookieValue = unescape(DomObj.getCookie(cookieName)); //Get the cookie value
        var cookieArray = theCookieValue.split(cookieDelim); //Split up the cookies
        var curCookie = "";
        var newCookieString = "";
        var ckDelim = "";
        for (var i=0; i<cookieArray.length; i++){ //Loop through the cookies array to find the one to retrieve
            curCookie = cookieArray[i].split(nameValDelim);    
            if (curCookie[0] == cookiePropertyName){
                newCookieString += ckDelim + curCookie[0] + nameValDelim + cookieValue; /* Change the value of this cookie */
            }else{ /* Use the existing value of the cookie */
                newCookieString += ckDelim + curCookie[0] + nameValDelim + curCookie[1];
            };    
            ckDelim = cookieDelim;
        };        
        var url = window.location.host;
        if (url.indexOf("localhost") == -1){
            DomObj.setCookie(cookieName, newCookieString, "", "/", CONST.DOMAIN);  
        }else{
             /*DomObj.trace("Setting cookies locally from JS");*/
             DomObj.setCookie(cookieName, newCookieString, "", "/");
        };
    };
    
    
       DomObj.showFocus = function(theFieldName){
         DomObj.getById(theFieldName).focus();
         DomObj.getById(theFieldName).select();
       };
           
       DomObj.reloadPage = function(){
            window.location.reload();
       };
       
       /*
       DomObj.escapeJsString = function(unsafeString){
           var escapeChars = /\r|\n|\r\n/g;
		   return (unsafeString.replace(escapeChars, " ").replace(/\'/g,"\\'").replace(/\"/g,"\\\""));
       };
       */
	
	/* ------------------------------------------------- TYPE TESTING -----------------------------------------------	
	* USEFUL METHODS FOR TESTING OBJECT TYPES 
	* The next 6 methods were incorporated into this object from the great work done by 
	* Douglas Crockford : douglas@crockford.com
	* http://www.crockford.com	
	-----------------------------------------------------------------------------------------------------------------*/
	//Is this a reference to an actual object?
	DomObj.isObject = function(obj){
		return (obj && typeof (obj) == 'object');
	}
	
	//Is the object being passed an array?
	DomObj.isArray = function(obj){
		return (DomObj.isObject(obj) && obj.constructor == Array); 
	}	
	
	//Is the object a function?
	DomObj.isFunction = function(obj) {
    	return (typeof (obj) == 'function');
	} //end testing if this is a function

	//Has this function been defined
	DomObj.isDefined = function(obj) {
    	return (typeof (obj) != 'undefined');
	}
	
	//Is this a number?
	DomObj.isNumber = function(obj) {
		return (typeof (obj) == 'number' );
	}
	
	//is this object NULL?
	DomObj.isNull = function(obj) {
    return (typeof (obj) == 'object' && !obj);
	}
	
	
	/* ------------------------------------------------- DOM UTILITY -----------------------------------------------	
	* USEFUL GENERIC DOM UTILITY METHODS 
	* Generic functions that belong in the dom and not the utility file
	-----------------------------------------------------------------------------------------------------------------*/
	
	DomObj.trace = function(textString){
	 /*
	  s = "";
	  for (prop in obj){
		s += prop + "<br />";
	  }
	  */
	  var d= DomObj.getById("traceDiv");
	  if (!d){	
	  var d = document.createElement("DIV");
	  d.id = "traceDiv";
	  d.style.backgroundColor='#EEEEEE';
	  d.style.position='absolute';
	  d.style.height='300px';
	  d.style.width='390px';
	  d.style.top='800px';
	  d.style.left='800px';
	  d.style.overflow='scroll';
	  d.style.zIndex = '30000';
	  //d.onclick = function() {this.style.display='none';};
	  DomObj.ac(document.body,d);
	  }	 	  
	  d.innerHTML += textString + "<br />";//Add all the properties to the div
	  
	
	}
	
	DomObj.showHideSelects = function(hideSelects){	    
	    var comboBoxes = DomObj.getByName("select");
	    if (comboBoxes.length > 0){
	        for (var i=0; i < comboBoxes.length; i++){
	            comboBoxes[i].style.display = (hideSelects) ? "none" : "inline";
	        }	
	    }
	}
	
	DomObj.openWindow = function(url){
	    var newWin = window.open(url, "mywin");
	}
	
	//Get the element's left and top coordinates
	DomObj.getElementTopAndLeftCoord = function(elem){			
	    
		var elem = DomObj.getById(elem); //Make sure we have the element and not just a string reference to an element
		
		var x = elem.offsetLeft;
		var y = elem.offsetTop;
		var p = elem.offsetParent; //This keeps track of the offSetParent		
		while (p != null){ //Loop through inner elements until we get to the actual element's left and top 
			x += p.offsetLeft;
			y += p.offsetTop;
			p = p.offsetParent;			
		} //end while					
		
		elem = p = null; //Null out the variables used				
		
		return {x:x, y:y}
	
	} //end function getElementTopAndLeftCoord();
	
	//Get an element's width and height
	DomObj.getElementWidthAndHeight = function(elem){
			
			var theElem = DomObj.getById(elem); //make sure we have the object				
			if (theElem){											
					w=theElem.offsetWidth;  //set the width
					h=theElem.offsetHeight; //set the height				
			} //end if
		
			return {w: w, h: h} //return a width and height object
	}
	
	
	//This function creates the placeholder that holds the place of the element being dragged
	DomObj.setElemDimensions = function(theElement, leftCoord, topCoord, w, h, theClassName){		
		var theElement = DomObj.getById(theElement); //make sure we have the actual element
		//Now set the width, height, left and top coords of this placholder to the same dimensions as the draggable div	
		if (leftCoord){ theElement.style.left = leftCoord + "px"; } //set the left coord
		if (topCoord){ theElement.style.top = topCoord + "px"; } //set the top coord
		if (w){	theElement.style.width = w + "px";	} //set the width
		if (h){	theElement.style.height = h + "px";	} //set the height
		//set the element's classname
		if (theClassName){ theElement.className = theClassName; }
		//Send back the element
		return theElement;	
	}

	DomObj.setElemWidth = function(theElement, theWidth){
		var px = (isNaN(theWidth)) ? "" : "px";
		var theElem = DomObj.getById(theElement);		
		theElem.style.width = theWidth + px;
		return theElem;
	}

	DomObj.setElemHeight = function(theElement, h){
		var px = (isNaN(h)) ? "" : "px";
		var theElem = DomObj.getById(theElement);
		theElem.style.height = h + px;
		return theElem;
	}
	
	
	//This function removes the passed element out of the flow of the document and returns it to the calling function
	DomObj.removeElementFromPageFlow = function(elementId, displayType){
			//grab a reference to the element
			 var theElement = DomObj.getById(elementId);
			 //hide it until we can actually remove it
			 if (displayType){ theElement.style.display = "none"; } else { theElement.style.visibility="hidden"; }		 
			 //Now totally remove it from the page
			 var elemRemovedFromFLow = theElement.parentNode.removeChild(theElement);
			 theElement = null; //dereference element
			 return elemRemovedFromFLow;
	} //end function removeElementFromPageFlow()
	
	//Removes the element without returning it to the calling function
	DomObj.removeElement = function(elementId){
		var elemRemoved = DomObj.removeElementFromPageFlow(elementId);
		elemRemoved = null;
	} //end function removeElement()
	
	
	//This function gets the inner area of the browser's height, width, left, top, bottom and right edge coords
	DomObj.getBrowserArea = function(){
		var windowChrome     = 0; //Take the browser scroll and status bar area into account (not needed anymore, but just in case)
		var WindowLeftEdge = DomObj.domRoot().scrollLeft; //find out the exact position of the left of the browser
		var WindowTopEdge  = DomObj.domRoot().scrollTop; //find out the exact top position of the browser window
		var WindowWidth    = (DomObj.domRoot().clientWidth != 'undefined') ? DomObj.domRoot().clientWidth  : window.innerWidth;
		var WindowHeight   = (DomObj.domRoot().clientHeight != 'undefined') ? DomObj.domRoot().clientHeight : window.innerHeight;
		var WindowRightEdge  = (WindowWidth) - windowChrome; //Get the right edge minus the scrollbar area
		var WindowBottomEdge = (WindowHeight) - windowChrome; //Get the bottom edge minus the scroll and status area
		//Return the numbers
		return {leftEdge: WindowLeftEdge, topEdge: WindowTopEdge, width: WindowWidth, height: WindowHeight, rightEdge: WindowRightEdge, bottomEdge: WindowBottomEdge};
	} //end function getBrowserArea()
	
	
	DomObj.positionModal = function(evt, modalId, nudgeAmount){
	        var coords = DomObj.getElementTopAndLeftCoord(evt.evtSource);	
	        var browserArea = DomObj.getBrowserArea();	        
		    var cssLeft = DomObj.getExternalCssStyle(evt.evtSource, 'paddingLeft', 'paddingLeft');
		    var leftCoords = (window.event) ? coords.x - parseInt(cssLeft) : coords.x;
		    if (nudgeAmount){
		        leftCoords += nudgeAmount;
		    };
		    var bottomPos = (window.event) ? ((evt.evtSource.getBoundingClientRect().bottom-1) + parseInt(browserArea.topEdge)) : (parseInt(evt.evtSource.offsetHeight) + parseInt(coords.y));				    
		    
		    DomObj.getById(modalId).style.visibility = 'visible';
		    DomObj.setElemDimensions(modalId, leftCoords, bottomPos);		    
	}; 
	
	DomObj.isNullOrEmpty = function(fieldId){
	    var textField = DomObj.getById(fieldId).value;
	    var isNullOrEmpty = false;
	    if (textField == "" || textField == null || textField.charAt(0) == ''){
	        isNullOrEmpty = true;
	    };
	    return isNullOrEmpty;
	};
	
	
	/*---------------------------------------- EVENTS -----------------------------------------------------
	* the function below deal with DOM events such as onmouseover onclick what element was the source
	* of the event, etc..
	------------------------------------------------------------------------------------------------------*/
	
	//Create a new Singleton Object called Evt
	function Evt(evt){
		this.evt = evt ? evt : window.event; //return the proper event for the correct browser
		this.evtSource = this.eventSource();  //Grab the source of this event		
		this.mouseX = this.evt.pageX ? this.evt.pageX : this.evt.clientX;
		this.mouseY = this.evt.pageY ? this.evt.pageY : this.evt.clientY;				
	} 		
	
	Evt.prototype.eventSource = function(){		
		var sourceOfEvent = (this.evt.currentTarget) ? this.evt.currentTarget : this.evt.srcElement;
		if (sourceOfEvent.nodeType == 3){ // defeat Safari bug that recognizes the text node
			 sourceOfEvent = sourceOfEvent.parentNode;
		}
			return sourceOfEvent; //return the element that fired the event	
	} //end function eventSource
	
	//Get the coordinates of where this event happened in this element
	Evt.prototype.getMouseClickCoords = function(){
		//Scope the object event to a local variable
		var evt = this.evt;		
		 //Use guard clause to return 0,0 coordinates if the browser doesn't support the DOM properties
		 if( !evt|| ( !DomObj.isNumber(evt.pageX) && !DomObj.isNumber(evt.clientX) ) ) { return { x:0, y:0 }; }
			
		//Now determine the coordinates based on object detection and not browser detection			
		return ((DomObj.isNumber(evt.pageX)) ? {x:evt.pageX , y:evt.pageY} : this.mostOtherBrowserCoords(evt.clientX, evt.clientY));			
		 
	}  // end function getElementCoords()
	
	//This function determines the majority of other popular browser for coordinates
	//Thanks to tarquinwj at http://evolt.org/user/27934 for this function that I slightly revised
	Evt.prototype.mostOtherBrowserCoords = function(xPos, yPos){		
		 if( !( ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) || ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) || window.navigator.vendor == 'KDE' ) ) {			 
			 if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {				
				xPos += document.documentElement.scrollLeft; yPos += document.documentElement.scrollTop;
			 } else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {				 
				xPos += document.body.scrollLeft; yPos += document.body.scrollTop;				
			 } //end inner if
		  } //end outer if
		  	//Will just return the number put in if they didn't change
		    return {x:xPos, y:yPos};
	} //end function mostOtherBrowserCoords()
	
	//Get Object's top and left coordinates regardless of whether it's relatively or absolutely positioned
	/* MUY IMPORTANTE -- THIS FUNCTION WILL STILL NOT REPORT CORRECTLY IN IE BECAUSE OF THE IDIOTIC WAY
		IT ATTACHES TO EVENTS. IT GOES THROUGH THE WINDOW OBJECT INSTEAD OF THE ELEMENT OBJECT
	*/
	Evt.prototype.getElementTopAndLeftCoord = function(){
		//Make a call to the DomObject's function
		return DomObj.getElementTopAndLeftCoord(this.evtSource);		
	} //end getRelativeElemCoords()
	
	
	//Add an event listener to the DOM (Class Level function)
	Evt.addEventListener = function (target,type,func,bubbles) {
			if (document.addEventListener) {
				target.addEventListener(type,func,bubbles);
			} else if (document.attachEvent) {
				target.attachEvent("on"+type,func,bubbles);
			} else {
				target["on"+type] = func;
			}
		}
	
	//Remove an event listener (Class Level function)
	Evt.removeEventListener = function (target,type,func,bubbles) {
			if (document.removeEventListener) {
				target.removeEventListener(type,func,bubbles);
			} else if (document.detachEvent) {
				target.detachEvent("on"+type,func,bubbles);
			} else {
				target["on"+type] = null;
			}
	}
	
	//Must refer to the specific instance of the selected event (Instance function)
	Evt.prototype.stopBubbling = function () {				
			if (this.evt.stopPropagation) {
				this.evt.stopPropagation();
				this.evt.preventDefault();
			} else {				
				this.evt.cancelBubble = true;
				this.evt.returnValue  = false;
			}
		};
	
	
	
	/*------------------------------------- SPECIAL EFFECTS ----------------------------------------------
	* The object below deals with cool special effects for your page	
	------------------------------------------------------------------------------------------------------*/

var EFX = {
	// 3 functions below are modified versions of one function found at www.blakems.com
	//This function will expand one or more elements if they are hidden
	expandIt: function(){
		if (arguments.length > 0){			
			var functionArgs = arguments;
			for (var i=0; i<functionArgs.length; i++) {
				var element = DomObj.getById(functionArgs[i]); //get the element
				if (element){ //make sure we grabbed a valid reference to an element
					element.style.display = "block"; //expand it
				} //end inner if
			} //end for
		} //end outer if	
	}, //end expandIt() function	
	
	//This function will collapse one or more elements if they are visible
	collapseIt: function(){
		if (arguments.length > 0){			
			var functionArgs = arguments;
			for (var i=0; i<functionArgs.length; i++) {
				var element = DomObj.getById(functionArgs[i]); //get the element
				if (element){ //make sure we grabbed a valid reference to an element
					element.style.display = "none"; //collapse it
				} //end inner if
			} //end for
		} //end outer if	
	}, //end collapseIt() function
	
	
	//This function will toggle expanding and collapsing elements
	expandOrCollapse: function(args){		
		if (arguments.length > 0){					
			var functionArgs = arguments;				
			for (var i=0; i<functionArgs.length; i++) {								
				var element = DomObj.getById(functionArgs[i]); //get the element
				if (element){ //make sure we grabbed a valid reference to an element					
					element.style.display = ((element.style.display == "none") ? "block" : "none");
				} //end inner if
			} //end for
		} //end outer if
	}, //end expandOrCollapse() function
	
	//This function swaps one image for another
	swapImage: function(imgElement, firstImg, secImg){			
		var imgSrc =  DomObj.getById(imgElement).src; //Grab the image source		
		DomObj.getById(imgElement).src = (imgSrc.indexOf(firstImg) == -1) ? (CONST.IMG_PATH + firstImg) : (CONST.IMG_PATH + secImg);		
		imgSrc = null; //dereference element
	} //end function swapImage()
	
	

} //---------------------- end of Special Effects=------------------------------------------


/*
function HM_f_StringTrim(){
    var TestString = this;
    var SpaceChar  = " ";
    while (TestString.charAt(0) == SpaceChar) {TestString = TestString.substr(1)};
    while (TestString.charAt(TestString.length-1) == SpaceChar) {TestString = TestString.substr(0,TestString.length-1)};
    return TestString.toString();
}

String.prototype.trim = HM_f_StringTrim;
*/


// The following block implements the string.parseJSON method


    
  