function checkVals() { if (document.all.pSearchvalue.value == '') { alert('You must enter a search keyword in order to perform a search.') try { searchform.elements.pSearchvalue.focus(); } catch(e) { } return false; } return true; } function openFas(pBook, pPage) { myWin = window.open("/pls/portal/url/page/AskAFIPDev/AskAFIP_Fascicle_Homepage/AskAFIP_Fascicle_Display?pAction=PAGE&pBook="+pBook+"&pPage="+pPage+"","mywin","left=20,top=20,width=700,height=600,toolbar=1,,resizable=1,scrollbars=1"); } function showTeaser() { alert('You must be a subscriber to view this item. For more information, click the "Subscriptions" button on the main toolbar.'); } function changeFolder(ctl) { if (document.all.lstFolders.value != "-1") { if (isItemSelected()==false) { document.all.btnAdd.disabled=true; } else {document.all.btnAdd.disabled=false; } } else { document.all.btnAdd.disabled=true; } } function checkCheckbox(ctl) { if (document.all.lstFolders.value != "-1") { if (ctl.checked) { document.all.btnAdd.disabled=false; } else { if (isItemSelected()==false) { document.all.btnAdd.disabled=true; } else {document.all.btnAdd.disabled=false; } } } else { document.all.btnAdd.disabled=true; } } function isItemSelected() { for (i=0; i < document.mainform.elements.length; i++) { if (document.mainform.elements[i].name=="chkItem") { if (document.mainform.elements[i].checked) { return true } } } return false; } // Validate search criteria selections for advanced search function checkEntries() { if (IsNumeric(document.all.pItemsPerPage.value) == false) { alert('"Items Per Page" appears to contain a non-numeric entry. Please change your entry in this field, then try again.'); document.portletform.elements.pSearchkeyword.focus(); return false; } if (eval(document.all.pItemsPerPage.value) < 0) { document.all.pItemsPerPage.value = 20; } if (document.portletform.elements.pSearchkeyword.value == '' && document.portletform.elements.pSpecialty.selectedIndex == "" && document.portletform.elements.pDiseaseCat.selectedIndex == "" && document.portletform.elements.pDocCategory.selectedIndex == "") { alert("The keyword field cannot be left blank without filters. Please enter a search keyword or choose a filter, then try again."); document.portletform.elements.pSearchkeyword.focus(); return false; } if( !document.portletform.pChkLib.checked && !document.portletform.pChkFas.checked && !document.portletform.pChkDCR.checked) { alert( "You must select at least one repository" ); return false; } return true; } // Validate selection of library categories. function validateLibCats() { if (document.portletform.pChkLib.checked){ document.portletform.pDocCategory.disabled = false; document.portletform.pDocCategory.style.background='WHITE'; } else{ document.portletform.pDocCategory.disabled = true; document.portletform.pDocCategory.style.background='#DCDCDC'; } } // Validate DCR selections. function checkDCR() { if (document.portletform.pChkDCR.checked) { document.portletform.pSpecialty.disabled = false; document.portletform.pSpecialty.style.background= 'WHITE'; document.portletform.pDiseaseCat.disabled = false; document.portletform.pDiseaseCat.style.background= 'WHITE'; document.portletform.pTemplate.disabled = false; document.portletform.pTemplate.style.background= 'WHITE'; } else { document.portletform.pSpecialty.disabled = true; document.portletform.pSpecialty.style.background='#DCDCDC'; document.portletform.pDiseaseCat.disabled = true; document.portletform.pDiseaseCat.style.background='#DCDCDC'; document.portletform.pTemplate.disabled = true; document.portletform.pTemplate.style.background='#DCDCDC'; } } function checkSearchVals(){ //alert(document.searchform.pSearchvalue.value); if (document.searchform.pSearchvalue.value =='Enter Search Term') { document.searchform.pSearchvalue.value = ''; } //searchform.elements.pSearchvalue.focus(); } function doSearch(){ if (document.all.pSearchvalue.value == '') { alert('You must enter a search keyword in order to perform a search.'); } document.searchform.pSearchkeyword.value=document.searchform.pSearchvalue.value; document.searchform.submit(); } function search() {; document.searchform.elements.pSearchkeyword.value=document.all.pSearchvalue.value; document.searchform.submit() } // Javascript prompt to get saved folder name from search code. function promptNewFolder() { var reply = prompt("Please enter the new folder name:", "") if (reply != null && reply != '') { document.mainform.elements.pFolderName.value=reply; document.mainform.elements.pAction.value='CREATEITEMFOLDER'; document.mainform.submit(); } else { return; } } // Prompt for name of saved search. function promptSaveSearch() { var reply = prompt("Please enter a name for this search:", "") if (reply != null && reply != '') { document.mainform.elements.pSearchName.value=reply; if (document.mainform.elements.pSearchName.value.length > 75) { alert('The search name may not exceed 75 characters. Please try again.') promptSaveSearch(); } else { document.mainform.elements.pAction.value='SAVESEARCH'; document.mainform.submit(); } } else { return; } } function openSurvey() { window.open("http://FreeOnlineSurveys.com/rendersurvey.asp?id=125737") } //This function checks to see if users browser has cookies enabled function cookie_enabled() { var is_enabled = false; if (typeof document.cookie == "string"){ if (document.cookie.length==0) { document.cookie = "test"; is_enabled = document.cookie == "test"; document.cookie = " "; } else { is_enabled = true; } } return is_enabled; } function OpenWin(jurl) { openLink(jurl); } function openWin(jurl) {; w=690; h=550; window.open(jurl,"awindow","width="+w+",height="+h+",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no"); } //this function will open a new window displaying the page whose url is passed in function openLink(jurl){ if(navigator.javaEnabled()==true){ if (self.innerHeight) // all except Explorer { w = self.innerWidth; h = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode { w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } else if (document.body) // other Explorers { w = document.body.clientWidth; h = document.body.clientHeight; } h= h *.85; w= w *.85; } else { w= 600; h= 450; } window.open(jurl,"somewindowname","width="+h+",height="+w+",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no"); } //used to add commas to dollar ammount fields function addCommas(nStr) { nStr += ''; x = nStr.split("."); x1 = x[0]; x2 = x.length > 1 ? "." + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, "$1" + "," + "$2"); } return x1 + x2; } //this function will truncate any characters beyon the length specified in the jlength param //it is called mainly to ensure that data entered in a text area from input will fit in a column in the database function Trim(jfield,jlength) { var maxchars = jlength; // Change number to maximum characters. if (jfield.value.length > maxchars) { var jdif=jfield.value.length-maxchars; alert("The maximum length of an entry into this field is "+maxchars+" characters. You entered "+jfield.value.length +" so "+jdif+" characters have been removed."); jfield.value = jfield.value.substring(0,maxchars-10); } } //this function will open a new window pointing to a page for a user to select from a list of all users function selUsers(pReturnControl, pMultiSelect, pReturnFunc) { var vURL; vURL = "/pls/askafip/pc_user_select?pReturnElemName="+pReturnControl.name+"&pUserStr="+pReturnControl.value+"&pMultiSelect="+pMultiSelect+"&pReturnFunc="+pReturnFunc; win = window.open(vURL,"userselwin","left=20,top=20,width=300,height=500,left=400,toolbar=1,resizable=0,toolbar=0") } var j_SaveNeeded = false; //this function simply clears the from of any new or edited info function cancelChanges () { document.mainform.reset(); j_saveNeeded = false; } //this function simply submits the navform which is used primarly for navigation via the menu bar and pg_askafip_home //the main mvc package for the application function menuPost(option) { if( cookie_enabled() ){ document.navform.elements.pAction.value=option; document.navform.submit(); } else{ alert( "Your browser is not accepting Cookies. To use this website, your browser must accept cookies" ); } } //used for navigation through the registration or profile screens function UserControlPost(option) { document.usercontrolform.elements.pAction.value=option; document.usercontrolform.submit(); } //used for navigation within a certain portlet function portletPost(option) { document.portletform.elements.pAction.value=option; document.portletform.submit(); } //this function simply submits the mainform which is used primarly for navigation within and between portlets and pg_askafip_home //the main mvc package for the application function mainformPost(option) { document.mainform.elements.pAction.value=option; document.mainform.submit(); } //opens a selected document from search in a new window function openDoc(pContentItemID) { thiswin = window.open(URLencode('docs/'+pContentItemID)); } //encodes a text string to be used as a url ie spaces are replacye with placeholder chars function URLencode(sStr) { return escape(sStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27'); } //returnss the value that was encoded using URLencode function URLDecode(sStr) { var HEXCHARS = "0123456789ABCDEFabcdef"; var encoded = sStr; var plaintext = ""; var i = 0; while (i < encoded.length) { var ch = encoded.charAt(i); if (ch == "+") { plaintext += " "; i++; } else if (ch == "%") { if (i < (encoded.length-2) && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) { plaintext += unescape( encoded.substr(i,3) ); i += 3; } else { plaintext += "%[ERROR]"; i++; } } else { plaintext += ch; i++; } } // while return plaintext; }; //return true if all chars are numbers or a . or - function IsNumeric(sText) { var ValidChars = "0123456789.-"; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1){ IsNumber = false; } } return IsNumber; } //return true if all chars ar text ie not numbers function IsAlpha(sText) { var ValidChars = "abcdefghijklmnopqrstuvwxyz!@#$%&()-?.,;;"; var IsAlpha=true; var Char; for (i = 0; i < sText.length && IsAlpha == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsAlpha = false; } } return IsAlpha; } //return true if the value contains at least one number character function ContainsNumber(sText) { var ValidChars = "0123456789"; var ContainsNum=false; var Char; for (i = 0; i < sText.length && ContainsNum != true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) != -1) { ContainsNum = true; } } return ContainsNum; } //return true if sText contains a special character function ContainsSpecial(sText) { var ValidChars = "!@#$%^&*()"; var ContainsSpec=false; var Char; for (i = 0; i < sText.length && ContainsSpec != true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) != -1) { ContainsSpec = true; } } return ContainsSpec; } //this function is called in the onBlur triggers of any field we want to remove whitespace from //in the future we may add extra validations to this function function doBlur(me, maxlen) { remove_XS_whitespace(me) } //this function is called in the onBlur triggers of any field we want to remove whitespace from function remove_XS_whitespace(item) { var tmp = ""; var item_length = item.value.length; var item_length_minus_1 = item.value.length - 1; for (index = 0; index < item_length; index++) { if (item.value.charAt(index) != ' ') { tmp += item.value.charAt(index); } else { if (tmp.length > 0) { if (item.value.charAt(index+1) != ' ' & index != item_length_minus_1) { tmp += item.value.charAt(index); } } } } item.value = tmp; } //return true if email a contains an @ and doesnot contain certain other chars and has a . after the @ function validEmail(email) { var altInvalidChars = '()<>@,;:\".[]'; invalidChars = " /:,:" if(email == "") { return false } for (i=0; i -1) { return false } } atPos = email.indexOf("@", 1) if (atPos == -1) { return false } if (email.indexOf("@",atPos+1) > -1) { return false } periodPos = email.indexOf(".",atPos) if (periodPos == -1) { return false } if (periodPos+3 > email.length) { return false } return true } //return true if url seems valid function ValidateUrl(url) { var is_http = url.indexOf("http://"); var is_https = url.indexOf("https://"); var is_ftp = url.indexOf("ftp://"); var is_dot = url.indexOf("."); if (is_dot!=-1) { if ((is_http==-1) && (is_https==-1) && (is_ftp==-1)) { return false; } else { return true; } } } // SSL enabled checker function isSSLEnabled() { return true; } function replaceText(el, text) { if (el != null) { clearText(el); var newNode = document.createTextNode(text); el.appendChild(newNode); } } function clearText(el) { if (el != null) { if (el.childNodes) { for (var i = 0; i < el.childNodes.length; i++) { var childNode = el.childNodes[i]; el.removeChild(childNode); } } } } function getText(el) { var text = ""; if (el != null) { if (el.childNodes) { for (var i = 0; i < el.childNodes.length; i++) { var childNode = el.childNodes[i]; if (childNode.nodeValue != null) { text = text + childNode.nodeValue; } } } } return text; } function makeRequest(url) { if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE http_request = new ActiveXObject("Microsoft.XMLHTTP"); } http_request.onreadystatechange = alertContents; http_request.open('GET', url, true); http_request.send(null); } // pass the element ID and error message to display alert then focus on element function displayElementErrMsg(pElemId, pMsg) { var thisObj = document.getElementById(pElemId); alert( pMsg ); thisObj.selected; thisObj.focus(); } // return true if something entered function requiredEntryTest(val){ if(val==null||val.length==0||val==""){return false;} return true; } // return true if val >= minVal function minValueTest(val, minVal){ if(eval(val - minVal)<0){return false;} return true; } // return true if val <= maxVal function maxValueTest(val, maxVal){ if(eval(val - maxVal)>0){return false;} return true; } function numberTest(val){ if(val==null){return true;} if (val.length==0){return true;} var retValid=true; var DecimalFound = false; for (i = 0; i < val.length; i++) { var ch = val.charAt(i); if (i == 0 && (ch == "+" || ch == "-")) { // allow PLUS or MINUS as first character continue; } if (ch == "." && !DecimalFound) { // allow single decimal DecimalFound = true; continue; } if (ch < "0" || ch > "9") { retValid=false; break; } } return retValid; } function headerTest(val){ var msg=""; if(!requiredEntryTest(val)){return msg;} //nothing to test var retValid=true; var DecimalFound = false; for (i = 0; i < val.length; i++) { var ch = val.charAt(i); if (i == 0 && ch == "." ) { msg="First character cannot be decimal."; break; } if (ch == ".") { // if (DecimalFound){ msg="Consecutive decimals not allowed."; break; } else { DecimalFound=true; continue; } } else if (ch < "0" || ch > "9") { msg="Invalid character."; break; } else { DecimalFound=false; } } return msg; } // maximum number of digits allowed to the right of the decimal function numberDecimalTest(val, dec){ var len=val.length; var pos=val.indexOf(".")+1; if (pos==0){return true;} // no decimal means nothing to test if (dec==0 && pos!=-1){return false;} // no decimal allowed if ((len-pos)> dec){ return false; // too many decimal } return true; } // Test for integer function integerTest(val){ return numberDecimalTest(val, 0); }