//Check whether specified value is numeric or not?
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 validate1()

{  
	 
	//validate name
  
	if (document.frm.name.value == "")
	{
		alert("Please Enter Your Name");
		document.frm.name.focus();
		return false;
	}
	
	//validate company name
	if (document.frm.company.value == "")
	{
		alert("Please Enter Your Company Name");
		document.frm.company.focus();
		return false;
	}
	
	//validate email
	var mail = document.frm.email.value;

	if(document.frm.email.value=="")
	{
		alert("Please enter a value for the Email Id.");
		document.frm.email.focus();
		return false;
	}

	if ((mail.length == mail.lastIndexOf('.')+1) || (mail.indexOf('@') != mail.lastIndexOf('@')))
	{
		alert("Please enter a proper Email Id");
		document.frm.email.focus();
		return false;
	}

	if(mail.indexOf('@')==-1 || mail.indexOf('.')==-1 ||  mail.indexOf('@',0)==0 || mail.indexOf('.',0)<1 || mail.indexOf('@.')!= -1 || mail.indexOf('.@')!=-1 || mail.indexOf('..')!=-1)
	{
		alert("Please enter a proper Email Id");
		document.frm.email.focus();
		return false;
	}

	if(!ValidateNo(document.frm.email.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
	{
		alert("Please enter a proper Email Id");
		document.frm.email.focus();
		return false;
	}
	
	//validating phone number
	//country code
	if (document.frm.cphone.value == "")
	{
		alert("Please enter country number");
		document.frm.cphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.cphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.cphone.focus();
		return false;
	}
	//area code
	if (document.frm.aphone.value == "")
	{
		alert("Please enter area number");
		document.frm.aphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.aphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.aphone.focus();
		return false;
	}
	//phone code
	if (document.frm.pphone.value == "")
	{
		alert("Please enter phone number");
		document.frm.pphone.focus();
		return false;
	}
	
	if(!ValidateNo(document.frm.pphone.value,"1234567890+- "))
	{
		alert("Please Enter Only Number");
		document.frm.pphone.focus();
		return false;
	}

	if (document.frm.country.selectedIndex == 0)
	{
		alert("Please Enter Your Country");
		document.frm.country.focus();
		return false;
	}
 
	if (document.frm.country.selectedIndex == 0)
	{
		alert("Please Enter Your Country");
		document.frm.country.focus();
		return false;
	}

	//validate comments
	if (document.frm.comments.value == "")
	{
		alert("Please Enter Your Comments");
		document.frm.comments.focus();
		return false;
	}

	var name , company , address , country , phone , fax , email , comments , mailsubject, mailto, mailcc, mailbcc, inqarticleid;

	name = escape(document.frm.name.value);
	company = escape(document.frm.company.value);
	email = escape(document.frm.email.value);
	phone = document.frm.cphone.value+'-'+document.frm.aphone.value+'-'+document.frm.pphone.value;
	country = document.frm.country.value ;
	comments = escape(document.frm.comments.value);
	mailsubject = document.frm.mailsubject.value;
	mailto = document.frm.mailto.value;
	mailcc = document.frm.mailcc.value;
	mailbcc = document.frm.mailbcc.value;
	inqarticleid = document.frm.inqarticleid.value;

	var str;
	str = "name="+name+"&company="+company+"&country="+country+"&phone="+phone+"&email="+email+"&comments="+comments+"&mailsubject="+mailsubject+"&mailto="+mailto+"&mailcc="+mailcc+"&mailbcc="+mailbcc+"&inqarticleid="+inqarticleid;
 
	var xmlHttp = null 	
	if (typeof window.ActiveXObject != 'undefined' ) 
	{ 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else 
	{ 
		xmlHttp = new XMLHttpRequest(); 
	}

	var url="/industry-article/usercontrols/contactus/sendmail.asp?"+str+"&sid="+Math.random()
 	xmlHttp.open("GET", url, false);
    xmlHttp.send(null);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") 
	{	
		document.getElementById("business").innerHTML=xmlHttp.responseText
	}
}