/* VALIDATION + AJAX SUBMISSION */
function callSuccessFunction() {
	
	//Serialize Form Data
	var str = $('#contact-form').serialize();
	//Disable Form Fields
	$('input').attr('disabled', 'true');
	//Show Loading GIF
	$('.loading').show();
	//Hide submit button
	$('#submit-contact').hide();
	//Send AJAX Request
	$.ajax({
		url: 'submit-contact.php',
		type: 'post',
		data: str,
		success: function (html) {
			$('#login').fadeOut('slow');
			$('.loading').fadeOut('slow');
			$('.contact-done').append(html).fadeIn('slow');
			$('.loading').hide();
		}
	});
}

$(document).ready(function(){
	$("#contact-form").validationEngine({
		success :  function() { callSuccessFunction() },
		failure : function() {}
	})
});

/* JQUERY SLIDE */
$(document).ready(function() {
	$("div.panel_button").click(function(){
		$("div#panel").animate({
			width: "600px"
		})
		.animate({
			width: "500px"
		}, "fast");
		$("div.panel_button").toggle();
		
		/* ANIMATE THE BUTTON */
		$('div.panel_button').animate({
			marginLeft: '600px'
		}).animate({
			marginLeft: '500px'
		}, 'fast');
		/* SHOW FORM VALIDATION */
		$('.formError').hide().delay(5000).show();
	
	})
	
   $("div#hide_button").click(function(){
		$("div#panel").animate({
			width: "0px"
		}, "fast");
		
		/* ANIMATE THE BUTTON */
		$('div.panel_button').animate({
			marginLeft: '0px'							  
		}, 'fast');
		
		/* HIDE FORM VALIDATION */
		$('.formError').hide();
	
   });	
	
});
