
function ValidateNo( NumStr, String ) 
{				
	for( var Idx = 0; Idx < NumStr.length; Idx ++ )
	{
		var Char = NumStr.charAt( Idx );
		var Match = false;
		 for( var Idx1 = 0; Idx1 < String.length; Idx1 ++) 
		 {
		 	 if( Char == String.charAt( Idx1 ) ) 
		 	 Match = true;
						 
		 }
		 if ( !Match ) 
			return false;
	}
	return true;
}

function validate()
{
		var txt;
		var error;
		error = false;
		txt=document.subfrm1.semail.value;
		if (document.subfrm1.sname.value=="")
		{
			alert("Please enter your Name");
			document.subfrm1.sname.focus();
			error = true;
		}
		if (error==false && document.subfrm1.scompany.value=="")
		{
			alert("Please enter your Companyname");
			document.subfrm1.scompany.focus();
			error = true;
		}	
		if (error==false && document.subfrm1.semail.value=="")
		{
			alert("Please enter your Email");
			document.subfrm1.semail.focus();
			error = true;
		}	
		if(error==false && txt.indexOf("@")<1)
		{
			alert("Please enter valid Email");
			document.subfrm1.semail.focus();
			error = true;
		}
		if(error==false && ( txt.indexOf('@',0)==0 || txt.indexOf('.',0)<1 ))
		{
			alert("Please enter valid Email");
			document.subfrm1.semail.focus();
			error = true;
		}
		if (error==false && !ValidateNo( document.subfrm1.semail.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.,-" ))
		{
				alert( "Invalid Email " + document.subfrm1.semail.value );
				document.subfrm1.semail.focus();
				error = true;
		}
		if(error==false && ( txt.indexOf("/")> 1 || txt.indexOf(",") > 1 ) )
		{
			alert("Please enter valid Email");
			document.subfrm1.semail.focus();
			error = true;
		}
		cnt=0;
		instr=txt.toString()
	for(var i=0;i<instr.length;i++)
	{
		var char1=instr.charAt(i)
		if (char1=="@")
		{
			cnt=cnt+1;
		}
	}					
	if(error==false && cnt > 1)
	{
		alert("Please enter valid Email");
		document.subfrm1.semail.focus();
		error = true;
	}
	var country_ph1,area_ph1,phno1;
	country_ph1=document.subfrm1.scphone.value;
	area_ph1=document.subfrm1.saphone.value;
	phno1=document.subfrm1.spphone.value;

	if (error==false && ( country_ph1 =="" || area_ph1 =="" || phno1 =="" ) )
	{
		if (error==false && country_ph1 =="") 
		{
			alert("Please fill the Country Code in the telephone number");
			document.subfrm1.scphone.focus();
			error = true;
		}
		if (error==false && area_ph1 =="") 
		{
			alert("Please fill the Area Code in the telephone number");
			document.subfrm1.saphone.focus();
			error = true;
		}
		if (error==false && phno1 =="") 
		{
			alert("Please fill the Telephone number properly");
			document.subfrm1.spphone.focus();
			error = true;
		}
	}		
		
	for(var i=0;i<document.subfrm1.scountry.length;i++)
	{
		if(document.subfrm1.scountry[i].selected)
		{
			if(error==false && document.subfrm1.scountry.options[i].value=="0")
			{
				alert("Please select the Country you belong to");
				document.subfrm1.scountry.focus();
				error = true;
			}
		}
	}		
		if (error==false && document.subfrm1.sSubject.value =="") 
		{
			alert("Please specify subject");
			document.subfrm1.sSubject.focus();
			error = true;
		}
		if (error==false && document.subfrm1.sInquiry.value =="") 
		{
			alert("Please write your inquiry");
			document.subfrm1.sInquiry.focus();
			error = true;
		}
		if(error==true)
		{
			return false;
		}
	/*if(error==false)
	{   
		document.subfrm1.action="sendInquiry.aspx";
		document.subfrm1.submit();
	}*/
}

