function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    //alert("Invalid E-mail ID")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 return true					
}

function DoCheck()
{
	if (document.list.name.value.length == 0)
	{
		alert('Please enter a name for the item.');
		document.list.name.focus();
	}
	else if (document.list.description.value.length == 0)
	{
		alert('Please enter a description for the item.');
		document.list.description.focus();
	}
	else if (document.list.price.value.length == 0)
	{
		alert('Please enter a price for the item.');
		document.list.price.focus();
	}
	else if (document.list.yourname.value.length == 0)
	{
		alert('Please enter a your name.');
		document.list.yourname.focus();
	}
	else if (!echeck(document.list.email.value))
	{
		alert('Please enter a VALID email address.');
		document.list.email.focus();
	}
	else if (!document.list.accept.checked)
	{
		alert('You must accept the terms and conditions to submit the ad.');
		document.list.accept.focus();
	}
	else
	{
		document.list.submit();
	}
}

function DoContactUsCheck()
{
	if (document.contactform.yourname.value.length == 0)
	{
		alert('Please enter your name.');
		document.contactform.yourname.focus();
	}
	else if (document.contactform.contactno.value.length < 10)
	{
		alert('Please enter a your contact number');
		document.contactform.contactno.focus();
	}
	else if (!echeck(document.contactform.emailaddress.value))
	{
		alert('Please enter a VALID email address.');
		document.contactform.emailaddress.focus();
	}
	else
	{
		document.contactform.submit();
	}
}

function DoAccContactUsCheck()
{
	if (document.emailus.yourname.value.length == 0)
	{
		alert('Please enter your name.');
		document.emailus.yourname.focus();
	}
	else if (document.emailus.contactno.value.length < 10)
	{
		alert('Please enter a your contact number');
		document.emailus.contactno.focus();
	}
	else if (!echeck(document.emailus.emailaddress.value))
	{
		alert('Please enter a VALID email address.');
		document.emailus.emailaddress.focus();
	}
	else
	{
		document.emailus.submit();
	}
}