
function checkinfo()
{

   	var company=document.frmisp.companyname;
	var year=document.frmisp.yearfound; 
	var add=document.frmisp.address;
	var city1=document.frmisp.city;
	var state1=document.frmisp.state;
	var zipcode1=document.frmisp.zipcode;	
	var country1=document.frmisp.country;	
	var url1=document.frmisp.url;
	var phoneone=document.frmisp.phone1;	
	var phonetwo=document.frmisp.phone2;	
	var phonethree=document.frmisp.phone3;	
	var fname=document.frmisp.firstname;	
	var lname=document.frmisp.lastname;	
	var emailadd=document.frmisp.emailid;	
	var pass=document.frmisp.isppassword;	
	var confirm1=document.frmisp.confirmpassword;	
//	var maxlength=30;
	var minlength=4;	

    if(company.value == "")
     {
       alert("Please type in the Company Name.")
       company.focus();
       return false;
     }


    for(i=0;i<= company.value.length-1;i++)
     {

        var newarray = ["@","*","!","#","$","%","^"]
          for (j=0; j < newarray.length ; j++)
           {
             if(company.value.charAt(i) == newarray[j])
              {
                alert("Invalid Company Name\n\n Following characters are not allowed anywhere when typing in the Company Name.\n @,*,!,#,$,%,^")
                company.focus();
                return false;
              }
           }
      }


      var newarray1 = ["&","(",")","-","+"]
          for (k=0; k < newarray1.length ; k++)
           {
             if(company.value.charAt(0) == newarray1[k])
              {
                alert("Invalid Company Name.\n\n Following characters are not allowed in the first place when typing in the Company Name. \n & ,( , ) , - , + ")
                company.focus();
                return false;
              }
           }

           if(company.value.charAt(0) == " ")
              {
                alert("Invalid Company Name. Spaces are not allowed in the first place when typing in the company name.")
                company.focus();
                return false;
              }





          if(year.value == "-")
                {
                        alert("Please select the year in which the company was established.")
                        year.focus();
                        return false;
                }



     if(add.value == "")
     {
       alert("Please type in the Street Address.")
       add.focus();
       return false;
     }


     if(city1.value == "")
     {
       alert("Please type in the City.")
       city1.focus();
       return false;
     }
	 

     if(state1.value == "-")
     {
       alert("Please select an appropriate State.")
       state1.focus();
       return false;
     }
     if(country1.value == "-")
     {
       alert("Please select an appropriate Country.")
       country1.focus();
       return false;
     }

	 
     if(zipcode1.value == "")
       {
                 alert("Please type in the Zip/Postal Code.")
                 zipcode1.focus();
                 return false;
       }
     else
       {
         zipval = noCharacter(zipcode1.value)
          if(zipval == 1)
           {
            alert("Invalid in Zip/Postal Code.")
            zipcode1.focus();
            zipcode1.select();
            return false;
           }


       }
/*	if(zipcode1.value.length != 5)
	{
		alert("Pleas type in the correct Zip Code.");
		zipcode1.focus();
		zipcode1.select();
		return false;
	}	
*/

     if(url1.value == "")
     {
       alert("Please type in the Company URL.")
       url1.focus();
       return false;
     }


     urlVal = url1.value
     urlLen = urlVal.length
     if(urlVal.indexOf(".") == -1)
      {
       alert("Invalid URL.")
       url1.focus();
	   url1.select();
       return false;
      }

/*      if(urlVal.indexOf("www.") == -1)
      {
       alert("Invalid URL.Please type a valid URL starting with 'www.'")
       document.frmisp.txturl.focus();
       return false;
      }*/

// checking the validation of phone number
//part1
     if(phoneone.value == "")
     {
       alert("Please type in the Company Phone Number in Field 1.")
       phoneone.focus();
       return false;
     }
	 if(phoneone.value.length!=3)
	 {
	 	alert("Please type in 3 digit number in first field of phone.");
		phoneone.focus();
		return false;
	 }
	//part2
     if(phonetwo.value == "")
     {
       alert("Please type in the Company Phone Number in Field 2.")
       phonetwo.focus();
       return false;
     }
	 if(phonetwo.value.length!=3)
	 {
	 	alert("Please type in 3 digit number in second field of phone.");
		phonetwo.focus();
		return false;
	 }
	

//part3
     if(phonethree.value == "")
     {
       alert("Please type in the Company Phone Number in Field 3.")
       phonethree.focus();
       return false;
     }
	 if(phonethree.value.length!=4)
	 {
	 	alert("Please type in 4 digit number in third field of phone.");
		phonethree.focus();
		return false;
	 }

     if(fname.value == "")
     {
       alert("Please type in the First Name of the contact person.")
       fname.focus();
       return false;
     }

     if(lname.value == "")
     {
       alert("Please type in the Last Name of the contact person.")
       lname.focus();
       return false;
     }

    if(emailadd.value == "")
       {
                 alert("Please type in the E-Mail Address.")
                 emailadd.focus();
                 return false;
       }
     else
      {

	    var obj=emailadd;
        var str=obj.value ;

		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")
		   obj.focus()
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   obj.focus()
		   obj.select();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    obj.focus()
			obj.select()
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    obj.focus()
			obj.select()
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    obj.focus()
			obj.select()
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    obj.focus()
			obj.select()
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")		    
		    obj.focus()
			obj.select()
		    return false
		    
		    
		 }
         
         
         
	  

      }

     if(emailadd.value == "")
     {
       alert("Please type in the Email Address.")
       emailadd.focus();
       return false;
     }

     if(pass.value == "")
     {
       alert("Please type in the password.")
       pass.focus();
       return false;
     }
	if(pass.value.length<minlength)
	{
		alert("Please enter the Password more than Four character.");
		pass.focus();
		pass.select();
		return false;
	}
     if(confirm1.value == "")
     {
       alert("Please confirm your password here.")
       confirm1.focus();
       return false;
     }

     if((pass.value) != (confirm1.value))
      {
       alert("The password and the confirm password field values do not match with each other.")
       pass.focus();
       return false;
      }
}	  


//function for checking numeric fields.
function checkprice(val1)

{
var notval5 = /[$\\@\\\#%\^\&\*\[\]\;\+\/\_\{\}\`\'\~\=\|\abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]/;
    var strPass1 = val1.value;    

    if(strPass1.charAt(0)==" ")

    {

        strPass1="";

        val1.value="";

    }

    //var strPass1 = val1.value;

    var strLength1 = strPass1.length;

    for(i=0;i<=strLength1;i++)

    {

        var lchar1 = val1.value.charAt(i);        

        if(lchar1.search(notval5) != -1)

        {

            var tst1 = val1.value.substring(0, (i));

            val1.value = tst1;

        }        

    }

}

function checkcity(val1)

{
var notval5 = /[$\\@\\\#%\^\?\<\>\,\;\:\&\*\'\"\[\]\+\_\/\!\{\}\`\~\=\|0123456789]/;
    var strPass1 = val1.value;    

    if(strPass1.charAt(0)==" ")

    {

        strPass1="";

        val1.value="";

    }

    //var strPass1 = val1.value;

    var strLength1 = strPass1.length;

    for(i=0;i<=strLength1;i++)

    {

        var lchar1 = val1.value.charAt(i);        

        if(lchar1.search(notval5) != -1)

        {

            var tst1 = val1.value.substring(0, (i));

            val1.value = tst1;

        }        

    }

}

   function noCharacter(fieldvalue)
    {
      var noChar = /\D+/

        if(fieldvalue.match(noChar))
         {
           return 1
         }
        else
         {
           return 0
         }
    }

	
//function to check the validation of step2.php
function customertype()
{
	var i;
	var custval=document.frmisp.typeval.value;
	var j=0;
    var custck;
	var pname=document.frmisp.planname;
	if(pname.value=="")
	{
		alert("Please Enter the Plan Name.");
		pname.focus();
		return false;
	}
	
	for(i=0;i<custval;i++)
	{
	   custck="chktype"+i 
       if(document.frmisp(custck).checked==true)
	   {
	    j=j+1;
	   }
		
	}
	if(j==0)
	{
		alert("Please select the Customer Type Service.");
		document.frmisp(custck).focus();
		return false;
	}
	
	//function for broadband services
	var bb;
	var bbval=document.frmisp.bbval.value;
	var j=0;
    var bbck;
	var areac=document.frmisp.textareacode;
	
	for(i=0;i<bbval;i++)
	{
	   bbck="chkbb"+i 
       if(document.frmisp(bbck).checked==true)
	   {
	    j=j+1;
	   }
		
	}
	if(j==0)
	{
		alert("Please select the Broadband Service.");
		document.frmisp(bbck).focus();
		return false;
	}

	if(areac.value=="")
	{
		alert("Please type in the Area Code\n\n Or Select it from the link");
		areac.focus();
		return false;
	}
var mfees=document.frmisp.monthlyfees;
if(mfees.value=="")
{
	alert("Please Enter the Monthly Fees Value.");
	mfees.focus();
	return false;
}
	//function for payment type
	var i;
	var payval=document.frmisp.payval.value;
	var j=0;
    var payck;
	
	for(i=0;i<payval;i++)
	{
	   payck="chkpay"+i 
       if(document.frmisp(payck).checked==true)
	   {
	    j=j+1;
	   }
		
	}
	if(j==0)
	{
		alert("Please select the Payment Type.");
		document.frmisp(payck).focus();
		return false;
	}
	
	//function for email & webspace validation
if(document.frmisp.emailchk.checked==true)
{
	if(document.frmisp.emailacct.value=="")
	{
		alert("Please type in the value in Email Account textbox.");
		document.frmisp.emailacct.focus();
		return false;
	}
}

if(document.frmisp.webspacechk.checked==true)
{
	if(document.frmisp.webspace.value=="")
	{
		alert("Please type in the value in Webspace textbox.");
		document.frmisp.webspace.focus();
		return false;
	}
}

//function for checking the term fields
if(document.frmisp.termday.value=="")
{
	alert("Please enter the Term Day value.");
	document.frmisp.termday.focus();
	return false;
}

if(document.frmisp.termcontract1.value=="")
{
	alert("Please enter the data in Term contract Field.");
	document.frmisp.termcontract1.focus();
	return false;
}

if(document.frmisp.termcontract2.value=="")
{
	alert("Please select the Term Contract field 2 from the list..");
	document.frmisp.termcontract2.focus();
	return false;
}
if(document.frmisp.termfees.value=="")
{
	alert("Please enter the Term Fees.");
	document.frmisp.termfees.focus();
	return false;
}


} //end of function

function textenabled(val)
{
 
  var val1=document.frmisp.emailacct;
  if(document.frmisp.emailchk.checked==true)
  {
    val1.disabled = false;
    val1.focus();

  }
  else
  {
    val1.disabled = true;
    val1.value = ""
  }
}
function textenabled1(val)
{
  var val1=document.frmisp.webspace;
  if(document.frmisp.webspacechk.checked==true)
  {
    val1.disabled = false;
    val1.focus();

  }
  else
  {
    val1.disabled = true;
    val1.value = ""
  }
}
   function checkcommaatend(txtareacodelength,fieldname,focusfield)
    {

      var txtareaval = document.frmisp.textareacode.value
      var txtarealen = txtareaval.length

      if(txtareaval.indexOf("undefined,")== 0)
       {

        re = /undefined,/i;

        txtareaval =   txtareaval.replace(re,"");
         document.frmisp.textareacode.value =  txtareaval
      }


          txtareaval = txtareaval.replace(/(\s+)/,"");


     var len1 = txtareaval.length
     var len2 = txtareaval.length-1


     var substringval = txtareaval.substring(len1,len2)

       if(substringval == ",")
        {
         alert("Please remove comma(,) from the last character.")
         document.frmisp.textareacode.focus();
         return false

        }


          checktxtarelen(txtareaval)

returnval=0;
     //   returnval = checktxtareaLen(txtareacodelength,fieldname,focusfield)

          if (returnval == 1)
           {
             alert("The " + fieldname + " field is too long. ");
             focusfield.focus();
             return false;
           }




    }
function checktxtareaLen(txtlength,fieldvalue,focusfield)
    {
                fieldLength = txtlength
                fieldname = fieldvalue

      if(fieldname == "Fees")
                {
                        if(fieldLength >= 500)
                                {
                                        alert("The " + fieldname  + " field is too long.")
                                        focusfield.focus();
                                        return false;
                                }
                }
      else if(fieldname == "Other Services")
        {
                        if(fieldLength >= 50)
                                {
                                        alert("The " + fieldname  + " field is too long.")
                                        focusfield.focus();
                                        return false;
                                }
                }
      else if(fieldname == "Address")
        {
                        if(fieldLength >= 100)
                                {
                                        alert("The " + fieldname  + " field is too long.")
                                        focusfield.focus();
                                        return false;
                                }
        }

     else if (fieldname == "Area Code")
      {
                        if(fieldLength >= 1500)
                                {
                                        return 1
                                }
                        else
                           {
                                return 0
                           }

      }

    }



    function checktxtarelen(areacodefieldval)
     {
       if(areacodefieldval != "")
        {
          if(areacodefieldval.indexOf(",") > 0)
            {
              singleareacodeval = areacodefieldval.split(",")

                for(i=0;i<=singleareacodeval.length-1;i++)
                 {

                  if(singleareacodeval[i].length > 3)
                    {
                                             alert("Please check the area codes you have entered. It seems you have either entered an invalid area code or there is incorrect spacing after entering an area code.")
                                             document.frmisp.textareacode.focus();
                                                 return false;
                    }

                 }

            }
          else
            {
              if(document.frmisp.textareacode.value.length > 3)
                {
                                                alert("Please check the area codes you have entered. It seems you have either entered an invalid area code or there is incorrect spacing after entering an area code.")
                                             document.frmisp.textareacode.focus();
                                                return false;
                }

            }
        }
     }
	 
//function for invalid email id used in requestaquote.php
function chkemailaddress(obj)
{
	
        var str=obj.value ;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		   return (0);
		}

	   else	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   return (0);
		}

		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
			return (0);
		}

		else if (str.indexOf(at,(lat+1))!=-1)
		 {
			return (0);
		 }

		 else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return (0);
		 }

		 else if (str.indexOf(dot,(lat+2))==-1){
		return (0);
		 }
		
		else if (str.indexOf(" ")!=-1){
			return (0);
		 }
}