var OpenWin = null; var prompt = 'Please complete the indicated field.'; var prompt1 = 'The authorization is invalid. The job is being cancelled. Please check your information and try again.'; var prompt2 = 'You have not been authorized to use this service.'; var prompt3 = 'Your document will not be printed.'; function popUpPrinterDetails(strURL) { PosX = Math.round((screen.availWidth/12)) PosY = Math.round((screen.availHeight/12)) window.open(strURL, "PrinterDetails", "menubar=yes,resizable=yes,scrollbars=yes,location=yes,status=yes,toolbar=yes,height="+610+",width="+805+",top="+PosY+",left="+PosX) } function isBlank(str) { return (trim(str)=="") } function ltrim(str) { if (str!=null) return str.replace(/^\s+/,"") } function rtrim(str) { if (str!=null) return str.replace(/\s+$/,"") } function trim(str) { if (str!=null) { //str = replaceAccents(str) str = str.replace(/[!#%*&=+|?'"]/g,"") str = str.replace(/;/g,",") return rtrim(ltrim(str)) } else return "" } function bar(message) { window.status = message; return true; } function closeWin() { if (OpenWin != null) { OpenWin.close() OpenWin = null } } function popWin(strURL) { if (OpenWin != null) { closeWin() popWin(strURL) } else { PosX = 0 PosY = 0 OpenWin = window.open(strURL,"WebHelp","height="+600+",width="+600+",top="+PosY+",left="+PosX+",scrollbars=yes,resizable=yes") } } function popWinStatus(strURL, windowID) { PosX = 0; PosY = 0; window.open(strURL,windowID,"height="+360+",width="+500+",top="+PosY+",left="+PosX+",scrollbars=yes,resizable=yes") } function replaceAccents(str) { str = str.replace(/[�����]/g,"A") str = str.replace(/[�����]/g,"a") str = str.replace(/[����]/g,"E") str = str.replace(/[����]/g,"e") str = str.replace(/[����]/g,"I") str = str.replace(/[����]/g,"i") str = str.replace(/[�����]/g,"O") str = str.replace(/[�����]/g,"o") str = str.replace(/[����]/g,"U") str = str.replace(/[����]/g,"u") str = str.replace(/[�]/g,"Y") str = str.replace(/[��]/g,"y") str = str.replace(/[�]/g,"C") str = str.replace(/[�]/g,"c") str = str.replace(/[�]/g,"N") str = str.replace(/[�]/g,"n") return str } function MM_preloadImages() { //v3.0 var d=document; if(d.images) { if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i < a.length; i++) { if(a[i].indexOf("#")!=0) { d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; } } } } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) { if((x=MM_findObj(a[i]))!=null) { document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2]; } } } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i< a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v3.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); } if(!(x=d[n])&&d.all) x=d.all[n]; { for(i=0;!x&&i< d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i< d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x; } } function getParentElement(myObject) { var obj = null; if (myObject.parentNode) { obj = myObject.parentNode; } else if (myObject.parentElement) { obj = myObject.parentElement; } return obj; } function validate(f) { var REQUIRED=true var OPTIONAL=false var result=true clearHighlights(f.elements) for (var i=0; i < f.elements.length; i++) { var type = f.elements[i].type.toLowerCase(); if (type == 'hidden' || type == 'submit' || type == 'button' || type == 'reset') { continue; } var pNode = getParentElement(f.elements[i]); if (pNode && pNode.style) { if (pNode.style.display.toLowerCase() == 'none' || pNode.style.visibility.toLowerCase().indexOf('hid') != -1) { continue; } } switch(f.elements[i].name) { // This switch is for type=FILE objects. // Doing a trim on type=FILE will cause JavaScript to crash. case "attachmentURL": result=validateTextField(f.elements[i], REQUIRED) break case "attachmentURL2": var textUri = eval('f.attachmentURL'); if (textUri) { var displayAlert = false; if (f.elements[i].value != textUri.value) { if (textUri.value.length > 2 && textUri.value.charAt(1) == ":") { displayAlert = true; } else if (textUri.value.length > 1 && (textUri.value.charAt(0) == "\\" || textUri.value.charAt(0) == "/")) { displayAlert = true; } } if (displayAlert) { result = false; showInputFormatError(textUri, 'It appears that you are trying to print a document. Please use the "Browse" or "Choose" button to select the document.'); } } break; default: // Perform a trim and validate other objects. f.elements[i].value=trim(f.elements[i].value); switch(f.elements[i].name) { case "email": var req_optional = REQUIRED; if (f.emailAddressOptional != null) { req_optional = OPTIONAL; } result=validateEmail(f.elements[i], req_optional) break case "jobReleaseCodeGambit": var req_optional = REQUIRED; if (f.releaseCodeOptional != null) { req_optional = OPTIONAL; if (isBlank(f.elements[i].value)) { //f.elements[i].value = "1234567"; } } result=validateTextField(f.elements[i], req_optional) break case "jobReleaseCode": var req_optional = REQUIRED; if (f.releaseCodeOptional != null) { req_optional = OPTIONAL; if (isBlank(f.elements[i].value)) { // f.elements[i].value = "1234567"; } } result=validateTextField(f.elements[i],req_optional) break case "printerAlias": result=validateTextField(f.elements[i], REQUIRED, 'Currenty there are no printers available to print.') break case "userPassword": result=validateTextField(f.elements[i], REQUIRED) break case "coverComment": result=validateTextField(f.elements[i], REQUIRED) break case "userName": result=validateTextField(f.elements[i], REQUIRED) break case "password": result=validateTextField(f.elements[i], REQUIRED) break case "networkLogin": var req_optional = REQUIRED; if (f.networkLoginOptional != null) { req_optional = OPTIONAL; } result=validateTextField(f.elements[i],req_optional) break case "coverRecipient": result=validateTextField(f.elements[i], REQUIRED) break case "specialInstructions": // This form field must be the last on the printing_options page. result=validateTextField(f.elements[i], OPTIONAL) break case "WorksheetRange": // This field is tied into the previous element (radio button) in the list. result=validateRadioTextField(f.elements, i, REQUIRED) break case "PageRange": // This field is tied into the previous element (radio button) in the list. result=validateRadioTextField(f.elements, i, REQUIRED) break case "PageRange2": // This field is tied into the previous element (radio button) in the list. result=validatePageRangeTextField(f.elements, i, REQUIRED) break default: switch(f.elements[i].name) { case "Back": case "Cancel": case "OK": case "Submit": case "Submit2": case "docAPIfunc": case "details": case "printers": case "processing": case "printMode": case "docJobStage": case "next": case "holdPrintJob": case "options": result=true break default: //alert("validateForm.js : validate : Unrecognized field element : "+f.elements[i].name) result=true break } } } if (!result) { return false } } return true } function validatePageRangeTextField(elements,idx,required) { var element = elements[idx]; var prevElement = null; if (idx < elements.length && (idx-1) >= 0) { prevElement = elements[idx-1]; } if (prevElement != null && !isBlank(prevElement.value) && isBlank(element.value)) { if (required) { showInputFormatError(element, prompt) return false } } return true } function validateRadioTextField(elements,idx,required) { var element = elements[idx]; var prevElement = null; if (idx < elements.length && (idx-1) >= 0) { prevElement = elements[idx-1]; } if (prevElement != null && prevElement.checked && isBlank(element.value)) { if (required) { showInputFormatError(element, prompt) return false } } return true } function validateTextField(element,required, prompt2) { if (isBlank(element.value)) { if (required) { showInputFormatError(element, (!prompt2?prompt:prompt2)) return false } } return true } function validateEmail(element,required) { if (isBlank(element.value)) { if (required) { showInputFormatError(element, prompt) return false } } else if (!isEmail(element.value)) { showInputFormatError(element, 'Invalid Email Address') return false } return true } function showInputFormatError(element,message) { var highlightColor="#CCCC99" if (element && element.type != "hidden") { element.focus() } if (element && element.style) { element.style.backgroundColor=highlightColor } if(message && message.length > 0){ alert(message) } } function clearHighlights(elements) { var noHighlight="" // No londer needed. We just need to check for the style property. //if (navigator.appName!="Netscape") { for (var i=0;i< elements.length;i++) { if (elements[i].style) { elements[i].style.backgroundColor=noHighlight } } //} } function isEmail(str) { str=trim(str) /* 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 string represents at atom (basically a series of non-special characters.) */ var atom="("+validChars+"+"+")" // The following pattern describes the structure of the user var userPat=new RegExp("^"+atom+"(\\."+atom+")*$") // The following pattern describes the structure of the domain var domainPat=new RegExp("^"+atom+"(\\."+atom+")+$") /* Finally, let's start trying to figure out if the supplied address is valid. */ /* Begin with the course 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] // 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 } // See if "domain" is valid if (domain.match(domainPat)==null) { //alert("The domain name doesn't seem to be valid.") return false } /* domain name seems valid, but now make sure that it ends in a three-letter word (like com, edu, gov) or a two-letter word, representing country (uk, nl).*/ /* Now we need to break up the domain to get a count of how many atoms it consists of. */ var atomPat=new RegExp(atom,"g") var domArr=domain.match(atomPat) var len=domArr.length if (domArr[len-1].length<2) { // the address must end in a two letter or three letter word. //alert("The address must end in a three-letter domain, or two letter country.") return false } // If we've gotten this far, everything's valid! return true } function validateRequest(form) { if (checkIfProcessing()) { return false; } var result = validate(form); if (result) { displayProcessingMessage(form); return true; } else { return false; } } function checkIfProcessing() { // Determine if there is currently a transaction in progress. if (changeInProgress) { alert('Your print job is being processed. Please wait.'); return true; } return false; } function displayProcessingMessage(form) { // Display a 'Processing' message to the user. displayProcessingTimer++; var dots = ""; for (var i=0; i< displayProcessingTimer; i++) { if ((i%30) == 0) { dots = "."; } else { dots = dots + "."; } } displayProcessingForm = form if (!changeInProgress) { changeInProgress = true; } if (form.processing) { form.processing.value = 'Processing your request...' + dots; displayProcessingTimerId = setTimeout("displayProcessingMessage(displayProcessingForm)", 100); } } function getParameter(parameterName, location) { var lletter, fletter; var querystring, parameterValue, rSpace; if (location) { querystring = location; } else { querystring = document.location.search; } parameterValue = ""; if (querystring.length > 1) { querystring = querystring.substr(1); // remove "?" fletter = querystring.indexOf(parameterName); if (fletter != -1) { // move past parameterName and = fletter += parameterName.length + 1; lletter = querystring.indexOf('&', fletter); if (lletter == -1) { lletter = querystring.length; } parameterValue = querystring.substring(fletter, lletter); rSpace = new RegExp("\\W+", "g"); parameterValue = parameterValue.replace(rSpace, " "); } } return parameterValue; } var displayProcessingForm; var displayProcessingTimer = 0; var displayProcessingTimerId; var changeInProgress = false; var oldWindowError = null; function aaaAuthorizeIFrame() { oldWindowError = window.onerror; window.onerror = supressJSError; try { aaaAuthorizeIFrame2(); } catch (e) { //alert('Encountered exception : ' + e.description); } window.onerror = oldWindowError; } function supressJSError() { if (oldWindowError != null) { window.onerror = oldWindowError; } return false; } function aaaAuthorizeIFrame2() { var locn = null; try { locn = frames.aaaFrame.location; } catch (e) { try { locn = getEl('aaaFrame').contentDocument.location; } catch (e2) { } } var queryString = locn.search; var apiFunc = getParameter('apiFunc', queryString); if (apiFunc != 'AuthorizeJobResponse') return; var approveUse = getParameter('approveUse', queryString); if (approveUse) { var jobReleased = false; approveUse = approveUse.toLowerCase(); var jobReferenceID = getParameter('jobReferenceID', queryString); if (jobReferenceID && jobReferenceID != '') { var authToken = getParameter('authorizeToken', queryString); var validToken = true; var authToken1 = 'null';; if (authToken != null && authToken != authToken1) { validToken = false; } if (approveUse == 'true') { if (validToken) { var tokenId = getParameter('tokenId', queryString); //if (tokenId == null) tokenId = ''; var tokenPagesUsed = getParameter('tokenPagesUsed', queryString); //if (tokenPagesUsed == null) tokenPagesUsed = ''; var tokenPagesTotal = getParameter('tokenPagesTotal', queryString); //if (tokenPagesTotal == null) tokenPagesTotal = ''; // The authorization was approved. // Relase the print job. var jobRel = getParameter('jobReleased', queryString); if (jobRel) { jobRel = jobRel.toLowerCase(); if (jobRel == 'true') { document.printForm.docAPIfunc.value = 'DocStatus'; } } document.printForm.supressUserEmail.value=getParameter('supressUserEmail', queryString); document.printForm.clientUID.value=getParameter('clientUID', queryString); document.printForm.sessionMetaData.value=getParameter('sessionMetaData', queryString); document.printForm.serviceUID.value=getParameter('serviceUID', queryString); document.printForm.approveUse.value=getParameter('approveUse', queryString); document.printForm.submit(); jobReleased = true; } else { alert(prompt1); // The authorization has failed. // Delete the print job. displayUserMessage(queryString); } } else if (approveUse == 'false') { // The authorization has failed. // Delete the print job. displayUserMessage(queryString); } var parentDiv = getEl('aaa'); if (!jobReleased && parentDiv) { var onComplete = function() { // Now that the IFrame has reloaded with valid parameters, we can now hide it from the user and // display the original page count information. parentDiv.hide(); }; parentDiv.setHeight(0, true, 1, onComplete); // Animate the DIV closing. } } } } function displayUserMessage(queryString) { var usrMsg = getParameter('userMessage', queryString); var userMessage = getEl('userMessage'); if (userMessage) { // Display the message in the page if (usrMsg == null) { // Provide a default message usrMsg = prompt2 + '

' + prompt3; } userMessage.update(usrMsg); userMessage.enableDisplayMode(); userMessage.show(); } else { // Display the message in an alert as there is no where to display the message in the page. if (usrMsg == null) { // Provide a default message usrMsg = prompt2 + '\r\n' + prompt3; } alert(usrMsg); } }