$(document).ready(function()
{
	if ($(".wpcf7-mail-sent-ok").html() == 'Your message was sent successfully. Thanks.')
	{
		$("#sidebar").show();
	}
});

function checkContactForm()
{
	var nameError = false;
	var emailError = false;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if ($('#yourname').val() == '')
	{
		$('#erroryourname').html('Please fill the required field.');
		nameError = true;
	}
	else if ($('#yourname').val() != '')
	{
		$('#erroryourname').html('');
		nameError = false;
	}
	
	if ($('#youremail').val() == '')
	{
		$('#erroryouremail').html('Please fill the required field.');
		emailError = true;
	}
	else if ($('#youremail').val() != '')
	{
	   	var address = $('#youremail').val();
	   	if(reg.test(address) == false)
	   	{
	      	$('#erroryouremail').html('Email address seems invalid.');
			emailError = true;
	   	}
		else
		{
			$('#erroryouremail').html('');
			emailError = false;
		}
	}
	
	if (nameError == true || emailError == true)
	{
		return false;
	}
	else
	{
		document.contactForm.submit();
		return true;
	}
	/*
	if ($("span").hasClass("wpcf7-not-valid-tip-no-ajax"))
	{
		$("#sidebar").show();
	}
	*/
}
//});