
      function getXMLReq() {
        var req;
        req = false;
        // branch for native XMLHttpRequest object
        if(window.XMLHttpRequest) {
          try {
            req = new XMLHttpRequest();
          } catch(e) {
            req = false;
          }
          // branch for IE/Windows ActiveX version
        } else if(window.ActiveXObject) {
          try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
          } catch(e) {
            try {
              req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
              req = false;
            }
          }
        }
        return req;
      }

      var regWasHit = false;

      var badColor      = "#f4d6c5";
      //var goodColor     = "#ffffff";
      var goodColor     = "#ffffff";
      var phoneColor    = "#f4d6c5";
      var reqColor      = "#ffffcc";
      var reqPhoneColor = "#fff7ea";

      function disableSubmit()
      {
        document.getElementById( 'idSUBMIT' ).disabled=true;
        document.getElementById( 'idSUBMIT' ).value='processing...';
      }

      function enableSubmit()
      {
        document.getElementById( 'idSUBMIT' ).disabled=false;
        document.getElementById( 'idSUBMIT' ).value='sign up submit';
      }

      function verifyRegexp( reg, object, value )
      {
        var retVal = 0;

        if ( !value.match(reg) ) {
          object.style.backgroundColor= badColor;
          retVal = 1;
        } else {
          object.style.backgroundColor = goodColor;
        }

        return( retVal );
      }

      function verifyEmail( object, value )
      {
        var regEmail =/^[^\s]+@.*\.[^\s]+$/;
        return(verifyRegexp( regEmail, object, value ));
      }

      function verifyAlpha( object, value)
      {
        var regHasAlpha = /[a-zA-Z]/;
        return(verifyRegexp( regHasAlpha, object, value ));
      }

      function verifyAny( object, value)
      {
        var regHasAny = /[a-zA-Z0-9]/;
        return(verifyRegexp( regHasAny, object, value ));
      }

      function verifyNum( object, value)
      {
        var regHasAlpha = /[0-9]/;
        return(verifyRegexp( regHasAlpha, object, value ));
      }

      function verifyZip( object, value)
      {
        var retVal = 0;
        var regZip = /^[0-9]{5}(|-?[0-9]{4})$/;
        var regEmpty = /^$/;
        if ( verifyRegexp( regZip, object, value ) && (value != String("")) )
        {
          retVal=1;
        }
        else
        {
          object.style.backgroundColor = goodColor;
        }
        return(retVal);
      }

      function verifyAltPhones( 
          oneKind, one1, one2, one3, strOne,
          twoKind, two1, two2, two3, strTwo )
      {
        var retVal = new String();
        var badOne = 0;
        var badTwo = 0;
        var emptyCount = 0;
        var phoneCount = 0;
        var regPhone = /^[0-9]{3}-[0-9]{3}-[0-9]{4}(|\s*[x#]\s*[0-9]*)$/;
        var emptyPHone = /^[\-][\-][#]?$/;

        if ( strOne.match(regPhone) ) { 
          phoneCount += 1; 
        } else { 
          if ( !strOne.match(emptyPHone) )
          {
            badOne = 1; 
            retVal += "Badly formated "+oneKind.value+"(1) Phone.\n"; 
          }
          else
          {
            emptyCount += 1;
          }
        }

        if ( strTwo.match(regPhone) ) { 
          phoneCount += 1; 
        } else { 
          if ( !strTwo.match(emptyPHone) )
          {
            badTwo = 1; 
            retVal += "Badly formatted "+twoKind.value+"(2) Phone.\n"; 
          }
          else
          {
            emptyCount += 1;
          }
        }

        if ( (phoneCount == 0) && (emptyCount == 2))
        {
          retVal += "At least one valid phone numbers is required.\n";

          oneKind.style.backgroundColor = phoneColor;
          one1.style.backgroundColor = phoneColor;
          one2.style.backgroundColor = phoneColor;
          one3.style.backgroundColor = phoneColor;
          twoKind.style.backgroundColor = phoneColor;
          two1.style.backgroundColor = phoneColor;
          two2.style.backgroundColor = phoneColor;
          two3.style.backgroundColor = phoneColor;
        }
        else
        {
          if ( badOne )
          {
            one1.style.backgroundColor = badColor;
            one2.style.backgroundColor = badColor;
            one3.style.backgroundColor = badColor;
          }
          else
          {
            one1.style.backgroundColor = goodColor;
            one2.style.backgroundColor = goodColor;
            one3.style.backgroundColor = goodColor;
          }
          if ( badTwo )
          {
            two1.style.backgroundColor = badColor;
            two2.style.backgroundColor = badColor;
            two3.style.backgroundColor = badColor;
          }
          else
          {
            two1.style.backgroundColor = goodColor;
            two2.style.backgroundColor = goodColor;
            two3.style.backgroundColor = goodColor;
          }

          if ( (String(twoKind.value) == String(oneKind.value)) && (phoneCount != 1) && (emptyCount != 1)   )
          {
            retVal += "Phone Numbers Must Be For 2 Different Locations.\n";
            oneKind.style.backgroundColor = badColor;
            twoKind.style.backgroundColor = badColor;
          }
          else
          {
            oneKind.style.backgroundColor = goodColor;
            twoKind.style.backgroundColor = goodColor;
          }
        }

        if ( (String(retVal) != String("")) && ( (String(oneKind.value) == String("Work")) || (String(twoKind.value) == String("Work")) ) )
        {
            retVal += "Work Numbers may have an extension in the format [123]-[123]-[1234x1234]\n";
        }


        return( retVal );
      }

      function verifyPhone( 
          h1, h2, h3, strh )
      {
        var retVal = new String();
        var badH = 0;
        var emptyCount = 0;
        var phoneCount = 0;
        var regPhone = /^[0-9]{3}-[0-9]{3}-[0-9]{4}(|[#][0-9]*)$/;
        var emptyPHone = /^[\-][\-][#]?$/;

        if ( strh.match(regPhone) ) { 
          phoneCount += 1; 
        } else { 
          if ( !strh.match(emptyPHone) )
          {
            badH = 1; 
            retVal += "Badly formated Home Phone.\n"; 
          }
          else
          {
            emptyCount += 1;
          }
        }

        if ( (phoneCount == 0) && (emptyCount == 1))
        {
          retVal += "A valid phone number is required.\n";
          h1.style.backgroundColor = phoneColor;
          h2.style.backgroundColor = phoneColor;
          h3.style.backgroundColor = phoneColor;
        }
        else
        {
          if ( badH )
          {
            h1.style.backgroundColor = badColor;
            h2.style.backgroundColor = badColor;
            h3.style.backgroundColor = badColor;
          }
          else
          {
            h1.style.backgroundColor = goodColor;
            h2.style.backgroundColor = goodColor;
            h3.style.backgroundColor = goodColor;
          }
        }

        return( retVal );
      }

      function verifyAllPhone( 
          h1, h2, h3, strh,
          m1, m2, m3, strm,
          w1, w2, w3, w4, strw )
      {
        var retVal = new String();
        var badH = 0;
        var badM = 0;
        var badW = 0;
        var emptyCount = 0;
        var phoneCount = 0;
        var regPhone = /^[0-9]{3}-[0-9]{3}-[0-9]{4}(|[#][0-9]*)$/;
        var emptyPHone = /^[\-][\-][#]?$/;

        if ( strh.match(regPhone) ) { 
          phoneCount += 1; 
        } else { 
          if ( !strh.match(emptyPHone) )
          {
            badH = 1; 
            retVal += "Badly formated Home Phone.\n"; 
          }
          else
          {
            emptyCount += 1;
          }
        }

        if ( strm.match(regPhone) ) { 
          phoneCount += 1; 
        } else { 
          if ( !strm.match(emptyPHone) )
          {
            badM = 1; 
            retVal += "Badly formatted Mobile Phone.\n"; 
          }
          else
          {
            emptyCount += 1;
          }
        }

        if ( strw.match(regPhone) ) { 
          phoneCount += 1; 
        } else { 
          if ( !strw.match(emptyPHone) )
          {
            badW = 1; 
            retVal += "Badly formatted Work Phone.\n";; 
          }
          else
          {
            emptyCount += 1;
          }
        }

        if ( (phoneCount == 0) && (emptyCount == 3))
        {
          retVal += "At least one valid phone number is required.\n";
          h1.style.backgroundColor = phoneColor;
          h2.style.backgroundColor = phoneColor;
          h3.style.backgroundColor = phoneColor;
          m1.style.backgroundColor = phoneColor;
          m2.style.backgroundColor = phoneColor;
          m3.style.backgroundColor = phoneColor;
          w1.style.backgroundColor = phoneColor;
          w2.style.backgroundColor = phoneColor;
          w3.style.backgroundColor = phoneColor;
          w4.style.backgroundColor = phoneColor;
        }
        else
        {
          if ( badH )
          {
            h1.style.backgroundColor = badColor;
            h2.style.backgroundColor = badColor;
            h3.style.backgroundColor = badColor;
          }
          else
          {
            h1.style.backgroundColor = goodColor;
            h2.style.backgroundColor = goodColor;
            h3.style.backgroundColor = goodColor;
          }
          if ( badM )
          {
            m1.style.backgroundColor = badColor;
            m2.style.backgroundColor = badColor;
            m3.style.backgroundColor = badColor;
          }
          else
          {
            m1.style.backgroundColor = goodColor;
            m2.style.backgroundColor = goodColor;
            m3.style.backgroundColor = goodColor;
          }
          if ( badW )
          {
            w1.style.backgroundColor = badColor;
            w2.style.backgroundColor = badColor;
            w3.style.backgroundColor = badColor;
            w4.style.backgroundColor = badColor;
          }
          else
          {
            w1.style.backgroundColor = goodColor;
            w2.style.backgroundColor = goodColor;
            w3.style.backgroundColor = goodColor;
            w4.style.backgroundColor = goodColor;
          }
        }

        return( retVal );
      }

      function verifyUserName( user, userVal, vuser, vuserVal )
      {
        var retVal    = new String();
        var badUser   = 0;
        var badvUser  = 0;

        if ( String(userVal) != String(vuserVal) )
        {
          retVal += "Email address doesn't match verify Email Address\n";;
        }

        if ( verifyEmail( user, userVal ) )
        {
          retVal += "Email address is badly formatted\n";
        }

        if ( retVal != String(""))
        {
          user.style.backgroundColor = badColor;
          vuser.style.backgroundColor = badColor;
        }
        else
        {
          user.style.backgroundColor = goodColor;
          vuser.style.backgroundColor = goodColor;
        }

        return( retVal );
      }

      function verifyAllPass( pass, passVal, vPass, vPassVal, passHint, passHintVal  )
      {
        var reg3 = /[\S]{3,}/;
        var retVal     = new String();
        var passBad    = 0;
        var vPassBad = 0;
        var passHintBad = 0;

        if ( String(passVal) != String(vPassVal) )
        {
          retVal += "Password doesn't Match Verify Password.\n";
          passBad += 1;
          vPassBad += 1;
        }

        if ( (String(passHintVal) == String(passVal)) && (passHintVal != String("")) )
        {
          retVal += "Password shouldn't match the Password Hint.\n";
          passHintBad += 1;
        }

        if ( verifyRegexp( reg3, pass, passVal ) )
        {
          retVal += "Password cannot be less than 3 characters long.\n";;
          passBad += 1;
          vPassBad += 1;
        }

        /*if ( verifyAny( passHint, passHintVal ) )
        {
          retVal += "Please, provide yourself with a Hint.\n";
          passHintBad += 1;
        }*/

        if ( passHint )
        {
          if ( passHintBad > 0) { 
            passHint.style.backgroundColor= badColor; 
          }else{
            passHint.style.backgroundColor= goodColor; 
          }
        }
        if ( passBad > 0) { 
          pass.style.backgroundColor= badColor; 
        }else{
          pass.style.backgroundColor= goodColor; 
        }
        if ( vPassBad > 0) { 
          vPass.style.backgroundColor= badColor; 
        }else{
          vPass.style.backgroundColor= goodColor; 
        }

        return( retVal );
      }


      function verifySearch14()
      {
        var errors = new String();

        /* Purchase Price Section */
        var oPriceMin  = document.getElementById("idPRICE_MIN");
        var strPriceMin = new String( oPriceMin.options[oPriceMin.selectedIndex].value );

        var oPriceMax  = document.getElementById("idPRICE_MAX");
        var strPriceMax = new String( oPriceMax.options[oPriceMax.selectedIndex].value );

        var ret1 = verifyNum( oPriceMin, strPriceMin );
        var ret2 = verifyNum( oPriceMax, strPriceMax );
        if (  ret1 || ret2  )
        {
          errors += "Please, provide a purchase price range.\n";
        }

        var oCity  = document.getElementById("idCITY");

        if ( oCity.selectedIndex == 0 )
        {
          errors += "Please, mark a city.\n";
          oCity.style.backgroundColor = badColor;
        }
        else
        {
          oCity.style.backgroundColor = goodColor;
        }

        if ( errors != String("") ) {
          //window.alert(errors);
          window.location.href="#top";
          //document.getElementById('idREG_WARNING').innerHTML='*Correct highlighted fields';
        }
        else
        {
          //document.getElementById('idREG_WARNING').innerHTML='';
          disableSubmit();
          document.getElementById('idFORM_REGISTER').submit();
        }

      }
