// BEGIN: Flash Create control function // Used to insert a flash element getting around the need to activate in IE //------------------------------------------------------- //-------------------VERSION HISTORY--------------------- //------------------------------------------------------- // Date Developer Comment | //------------------------------------------------------- // 25-AUG-06 Mark Richardson Function Created //------------------------------------------------------- // // // //------------------------------------------------------- function CreateControl(DivID,WIDTH, HEIGHT, URL) { var d = document.getElementById(DivID); d.innerHTML = ''; } // END: // BEGIN: Browser sniff isDOM = (document.getElementById) ? true : false; isNS = (navigator.appName.indexOf("Netscape")!=-1); isNS4 = (document.layers) ? true : false; isNS4old = (isNS4 && (parseFloat(navigator.appVersion) < 4.02)); isNS6 = isNS&&isDOM; isIE = (document.all) ? true : false; isIE4 = isIE && !isDOM; isIE5or6 = isIE&&isDOM; isXPSP2 = (navigator.userAgent.indexOf("SV1") != -1); isMac = (navigator.appVersion.indexOf("Mac") != -1); isIE4M = isIE4 && isMac; isOpera = (navigator.userAgent.indexOf("Opera")!=-1); isKonqueror = (navigator.userAgent.indexOf("Konqueror")!=-1); // END: Browser sniff // BEGIN: Body onload utility - supports multiple onload functions /* Modified from: http://javascript.about.com/library/scripts/blsafeonload.htm Call the following with your function as the argument SafeAddOnload(yourfunctioname); */ var gSafeOnload = new Array(); function SafeAddOnload(f){ if (isIE && isMac && isIE4) { // IE 4.5 blows out on testing window.onload window.onload = SafeOnload; gSafeOnload[gSafeOnload.length] = f; } else if (window.onload) { if (window.onload != SafeOnload){ gSafeOnload[0] = window.onload; window.onload = SafeOnload; } gSafeOnload[gSafeOnload.length] = f; } else window.onload = f; } function SafeOnload() { for (var i=0;i topNavWidth) document.getElementById("topNavArrows").style.visibility="visible"; }else if (document.layers){ topNavNS=document.topNavNSLayer.document.topNavNSLayer2 topNavNS.document.write(topNavContents) topNavNS.document.close() topNavActualWidth=topNavNS.document.width } } function topNavMoveLeft(){ if (document.all&&topNavIE.style.pixelLeft>(topNavWidth-topNavActualWidth)) topNavIE.style.pixelLeft-=topNavScrollSpeed else if (document.layers&&topNavNS.left>(topNavWidth-topNavActualWidth)) topNavNS.left-=topNavScrollSpeed topNavLeftTimeout=setTimeout("topNavMoveLeft()",50) } function topNavMoveRight(){ if (document.all&&topNavIE.style.pixelLeft<0) topNavIE.style.pixelLeft+=topNavScrollSpeed else if (document.layers&&topNavNS.left<0) topNavNS.left+=topNavScrollSpeed topNavRightTimeout=setTimeout("topNavMoveRight()",50) } // END: Scrollable Menu Links function isEmpty(str) { if (str.length == 0) return true; if (str.search(/\S/) == -1) return true; return false; } function isNumber(str,blnRequired) { if (isEmpty(str) && (blnRequired)) return false; else if ((str.length > 0)) { var strCharCode = ""; for (j=0;j= 44 && strCharCode <= 57)) return false; } } return true; } function isURL(str,blnRequired) { if (isEmpty(str) && (blnRequired)) return false; if (!isEmpty(str)) { if (str.search(" ") > -1) return false; if (str.search(/\./) == -1) return false; for(i=0;i<=str.length;i++) { if(str.charCodeAt(i) > 128) return false; } } return true; } function isEmail(str,blnRequired) { // This script and many more are available free online at // The JavaScript Source!! http://javascript.internet.com // V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) // Modified by Tony Ruscoe (truscoe@sdlintl.com) /* If blnRequired = false then blank entries are allowed. */ if (isEmpty(str) && (blnRequired)) return false; if (!isEmpty(str)) { /* The following variable tells the rest of the function whether or not to verify that the address ends in a two-letter country or well-known TLD. 1 means check it, 0 means don't. */ var checkTLD=1; /* The following is the list of known TLDs that an e-mail address must end with. */ var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; /* The following pattern is used to check if the entered e-mail address fits the user@domain format. It also is used to separate the username from the domain. */ var emailPat=/^(.+)@(.+)$/; /* The following string represents the pattern for matching all special characters. We don't want to allow special characters in the address. These characters include ( ) < > @ , ; : \ " . [ ] */ var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; /* The following string represents the range of characters allowed in a username or domainname. It really states which chars aren't allowed.*/ var validChars="\[^\\s" + specialChars + "\]"; /* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters are allowed and which aren't; anything goes). E.g. "jiminy cricket"@disney.com is a legal e-mail address. */ var quotedUser="(\"[^\"]*\")"; /* The following pattern applies for domains that are IP addresses, rather than symbolic names. E.g. joe@[123.124.233.4] is a legal e-mail address. NOTE: The square brackets are required. */ var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; /* The following string represents an atom (basically a series of non-special characters.) */ var atom=validChars + '+'; /* The following string represents one word in the typical username. For example, in john.doe@somewhere.com, john and doe are words. Basically, a word is either an atom or quoted string. */ var word="(" + atom + "|" + quotedUser + ")"; // The following pattern describes the structure of the user var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); /* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */ var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); /* Finally, let's start trying to figure out if the supplied address is valid. */ /* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */ var matchArray=str.match(emailPat); if (matchArray==null) { /* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */ //alert("Email address seems incorrect (check @ and .'s)"); return false; } var user=matchArray[1]; var domain=matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127). for (i=0; i127) { //alert("The username contains invalid characters."); return false; } } for (i=0; i127) { //alert("The domain name contains invalid characters."); return false; } } // See if "user" is valid if (user.match(userPat)==null) { // user is not valid //alert("The username doesn't seem to be valid."); return false; } /* if the e-mail address is at an IP address (as opposed to a symbolic host name) make sure the IP address is valid. */ var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { // this is an IP address for (var i=1;i<=4;i++) { if (IPArray[i]>255) { //alert("Destination IP address is invalid!"); return false; } } return true; } // Domain is symbolic name. Check if it's valid. var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i 0) && (blnRequired)) { var strCheck = str; //string too long to be a valid date if (strCheck.length > 10) return false; var aDate; var strDate; var strMonth; var strYear; aDate = strCheck.split("/"); if (aDate.length != 3) return false; if (UKUS == "UK") { strDate = aDate[0]; strMonth = aDate[1] - 1; } else if (UKUS == "US") { strDate = aDate[1]; strMonth = aDate[0] - 1; } strYear = aDate[2]; if (strYear.length != 2 && strYear.length != 4) return false; if (strYear.length == 2) { if (bln4DigitYear) return false; if (strYear >= "70") strYear = "19" + strYear; else strYear = "20" + strYear; } var oDate = new Date(strYear,strMonth,strDate); if (isNaN(oDate)) return false; //a valid date could not be constructed if (strDate != oDate.getDate()) return false; //the date returned was different to the original date if (strMonth != oDate.getMonth()) return false; //the month returned was different to the original date if (strYear < 2000 && strYear > 1899) strYear = strYear.substr(2); if (strYear != oDate.getYear()) return false; //the month returned was different to the original date return true; } } function isTime(str,strFormat,blnRequired) { if (isEmpty(str) && (blnRequired)) return false; else if ((str.length > 0) && (blnRequired)) { var strCheck = str; if (strCheck.length > 12) return false; //string too long to be a valid time var aCheck = strCheck.split(":"); if (aCheck.length != 3) return false; strHour = aCheck[0]; strMinute = aCheck[1]; strSecond = aCheck[2]; if (strFormat == "24Hr") { var aCheck = strCheck.split(":"); strHour = aCheck[0]; strMinute = aCheck[1]; strSecond = aCheck[2]; if (strHour > 23 || isNaN(strHour)) return false; if (strMinute > 59 || isNaN(strMinute)) return false; if (strSecond > 59 || isNaN(strSecond)) return false; } if (strFormat == "12Hr") { var aCheck2 = strSecond.split(" "); if (aCheck2.length != 2) return false; strSecond = aCheck2[0]; strAMPM = aCheck2[1]; if (strHour > 12 || isNaN(strHour)) return false; if (strMinute > 59 || isNaN(strMinute)) return false; if (strSecond > 59 || isNaN(strSecond)) return false; if (strAMPM != "AM" && strAMPM != "PM") return false; } } return true; } function isDateTime(str,UKUS,strFormat,blnRequired,bln4DigitYear) { if (isEmpty(str) && (blnRequired)) return false; else if ((str.length > 0) && (blnRequired)) { aCheck = str.split(" "); if ((strFormat == "12Hr") && (aCheck.length != 3)) return false; if ((strFormat == "24Hr") && (aCheck.length != 2)) return false; if (!isDate(aCheck[0],blnRequired,UKUS,bln4DigitYear)) return false; var strTime; if(strFormat == "12Hr") strTime = aCheck[1] + " " + aCheck[2]; else if (strFormat == "24Hr") strTime = aCheck[1]; if (!isTime(strTime,strFormat,blnRequired)) return false; } return true; } function isLengthOK(str,min,max,blnRequired) { if (isEmpty(str) && (blnRequired)) return false; if(str.length < min || str.length > max && blnRequired) return false; else return true; } function isValueOK(str,min,max,blnRequired) { if (isEmpty(str) && (blnRequired)) return false; if (isNaN(str) && blnRequired) return false; if(str < min || str > max && blnRequired) return false; else return true; } function isUsernamePassword(str,blnRequired) { if (isEmpty(str) && (blnRequired)) return false; else if (!isLengthOK(str, 6, 16, true)) return false; else if (str.search(/[\W_]+/) > -1) return false; return true; } function isCreditCard(strNumber) { // Original from: http://www.sislands.com/jscript/week6/ccvalidation.htm // Modified by Tony Ruscoe (truscoe@sdlintl.com) // REMOVE ANY NON-NUMERIC CHARACTERS strNumber = strNumber.replace(/[^0-9]/gi, ""); // REJECT CC NUMBER IF EMPTY, SHORTER THAN 4 OR LONGER THAN 19 if (isEmpty(strNumber) || strNumber.length < 4 || strNumber.length > 19) { return false; } // THE LUHN FORUMLA / MODULUS 10 CHECK var sum = 0; var mul = 1; var lenNumber = strNumber.length; for (var i = 0; i < lenNumber; i++) { var digit = strNumber.substring(lenNumber - i - 1, lenNumber - i); var tproduct = parseInt(digit, 10) * mul; if (tproduct >= 10) sum += (tproduct % 10) + 1 else sum += tproduct; if (mul == 1) mul++; else mul--; } if ((sum % 10) == 0) return true; else return false; } function isExpiryDate(d) { // REGULAR EXPRESSION TO REMEMBER THE MONTH (EITHER 1 OR 2 DIGIT) // AND YEAR (EITHER 2 OR 4 DIGIT) INPUT AND KEEP THEM SEPARATE var re = /(\d{1,2})[ \-\/](\d{2,4})/; var arr = re.exec(d); var enteredMonth = parseInt(eval(RegExp.$1)); var enteredYear = parseInt(eval(RegExp.$2)); if (enteredYear < 100) { // IF A 2 DIGIT YEAR IS ENTERED if (enteredYear < 70) enteredYear += 2000; // IF LESS THAN 70 ASSUME 20xx else enteredYear += 1900; // ELSE ASSUME 19xx } var now = new Date(); var nowMonth = now.getMonth() + 1; var nowYear = now.getFullYear(); // IF ENTERED YEAR IS LARGER THAN TODAY'S YEAR, IT'S VALID if (enteredYear > nowYear) return true; // IF TODAY'S MONTH IS GREATER OR EQUAL TO ENTERED MONTH, IT'S VALID if (enteredYear == nowYear) { if (enteredMonth >= nowMonth) return true; } return false; } function openWindow(strURL){ var xPos = (screen.width - 400) / 2; var yPos = (screen.height - 300) / 2 - 20; window.open(strURL,"_blank","width=400,height=300,left="+xPos+",top="+yPos+";"); } function redrawWindow(intWidth, intHeight){ if (isEmpty(intWidth)) intWidth = 300; if (isEmpty(intHeight)) intHeight = 300; intWidth = (intWidth > screen.width) ? screen.width : intWidth; intHeight = (intHeight > screen.height-25) ? screen.height-25 : intHeight; intHeight = isXPSP2 ? parseInt(intHeight) + 20 : intHeight; var xPos = (screen.width - intWidth) / 2; var yPos = (screen.height - intHeight) / 2 - 25; xPos = (xPos < 0) ? 0 : xPos; yPos = (yPos < 0) ? 0 : yPos; self.moveTo(xPos, yPos); self.resizeTo(intWidth, intHeight); self.focus(); } function viewLicenseHistory(licenseID){ var xPos = (screen.width - 400) / 2; var yPos = (screen.height - 300) / 2 - 20; window.open("/?LicenseID="+licenseID+"&width=640&height=400","licenseHistory","width=400,height=300,left="+xPos+",top="+yPos+",scrollbars,resizable;"); } function viewPSADetails(PSAID){ var xPos = (screen.width - 400) / 2; var yPos = (screen.height - 300) / 2 - 20; window.open("/?PSAID="+PSAID+"&width=640&height=400","PSADetails","width=400,height=300,left="+xPos+",top="+yPos+",scrollbars,resizable;"); }