﻿Sys.Application.add_init(function() {

    // Get a reference to the PageRequestManager.
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    
     // Unblock the form when a partial postback ends.
    prm.add_endRequest(function() {
        $('.formSending').html("<p>THANKYOU FOR YOUR QUERY.<br />IF YOUR MESSAGE REQUIRES A RESPONSE,<br />SOMEONE WILL GET BACK TO YOU AS SOON AS POSSIBLE.</p><p><strong>- The Moopa Team</strong></p>");
        $('.main-navigation a.show-form ').text("Contact Us");
        $('.formFieldset').hide();
        setTimeout(hideForm,2500);
    });
    
    
    function hideForm()
    {
        $('#contact-form').slideToggle(500);
    }


  $addHandler($get('submit'), 'click', function() {
  
     var isValid = Page_ClientValidate('formGroup');
     if (!isValid)
     {
        return (false);
     }       
    $('.main-navigation a.show-form ').text("Contact Us (close)");
    $('.formFieldset').hide();
    $('.formSending').show();
    
  });
  
});

$(function () {
    $('.main-navigation a.show-form ').click(function () {
        $(this.hash).slideToggle(500);
        if ($('.main-navigation a.show-form ').text() == 'Contact Us (close)') {
        $('.main-navigation a.show-form ').text("Contact Us");
        } else {
        $('.main-navigation a.show-form ').html("Contact Us <span>(close)</span>");
        }
        return false;
    });
})