//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 Validate()
{
	//validating name
	if (document.myform.name.value == "")
	{
		alert("Please enter your name");
		document.myform.name.focus();
		return false;
	}

	//validating company name
	if (document.myform.company_name.value == "")
	{
		alert("Please enter your company name");
		document.myform.company_name.focus();
		return false;
	}

	//validating designation
	if (document.myform.designation.value == "")
	{
		alert("Please enter your designation");
		document.myform.designation.focus();
		return false;
	}

	//validating country
	if (document.myform.country.selectedIndex == 0)
	{
		alert("Please select your country");
		document.myform.country.focus();
		return false;
	}

	//validating email
	var mail = document.myform.email.value;

	if(document.myform.email.value=="")
	{
		alert("Please enter a value for the Email Id.");
		document.myform.email.focus();
		return false;
	}

	if ((mail.length == mail.lastIndexOf('.')+1) || (mail.indexOf('@') != mail.lastIndexOf('@')))
	{
		alert("Please enter a proper Email Id");
		document.myform.email.focus();
		return false;
	}

	if(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.myform.email.focus();
		return false;
	}

	if(!ValidateNo(document.myform.email.value,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-"))
	{
		alert("Please enter a proper Email Id");
		document.myform.email.focus();
		return false;
	}

	//validating phone
	if (document.myform.phone.value == "")
	{
		alert("Please enter your phone number.");
		document.myform.phone.focus();
		return false;
	}

	if(!ValidateNo(document.myform.phone.value,"0123456789 +-"))
	{
		alert("Please Enter Only Number");
		document.myform.phone.focus();
		return false;
	}
	
	//validating suggestion
	if (document.myform.suggestions.value == "")
	{
		alert("Please specify search suggestion");
		document.myform.suggestions.focus();
		return false;
	}
	
	if (document.myform.rndString.value != document.myform.txtrndString.value)
	{
		alert("Please specify String that Show Above");
		document.myform.txtrndString.focus();
		return false;
	}
	/*
	//validating URL
	var web = document.myform.url.value;

	if ((web.indexOf('www.') == -1) || (web.length == web.lastIndexOf('.')+1) || (web.lastIndexOf('.') == web.indexOf('.')))
	{
		alert("Please enter your valid URL");
		document.myform.url.focus();
		return false;
	}

	if ( document.myform.url.value.search(/[^A-Za-z0-9./:;_+-]/) >= 0 || document.myform.url.value == "")
	{
		alert("Please enter your valid URL");
		document.myform.url.focus();
		return false;
	}
	*/
}
