﻿// JScript File
/* Form Validation Script for Contact Us
Developed By	: Pooja Verma
Date			: Sept 23, 2008
Message			: Functions related to Adding of Contact Us Entry
*/

function phoneKeypress(e)
{
    if ([e.keyCode||e.which]==8) //this is to allow backspace
    return true;
    if ([e.keyCode||e.which]==9) //this is to allow tab
    return true;
    if ([e.keyCode||e.which]==46) //this is to allow period
    return true;
    if ([e.keyCode||e.which]==43) //this is to allow + symbol
    return true;
    if ([e.keyCode||e.which]==45) //this is to allow - symbol
    return true;
    if ([e.keyCode||e.which] < 48 || [e.keyCode||e.which] > 57)
    e.preventDefault? e.preventDefault() : e.returnValue = false;
}

function validate()
{
    var rules=new Array();
   
    rules[0]='ctl00_cphGeneral_txtFirstName|required|Please Enter First Name';
    rules[1]='ctl00_cphGeneral_txtLastName|required|Please Enter Last Name';
    rules[2]='ctl00_cphGeneral_txtEmail|required|Please Enter Email';
    rules[3]='ctl00_cphGeneral_txtEmail|email|Please enter valid  email address.The address should be of this form name@company.com';
    rules[4]='ctl00_cphGeneral_txtSubject|required|Please Enter Subject';
    rules[5]='ctl00_cphGeneral_txtMessage|required|Please Enter Message';
    rules[6]='ctl00_cphGeneral_txtMessage:Message|maxlength|1000';
    
    if(rules.length>0)
    {
        return performCheck('aspnetForm', rules, 'classic');
    }
   
}

var id=0;
function refreshCaptcha()
{
    id++;
    document.getElementById("ctl00_cphGeneral_imgCaptcha").src="imagecaptcha.aspx?id="+id;
}


function HandleKeyPress(e)
 {
    if(e.target)
      el=e.target;
     else if(e.srcElement)
      el=e.srcElement;
    var unicode=e.keyCode? e.keyCode : e.charCode ? e.charCode : e.which
    if(unicode=='13')
    {       if(el.type.indexOf('textarea')<0)
            {
    		document.getElementById("ctl00_cphGeneral_imbSubmit").click();
		    e.returnValue=false;
		    return false;
		    }
		    else
		    {
		     e.returnValue=true;
		     return true;
		    }
	}
   
 }