function getKeyCode(e)
{if(window.event)
return window.event.keyCode;else if(e)
return e.which;else
return null;}
function keyRestrict(e,validchars){var key='',keychar='';key=getKeyCode(e);if(key==null)return true;keychar=String.fromCharCode(key);keychar=keychar.toLowerCase();validchars=validchars.toLowerCase();if(validchars.indexOf(keychar)!=-1)
return true;if(key==null||key==0||key==8||key==9||key==13||key==27)
return true;return false;}
function validate()
{var name=document.frmFirst.txtName.value;var email=document.frmFirst.txtEmail.value;email=email.toLowerCase();var areaCode=document.frmFirst.txtAreaCode.value;var phone=document.frmFirst.txtPhone.value;var mobile=document.frmFirst.txtMobile.value;var pincode=document.frmFirst.txtPincode.value;var selectind=document.getElementById('cboCity').selectedIndex;var errmsg="";var RegExpName=/^[ a-zA-Z]+$/;var RegExpPhone=/^[0-9]{5,10}$/;var RegExpMobile=/^[8-9]{1}[0-9]{9}[ ]*$/;var RegExpAreaCode=/^[0-9]{2,6}$/;var RegExpEmail=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;var invalidMobile=/^[0-9]*[1][2][3][4][5][0-9]*$/;var n=0,k=0,flag=0;if(selectind=="74")
{alert("Thank you for your interest in Sharekhan.\n Sorry, we are not available at cities other than those mentioned in the form.\n Keep checking this page for regular   updates.\n Until then feel free to refer us to your friend ");return false;}
if(name=="")
{errmsg=errmsg+"Please enter your name.\n";if(flag==0)
{document.frmFirst.txtName.focus();flag=1;}}
else
if(document.frmFirst.txtName.value.search(RegExpName)==-1)
{errmsg=errmsg+"Please enter valid name.\n";if(flag==0)
{document.frmFirst.txtName.focus();flag=1;}}
if(email=="")
{errmsg=errmsg+"Please enter your email address.\n";if(flag==0)
{document.frmFirst.txtEmail.focus();flag=1;}}
else
if(email.search(RegExpEmail)==-1)
{errmsg=errmsg+"Please enter valid email address.\n";if(flag==0)
{document.frmFirst.txtEmail.focus();flag=1;}}
if(document.getElementById('cboCity').selectedIndex==0)
{errmsg=errmsg+"Please select city.\n";if(flag==0)
{document.frmFirst.cboCity.focus();flag=1;}}
if(phone==""&&mobile=="")
{errmsg=errmsg+"Please enter either phone or mobile number.\n";}
else
{var lengthAreaCode=areaCode.length;if(selectind=="11"||selectind=="24"||selectind=="28"||selectind=="51"||selectind=="52"||selectind=="74")
{if(selectind=="11")
{lengthAreaCode=document.frmFirst.selectBaraoda.value.length}
else if(selectind=="24")
{lengthAreaCode=document.frmFirst.selectFaizabad.value.length}
else if(selectind=="28")
{lengthAreaCode=document.frmFirst.selectGurgaon.value.length
lengthAreaCode=document.getElementById('selectGurgaon').value.length;}
else if(selectind=="51")
{lengthAreaCode=document.frmFirst.selectNaviMumbai.value.length}
else if(selectind=="52")
{lengthAreaCode=document.frmFirst.selectNavsari.value.length}
else if(selectind=="74")
{alert("Thank you for your interest in Sharekhan.\n Sorry, we are not available at cities other than those mentioned in the form.\n Keep checking this page for regular   updates.\n Until then feel free to refer us to your friend ");return false;}}
var lengthOfPhoneShouldBe=10-lengthAreaCode;if(phone!=""&&phone.length!=lengthOfPhoneShouldBe)
{errmsg=errmsg+"Please enter "+lengthOfPhoneShouldBe+" digit phone number.\n";if(flag==0)
{document.frmFirst.txtPhone.focus();flag=1;}}
if(mobile!="")
{if(document.frmFirst.txtMobile.value.search(RegExpMobile)==-1)
{errmsg+="Please enter valid mobile number.\n";if(flag==0)
{document.frmFirst.txtMobile.focus();flag=1;}}
else
if(document.frmFirst.txtMobile.value.search(invalidMobile)>=0)
{errmsg+="This number is not valid\n";if(flag==0)
{document.frmFirst.txtMobile.focus();flag=1;}}}}
if(pincode=="")
{errmsg=errmsg+"Please enter pincode.\n";if(flag==0)
{document.frmFirst.txtPincode.focus();flag=1;}}
else if(pincode.length<6)
{errmsg=errmsg+"Please enter valid pincode.\n";if(flag==0)
{document.frmFirst.txtPincode.focus();flag=1;}}
if(errmsg=="")
{$('posted').value=1;document.frmFirst.submit();}
else
{alert(errmsg);return false;}}
function getAreaCode()
{var codes=new Array("","79","145","532","171","721","183","2692","2646","80","581","7531","265","2642","278","755","674","151","495","172","44","422","11","424","5278","129","551","863","124","33","40","731","141","191","288","657","291","484","488","231","33","474","522","824","832","2762","22","821","268","712","253","22","2637","120","4926","491","832","20","281","427","40","353","261","261","22","487","421","494","471","260","416","866","891","7152");var selectind=document.getElementById('cboCity').selectedIndex;if(selectind=="11"||selectind=="24"||selectind=="28"||selectind=="51"||selectind=="52")
{if(selectind=="11")
{Display('none','block','none','none','none','none');}
else if(selectind=="24")
{Display('none','none','block','none','none','none');}
else if(selectind=="28")
{Display('none','none','none','block','none','none');}
else if(selectind=="51")
{Display('none','none','none','none','block','none');}
else if(selectind=="52")
{Display('none','none','none','none','none','block');}}
else if(selectind=="53")
{Display('block','none','none','none','none','none');document.getElementById("txtAreaCode").value="";alert("Thank you for your interest in Sharekhan. Sorry, we are not available at cities other than those mentioned in the form. Keep checking this page for regular updates. Until then feel free to refer us to your friend.");}
else
{Display('block','none','none','none','none','none');document.getElementById("txtAreaCode").value=codes[selectind];}}
function Display(val1,val2,val3,val4,val5,val6)
{$('inputBox').style.display=val1;$('selectBarodaId').style.display=val2;$('selectFaizabadId').style.display=val3;$('selectGurgaonId').style.display=val4;$('selectNaviMumbaiId').style.display=val5;$('selectNavsariId').style.display=val6;}
function validateMe(val,num)
{var RegExpEmail=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;if(num==1)
{if(num==1&&val=="")
{$('name').style.display='block';}
else
{$('name').style.display='none';}}
else
if(num==2)
{val=val.toLowerCase();if(num==2&&val=="")
{$('email1').innerHTML='Please enter email.';$('email1').style.display='block';}
else
if(val.search(RegExpEmail)==-1)
{$('email1').innerHTML='Please enter valid email.';$('email1').style.display='block';}
else
{$('email1').innerHTML="";$('email1').style.display='none';var url='checkEmail.php';var pars=Form.serialize('frmFirst');var myAjax=new Ajax.Request(url,{method:'post',parameters:pars,onLoading:loading,onComplete:response});}}
if(num==3)
{if(document.getElementById('cboCity').selectedIndex==0)
{$('city').innerHTML='Please select city.';$('city').style.display='block';}
else
{$('city').innerHTML='';$('city').style.display='none';}}
if(num==6)
{if(num==6&&val=="")
{$('pincode').style.display='block';}
else
{$('pincode').style.display='none';}}}
function loading()
{$("loading").style.display='block';$("email1").innerHTML="";}
function response(originalRequest)
{var newData=originalRequest.responseText;$("loading").style.display='none';if(newData==1)
{$('email1').style.display='block';$("email1").innerHTML="You are already registered with us.";}
else
{$("email1").innerHTML="";}}