  $(document).ready(function(){
  
    $("#contactLink").click(function(){
      $(':input','#ASC_Contact')
        .not(':button, :submit, :reset, :hidden')
        .val('')
        .removeAttr('checked')
        .removeAttr('selected');

      if ($("#contactForm").is(":hidden")){
        $("#contactForm").css({'background-image' : 'url(/contact_bg.png)', 'height' : '377px'});
        $("#contactError").hide();
        $("#contactForm fieldset").show();
        $("#contactForm").slideDown("slow");
      }
      else{
        $("#contactForm").slideUp("slow");
      }
    });

    $("#ASC_Contact").submit(function(){
      var str = $('#ASC_Contact').serialize();
      $.ajax({
        type: "POST",
        url: "contact.php",
        data: str,
        success: function(msg){
    
          $("#contactForm").ajaxComplete(function(event, request, settings){
            if(msg == 'OK')
            {
              $("#contactForm fieldset").hide("slow");
              $(':input','#ASC_Contact')
                .not(':button, :submit, :reset, :hidden')
                .val('')
                .removeAttr('checked')
                .removeAttr('selected');
              $("#contactError").hide();
              $("#contactConfirm").show("slow");
              $("#contactForm").unbind();
              setTimeout('$("#contactConfirm").hide();$("#contactForm").slideUp("slow");$("#contactForm").css({"background-image" : "url(/contact_bg.png)", "height" : "377px"});', 3000);
              return false;
            }
            else
            {
              $("#contactForm").css({'background-image' : 'url(/contact_bg_error.png)', 'height' : '430px'});
              $("#contactError").show("slow");
              event.preventDefault();
              $("#contactForm").unbind();
              return false;
            }
          });
          return false;
        }
      });
      return false;
    });


  });

  function cancelForm(){
      $(':input','#ASC_Contact')
        .not(':button, :submit, :reset, :hidden')
        .val('')
        .removeAttr('checked')
        .removeAttr('selected');
    $("#contactForm").css({'background-image' : 'url(/contact_bg.png)', 'height' : '377px'});
    $("#contactError").hide();
    $("#contactForm").slideUp("slow");
  }

