$j('#resetbutton').click(function(){
	var formData = $j('#resetForm').serialize();
	if ($j('#resetForm').valid()) { 	
		$j.post(
			'post/reset.php',
			formData,
			function( data ){			
				if(data.success) {		
					$j('#success').html(data.message);				
					$j('#success').show("normal");					
					var statusTimeout = window.setTimeout("$j('#success').hide('normal');",6000);
					$j('form')[2].reset();			
				} else {
					$j('#error').html(data.message);
					$j('#error').show("normal");
					var statusTimeout = window.setTimeout("$j('#error').hide('normal');",6000);					
				}
			},
			'json'
		);
	} else {
		$j('#error').html('Hiba! Helytelen űrlapkitöltés!');
		$j('#error').show("normal");
		var statusTimeout = window.setTimeout("$j('#error').hide('normal');",5000);
	}
});

$j('#newsletterbutton').click(function(){
	var formData = $j('#newsletterForm').serialize();
	if ($j('#newsletterForm').valid()) { 	
		$j.post(
			'post/newsletter.php',
			formData,
			function( data ){
				if(data.success) {		
					$j('#success').html(data.message);				
					$j('#success').show("normal");
					var statusTimeout = window.setTimeout("$j('#success').hide('normal');",6000);
					$j('form')[2].reset();					
				} else {
					$j('#error').html(data.message);
					$j('#error').show("normal");
					var statusTimeout = window.setTimeout("$j('#error').hide('normal');",6000);
				}
			},
			'json'
		);
	} else {
		$j('#error').html('Hiba! Helytelen űrlapkitöltés!');
		$j('#error').show("normal");
		var statusTimeout = window.setTimeout("$j('#error').hide('normal');",5000);
	}
});

$j('#regbutton').click(function(){
	var formData = $j('#regForm').serialize();
	if ($j('#regForm').valid()) {
		$j.ajaxSetup({
   			cache: false
		});
		$j.post(
			'post/register.php',
			formData,
			function( data ){
				if(data.success) {		
					$j('#success').html(data.message);				
					$j('#success').show("normal");
					var statusTimeout = window.setTimeout("$j('#success').hide('normal');",6000);
					$j('form')[2].reset();					
				} else {
					$j('#error').html(data.message);
					$j('#error').show("normal");
					var statusTimeout = window.setTimeout("$j('#error').hide('normal');",6000);
				}
			},
			'json'
		);
	} else {
		$j('#error').html('Hiba! Helytelen űrlapkitöltés!');
		$j('#error').show("normal");
		var statusTimeout = window.setTimeout("$j('#error').hide('normal');",5000);
	}		
});

$j('#orderbutton').click(function(){
	var formData = $j('#orderForm').serialize();	
	$j.post(
		'post/order.php',
		formData,
		function( data ){
			if(data.success) {		
				$j('#success').html(data.message);				
				$j('#success').show("normal");
				$j('#main-cart').html(data.cart);
				$j('#cart-details').hide("fast");
				var statusTimeout = window.setTimeout("$j('#success').hide('normal');",6000);
				$j('form')[1].reset();					
			} else {
				$j('#error').html(data.message);
				$j('#error').show("normal");
				var statusTimeout = window.setTimeout("$j('#error').hide('normal');",6000);
			}
		},
		'json'
	);	
});

$j('#userbutton').click(function(){
	var formData = $j('#userForm').serialize();
	if ($j('#userForm').valid()) {
		$j.ajaxSetup({
   			cache: false
		});
		$j.post(
			'post/profile.php',
			formData,
			function( data ){
				if(data.success) {		
					$j('#success').html(data.message);				
					$j('#success').show("normal");
					var statusTimeout = window.setTimeout("$j('#success').hide('normal');",6000);			
				} else {
					$j('#error').html(data.message);
					$j('#error').show("normal");
					var statusTimeout = window.setTimeout("$j('#error').hide('normal');",6000);
				}
			},
			'json'
		);
	} else {
		$j('#error').html('Hiba! Helytelen űrlapkitöltés!');
		$j('#error').show("normal");
		var statusTimeout = window.setTimeout("$j('#error').hide('normal');",5000);
	}		
});
