function isBlank(val)
{
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) 
	{
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
		{return false;}
	}
	return true;
}
function isDigit(num) 
{
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
}

//-------------------------------------------------------------------
// isInteger(value)
//   Returns true if value contains all digits
//-------------------------------------------------------------------
function isInteger(val)
{
	if (isBlank(val)){return false;}
	for(var i=0;i<val.length;i++){
		if(!isDigit(val.charAt(i))){return false;}
		}
	return true;
}

function showLCOBox() 
    {
	//frm=document.forms[0]
	//if (document.form1.service_type.value=="Wireless")
	if(document.form1.service_type[1].checked)
	{
		form1.lco.disabled=true	
	}else {
		form1.lco.disabled=false;
	}
    }
function showCheckBox() 
    {
	//frm=document.form1
	frm=document.forms[0]
	if (document.getElementById('agree').checked==false)
	{
		frm.commit.disabled=true
	}else {
		frm.commit.disabled=false
	}
    }
//##############################################################

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)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}
		
	if (str.indexOf(" ")!=-1)
	{
		//alert("Invalid E-mail ID")
		document.getElementById('error_msg').innerHTML = "Invalid E-mail ID";
		return false
	}

	 return true					
}


//####################################################################

function validate()
{
	if(document.form1.name.value=='')
	{	
		document.getElementById('error_msg').innerHTML = "Please Fill Name.";
		document.form1.name.focus();
		return false;
	}


	if(document.form1.email.value=='')
	{	
		document.getElementById('error_msg').innerHTML = "Please Fill Email";
		document.form1.email.focus();
		return false;
	}
	var emailID=document.form1.email
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}


	if(document.form1.phone.value=='')
	{	
		document.getElementById('error_msg').innerHTML = "Please Fill Mobile";
		document.form1.phone.focus();
		return false;
	}
	
	if(!(isInteger(document.form1.phone.value)))
	{
		document.getElementById('error_msg').innerHTML = "Please Fill valid Mobile";
		document.form1.phone.value ="";
		document.form1.phone.focus();
		return false;
	}
	if(document.form1.phone.value.length != 10)
	{
		document.getElementById('error_msg').innerHTML = "Please Fill 10 digit Mobile Number";
		document.form1.phone.focus();
		return false;
	}
	if(document.form1.company.value=='')
	{	
		document.getElementById('error_msg').innerHTML = "Please Fill company";
		document.form1.company.focus();
		return false;
	}
	if(document.form1.location.value=='')
	{	
		document.getElementById('error_msg').innerHTML = "Please Fill location";
		document.form1.location.focus();
		return false;
	}

	document.form1.action ="../allFormSubmit.php";
        document.form1.submit();
        return true;

}
