function getExternalUrl(extUrl) { openWin("/italian/etc/externalUrlPrompt.jsp?u="+escape(extUrl),"externalUrl", 324, 399, false); } function getStage(menuObj) { if (menuObj.selectedIndex>0) { location.href=pathToAppRoot+"content/" +menuObj.options[menuObj.selectedIndex].value } } function isValidSearchForm(formObj) { if (formObj.elements["query"].value.length==0 || formObj.elements["query"].value=="Search") { formObj.elements["query"].focus() alert("Please enter a search keyword or keywords before performing a search.") formObj.elements["query"].focus() return false } return true } function isValidSearchForm(formObj) { if (formObj.elements["query"].value.length==0 || formObj.elements["query"].value=="Search") { formObj.elements["query"].focus() alert("Please enter a search keyword or keywords before performing a search.") formObj.elements["query"].focus() return false } return true } // Check whether string s is empty. function isEmpty(s) { return ((s == null) || (s.length == 0)) } // Returns true if string s is empty or // whitespace characters only. function isWhitespace (s) { // Is s empty? return (isEmpty(s) || reWhitespace.test(s)); } // Notify user that required field theField is empty. // String s describes expected contents of theField.value. // Put focus in theField and return false. function warnEmpty (theField, s) { theField.focus(); alert(mPrefix + s + mSuffix); return false; } // Notify user that contents of field theField are invalid. // String s describes expected contents of theField.value. // Put select theField, pu focus in it, and return false. function warnInvalid (theField, s) { theField.focus(); theField.select(); alert(s); return false; } function warnMustFill (theField, s) { theField.focus(); alert(s); return false; } /* FUNCTIONS TO INTERACTIVELY CHECK VARIOUS FIELDS. */ // checkString (TEXTFIELD theField, STRING s, [, BOOLEAN emptyOK==false]) // // Check that string theField.value is not all whitespace. // // For explanation of optional argument emptyOK, // see comments of function isInteger. function checkString (theField, s, emptyOK) { // Next line is needed on NN3 to avoid "undefined is not a number" error // in equality comparison below. if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (isWhitespace(theField.value)) return warnEmpty (theField, s); else return true; } // ********************** Email field testing *************** // isEmail (STRING s [, BOOLEAN emptyOK]) // // Email address must be of form a@b.c -- in other words: // * there must be at least one character before the @ // * there must be at least one character before and after the . // * the characters @ and . are both required function isEmail (s) { if (isEmpty(s)) if (isEmail.arguments.length == 1) return defaultEmptyOK; else return (isEmail.arguments[1] == true); else { return reEmail.test(s) } } // isAlphanumeric (STRING s [, BOOLEAN emptyOK]) // // Returns true if string s is English letters // (A .. Z, a..z) and numbers only. // // For explanation of optional argument emptyOK, // see comments of function isInteger. // // NOTE: Need i18n version to support European characters. // This could be tricky due to different character // sets and orderings for various languages and platforms. function isAlphanumeric (s) { var i; if (isEmpty(s)) if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK; else return (isAlphanumeric.arguments[1] == true); else { return reAlphanumeric.test(s) } } // isInteger (STRING s [, BOOLEAN emptyOK]) // // Returns true if all characters in string s are numbers. // // Accepts non-signed integers only. Does not accept floating // point, exponential notation, etc. // // We don't use parseInt because that would accept a string // with trailing non-numeric characters. // // By default, returns defaultEmptyOK if s is empty. // There is an optional second argument called emptyOK. // emptyOK is used to override for a single function call // the default behavior which is specified globally by // defaultEmptyOK. // If emptyOK is false (or any value other than true), // the function will return false if s is empty. // If emptyOK is true, the function will return true if s is empty. // // EXAMPLE FUNCTION CALL: RESULT: // isInteger ("5") true // isInteger ("") defaultEmptyOK // isInteger ("-5") false // isInteger ("", true) true // isInteger ("", false) false // isInteger ("5", false) true function isInteger (s) { var i; if (isEmpty(s)) if (isInteger.arguments.length == 1) return defaultEmptyOK; else return (isInteger.arguments[1] == true); return reInteger.test(s) } // isAlphabetic (STRING s [, BOOLEAN emptyOK]) // // Returns true if string s is English letters // (A .. Z, a .. z, 0 .. 9) only. // function isAlphabetic (s) { var i; if (isEmpty(s)) if (isAlphabetic.arguments.length == 1) return defaultEmptyOK; else return (isAlphabetic.arguments[1] == true); else { return reAlphabetic.test(s) } } // checkEmail (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid Email. // function checkEmail (theField, message, emptyOK) { if (checkEmail.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isEmail(theField.value, false)) return warnInvalid (theField, message); else return true; } // check alphanumeric (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid alphanumeric string. // function checkAlphanumeric (theField, message, emptyOK) { if (checkAlphanumeric.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isAlphanumeric(theField.value)) return warnInvalid (theField, message); else return true; } // checkAlphabetic (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid alphabetic string. // function checkAlphabetic (theField, message, emptyOK) { if (checkAlphabetic.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isAlphabetic(theField.value)) return warnInvalid (theField, message); else return true; } // checkNumber (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid number string. // function checkNumber (theField, message, emptyOK) { if (checkNumber.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isInteger(theField.value)) return warnInvalid (theField, message); else return true; } // checkRequiredSelect (SelectField theField) // // Check that option theField.value is filled by user // function checkRequiredSelect(theField, message) { if (theField.options[theField.options.selectedIndex].value == "$$$$$") return warnMustFill(theField, message); else return true; } function checkRequiredRadio(theField, message) { if (!theField.checked) return warnMustFill(theField, message); else return true; } // check form element values before submitting // if all fields look good return true so that the form can be submitted function CheckForm(theForm, fes) { // first check that all "required" fields are filled for (i = 0; i < theForm.elements.length; i++) { if (typeof(fes[theForm.elements[i].name]) == "undefined") { continue; } if (fes[theForm.elements[i].name].required == 1) { if (fes[theForm.elements[i].name].type == "text") { // if (!checkString(theForm.elements[i], // theForm.elements[i].name, false)) if (!checkString(theForm.elements[i], fes[theForm.elements[i].name].desc, false)) return false; } else if (fes[theForm.elements[i].name].type == "select") { if (!checkRequiredSelect(theForm.elements[i], iSelectPrefix + fes[theForm.elements[i].name].desc+iSelectSuffix)) return false; } else if (fes[theForm.elements[i].name].type == "radio") { var radiochecked = theForm.elements[i].checked; var radioname = theForm.elements[i].name; var j = i+1; while (j < theForm.elements.length) { if (theForm.elements[j].type == "radio" && theForm.elements[j].name == radioname) { if (!radiochecked) radiochecked = theForm.elements[j].checked; j++; } else break; // reached end of radio button sequence } if (!radiochecked) return warnMustFill(theForm.elements[i], iRadioPrefix + fes[theForm.elements[i].name].desc+iRadioSuffix); i = j - 1; } } } /* var phone = document.contact.phone.value; //alert(document.contact.phone.value); if(phone.length != 10) { alert("Immetti un numero di telefono standard a 10 cifre") return false; } else { return true; } */ // now check the contents of all fields that require tests for (i = 0; i < theForm.elements.length; i++) { if (typeof(fes[theForm.elements[i].name]) == "undefined") { continue; } if (fes[theForm.elements[i].name].ctype == "Alphabetic") { if (!checkAlphabetic(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iAlphabeticSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "Alphanumeric") { if (!checkAlphanumeric(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iAlphanumericSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "Number") { if (!checkNumber(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iNumberSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "Email") { if (!checkEmail(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iEmailSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "None") { } } //theForm.submitTime.value=new Date();; return true; } function formelement(req, typ, contentt, flddesc) { this.required = req; // is this a required item? this.ctype = contentt; // is content numeric, alphabetic etc. // applies only to text item fields // possible values are "Alphabetic", "Number", // "Alphanumeric", "Email", "None" this.type = typ; // what is the type of this item // "text", "select", "radio" this.desc = flddesc; // descriptive string for item return this; } function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter else countfield.value = maxlimit - field.value.length; } function textChecker(field, countfield, maxlimit) { if (field.value.length != maxlimit) // if too short...extend it! { field.value = field.value.substring(0, maxlimit); alert("Numero di telefono non valido. Immetti di nuovo un numero di telefono standard a 10 cifre SENZA TRATTINI"); } // otherwise, update 'characters left' counter else countfield.value = maxlimit - field.value.length; } // Check whether string s is empty. function isEmpty(s) { return ((s == null) || (s.length == 0)) } // Returns true if string s is empty or // whitespace characters only. function isWhitespace (s) { // Is s empty? return (isEmpty(s) || reWhitespace.test(s)); } // Notify user that required field theField is empty. // String s describes expected contents of theField.value. // Put focus in theField and return false. function warnEmpty (theField, s) { theField.focus(); alert(mPrefix + s + mSuffix); return false; } // Notify user that contents of field theField are invalid. // String s describes expected contents of theField.value. // Put select theField, pu focus in it, and return false. function warnInvalid (theField, s) { theField.focus(); theField.select(); alert(s); return false; } function warnMustFill (theField, s) { theField.focus(); alert(s); return false; } /* FUNCTIONS TO INTERACTIVELY CHECK VARIOUS FIELDS. */ // checkString (TEXTFIELD theField, STRING s, [, BOOLEAN emptyOK==false]) // // Check that string theField.value is not all whitespace. // // For explanation of optional argument emptyOK, // see comments of function isInteger. function checkString (theField, s, emptyOK) { // Next line is needed on NN3 to avoid "undefined is not a number" error // in equality comparison below. if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (isWhitespace(theField.value)) return warnEmpty (theField, s); else return true; } // ********************** Email field testing *************** // isEmail (STRING s [, BOOLEAN emptyOK]) // // Email address must be of form a@b.c -- in other words: // * there must be at least one character before the @ // * there must be at least one character before and after the . // * the characters @ and . are both required function isEmail (s) { if (isEmpty(s)) if (isEmail.arguments.length == 1) return defaultEmptyOK; else return (isEmail.arguments[1] == true); else { return reEmail.test(s) } } // isAlphanumeric (STRING s [, BOOLEAN emptyOK]) // // Returns true if string s is English letters // (A .. Z, a..z) and numbers only. // // For explanation of optional argument emptyOK, // see comments of function isInteger. // // NOTE: Need i18n version to support European characters. // This could be tricky due to different character // sets and orderings for various languages and platforms. function isAlphanumeric (s) { var i; if (isEmpty(s)) if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK; else return (isAlphanumeric.arguments[1] == true); else { return reAlphanumeric.test(s) } } // isInteger (STRING s [, BOOLEAN emptyOK]) // // Returns true if all characters in string s are numbers. // // Accepts non-signed integers only. Does not accept floating // point, exponential notation, etc. // // We don't use parseInt because that would accept a string // with trailing non-numeric characters. // // By default, returns defaultEmptyOK if s is empty. // There is an optional second argument called emptyOK. // emptyOK is used to override for a single function call // the default behavior which is specified globally by // defaultEmptyOK. // If emptyOK is false (or any value other than true), // the function will return false if s is empty. // If emptyOK is true, the function will return true if s is empty. // // EXAMPLE FUNCTION CALL: RESULT: // isInteger ("5") true // isInteger ("") defaultEmptyOK // isInteger ("-5") false // isInteger ("", true) true // isInteger ("", false) false // isInteger ("5", false) true function isInteger (s) { var i; if (isEmpty(s)) if (isInteger.arguments.length == 1) return defaultEmptyOK; else return (isInteger.arguments[1] == true); return reInteger.test(s) } // isAlphabetic (STRING s [, BOOLEAN emptyOK]) // // Returns true if string s is English letters // (A .. Z, a .. z, 0 .. 9) only. // function isAlphabetic (s) { var i; if (isEmpty(s)) if (isAlphabetic.arguments.length == 1) return defaultEmptyOK; else return (isAlphabetic.arguments[1] == true); else { return reAlphabetic.test(s) } } function validateEmail(emailAddress) { var match = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/.test(emailAddress); return match; } // checkEmail (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid Email. // function checkEmail (theField, message, emptyOK) { if (checkEmail.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isEmail(theField.value, false)) return warnInvalid (theField, message); else if(!validateEmail(theField.value)) alert(message); else return true; } // check alphanumeric (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid alphanumeric string. // function checkAlphanumeric (theField, message, emptyOK) { if (checkAlphanumeric.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isAlphanumeric(theField.value)) return warnInvalid (theField, message); else return true; } // checkAlphabetic (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid alphabetic string. // function checkAlphabetic (theField, message, emptyOK) { if (checkAlphabetic.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isAlphabetic(theField.value)) return warnInvalid (theField, message); else return true; } // checkNumber (TEXTFIELD theField [, BOOLEAN emptyOK==false]) // // Check that string theField.value is a valid number string. // function checkNumber (theField, message, emptyOK) { if (checkNumber.arguments.length == 2) emptyOK = defaultEmptyOK; if ((emptyOK == true) && (isEmpty(theField.value))) return true; else if (!isInteger(theField.value)) return warnInvalid (theField, message); else return true; } // checkRequiredSelect (SelectField theField) // // Check that option theField.value is filled by user // function checkRequiredSelect(theField, message) { if (theField.options[theField.options.selectedIndex].value == "$$$$$") return warnMustFill(theField, message); else return true; } function checkRequiredRadio(theField, message) { if (!theField.checked) return warnMustFill(theField, message); else return true; } // check form element values before submitting // if all fields look good return true so that the form can be submitted function CheckForm(theForm, fes) { // first check that all "required" fields are filled for (i = 0; i < theForm.elements.length; i++) { if (typeof(fes[theForm.elements[i].name]) == "undefined") { continue; } if (fes[theForm.elements[i].name].required == 1) { if (fes[theForm.elements[i].name].type == "text") { // if (!checkString(theForm.elements[i], // theForm.elements[i].name, false)) if (!checkString(theForm.elements[i], fes[theForm.elements[i].name].desc, false)) return false; } else if (fes[theForm.elements[i].name].type == "select") { if (!checkRequiredSelect(theForm.elements[i], iSelectPrefix + fes[theForm.elements[i].name].desc+iSelectSuffix)) return false; } else if (fes[theForm.elements[i].name].type == "radio") { var radiochecked = theForm.elements[i].checked; var radioname = theForm.elements[i].name; var j = i+1; while (j < theForm.elements.length) { if (theForm.elements[j].type == "radio" && theForm.elements[j].name == radioname) { if (!radiochecked) radiochecked = theForm.elements[j].checked; j++; } else break; // reached end of radio button sequence } if (!radiochecked) return warnMustFill(theForm.elements[i], iRadioPrefix + fes[theForm.elements[i].name].desc+iRadioSuffix); i = j - 1; } } } /* var phone = document.contact.phone.value; //alert(document.contact.phone.value); if(phone.length != 10) { alert("Immetti un numero di telefono standard a 10 cifre") return false; } else { return true; } */ // now check the contents of all fields that require tests for (i = 0; i < theForm.elements.length; i++) { if (typeof(fes[theForm.elements[i].name]) == "undefined") { continue; } if (fes[theForm.elements[i].name].ctype == "Alphabetic") { if (!checkAlphabetic(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iAlphabeticSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "Alphanumeric") { if (!checkAlphanumeric(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iAlphanumericSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "Number") { if (!checkNumber(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iNumberSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "e-Mail") { if (!checkEmail(theForm.elements[i], iPrefix + fes[theForm.elements[i].name].desc + iEmailSuffix, (fes[theForm.elements[i].name].required == 1) ? false : true)) return false; } else if (fes[theForm.elements[i].name].ctype == "None") { } } //theForm.submitTime.value=new Date();; return true; } function formelement(req, typ, contentt, flddesc) { this.required = req; // is this a required item? this.ctype = contentt; // is content numeric, alphabetic etc. // applies only to text item fields // possible values are "Alphabetic", "Number", // "Alphanumeric", "Email", "None" this.type = typ; // what is the type of this item // "text", "select", "radio" this.desc = flddesc; // descriptive string for item return this; } function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter else countfield.value = maxlimit - field.value.length; } function textChecker(field, countfield, maxlimit) { if (field.value.length != maxlimit) // if too short...extend it! { field.value = field.value.substring(0, maxlimit); alert("Numero di telefono non valido. Immetti di nuovo un numero di telefono standard a 10 cifre SENZA TRATTINI"); } // otherwise, update 'characters left' counter else countfield.value = maxlimit - field.value.length; } function init() { } //function glossary(term) { // openWin("/italian/etc/glossaryPopup.jsp?m="+mode+"&term="+escape(term),"glossary", 324, 399, false) //} function glossary(term) { openWin("/italian/etc/glossaryPopup.jsp?m="+mode+"&term="+escape(term)+"","glossary", 324, 399, false); } function openWin(url, name, ht, wd, scrolling) { var scrollYesOrNo="yes" if (arguments.length==5) { scrollYesOrNo=(scrolling?"yes":"no") } return window.open(url, name, "directories=no, location=no, menubar=no, resizable=no, scrollbars="+scrollYesOrNo+", status=no, toolbar=no, height="+ht+", width="+wd) } function printPage() { if (window.print) { window.print() } else if (document.print) { document.print() } else { alert("Per stampare questa pagina, scegli \"Stampa...\" dal menu \"File\".") } } function checkSearchBox(textboxObj, clickIn) { if (clickIn && textboxObj.value=="Search") { textboxObj.value="" } if (!clickIn && textboxObj.value.length==0) { textboxObj.value="Search" } } function getResource(selectObj) { if (selectObj.selectedIndex>0) { newUrl=mainSiteHttpRoot+selectObj.options[selectObj.selectedIndex].value if (newUrl.indexOf("Redir")==-1) { location.href=newUrl } else { window.open(newUrl,"","") } } } function isValidForm(formObj) { var state = "Scegli uno stato"; validate("RegisterReadForm"); } function isValidEmail(s) { s=""+s s=trim(s) if (s.length==0 || s.indexOf("@")==-1 || s.indexOf(".")==-1) { return false } var splitOnAt=s.split("@") if (splitOnAt.length!=2) { return false } var preAt=splitOnAt[0] var postAt=splitOnAt[1] if (preAt.length==0) { return false } if (postAt.length==0) { return false } if (postAt.indexOf(".")==-1) { return false } var splitOnDot=postAt.split(".") if (splitOnDot[splitOnDot.length-1].length<2) { return false } for (var i=0; i0) { location.href=resourceUrl } }