/***************************************************************************** Declare the strings for localization ****************************************************************************/ var g_sYouMust = 'Vous devez vérifier'; var g_sYouNeedToEnter = 'Vous devez saisir une valeur valide pour votre'; var g_sMustBeCompleted = 'doit contenir une valeur valide.'; var g_sTheValueFor = 'La valeur pour'; var g_sMustContainAtLeast = 'doit contenir au moins'; var g_sCharacters = 'caractères'; var g_sMustBeNumeric = 'doit être une valeur numérique.'; var g_sInternational1 = 'peut uniquement contenir des chiffres et des symboles \'()- \ et doit contenir au moins'; var g_sInternational2 = 'chiffres'; var g_sMustMatch = 'doit correspondre à'; var g_sMustBeInAValidDateFormat = 'doit être une date valide au format jj/mm/aaaa.'; var g_sMustBeAValidEmailAddress = 'doit être une adresse électronique valide.'; /***************************************************************************** Form validation functions ****************************************************************************/ function form_validation(formName) { if(ValidateForm(formName) == true) { // Form has passed all the defined checks window.document[formName].submit(); } else { //The form has not passed validation } } function isDigit (c){ if (c=="." || c==":" || c=="," || c==" ")return true; return ((c >= "0") && (c <= "9")); } function IsNumeric(s){ if(s.length == 1 && s == "-") return false; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (!isDigit(c))return false; } return true; } function IsInteger(n){ if(n != parseInt(n)) return false; return true; } function FocusField(f) { f.focus();if(eval(f.type == "text"))f.select(); } function ValidateForm(formName) { document[formName].Submit.disabled = true; var fields = eval('document.'+formName+'.elements'); for(var i = 0;i= minDigitsInIPhoneNumber); } function isInteger(s) { var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function IsEmail(emailStr) { var emailReg = "^[._A-z0-9-]+@[.A-z0-9-]+[.]{1}[A-z]{2,4}$"; var regex = new RegExp(emailReg); return regex.test(emailStr); } function stripCharsInBag(s, bag) { var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } /***************************************************************************** * Function: validateDate * Description: Checks date to make sure it is valid ****************************************************************************/ function validateDate(thisdate){ var theDay, theMonth, theYear, dateArr; //alert(thisdate) dateArr = thisdate.split("/"); theDay = dateArr[0]; theMonth = dateArr[1]; theYear = dateArr[2]; if(!(theMonth >=1 && theMonth <=12)) { return false; } if(!(theYear>=1900)) { return false; } if(theMonth == 1 || theMonth == 3 || theMonth == 5 || theMonth == 7 || theMonth == 8 || theMonth == 10 || theMonth == 12) { if(!(theDay >= 1 && theDay <= 31)) { return false; } } else if(theMonth == 2) { if(theDay == 29 && (!((theYear % 4) == 0))) { return false; //leap year check } if(!(theDay >= 1 && theDay <=29)) { return false;//average feb } else { return true; } } else { if(!(theDay >= 1 && theDay <= 30)) { return false; } } return true; } //only checks for distance of 18 years at the moment - not very generic, should be rewritten to take distance as a parameter, and distance type (so we can do any distance in seconds or years, or days, whatever!) //also this doesn't yet reject for dates between 17.5 and 18 years ago by the looks off things function checkDateDistance() { //Set the two dates today = new Date(); var selectedDate = new Date(document.frm.year_dob.value, document.frm.month_dob.value - 1, document.frm.day_dob.value) var one_day=1000*60*60*24 if(Math.ceil((today.getTime()-selectedDate.getTime())/(one_day)) >= (365*18)) { return true; } else { return false; } } function validatePassword(SiteMode,Password) { var passwordRegExp; if (SiteMode != "SIM") { passwordRegExp = new RegExp(/^.*(?=.{6,20})(?=.*\d)(?=.*[a-zA-Z]).*$/); } else { passwordRegExp = new RegExp(/^[a-zA-Z]{6,20}$/); } if (passwordRegExp.test(Password)) { return true; } else { return false; } } function formatNumber(pnumber,decimals){ if (isNaN(pnumber)) { pnumber = 0;}; if (pnumber=='') { pnumber = 0;}; var snum = new String(pnumber); var sec = snum.split('.'); var whole = parseFloat(sec[0]); var result = ''; if(sec.length > 1){ var dec = new String(sec[1]); dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals))); dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals)); var dot = dec.indexOf('.'); if(dot == -1){ dec += '.'; dot = dec.indexOf('.'); } while(dec.length <= dot + decimals) { dec += '0'; } result = dec; } else{ var dot; var dec = new String(whole); dec += '.'; dot = dec.indexOf('.'); while(dec.length <= dot + decimals) { dec += '0'; } result = dec; } return result; } function hideObject(divName) { document.getElementById(divName).style.display = "none"; } function showObject(divName) { document.getElementById(divName).style.display = "block"; } function changeDate(formElement) { var yearSelect = document.getElementById(formElement); yearSelect.selectedIndex = yearSelect.length - 1; } function resizeWindow(sIFrameLocation) { if(is_ie != false) { var pageLocation = ""+sIFrameLocation var resizePages = new Array('applicationform.html','applicationform1.html','applicationform2.html','applicationform3.html','applicationform4.html','applicationform5.html','applicationform6.html','applicationform7.html'); var IFrame = document.getElementById('text'); for (var i = 0; i < resizePages.length; i++) { if(pageLocation.indexOf(resizePages[i]) != -1) { document.getElementById('menuDIV').style.height = "550px"; IFrame.style.height = "550px"; break; } else { document.getElementById('menuDIV').style.height = "100%"; IFrame.style.height = "380px"; } } } } var popup; function simplePopup(url, width, height){ if(popup) popup.close(); popup = window.open(url,"popup","width="+width+",height="+height+", location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no"); return popup; } function simplePopupScroll(url, width, height){ if(popup) popup.close(); popup = window.open(url,"popup","width="+width+",height="+height+",scrollbars=yes"); } function roundto(thenumber, dp) { return Math.round(thenumber*Math.pow(10,dp))/Math.pow(10,dp); } function includeDynamicScript(url) { var remoteScript=document.createElement('script'); remoteScript.id = 'rs'; remoteScript.setAttribute('type','text/javascript'); remoteScript.setAttribute('src', url); var hd=document.getElementsByTagName('head')[0]; // Gotcha: set attribute and src BEFORE appending, or Safari won't work hd.appendChild(remoteScript); } function openDesigner(url) { myWindow = window.open(url, "designer", "toolbar=no") } //-->