// JavaScript Document
function emailvalidation(entered,alertbox)
{

  with(entered)
  {
     apos=entered.value.indexOf("@");
      dotpos1=entered.value.indexOf(".");
	  
     dotpos=entered.value.lastIndexOf(".");
	  t=dotpos-dotpos1;
	  if(t==1)
	  {

        alert(alertbox);

		entered.focus();
        return false;

	  }
	  
     lastpos=(entered.value.length)-1;
     if(apos<1 || (dotpos-apos)<2 ||  (lastpos-dotpos)<2)
     {	
        alert(alertbox);
		entered.focus();
        return false;
     }
   	else
   	{
   		return true;
   	}
 }
}


function validsthform(sthform)
{
	
		if(sthform.contactname.style.background = "pink")
	{
		sthform.contactname.style.background = "white";
	}
	
			if(sthform.email.style.background = "pink")
	{
		sthform.email.style.background = "white";
	}
	
			if(sthform.msg.style.background = "pink")
	{
		sthform.msg.style.background = "white";
	}
	
	
	
	if(sthform.contactname.value.length==0)
	{
		sthform.contactname.style.background = "pink";
		sthform.contactname.focus();
		return false;
	}

	if(sthform.email.value.length==0)
	{
		sthform.email.style.background = "pink";
		sthform.email.focus();
		return false;
	}
	
	if(!emailvalidation(sthform.email,"Please Enter a Valid Email"))
	{
		sthform.email.style.background = "pink";
		sthform.email.focus();
		return false;
	}
	
			if(sthform.msg.value.length==0)
	{
		sthform.msg.style.background = "pink";
		sthform.msg.focus();
		return false;
	}
	
}
