function signupform_obj(){ 
this.popup = false;
this.ajax;
this.fname;
this.email;
this.pass;
this.zip;
this.focus_set;
this.passed;       
     

  if (typeof signupform_obj._initialized == "undefined") {
    
     signupform_obj.prototype.build = function (popup) {    
       this.popup = popup;
       this.ajax = new ajaxtester(); this.ajax.test();
       this.set_form_fields();

       //focus on first field
       if ($("new_signup_frm")){
         $("fname_hj").focus();
       }else{
         $("email_hj").focus();
       }  
       
       $ev("submit_hj", "click",  this.check_form, this, true);
  	   $ev("complete_button", "click",  this.complete_signup, this, true);
     }
        

     /* 
       Set the Form Field Input Vars
     */
     signupform_obj.prototype.set_form_fields = function () {
        if ($("fname_hj"))   this.fname     = $("fname_hj");
        if ($("lname_hj"))   this.lname     = $("lname_hj");
        if ($("email_hj"))   this.email     = $("email_hj");
        if ($("email_c_hj")) this.email_c   = $("email_c_hj");
        if ($("sn_key_hj"))  this.pass      = $("sn_key_hj");
        if ($("zip_hj"))     this.zip       = $("zip_hj");
        if ($("verif_hj"))   this.verif     = $("verif_hj");
        if ($("terms_hj"))   this.terms     = $("terms_hj");
        if ($("err_resp"))   this.error_div = $("err_resp");
     }
     
     
     /* 
       Check the Form Field Inputs
     */
     signupform_obj.prototype.check_form = function () {
       $("submit_hj").disabled = true;
       this.focus_set = false;
       this.passed    = true;
       //run checks
       if (typeof(this.fname) != "undefined") this.check_fname(); 
       if (this.passed) { if (typeof(this.lname) != "undefined")   {this.check_lname();}}
       if (this.passed) { if (typeof(this.email) != "undefined")   {this.check_email();}}
       if (this.passed) { if (typeof(this.email_c) != "undefined")   {this.check_email_c();}}
       if (this.passed) { if (typeof(this.pass) != "undefined")    {this.check_pass();}}
       if (this.passed) { if (typeof(this.zip) != "undefined")    {this.check_zip();}}
       //process check results 
       if (this.passed){ 
         $("form_1").style.display = "none";
         $("form_2").style.display = "block";
         if (typeof(this.error_tip) != "undefined") this.hide_error();     
       } else { 
         this.create_tip();
       }
       if ($("submit_hj")) {$("submit_hj").disabled = false;}
     }
     

     /* 
       check the verification
     */
     signupform_obj.prototype.complete_signup = function () {
       $("complete_button").disabled = true;
       this.focus_set = false;
       this.passed    = true;
       //run checks
       if (typeof(this.verif) != "undefined")   {this.check_verif();}
        
       //process check results 
       if (this.passed){ 

         this.post_call = new post_call(this, "signup");
         this.post_call.set_call($F("signup_call")); 
         this.post_call.post(); 
         
         if (typeof(this.error_tip) != "undefined") this.hide_error();
                    
       } else { 
         this.create_tip();
       }
       if ($("complete_button")) {$("complete_button").disabled = false;}
     }
     
        
     /* 
     *
     *  Create the error tip
     *
     */
     signupform_obj.prototype.create_tip = function () {
       this.error_tip = new YAHOO.widget.Overlay("error_tip", { 
                                                context:[this.error_div,"tl","bl"], visible:false, width:"220px", zIndex:9999 });
       this.error_tip.setBody("<div class='error_message'>"+this.error_message+"</div>"); 
       this.error_tip.render(document.body); 
       this.error_tip.show();
       $ev(this.error_div, "keypress", this.hide_error, this, true);
       $ev(this.error_div, "blur", this.hide_error, this, true);
     }
     
     
     /* 
     *
     *  Check the Full Name Input
     *
     */
     signupform_obj.prototype.check_fname = function () {
       this.fname.value = trim(this.fname.value);
       if (this.fname.value.length == 0){
         this.error_message = "Please enter your first name.";
         this.error_div     = "fname_hj";
         this.fname.focus(); this.focus_set = true;
         this.passed = false;
       }
     }
     
     
     /* 
       Check the Last Name Input
     */
     signupform_obj.prototype.check_lname = function () {
       this.lname.value = trim(this.lname.value);
       if (this.lname.value.length == 0){
         this.error_message = "Please enter your last name.";
         this.error_div     = "lname_hj";
         this.lname.focus(); this.focus_set = true;
         this.passed = false;
       }
     }
     

     /* 
       Check the Email Input
     */
     signupform_obj.prototype.check_email = function () {
       this.email.value = trim(this.email.value);
       var isValidEmail = function(sText) { 
          var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
          return reEmail.test(sText);  
       };
       ////////////////////////////////////////////////// 
       if (this.email.value.length > 0){
         if (!isValidEmail(this.email.value)) {
           this.error_message = "Please enter a valid email address.";
           this.error_div     = "email_hj";
           if(!this.focus_set) { this.email.focus(); this.focus_set = true; }
           this.passed = false;
         } 
       }else{  
         this.error_message = "Please enter your email address.";
         this.error_div     = "email_hj";
         if(!this.focus_set) { this.email.focus(); this.focus_set = true; }
         this.passed = false;
       }
     }
     
     
     /* 
       Check the Confirmation Email Input
     */
     signupform_obj.prototype.check_email_c = function () {
       this.email_c.value = trim(this.email_c.value);
       if (this.email_c.value != this.email.value){
         this.error_message = "The emails you entered did not match.";
         this.error_div     = "email_hj";
         this.email.focus(); this.focus_set = true;
         this.passed = false;
         this.email.value = "";
         this.email_c.value = "";
       }
     }
     
     
     
     /* 
       Check the Password Input
     */
     signupform_obj.prototype.check_pass = function () {
       this.pass.value = trim(this.pass.value);
       var isValidPass = function(sText, type) {
          if (type == "alpha"){
            var rePass =  /^[a-zA-Z]*$/;
          }else{
            var rePass =  /^[0-9]*$/;
          }
          return rePass.test(sText);  
       };
       //////////////////////////////////////////////////   
       if (this.pass.value.length > 0){
         if (this.pass.value.length < 6){
           this.error_message = "Please enter a password between 6 and 20 characters in length.";
           this.error_div     = "sn_key_hj";
           if(!this.focus_set) { this.pass.focus(); this.focus_set = true; }
           this.passed = false;
         }else{
           if (isValidPass(this.pass.value, 'alpha')) {
             this.error_message = "Your password must contain at least one number.";
             this.error_div     = "sn_key_hj";
             if(!this.focus_set) { this.pass.focus(); this.focus_set = true; }
             this.passed = false;
           } else if (isValidPass(this.pass.value, 'num')) {
             this.error_message = "Your password must contain at least one letter.";
             this.error_div     = "sn_key_hj";
             if(!this.focus_set) { this.pass.focus(); this.focus_set = true; }
             this.passed = false;
           } 
         }
       }else{
         this.error_message = "Please enter a password.";
         this.error_div     = "sn_key_hj";
         if(!this.focus_set) { this.pass.focus(); this.focus_set = true; }
         this.passed = false;
       }
     }
         
     
     /*
     *
     * Check for a valid Zip Code
     *
     */
     signupform_obj.prototype.check_zip = function(){
       this.zip.value = trim(this.zip.value);
       if (this.is_valid_zip(this.zip.value) || this.is_valid_canada_zip(this.zip.value)){
       }else{  
         this.error_message = "Please enter a valid zip code.";
         this.error_div     = "zip_hj";
         this.zip.focus(); this.focus_set = true;
         this.passed = false;
       }
     }
     signupform_obj.prototype.is_valid_zip = function( zip ) {
			 if ( typeof( zip ) == "object" ) zip = zip.value;
       zip = trim(zip);
			 var reZip = /^\d{5}?$/;
			 return reZip.test( zip );
		 }
     signupform_obj.prototype.is_valid_canada_zip = function( zip ) {
			 if ( typeof( zip ) == "object" ) zip = zip.value;
       zip = trim(zip);
			 var reZip = /^([ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9])*$/;
			 return reZip.test( zip );
		 }

	    
     /* 
       Check the Verification Input
     */
     signupform_obj.prototype.check_verif = function () {
       this.verif.value = trim(this.verif.value);
       if (this.verif){
         var isValidCode = function(sText) { 
            var reCode = /[a-zA-Z]{5,}/;
            return reCode.test(sText);  
         };
         ////////////////////////////////////////////////// 
         if (this.verif.value.length > 0){
           if (!isValidCode(this.verif.value)) {
             this.error_message = "The verification text your entered is incorrect";
             this.error_div     = "verif_hj";
             if(!this.focus_set) { this.verif.focus(); this.focus_set = true; }
             this.passed = false;
           }
         }else{
           this.error_message = "Please enter the text from the image above.";
           this.error_div     = "verif_hj";
           if(!this.focus_set) { this.verif.focus(); this.focus_set = true; }
           this.passed = false;
         }
       }
     }
          
     
    /* 
       Hide the error tip
    */
    signupform_obj.prototype.hide_error = function () {
      YAHOO.util.Event.removeListener(this.error_div, "keypress", this.hide_error);
      YAHOO.util.Event.removeListener(this.error_div, "blur", this.hide_error);
      this.error_tip.hide();
    }  
     
         
    /*
    *
    * Singup Object Return Call
    *
    */ 
    signupform_obj.prototype.return_call = function (response_text, call) {
       switch(call){
        case "new_signup":  
            m = YAHOO.lang.JSON.parse(response_text);
            if (m.passed == "true") {
              var cb = function () {window.location.replace('/gethired/');}
              var cb2 = function () {window.location.replace('/mybragadoo/');}
              $("form_2").style.display = "none";
              $("form_3").style.display = "block";
              $ev("areyou_yes", "click", cb, this, true);
              $ev("areyou_no", "click", cb2, this, true);
            } else {
              this.process_error(m);
            }
        break;
        case "full_signup":
            m = YAHOO.lang.JSON.parse(response_text);
            if (m.passed == "true") {
              $("signup_form").style.display = "none";
              $("service_form").style.display = "block";
            } else {
              this.process_error(m);
            }
        break;
        case "brag_signup": 
            m = YAHOO.lang.JSON.parse(response_text);
            if (m.passed == "true") {  
              window.location.replace(m.userurl);
            } else {
              this.process_error(m);
            }
        break;
      }
    }
    
    
    /*
    *
    * Process a signup error
    *
    */ 
    signupform_obj.prototype.process_error = function (error_json) {
      switch (error_json.err_form){  
        case "form_1":
          $("form_1").style.display = "block";
          $("form_2").style.display = "none";
          if ($("ser_form_1")) $("ser_form_1").style.display = "none";
          if ($("ser_form_2")) $("ser_form_2").style.display = "none";    
          if (!YAHOO.lang.isUndefined(error_json.fname_hj)) {
            this.error_message = error_json.fname_hj;
            this.error_div     = "fname_hj";
            this.fname.focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.lname_hj)) {
            this.error_message = error_json.lname_hj;
            this.error_div     = "lname_hj";
            this.lname.focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.email_hj)) {
            this.error_message = error_json.email_hj;
            this.error_div     = "email_hj";
            this.email.focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.sn_key_hj)) {
            this.error_message = error_json.sn_key_hj;
            this.error_div     = "sn_key_hj";
            this.pass.focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.zip_hj)) {
            this.error_message = error_json.zip_hj;
            this.error_div     = "zip_hj";
            this.zip.focus(); 
          } 
          refreshVerification();
        break;
        case "form_2":
          $("form_1").style.display = "none";
          $("form_2").style.display = "block";
          if ($("ser_form_1")) $("ser_form_1").style.display = "none";
          if ($("ser_form_2")) $("ser_form_2").style.display = "none";
          this.error_message = error_json.verif_hj;
          this.error_div     = "verif_hj";
          this.verif.value   = "";
          refreshVerification();
          this.verif.focus(); 
        break;
        case "ser_form_1":
          $("form_1").style.display = "none";
          $("form_2").style.display = "none";
          if ($("ser_form_1")) $("ser_form_1").style.display = "block";
          if ($("ser_form_2")) $("ser_form_2").style.display = "none";
          if (!YAHOO.lang.isUndefined(error_json.sername_hj)) {
            this.error_message = error_json.sername_hj;
            this.error_div     = "sername_hj";
            $("sername_hj").focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.descr_hj)) {
            this.error_message = error_json.descr_hj;
            this.error_div     = "descr_hj";
            $("descr_hj").focus(); 
          } 
          refreshVerification();
        break;
        case "ser_form_2":
          $("form_1").style.display = "none";
          $("form_2").style.display = "block";
          if ($("ser_form_1")) $("ser_form_1").style.display = "none";
          if ($("ser_form_2")) $("ser_form_2").style.display = "block";
          if (!YAHOO.lang.isUndefined(error_json.sform_gens)) {
            this.error_message = error_json.sform_gens;
            this.error_div     = "sform_gens";
            $("sform_gens").focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.sform_sers)) {
            this.error_message = error_json.sform_sers;
            this.error_div     = "sform_sers";
            $("descr_hj").focus(); 
          } else if (!YAHOO.lang.isUndefined(error_json.sform_subs)) {
            this.error_message = error_json.sform_subs;
            this.error_div     = "sform_subs";
            $("sform_subs").focus(); 
          } 
          refreshVerification();
        break;
      }
      
      this.create_tip(); this.focus_set = true;
    }
    
       
    signupform_obj._initialized = true;
  } 
}


function refreshVerification (){
  $("ver_img").src = "/verification.hj?cachebuster="+new Date().getTime();
  $("verif_hj").value = "";
}
