﻿// JScript File
function checkspecial(checkfield)
{
 	var iChars = "!$%^&()[]\\\';,/{}|\":<>?";
	for (var i = 0; i < checkfield.length; i++)
	{
		if (iChars.indexOf(checkfield.charAt(i)) != -1)
		{
			//alert("yes")
			return true;
		}			
	}					
}
function Function2()
{
	document.forms['forminfo'].reset();
	//alert("hello2");
	document.forms['forminfo'].txtfname.focus();
	GenNewCap();
}
function onkeyPress(e)
{
    var key = window.event ? e.keyCode : e.which;
    if (key == 13)
    StartClick();
    e.cancelBubble = true;
    e.returnValue = false;
    return false;
}
function echeck(str)
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	//alert(str.indexOf(dot));
	//alert(lstr);
	if (str.indexOf(at)==-1)
	{
	   alert("Invalid E-mail ID");
	   return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	   alert("Invalid E-mail ID");
	   return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==(lstr-1))
	{
		alert("Invalid E-mail ID");
		return false;
	}
	 if (str.indexOf(at,(lat+1))!=-1)
	 {
		alert("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");
		return false;
	 }
	 if (str.indexOf(dot,(lat+2))==-1)
	 {
		alert("Invalid E-mail ID");
		return false;
	 }
	 if (str.indexOf(" ")!=-1 || str.indexOf("!")!=-1 || str.indexOf("?")!=-1 || str.indexOf("$")!=-1 || str.indexOf("^")!=-1 || str.indexOf("*")!=-1 || str.indexOf("{")!=-1)
	 {
		alert("Invalid E-mail ID");
		return false;
	 }
	 return true;
}
function checkgaq()
{
    var emailID=document.forminfo.txtemail;
    if (document.forminfo.txtfname.value == "")
    {
	    alert("This entry must be completed before you can submit this form for processing.");
	    document.forminfo.txtfname.focus();
	    return false;
    }
    else if(checkspecial(document.forminfo.txtfname.value))
    {
	    alert ("Special characters are not allowed.");
	    document.forminfo.txtfname.focus();
	    return false;
    }
    else if (document.forminfo.txt_company.value == "")
    {
	    alert("This entry must be completed before you can submit this form for processing.");
	    document.forminfo.txt_company.focus();
	    return false;}
    else if(checkspecial(document.forminfo.txt_company.value))
    {
	    alert ("Special characters are not allowed.");
	    document.forminfo.txt_company.focus();
	    return false;
    }
    else if (document.forminfo.txttel.value == "")
    {
	    alert("This entry must be completed before you can submit this form for processing.");
	    document.forminfo.txttel.focus();
	    return false;}
    else if(checkspecial(document.forminfo.txttel.value))
    {
	    alert ("Special characters are not allowed.");
	    document.forminfo.txttel.focus();
	    return false;
    }
    if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please Enter your Email ID");
		emailID.focus();
		return false
	}
	else if (echeck(emailID.value)==false)
	{
		//emailID.value="";
		emailID.focus();
		return false
	}    
	else if (echeck(document.forminfo.txtemail.value)==false)
    {
        document.forminfo.txtemail.focus();
        return false;
    }
	else if (document.forminfo.Dist_country.value == "-select country-")
    {
	    alert("This entry must be completed before you can submit this form for processing.");
	    document.forminfo.Dist_country.focus();
	    return false;
	}
	else if(document.getElementById("testtext").value=="")
	{
		alert("Please enter the security code!");
		document.getElementById("testtext").focus();
		return false;
	}
	else if(document.getElementById("holdCAP").value.toLowerCase()!=document.getElementById("testtext").value.toLowerCase())
	{
		alert("Sorry that was not the correct code");		
		document.getElementById("testtext").focus();
		return false;
	}		
	else
	{
		return true;
	}
}
