$j(document).ready(function(){
	$j('.contact_req')
		.unbind('blur')
		.blur(function(){
			$j(this).next('img').remove();
			if ($j(this).isEmpty())
			{
				$j(this).after('<img src="images/wrong_icon.gif" align="absmiddle" alt="wrong">');
				return;
			}
			$j(this)
				.after('<img src="images/correct_icon.gif" align="absmiddle" alt="correct">')
				.next('img')
					.fadeOut(2500);
		});
	$j('#email')
		.unbind('blur')
		.blur(function(){
			$j(this).next('img').remove();
			if (!$j(this).emailCheck())
			{
				$j(this).after('<img src="images/wrong_icon.gif" align="absmiddle" alt="wrong">');
				return;
			}
			$j(this)
				.after('<img src="images/correct_icon.gif" align="absmiddle" alt="correct">')
				.next('img')
					.fadeOut(2500);
		});
	$j('.contact_req')
		.unbind('focus')
		.focus(function(){
			$j(this).next('img').remove();
		});
	$j('#submitcontact')
		.unbind('click')
		.click(function(){
			$j('.contact_req').blur();
			$j('#email').blur();
			if ($j('[@alt="wrong"]').length > 0)
			{
				return;
			}
			var f = $j(this).parent().parent();
			//f.submit();
			var data = f.serializeArray();
			
			$j.ajax({
				data:		data,
				url:		'contactus.php',
				type:		'post',
				dataType:	'json',
				success:	function(response){
					if (response.flag)
					{
						$j('#divError')
							.html(response.message);
						$j('#cont_block').hide();
					}
					else
					{
						$j('#divError').html(response.message);
					}
				}
			});
		});
});