/****************************************************************************** * Copyright (c) 2006 : GTI Online Solutions Limited * * This software is provided under the terms of a License Agreement and * may only be used and/or copied in accordance with the terms of such an * agreement. Neither this software nor any copy thereof may be provided * or otherwise made available to any other person. No title or ownership * of this software is hereby transferred. * ******************************************************************************/ function confirmLogoff(astrRoot) { var confirmedLogoff = window.confirm("Do you want to log out?\n\nClick 'OK' to proceed."); if (confirmedLogoff) { document.location.href = astrRoot+'/Logout.asp'; return true; } } function openViewApplication(aoForm, astrRoot) { if (document.forms.length > 0) { aoForm.target = '_BLANK'; aoForm.action = astrRoot + '/Application/View/ApplicationView.asp'; aoForm.submit(); } else { var newWindow; newWindow = window.open(astrRoot + '/Application/View/ApplicationView.asp'); newWindow.focus(); } } function openViewCV(aoForm, astrRoot) { if (document.forms.length > 0) { aoForm.target = '_BLANK'; aoForm.action = astrRoot + '/View/ViewCV.asp'; aoForm.submit(); } else { var newWindow; newWindow = window.open(astrRoot + '/View/ViewCV.asp'); newWindow.focus(); } } function openViewEmail(aoForm, astrRoot) { if (document.forms.length > 0) { aoForm.target = '_BLANK'; aoForm.action = astrRoot + '/View/ViewEmail.asp'; aoForm.submit(); } else { alert('Error opening the e-mail for viewing.'); } } function openViewNote(aoForm, astrRoot) { if (document.forms.length > 0) { aoForm.target = '_BLANK'; aoForm.action = astrRoot + '/View/ViewNote.asp'; aoForm.submit(); } else { alert('Error opening the note for viewing.'); } } function IsTelephone(astrTelephoneNumber) { var reTelephone = /^(\d|\+)\d{5,}$/; return reTelephone.test(astrTelephoneNumber); } function IsValidDate (strFMode, theDate, blnMandatory) { var theDay = theDate.substring(6,9); var theMonth = theDate.substring(4,6); var theYear = theDate.substring(0,4); var correctDays = 0; //alert (theDay); //alert (theMonth); //alert (theYear); if (blnMandatory == false && theDate == "00000000") { return true; } else { //Check that all have value other than "00", "00, "0000" if (theDay == "00") { if (strFMode != "MONTHYEAR") { return false; } } if (theMonth == "00") { return false; } if (theYear == "0000") { return false; } // 30 days has September,April, June and November if ((theMonth == 4) || (theMonth == 6)|| (theMonth == 9)|| (theMonth ==11)) { correctDays = 30; } else { // All the rest have 31 except February if((theMonth == 2)) { if (( theYear % 4 == 0 && theYear % 100 != 0) || theYear % 400 == 0 ) { correctDays = 29; } else { correctDays = 28; } } else { correctDays = 31; } } if (theDay > correctDays) { return false; } if (blnMandatory == true && theDate == "00000000") { return false; } return true; } } function ValidateDate(aintYear, aintMonth, aintDay) { var intCorrectDays = 0; if ((aintYear == 0) || (aintMonth == 0) || (aintDay == 0)) { return false; } else { // 30 days has September,April, June and November if ((aintMonth == 4) || (aintMonth == 6)|| (aintMonth == 9)|| (aintMonth ==11)) { intCorrectDays = 30; } else { // All the rest have 31 except February if((aintMonth == 2)) { if (( aintYear % 4 == 0 && aintYear % 100 != 0) || aintYear % 400 == 0 ) { intCorrectDays = 29; } else { intCorrectDays = 28; } } else { intCorrectDays = 31; } } if (aintDay > intCorrectDays) { return false; } return true; } } function validateEmail(astrEmail) { // Define patterns for different parts of the email address var strValidEmailPart = "\[^\\s\\(\\)><@,;:\\\\\\\"\\.\\[\\]\]+"; // Valid sequence of chars I.E. everything except spaces and ( ) < > @ , ; : \ " . [ ] var strValidLocalPart = "((\[^\\s\\(\\)><@,;:\\\\\\\"\\.\\[\\]\]+)|(\"[^\"]*\"))"; // As above but allow quoted strings containing otherwise invalid chars // Define regular expressions var reEmailStructure = /^(.+)@(.+)$/; // Valid email address structure var reLocalPart = new RegExp("^" + strValidLocalPart + "(\\." + strValidLocalPart + ")*$"); // Valid localpart (the part preceding the @) var reIPAddress = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; var reDomainName = new RegExp("^" + strValidEmailPart + "(\\." + strValidEmailPart +")+$"); // Valid domain name var reDomainExtensions = /^(?:(?:\.(?:cat|com|net|org|edu|mil|gov|biz|int|jobs|pro|info|mobi|name|coop|arpa|aero|museum|travel)))$/; // Valid Domain-name extensions // Declare other local variables var strLocalPart; var strDomain; var arrEmailParts; var arrDomainParts; // Validate address structure (xxxxx@xxxxxx) arrEmailParts = astrEmail.match(reEmailStructure); if (!arrEmailParts || arrEmailParts.length == 0) { return false; } strLocalPart = arrEmailParts[1]; strDomain = arrEmailParts[2]; // Validate local part if (!reLocalPart.test(strLocalPart)) { return false; } // Validate domain part if (!reIPAddress.test(strDomain)) { arrDomainParts = strDomain.match(reDomainName); if (arrDomainParts && arrDomainParts.length > 1) { // Validate domain extension (Known domain extension / 2 letter country-code) if (!reDomainExtensions.test(arrDomainParts[arrDomainParts.length - 1].toLowerCase()) && arrDomainParts[arrDomainParts.length - 1].length != 3) { return false; } } else { return false; } } // Must be valid return true; } function trim(astrString) { return astrString.replace(/^\s+|\s+$/g, ''); } function countWords(strTarget) { var arrWords = strTarget.match(/\S+/g); if (arrWords) return arrWords.length; return 0; } function isInteger(intTarget) { var reInteger = /^[0-9]+$/; return reInteger.test(intTarget); } function isFirstDateEarlier() { if (arguments.length == 4) { // Month1,Year1,Month2,Year2 if (arguments[1] < arguments[3]) return true; if (arguments[1] > arguments[3]) return false; if (arguments[0] <= arguments[2]) return true; // Allows identical months when not using days if (arguments[0] > arguments[2]) return false; } else if (arguments.length == 6) { // Date1,Month1,Year1,Date1,Month2,Year2 if (arguments[2] < arguments[5]) return true; if (arguments[2] > arguments[5]) return false; if (arguments[1] < arguments[4]) return true; if (arguments[1] > arguments[4]) return false; if (arguments[0] < arguments[3]) return true; if (arguments[0] >= arguments[3]) return false; // Does not allow identical days } else { window.alert("Function isFirstDateEarlier requires 4 or 6 arguments:\n\nd1,m1,y1,d2,m2,y2 or\nm1,y1,m2,y2"); return false; } } function isSubmitted() { if (blnSubmitted == true) return true; else { blnSubmitted = true; return false; } } function IsValidDayMonthYear (strFMode, theDate, blnMandatory) { var theDay = theDate.substring(6,9); var theMonth = theDate.substring(4,6); var theYear = theDate.substring(0,4); var correctDays = 0; //alert (theDay); //alert (theMonth); //alert (theYear); if (blnMandatory == false && theDate == "00000000") { return true; } else { //Check that all have value other than "00", "00", "0000" if (theDay == "00") { if (strFMode != "MONTHYEAR") { return false; } } if (theMonth == "00") { return false; } if (theYear == "0000") { return false; } // 30 days has September,April, June and November if ((theMonth == 4) || (theMonth == 6)|| (theMonth == 9)|| (theMonth ==11)) { correctDays = 30; } else { // All the rest have 31 except February if((theMonth == 2)) { if (( theYear % 4 == 0 && theYear % 100 != 0) || theYear % 400 == 0 ) { correctDays = 29; } else { correctDays = 28; } } else { correctDays = 31; } } if (theDay > correctDays) { return false; } if (blnMandatory == true && theDate == "00000000") { return false; } return true; } } function isValidPageNumber(aintValue, aintMax) { if (isNaN(aintValue)) return false; if ((aintValue < 1) || (aintValue > aintMax)) return false; return true; }