﻿	// returns an object if it exists in the current DOM displayed, or null if it doesn't
/*
(C) Copyright MarketLive. 2006. All rights reserved.
MarketLive is a trademark of MarketLive, Inc.
Warning: This computer program is protected by copyright law and international treaties.
Unauthorized reproduction or distribution of this program, or any portion of it, may result
in severe civil and criminal penalties, and will be prosecuted to the maximum extent
possible under the law.
*/

	function buildObj(sObject){
		// if netscape build the correct path to the element in the DOM
		if (!document.all){
			var aObjTree = sObject.split("."); // split and store the ie version of the DOM tree
			var sTree = "";

			// when the tree is long, construct a new tree out of the split apart ie tree
			if (aObjTree.length > 1){
				for (var i=0; i<aObjTree.length; i++){
					if ((i+1)%2 == 0) sTree += ".document."; // inserts ref to the DOM document
					if (i < aObjTree.length -1) sTree += aObjTree[i]; // skips the last element
				}

			// just start a basic NS tree
			} else sTree += "document.";

			// reconstruct the sObject for a correct NS path to the element
			sObject = (sTree + "getElementById('"+ aObjTree[aObjTree.length -1] +"')");
		}

		// return the element or null if it doesn't exist
		return oCreatedObj = (eval("typeof("+sObject+")") != "undefined")? (eval(sObject)):null;
	}

    //  Legacy Javascript for enforcing maxlength 
    function maxlengthCheck(txt, maxlength){
        if(txt.value.length > maxlength){
            txt.value = txt.value.substring(0,maxlength);
        }
    }