// JavaScript Document    

    var voptions = {
                     rules: {
                              name: "required",
                              email: {
                                      required: true,
                                      email: true
                              }
                      },
                      messages: {
                              name: "<em class='req'>Please enter your name.</em>",
                              email: "<em class='req'>Please enter a valid email address.</em>"                        
                      }
                  };

  
    function formDisplay(data)
    {
        // FF2.0 was causing a jQuery UI sliding bug 
        if (BrowserDetect.browser == 'Firefox' && BrowserDetect.version == '2')
        {
            $("#dynamic").empty().append(data);
        }
        else
        {     
            $("#dynamic").empty().append(data).show("slide", { direction: "down"}, 1000);
        }
        if ( $("#enrollForm").is('form')) {
  	       $("#enrollForm").validate(voptions);
  	    }
    }


    $(document).ready(function() {
    
      $.validator.setDefaults({
        	submitHandler: function() {
              window.location.hash = 'thankyou';                             
              $.post("emailSend.php",
                      { data : $("#enrollForm").serialize() },
                      function(data) {
                          // FF2.0 was causing a jQuery UI sliding bug
                          if (BrowserDetect.browser == 'Firefox' && BrowserDetect.version == '2')
                          {
                              $("#dynamic").empty().append(data);
                          }
                          else
                          {
                              $("#dynamic").empty().append(data).show("slide", { direction: "down"}, 1000);
                          }                                                         
                          $("#success").css("color","blue");                                       
                          $("#success").css("text-align","center");
                          $("#success").css("font-weight","bold");
                          $("#failure").css("color","red");                                       
                          $("#failure").css("text-align","center");                          
                          $("#failure").css("font-weight","bold");                          
                      }
              );                
          }
      }); 
              
      var uri = location.href;
      var hash = location.hash.slice(1);
      if (hash)
      {
          if (hash == "companies")
          {
              $.get("companies.html", { }, formDisplay);                          
          } 
          else if (hash == 'private')
          {          
              $.get("private.html", { }, formDisplay);                                    
          }
      }
            
      $(".request").click(function () {                                        
        $.get("companies.html", { }, formDisplay);                                  
      });
      
      $(".request2").click(function () {                      
        $.get("private.html", { }, formDisplay);                                      
      });
      
    });
  

