// JavaScript Document
function IsNumeric(s)
{
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	
	if (s.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < s.length && blnResult == true; i++)
	{
		strChar = s.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}
function IsChar(strString)
{
	var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. ";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}
function checkName()
{
	var nm=document.f1.contact.value;
	if(nm=="")
	{
		return "Please fill in the Contact Name. It cannot be left blank.\n";	
	}
	else
	{
		if(nm.length<5)	
			return "Please fill in the Contact Name correctly. It seems that the Contact Name is incorrect.\n";
	}
	return "";
}
function checkCompany()
{
	var nm=document.f1.company.value;
	if(nm=="")
	{
		return "Please fill in the Company Name. It cannot be left blank.\n";	
	}
	else
	{
		if(nm.length<10)	
			return "Please fill in the Company Name correctly. It seems that the Company Name is incorrect.\n";
	}
	return "";
}
function checkPhone()
{
	var ph=document.f1.phone.value;
	if(ph=="")
		return "Phone No. cannot be left blank.\n";
	else
	{
		if(!IsNumeric(ph))
			return "Phone No. should contain digits only.\n";
	}
	return "";
}
function checkEmail()
{
	var em=document.f1.email.value;
	if(em=="")
		return "Email cannot be left blank.\n";
	else
	{
		if(em.indexOf("@")==-1 || em.indexOf(".")==-1)
			return "The Email ID provided by you seems to be invalid. Please check it.\n";
		else
			return "";
	}
}

function checkVerify()
{
	var v=document.f1.verifycode.value;
	if(v=="")
		return "Verify Code cannot be left empty.\n";
	else
		return "";
}
function checkServices()
{
	if(!document.f1.checkbox5.checked && !document.f1.checkbox6.checked && !document.f1.checkbox7.checked && !document.f1.checkbox8.checked && !document.f1.checkbox9.checked && !document.f1.checkbox10.checked && !document.f1.checkbox11.checked && !document.f1.checkbox12.checked && !document.f1.checkbox13.checked && !document.f1.checkbox14.checked && !document.f1.checkbox15.checked && !document.f1.checkbox16.checked && !document.f1.checkbox17.checked && !document.f1.checkbox18.checked && !document.f1.checkbox19.checked && !document.f1.checkbox20.checked && !document.f1.checkbox21.checked)
		return "Please select the service(s) you want to get quote.\n";
	else
	{
		if(document.f1.checkbox19.checked)
		{
			if(document.f1.other.value=="")
				return "Please fill in what Other Service(s) you need.\n";
		}
	}
	return "";
}
function chkForm()
{
	var msg="";
	msg += checkName();
	msg += checkCompany();
	msg += checkEmail();
	msg += checkPhone();
	msg += checkServices();
	msg += checkVerify();
	if(msg=="")	
		return true;
	else
	{
		alert(msg);
		return false;
	}
}
