$(document).ready(function() { 
    var options = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
 
        url:       '/Modules/ContactModule/Contact/Contact.class.php',         
        type:      'post',        // 'get' or 'post', override for form's 'method' attribute 
        clearForm: true,        // clear all form fiel	ds after successful submit 
        resetForm: true        // reset the form after successful submit 
     }; 
	 
	 
	var submit_options = { 
		beforeSubmit:  showGameRequest,  // pre-submit callback 
		success:       showGameResponse,  // post-submit callback 
		iframe: 		true,
        url:       '/Modules/Uploads/Games.class.php',         
	
		// other available options: 
		type:      'post',        // 'get' or 'post', override for form's 'method' attribute 
		//dataType:  'json',        // 'xml', 'script', or 'json' (expected server response type) 
		clearForm: true,        // clear all form fields after successful submit 
		resetForm: true,        // reset the form after successful submit 
	 }; 
	 
 
    // bind form using 'ajaxForm' 
    $('#ContactForm').ajaxForm(options); 
    $('#SwfGameForm').ajaxForm(submit_options); 
}); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
	if (ValidateContact(this) == true)
	{
		$('.contact_btns').fadeOut('normal', function()
			{
				$('#FormPreloader').fadeIn('normal');
		});
		return true; 
	}else{
		return false;
	}
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  {
 		$('#FormPreloader').fadeOut('normal', function()
		{
			$('.contact_btns').fadeIn('slow');

		alert('Hey.. it seems that we\'ve got your message! We\'ll get back soon! Thanks!');


	});
} 


// pre-submit game callback 
function showGameRequest(formData, jqForm, submit_options) 
{ 
	var queryString = $.param(formData); 
	//alert(queryString);
	
	if (CheckGameForm(this) == true)
	{
		$('.contact_btns').fadeOut('normal', function()
			{
				$('#FormPreloader').fadeIn('normal');
		});
		return true; 
	}else{
		return false;
	}
} 
 
// post-submit game callback 
function showGameResponse(responseText, statusText)  
{
		//alert(responseText + '\n' + statusText);
 		$('#FormPreloader').fadeOut('normal', function()
		{
			$('.contact_btns').fadeIn('slow');
		});
		
		alert('Thank you! Your game has been received! We will review it as soon as possible and we will let you know when it is published!');
		
} 
