$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('#subscriber_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);
		})
		.unbind('focus')
		.focus(function(){
			$j(this).nextAll('img').remove();
		});
		
	$j('.contact_req')
		.unbind('focus')
		.focus(function(){
			$j(this).next('img').remove();
		});
	$j('#submitcontact')
		.unbind('click')
		.click(function(){
			$j('.contact_req').blur();
			$j('#subscriber_email').blur();
			if ($j('[@alt="wrong"]').length > 0)
			{
				return;
			}
			
			$j('#divError').hide();
			var f = $j(this).parent().parent();
			//f.submit();
			var data = f.serializeArray();
			
			
			$j.ajax({
				data:		data,
				url:		'newsletter_process.php',
				type:		'post',
				dataType:	'json',
				success:	function(response){
					if (response.flag == 1)
					{
						//$j('#cont_block').hide();
						$j.blockUI({
							message: "<div style='border-top:1px solid #3f3f3f; border-right:1px solid #3f3f3f; border-left:3px solid #494949; border-bottom:3px solid #494949; overflow: auto;overflow-x: auto;' class='my-rtl'><div style='background:url(images/bar-bg.gif) repeat-x #ececec; height:250px; text-align:left'><div style='color:white; font-weight:bold; padding:2px 0 5px 5px; text-align:left'>Message</div>" + response.message + "</div><div style='background-color:#ececec; padding:5px 3px 3px 3px; text-align:center;'><img src='images/wrong_icon.gif' align='absbottom' onclick='JavaScript: closeModal();'></div><div>",
							css: {
								border: 'none',
								background: 'transparent',
								width:	'450px',
								cursor: 'default',
								top: '150px'
							},
							overlayCSS: {
								opacity: 0.7
							}
						});
					}
					else
					{
						$j('#divError').show();
						$j('#divError').html(response.message)
							.css({ backgroundColor:"#e6e6e6", fontWeight:"bolder" })
								.hide(10000);
					} 
				}
			});
		});
});
function closeModal()
{
	$j.unblockUI();
}