// returns an object if it exists in the current DOM displayed, or null if it doesn't
	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);
        }
    }
    
    
// ************************************************
// Added 5.20.08 - bjackson - implementing a global replacement of umlaut 
// characters on all site form input and textarea elements
// ************************************************

// function to swap unlaut characters for their roman counterparts
// this replaces in ALL text fields within the document
// not just the submitted form to handle any javascript form submissions that
// may be in place with inline submit handlers
function SwapUmlauts() {
   var r  = new Object();
   r["ä"] =  "ae";
   r["ö"] =  "oe";
   r["ü"] =  "ue";
   r["Ä"] =  "Ae";
   r["Ö"] =  "Oe";
   r["Ü"] =  "Ue";
   r["ß"] =  "ss";   
   
   var inputs = document.getElementsByTagName('input');
   for(var i=0;i<inputs.length;i++){
      var input = inputs[i];
      if(input.type == 'text'){
        for(c in r){
            if(input.value.indexOf(c) != -1){
                var re = new RegExp(c,"g");
                var v = input.value.replace(re,r[c]);
                input.value = v;
            }
        }           
      }
   }
}

// Cross-browser implementation of element.addEventListener()
function addListener(element, type, expression, bubbling){
      bubbling = bubbling || false;
      if(window.addEventListener) { // Standard
              element.addEventListener(type, expression, bubbling);
              return true;
      } else if(window.attachEvent) { // IE
              element.attachEvent('on' + type, expression);
              return true;
      } else return false;
}

// Sets event handlers for all form submits to the umlaut replacement script
function SetGlobalSubmitHandle(){
     for(var i=0;i<document.forms.length;i++){
         addListener(document.forms[i],'submit',SwapUmlauts);
     }       
}

// on document load, add submit listeners to any form to call umlaut repalcement script globally
addListener(window,'load',SetGlobalSubmitHandle);