// JavaScript Document
function press(e)
{
var keynum;
if(window.event)
{
 keynum=e.keyCode;
 }
 if(keynum==13)
 {
   if(confirm("Do you want to submit the form"))
   {
     btnSubmit_onclick();
   }
   else
   {
   document.frmContact.control_fnameText.focus();
   return;
   }
      }
   }
function resetForm()
 {      
     document.frmContact.reset();
   }

function btnSubmit_onclick() 
 {
        if(document.frmContact.firstName.value =='') 
        {
        alert("First name cannot be blank.");
        document.frmContact.firstName.focus();
		return false;
         }
		if(document.frmContact.lastName.value =='')
        {
        alert("Last name cannot be blank.");
        document.frmContact.lastName.focus();
        return false;
        }
		if(isNaN(document.frmContact.zipCode.value))
	    {
		alert("Zip code should  be in Numerics.");
        document.frmContact.zipCode.focus();
        return false;
		}
		if(isNaN(document.frmContact.phone.value))
	    {
		alert("Phone No. should  be in Numerics.");
        document.frmContact.phone.focus();
        return false;
		}
		if(document.frmContact.phone.value.length > 15)
	    {
		alert("Phone No. too long");
        document.frmContact.phone.focus();
        return false;
		}
		if(isNaN(document.frmContact.fax.value))
		{
		alert("Fax No. should  be in Numerics.");
        document.frmContact.fax.focus();
        return false;
		}
		if(document.frmContact.fax.value.length > 15)
		{
		alert("Fax No. too long.");
        document.frmContact.fax.focus();
        return false;
		}
		if(isNaN(document.frmContact.ext1.value))
		{
		alert("Ext1 No. should  be in Numerics.");
        document.frmContact.ext1.focus();
        return false;
		}
		if(document.frmContact.ext1.value.length > 6)
		{
		alert("Ext1 No. too long");
        document.frmContact.ext1.focus();
        return false;
		}
		if(isNaN(document.frmContact.ext2.value))
		{
		alert("Ext2 No. should  be in Numerics.");
        document.frmContact.ext2.focus();
        return false;
		}
		if(document.frmContact.ext2.value.length > 6)
		{
		alert("Ext2 No. too long");
        document.frmContact.ext1.focus();
        return false;
		}

		if(document.frmContact.investortypeid.value =='')
        {
        alert("Please select Investor Type");
        document.frmContact.investortypeid.focus();
        return false;
        }

		if(document.frmContact.email.value =='')
        {
        alert("Please enter a valid Email Address!");
        document.frmContact.email.focus();
        return false;
        }
			
		if (validate_email(document.frmContact.email,"Please enter a valid Email Address!")==false)
        {
         document.frmContact.email.focus();
	     return false;
         }
		 	document.frmContact.countryName.value=document.frmContact.countryid[document.frmContact.countryid.selectedIndex].text;
			document.frmContact.investorTypeName.value=document.frmContact.investortypeid[document.frmContact.investortypeid.selectedIndex].text;
			return true;
  }
 function validate_email(field,alerttxt)
 {
    with (field)
    {
    apos=value.indexOf("@")
    dotpos=value.lastIndexOf(".")
   if (apos<1||dotpos-apos<2) 
    {
    alert(alerttxt);
    return false;
     }
    else {return true;}
      }
   }
