function validate_required(field,alerttxt)
{with(field)
{if(value==null||value=="")
{alert(alerttxt);return false;}
else{return true}}}
function validate_form(thisform)
{with(thisform)
{if(validate_required(name,"Please fill out your name!")==false)
{name.focus();return false;}
if(validate_required(address,"Please fill out your address!")==false)
{address.focus();return false;}
if(validate_required(country,"Please fill out your country name!")==false)
{country.focus();return false;}
if(validate_required(cell,"Please fill out your cell no.!")==false)
{cell.focus();return false;}
if(validate_required(email,"Please fill out your email id!")==false)
{email.focus();return false;}
if(validate_required(req,"Please fill out your requirements!")==false)
{req.focus();return false;}}}
function validateInteger(text)
{var charpos=text.search("[^0-9]");if(eval(text.length)>0&&charpos>=0)
{alert("please insert numeric value");document.registration.SignalingPort.value='';}
if(text>65000&&text<1)
{alert("Please put Signaling Port between 1 and 65000");document.registration.SignalingPort.value='';}}
function validateInteger1(text)
{var charpos=text.search("[^0-9]");if(eval(text.length)>0&&charpos>=0)
{alert("please insert numeric value");document.registration.sipSwitchIP1.value='';}
validate_ip();}
function validateInteger2(text)
{var charpos=text.search("[^0-9]");if(eval(text.length)>0&&charpos>=0)
{alert("please insert numeric value");document.registration.sipSwitchIP2.value='';}
validate_ip();}
function validateInteger3(text)
{var charpos=text.search("[^0-9]");if(eval(text.length)>0&&charpos>=0)
{alert("please insert numeric value");document.registration.sipSwitchIP3.value='';}
validate_ip();}
function validateInteger4(text)
{var charpos=text.search("[^0-9]");if(eval(text.length)>0&&charpos>=0)
{alert("please insert numeric value");document.registration.sipSwitchIP4.value='';}
validate_ip();}
function check_state1()
{document.getElementById("other_search_txt").value='';if(document.registration.other_search.checked)
document.getElementById("other_search_txt").style.display='block';else
document.getElementById("other_search_txt").style.display='none';}
function check_state2()
{document.getElementById("others_txt").value='';if(document.registration.others_chk.checked)
document.getElementById("others_txt").style.display='block';else
document.getElementById("others_txt").style.display='none';}
function check_state3()
{document.getElementById("blog_txt").value='';if(document.registration.blog_chk.checked)
document.getElementById("blog_txt").style.display='block';else
document.getElementById("blog_txt").style.display='none';}
function emailCheck(emailStr){var checkTLD=1;var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;var emailPat=/^(.+)@(.+)$/;var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";var validChars="\[^\\s"+specialChars+"\]";var quotedUser="(\"[^\"]*\")";var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;var atom=validChars+'+';var word="("+atom+"|"+quotedUser+")";var userPat=new RegExp("^"+word+"(\\."+word+")*$");var domainPat=new RegExp("^"+atom+"(\\."+atom+")*$");var matchArray=emailStr.match(emailPat);if(matchArray==null){alert("Email address seems incorrect (check @ and .'s)");return false;}
var user=matchArray[1];var domain=matchArray[2];for(i=0;i<user.length;i++){if(user.charCodeAt(i)>127){alert("Ths username contains invalid characters.");return false;}}
for(i=0;i<domain.length;i++){if(domain.charCodeAt(i)>127){alert("Ths domain name contains invalid characters.");return false;}}
if(user.match(userPat)==null){alert("The username doesn't seem to be valid.");return false;}
var IPArray=domain.match(ipDomainPat);if(IPArray!=null){for(var i=1;i<=4;i++){if(IPArray[i]>255){alert("Destination IP address is invalid!");return false;}}
return true;}
var atomPat=new RegExp("^"+atom+"$");var domArr=domain.split(".");var len=domArr.length;for(i=0;i<len;i++){if(domArr[i].search(atomPat)==-1){alert("The domain name does not seem to be valid.");return false;}}
if(checkTLD&&domArr[domArr.length-1].length!=2&&domArr[domArr.length-1].search(knownDomsPat)==-1){alert("The address must end in a well-known domain or two letter "+"country.");return false;}
if(len<2){alert("This address is missing a hostname!");return false;}
return true;}
function validate_ip()
{if(document.registration.sipSwitchIP1.value.length==3)
{if(document.registration.sipSwitchIP1.value>255||document.registration.sipSwitchIP1.value<1)
alert("Please put a value between 1 and 255");}
if(document.registration.sipSwitchIP2.value.length==3)
{if(document.registration.sipSwitchIP2.value>255||document.registration.sipSwitchIP2.value<0)
alert("Please put a value between 0 and 255");}
if(document.registration.sipSwitchIP3.value.length==3)
{if(document.registration.sipSwitchIP3.value>255||document.registration.sipSwitchIP3.value<0)
alert("Please put a value between 0 and 255");}
if(document.registration.sipSwitchIP4.value.length==3)
{if(document.registration.sipSwitchIP4.value>255||document.registration.sipSwitchIP4.value<1)
alert("Please put a value between 1 and 255");}}
function validate_required_reg(field,alerttxt)
{with(field)
{if(value==null||value=="")
{alert(alerttxt);return false;}
else{return true}}}
function validate_form_reg(thisform)
{with(thisform)
{if(validate_required_reg(name,"Please fill out your first name!")==false)
{name.focus();return false;}
if(validate_required_reg(lname,"Please fill out your last name!")==false)
{lname.focus();return false;}
if(validate_required_reg(email,"Please fill out your email!")==false)
{email.focus();return false;}
if(validate_required_reg(password,"Please fill out your password!")==false)
{password.focus();return false;}
else
{var pass=document.registration.password.value;var len=pass.length;if(len<6)
{alert("Password minimum 6 character");document.registration.password.value='';password.focus();return false;}
if(document.registration.password.value!=document.registration.password1.value)
{alert("Please verify your password");document.registration.password1.value="";password1.focus();return false;}}
if(document.registration.country.options[document.registration.country.selectedIndex].text=='Choose your country')
{alert("please select your country");return false;}
if(validate_required_reg(email,"Please fill out your email id!")==false)
{email.focus();return false;}
else
{if(emailCheck(document.registration.email.value)==false)
{email.focus();return false;}}
if(validate_required_reg(cell_phone2,"Please fill out your phone number!")==false)
{cell_phone2.focus();return false;}
if(validate_required_reg(dialer_name,"Please fill out your Company Name/Brand!")==false)
{dialer_name.focus();return false;}
if(document.registration.sipSwitchIP1.value>255||document.registration.sipSwitchIP1.value<1||document.registration.sipSwitchIP1.value=="")
{alert("Please put a SIP Switch IP between 1 and 255");sipSwitchIP1.focus();return false;}
if(document.registration.sipSwitchIP2.value>255||document.registration.sipSwitchIP2.value<0||document.registration.sipSwitchIP2.value=="")
{alert("Please put a SIP Switch IP between 0 and 255");sipSwitchIP2.focus();return false;}
if(document.registration.sipSwitchIP3.value>255||document.registration.sipSwitchIP3.value<0||document.registration.sipSwitchIP3.value=="")
{alert("Please put a SIP Switch IP between 0 and 255");sipSwitchIP3.focus();return false;}
if(document.registration.sipSwitchIP4.value>255||document.registration.sipSwitchIP4.value<1||document.registration.sipSwitchIP4.value=="")
{alert("Please put a SIP Switch IP between 1 and 255");sipSwitchIP4.focus();return false;}
if(validate_required_reg(SignalingPort,"Please fill out your Signaling Port!")==false)
{SignalingPort.focus();return false;}
else
{var sPort=document.registration.SignalingPort.value;if(sPort<1||sPort>65000){alert("Please put Signaling Port between 1 and 65000");SignalingPort.focus();return false;}
if(document.registration.checkbox.checked){document.registration.sButton.disabled=true;return true;}
else
{alert("You have not read and accepted \n'the Operator's Agreement for iTel Mobile Dialer'");return false;}}}}
