$(document).ready(function() {
    var ajaxurl = 'http://www.republicmoving.com/wp-admin/admin-ajax.php';

   $('#navbar ul a + ul').each(function() {
      // Create the tooltip
      $(this).prev('a').qtip({
         content: {
            text: $(this)
         },
         position: {
            my: 'top left',
            at: 'bottom left'
         },
         hide: {
            fixed: true,
            delay: 100
         },
         style: {
            classes: 'ui-tooltip-blue',
            tip: false
         }
      });
   });
   $('#submit').click(function(){
       $('#contact_loader').show();
       $('#contact_form').hide();
       $.ajax({
         url: ajaxurl,
         type: "POST",
         data: {
             action: 'contact_us',
             name: $('#contact_name').val(),
             email: $('#contact_email').val(),
             message: $('#contact_message').val()
         },
         success: function(data){
           if (data.success == true) {
               $('#contact_loader').hide();
               $('#contact_thankyou').show();
           } else {
               $('#contact_loader').hide();
               $('#contact_form').show();
               alert(data.message);
           }
         },
         dataType: 'json'
       });
      return false;
   });
   $('#lead_submit').click(function(){
       $('#lead_loader').show();
       $('#lead_form').hide();
        $.ajax({
          url: ajaxurl,
          type: "POST",
          data: {
              action: 'lead_submit',
              name: $('#lead_name').val(),
              email: $('#lead_email').val(),
              pickupzip: $('#lead_pickupzip').val(),
              deliveryzip: $('#lead_deliveryzip').val(),
              phone: $('#lead_phone').val(),
              movingdate: $('#lead_movingdate').val(),
              dwellingtype: $('#lead_dwellingtype').val()
          },
          success: function(data){
            if (data.success == true) {
                $('#lead_loader').hide();
                $('#lead_thankyou').show();
            } else {
                $('#lead_loader').hide();
                $('#lead_form').show();
                alert(data.message);
            }
          },
          dataType: 'json'
        });
       return false;
   });

   $('#lead_submit2').click(function(){
       $('#lead_loader').show();
       $('#lead_form2').hide();
        $.ajax({
          url: ajaxurl,
          type: "POST",
          data: {
              action: 'lead_submit',
              name: $('#lead_name').val(),
              email: $('#lead_email').val(),
              pickupzip: $('#lead_pickupzip').val(),
              deliveryzip: $('#lead_deliveryzip').val(),
              phone: $('#lead_phone').val(),
              movingdate: $('#lead_movingdate').val(),
              dwellingtype: $('#lead_dwellingtype').val()
          },
          success: function(data){
            if (data.success == true) {
                $('#lead_loader').hide();
                $('#lead_thankyou').show();
            } else {
                $('#lead_loader').hide();
                $('#lead_form2').show();
                alert(data.message);
            }
          },
          dataType: 'json'
        });
       return false;
   });
	
	$("#contactArea").css('height', '0px');

	$("a.contact").toggle( 
				function () { 
 					$("#contactArea").animate({height: "225px"}, {queue:false, duration: 1700, easing: 'easeOutBounce'}) 
                }, 
                function () { 
					$("#contactArea").animate({height: "0px"}, {queue:false, duration: 1700, easing: 'easeOutBounce'})  
				} 
		);

});
