			//** script for the contact form **//

/** script to check spaces in the form **/ 

function checkSpaces (str)
	{
		var count =0;
		
	for (var i=0; i<str.length; i++)
	{
		if (str.charAt(i) == " ")
		{
		count++;
		}	
	}
		if (count==str.length)
		{
		return false;
		}
		return true;
	}

/** script to check numbers in the form  **/ 	
	
function checkNumbers (str)
	{
		var count =0;
		
	for (var i=0; i<str.length; i++)
	{
		if (!isNaN(str.charAt(i)))
		{
		count++;
		}	
	}
		if (count>0)
		{
		return false;
		}
		return true;
	}
	
/** script to validate the form **/
 
function validate()	
	{
		var t1 =document.getElementById("name");
		var name =t1.value;
		var t2 =document.getElementById("email");
		var email =t2.value;
		var errMsg ="";
		var nameflag =true, emailflag=true;
		
		if (name.length<3)
			{
			errMsg += ("invalid name provided\n");
			nameflag =false;
			}		
		
		if (!echeck(email))
			{
			errMsg += ("invalid email address\n");
			emailflag =false;
			}	
					
		if 	
			(errMsg.length>0)
			{
			alert(errMsg);
				
			if (nameflag==false)
				{
				t1.select();
				t1.focus();
				}
				
				
			else if (emailflag==false)
				{
				t2.select();
				t2.focus();
				}					
				
				return false;
			}	
			return true ;	
	}
			

/** DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */

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){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false;
		 }

 		 return true;					
}