$(document).ready(function(){

  $('.contact_button').click(function() {
		dataString = $("#ajax_contact").serialize();
		$.ajax({
			type: "POST",
			url: "process_contact.php",
			data: dataString,
			success: function(data)
			{
				//alert(data);
				var obj = $.parseJSON(data);
				var type = obj.type;
				var message = obj.message;
				if(type=='success')
				{
					$('#FormSuccess').html('<span>Thank you for your query, we wil get back to you within 24 hours.</span>');
					$('#FormSuccess').show();
					$('#FormError').hide();
					$('#contact_form').hide();
				}
				else
				{
					$(type).html(message);
					$(type).show();
					$('#FormSuccess').hide();
				}
			}
		});
	});
	
	$('.affiliate_button').click(function() {
		dataString = $("#ajax_affiliate").serialize();
		//alert(dataString);
		$.ajax({
			type: "POST",
			url: "process_affiliate.php",
			data: dataString,
			success: function(data)
			{
				//alert(data);
				var obj = $.parseJSON(data);
				var type = obj.type;
				var message = obj.message;
				if(type=='success')
				{
					$('#FormSuccess').html('<span>Thank you for your query, we wil get back to you within 24 hours.</span>');
					$('#FormSuccess').show();
					$('#FormError').hide();
					$('#affiliate_form').hide();
				}
				else
				{
					$(type).html(message);
					$(type).show();
					$('#FormSuccess').hide();
				}
			}
		});
	});
	
	$('.whitelabel_button').click(function() {
		dataString = $("#ajax_whitelabel").serialize();
		//alert(dataString);
		$.ajax({
			type: "POST",
			url: "process_whitelabel.php",
			data: dataString,
			success: function(data)
			{
				//alert(data);
				var obj = $.parseJSON(data);
				var type = obj.type;
				var message = obj.message;
				if(type=='success')
				{
					$('#FormSuccess').html('<span>Thank you for your query, we wil get back to you within 24 hours.</span>');
					$('#FormSuccess').show();
					$('#FormError').hide();
					$('#whitelabel_form').hide();
				}
				else
				{
					$(type).html(message);
					$(type).show();
					$('#FormSuccess').hide();
				}
			}
		});
	});
	
});
