function prepareInputsForHints() {
    var inputs = document.getElementsByTagName("input");        
    for (var i=0; i<inputs.length; i++){
      // test to see if the hint span exists first
      if (((inputs[i].type == "text") || (inputs[i].type == "password")) && (inputs[i].id != "textZip")) {  
        if (inputs[i].parentNode.getElementsByTagName("span")[0]) {       
          // the span exists!  on focus, show the hint
          inputs[i].onfocus = function () {
            this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
          }
          // when the cursor moves away from the field, hide the hint
          inputs[i].onblur = function () {
            this.parentNode.getElementsByTagName("span")[0].style.display = "none";
          }
        }
      }
    }/* exclude the textZip input since we also need to call the zip lookup on onblur - handled below in the showZipError()*/

    

    var selects = document.getElementsByTagName("select");
    for (var k=0; k<selects.length; k++){
      if (selects[k].parentNode.getElementsByTagName("span")[0]) {
        selects[k].onfocus = function () {
          this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
        }
        selects[k].onblur = function () {
          this.parentNode.getElementsByTagName("span")[0].style.display = "none";
        }
      }
    }
    var links = document.getElementsByTagName("a");
    for (var j=0; j<links.length; j++){
      if (links[j].className == "ttlink") {
        if (links[j].parentNode.getElementsByTagName("span")[0]) {
          links[j].onmouseover = function () {
            this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
          }
          links[j].onmouseout = function () {
            this.parentNode.getElementsByTagName("span")[0].style.display = "none";
          }
        }
      }
    }
    
  }
  /* special function for the Zip/Postal Code lookup - we need to execute two functions on onblur when there's an error - displaying the tooltip and zip code lookup */
  function showZipError(){
      var inputZip = document.getElementById("textZip");  
      
      if(inputZip){     
        inputZip.onfocus = function () {
          document.getElementById("zipError").style.display = "inline";
        }
        inputZip.onblur = function () {
          document.getElementById("zipError").style.display = "none";
            getAddress(inputZip);
        }
      }
    }
  /* /special function for the Zip/Postal Code lookup */
  
  function checkboxes() {
      
      var postal = document.getElementById("commMethodCds2");
      var mobile = document.getElementById("commMethodCds3");
      
      var whyDiv = document.getElementById("why");
      var postalDiv = document.getElementById("showhide");
      var mobileDiv = document.getElementById("showHideMobile");
      
      if(postal && mobile && whyDiv && postalDiv && mobileDiv){
      
        if (postal.checked == 1){
          postalDiv.style.display = "block";
          whyDiv.style.display = "block";
        } else {
          postalDiv.style.display = "none";
          //whyDiv.style.display = "none";
        }
        mobileDiv.style.display = "block";
        if (mobile.checked == 1){
          mobileDiv.style.display = "block";
        } else {
          mobileDiv.style.display = "none";
        }
      
      }
      
    }
    
  /*For ZipCode lookup in Registration Step2 page*/ 
  function getAddress(field) {  
  
    //clear the address fields.
    $('#cityId')[0].value='';
    $('#state')[0].options[0].selected=true;
    $('#country_select')[0].options[0].selected=true;   
  
    var zipCode = field.value;    
    if(zipCode != null && !isNaN(zipCode)) {      
      zipCode = zipCode.trim();     
      if(zipCode != '') {   
        try {
          $.get("/zipcodelookup.htm?action=getAddress", {zipCode: zipCode },
                 function(data){                
              if(data.indexOf('|') > 0) {
                  var address = new Array();
                  address = data.split('|');
                  var city = address[0];
                  var state = address[1];
                  var country = address[2];
                  
                  //set the city
                  $('#cityId')[0].value=city;
                  
                  //set the state
                  var stateFieldElem = $('#state')[0];          
                    for(var i=0;i<stateFieldElem.options.length;++i){
                      if(stateFieldElem.options[i].value == state){
                        stateFieldElem.options[i].selected=true;
                        break;
                      } 
                  } 
                  
                  //set the country
                  var countryFieldElem = $('#country_select')[0];                       
                  for(var j=0; j<countryFieldElem.options.length; ++j){
                    if(countryFieldElem.options[j].value == country){
                      countryFieldElem.options[j].selected=true;
                      break;
                    } 
                  }
              }
                }
          );
        } catch (x) {       
          return;
        }
      }
    }
  } 
  
  
// Populates the hidden indiv checkbox when the indiv version of register now submit button is clicked
  function checkIndivInvestorType() {
    document.getElementById('indiv_checkbox').checked=true;
  }