function ValidateDatePattern(f){var e=false;var b,a,d,c;b=document.getElementById(f).value;a="(\\d{1,2})(\\/)(\\d{1,2})(\\/)(\\d{4})";d=new RegExp(a);d.ignoreCase=true;d.global=true;c=d.test(b);if(c==true){e=true}else{e=false}c=null;d=null;return e}function Left(a,b){if(b<=0){return""}else{if(b>String(a).length){return a}else{return String(a).substring(0,b)}}}function Right(b,c){if(c<=0){return""}else{if(c>String(b).length){return b}else{var a=String(b).length;return String(b).substring(a,a-c)}}}function validateDateRange(f){var a,e,h,g,c,d,b;c=document.getElementById(f).Value;c=Trim(c);g=c.split("../index.html");if((g.length==2)){e=g[0];a=g[1];h=g[2];if(h.length==4&&!isNaN(h)&&!isNaN(a)&&!isNaN(e)){if(((h<=1900)||(h>9998))){return false}else{if((a<1||a>12)){return false}else{if((e<1||e>31)){return false}else{if(((a==4||a==6||a==9||a==11)&&e==31)){return false}else{if((a==2)){if((h%4==0&&h%100!=0)||h%400==0){b=true}else{b=false}if((e>29||(e==29&&!b))){return false}}}}}}}else{return false}}}function ValidateDOB(c){var a,b;if(ValidateDate(c)==false){return}if(document.getElementById(c).Value!=""){a=document.getElementById(c).Value;b=new Date();b=((b.getMonth()+1)+"/"+(b.getDate())+"/"+(b.getFullYear()));if((dateDiff("d",a,b)<0)){alert("Date of Birth cannot be greater than Current date");document.getElementById(c).Value="";return}}}function ValidateDate(a){if(ValidateDatePattern(a)==false||validateDateRange(a)==false){alert("Please enter a date between January 1,1900 && December 31,9998");document.getElementById(a).value="";return false}return true}function ValidateExpiryDate(a){if((document.getElementById(a).value=="DD/MM/YYYY")){document.getElementById(a).value=""}if((document.getElementById(a).value!="")){if(ValidateDatePattern(a)==false||validateDateRange(a)==false){alert("Enter Date in dd/MM/yyyy format for Date field.");document.getElementById(a).value="";document.getElementById(a).style.color="gray";document.getElementById(a).style.fontSize="11px";document.getElementById(a).value="DD/MM/YYYY";return}}}function validateName(c){var b,a;b=Trim(document.getElementById(c).value);if(b!=""){if(ValidateRegExpr("IsAlphaSpaceOH",b)==false){alert("Name should not contain Special characters or numeric values");document.getElementById(c).value="";document.getElementById(c).focus();return}if(ValidateRegExpr("IsAllHyhen",b)==true){alert("Name should not contain all Hyphen as a Special characters");document.getElementById(c).value="";document.getElementById(c).focus();return}if(ValidateRegExpr("IsAllApostrophe",b)==true){alert("Name should not contain all Apostrophe as a Special characters");document.getElementById(c).value="";document.getElementById(c).focus();return}document.getElementById(c).style.background="White";a=Mid(b,0,1).toUpperCase();a=a+Mid(b,1,b.length);document.getElementById(c).value="";if(a.search("  ")!=-1){a=a.replace("  "," ")}document.getElementById(c).value=a}}function ValidatePinCode(b){var a;a=document.getElementById(b).value;if(a!=""){if(!isNaN(a)==false){alert("PinCode should be a number");document.getElementById(b).value="";document.getElementById(b).focus();return}if(a<0){alert("Please enter correct pin code");document.getElementById(b).value="";document.getElementById(b).focus();return}if(a.length!=6){alert("PinCode should be of 6 digits");document.getElementById(b).value="";document.getElementById(b).focus();return}if(a=="000000"){alert("Pin Code cannot just contain zeroes alone. Please correct it.");document.getElementById(b).value="";document.getElementById(b).focus();return}if(Mid(a,1,6)=="00000"){alert("Pin Code cannot contain 5 zeroes from 2nd to 6th digit. Please enter the correct Pin Code");document.getElementById(b).value="";document.getElementById(b).focus();return}if(Math.round(Mid(a,0,1)=="0")){alert("PinCode should not start with 0");document.getElementById(b).value="";document.getElementById(b).focus();return}}}function ValidateTime(h){var d,c,e,b,f,a,g;b=document.getElementById(h).value;g="[0-9][0-9]:[0-9][0-9]";d=new RegExp(g,"g");d.global=true;d.ignoreCase=true;c=d.test(b);if(c==false){alert("Please enter time in hh:mm format");document.getElementById(h).value="";return false}else{a=b.split(":");if(a[0]>23){alert("Please enter valid hours upto 23");document.getElementById(h).value="";return false}if(a[1]>59){alert("Please enter valid minutes upto 59");document.getElementById(h).value="";return false}}}function Pattern(a){var b;if(a=="IsAlphaWithSpaceM"){b="[A-Z]|[a-z]|[ ]|[']|[.]"}else{if(a=="IsAddress"){b="[A-Z]|[a-z]|[-]|[/]|[0-9]|[,]|[#]|[ ]|[:]"}else{if(a=="IsAlphaM"){b="[A-Z]|[a-z]|[ ]"}else{if(a=="IsAlphaNumericValues"){b="[A-Z]|[a-z]|[0-9]|[ ]|[']|[-]|[+]"}else{if(a=="OnlyAlphaValues"){b="[']|[-]|[+]|[0-9]"}else{if(a=="IsAlphaNumeric"){b="[A-Z]|[a-z]|[0-9]"}else{if(a=="IsAllAlphabet"){b="[A-Z]|[a-z]"}else{if(a=="IsAlphaNumericWithSpace"){b="[A-Z]|[a-z]|[ ]|[0-9]"}else{if(a=="IsAlphaSpaceOH"){b="[A-Z]|[a-z]|[ ]|[']|[-]"}else{if(a=="IsAlphtNumbericHSCHS"){b="[A-Z]|[a-z]|[-]|[/]|[0-9]|[,]|[#]|[ ]"}else{if(a=="IsAlphaSpaceCH"){b="[A-Z]|[a-z]|[ ]|[,]|[-]"}else{if(a=="IsAlphaNumericHS"){b="[A-Z]|[a-z]|[0-9]|[-]|[/]"}else{if(a=="IsSelectedNumeric"){b="[A-Z]|[a-z]|[0-9]|[/]|[ ]|[-]"}else{if(a=="IsAlphaNumericCSHD"){b="[A-Z]|[a-z]|[0-9]|[,]|[ ]|[-]|[.]"}else{if(a=="IsAlphaWithSpace"){b="[A-Z,' ']|[a-z,' ']"}else{if(a=="IsDescriptionCheck"){b="[^/^]"}else{if(a=="MakeModelAccessories"){b="[A-Z]|[a-z]|[0-9]|[ ]|[-]"}else{if(a=="IsAllHyhen"){b="[-]"}else{if(a=="IsAllApostrophe"){b="[']"}else{if(a=="IsAllDot"){b="[.]"}else{if(a=="IsAllNumeric"){b="[0-9]"}}}}}}}}}}}}}}}}}}}}}return b}function ValidateRegExpr(f,a){var g=true;var d,c,e,h,b;h=Pattern(f);for(e=0;e<(a.length);e++){b=Mid(a,e,1);d=new RegExp(h,"g");d.global=true;d.ignoreCase=true;c=d.test(b);if(c==false){g=false}d=null}return g}function CheckForZero(a){var c,b,e,d=false;e="[A-Z]|[a-z]|[1-9]";c=new RegExp(e);c.global=true;c.ignoreCase=true;b=c.test(a);if((b==false)){d=true}return d}function CheckTwoDecimalPoint(d){var c;c=d.value;var b,a;a=InStr(1,c,".");if(a!=0){b=c.split(".");if(b.length>1){if(b[1]!=""){if(b[1].length>2){alert("Sum Insured cannot be more than 2 decimal points.");d.value="";return}}}}}function Checknumeric(c){var b=true;var a=Trim(document.getElementById(c).Value);if(isNaN(a)){alert("Please enter a valid number");document.getElementById(c).Value="";b=false}return b}function CheckCurrency(d){var c,b=true,a=0;a=document.getElementById(d).value;c="[0-9]";regExp=new RegExp(c);regExp.global=true;regExp.ignoreCase=true;match=regExp.test(a);if((match==false)&&(isNaN(a))){alert("Please enter a valid number");document.getElementById(d).Value="";document.getElementById(d).focus();b=false;return b}if(CheckCurrencyFieldLength(d)==false){b=false;return b}}function CheckCurrencyFieldLength(c){var a,b=true;a=document.getElementById(c).Value;if(document.getElementById(c).value!=""){if(document.getElementById(c).value>99999999999999){alert("Value cannot be more than 99999999999999.");document.getElementById(c).value=99999999999999;b=false}}return b}function SafeDbl(a){var b=0;b=parseFloat(a);b=Math.round(b);return b}function ConverTosafeInt(a){var b=0;b=Math.round(a);return b}function CurrencyAndFormat(b){var a;if(document.getElementById(b).value!=""){if(CheckCurrency1(b)==false){document.getElementById(b).value="";return}}if(document.getElementById(b).value!=""){a=document.getElementById(b).value;document.getElementById(b).value=FormatNumber(a,2);document.getElementById(b).Style.BackGround="White";return}}function CheckCurrency1(f){var a,c,b,e,d;a=document.getElementById(f).value;e="[0-9]";b=new RegExp(e);b.global=true;b.ignoreCase=true;c=b.test(a);if((c==false)&&(isNaN(a))){alert("Please enter a valid value");document.getElementById(f).Value="";document.getElementById(f).focus();d=false;return d}if(CheckCurrencyFieldLength1(f)==false){d=false;return d}}function CheckCurrencyFieldLength1(b){var a;a=document.getElementById(b).value;if(document.getElementById(b).value!=""){if(document.getElementById(b).value>99999999999999){alert("Value cannot be more than 99999999999999.");document.getElementById(b).value=99999999999999;return false}}}function GetCofigurationValue(e,c){var g;var b;var a;var h;var f;var d=0;Hidden=document.getElementById(c).value;g=Hidden.split(";");h=g.length-1;while(h>=0){b=g[h].split(",");f=b.length;if(f>=1){if((b[0]==e)){d=b[1]}}h=h-1}return d}function AcceptNumeric(a){var b;b=Trim(document.getElementById(a).value);If(b!="");if(!isNaN(b)==false){document.getElementById(a).value="";document.getElementById(ControlName).focus();alert("Please Enter Numeric Values")}}function ClearBox(a){document.getElementById(a).value=""}function InStr(b,a){if(b){for(i=0;i<b.length;i++){if(a==Mid(b,i,1)){return i}}}else{b=""}return -1}function Mid(d,e,b){if(e<0||b<0){return""}var c;var a=String(d).length;if((e+b)>a){c=a}else{c=e+b}return String(d).substring(e,c)}function Trim(a){if(a!=undefined){if(a.length>0){return a.replace(/^\s+|\s+$/g,"")}}else{return""}}function FormatNumber(d,b){if(isNaN(d)){return 0}if(d==""){return 0}var h=new String(d);var e=h.split(".");var f=parseFloat(e[0]);var a="";if(e.length>1){var g=new String(e[1]);g=String(parseFloat(e[1])/Math.pow(10,(g.length-b)));g=String(f+Math.round(parseFloat(g))/Math.pow(10,b));var c=g.indexOf(".");if(c==-1){g+=".";c=g.indexOf(".")}while(g.length<=c+b){g+="0"}a=g}else{var c;var g=new String(f);g+=".";c=g.indexOf(".");while(g.length<=c+b){g+="0"}a=g}return a}function DateSplit(a){var b;b=a.split("../index.html");return b}function dateDiff(f,c,j,l){var d,e,a=0,h;var b="Check the Start Date and End Date\n";b+="must be a valid date format.\n\n";b+="Please try again.";var k="Sorry the dateAdd function only accepts\n";k+="d, h, m OR s intervals.\n\n";k+="Please try again.";e=Date.parse(c);d=Date.parse(j);if(isNaN(e)||isNaN(d)){return null}if(f.charAt=="undefined"){return null}var g=d-e;switch(f.charAt(0)){case"d":case"D":a=parseInt(g/86400000);if(l){a+=parseInt((g%86400000)/43200001)}break;case"yyyy":case"YYYY":a=parseInt(g/31536000000);if(l){a+=parseInt((g%31536000000)/15768000001)}break;case"h":case"H":a=parseInt(g/3600000);if(l){a+=parseInt((g%3600000)/1800001)}break;case"m":case"M":a=parseInt(g/2592000000);if(l){a+=parseInt((g%2592000000)/1296000001)}break;case"n":case"N":a=parseInt(g/60000);if(l){a+=parseInt((g%60000)/30001)}break;case"s":case"S":a=parseInt(g/1000);if(l){a+=parseInt((g%1000)/501)}break;default:return null}return a};
