//*************************************** //functions for index_models.shtml //************************************* //constructor for image objects of model module function createModelHilite(whichBGImg,whichImg,lowsrc){ //erzeugen der mouseover-Images if(!whichImg.counter){ whichImg.counter = 1; whichImg.hilitetoggle = 1; whichImg.bgimg = "url(" + whichBGImg + ")"; whichImg.offimg = new Image(); whichImg.offimg.src = lowsrc; //creating hilite images if(arguments.length > 3){ whichImg.addImages = new Array(); for(i=0;i' + (this.activeMenu[i+2]!=null ? this.activeMenu[i+2] : "") + '' + this.activeMenu[i] + ':' + ' ' + this.activeMenu[i+1] + (this.activeMenu[i+2]!=null ? this.activeMenu[i+2] : "") + ''; i = i + 2; } } } //writing newsscroller start html function initNewsScroller(whichMenu){ if(whichMenu.activeMenu != 0) { document.getElementById("nscr_news").innerHTML = whichMenu.subMenuItemsList; document.getElementById("nscr_maindiv_nolink").style.visibility = "visible"; document.getElementById("nscr_maindiv_nolink").style.display = "block"; document.getElementById("nscr_news").style.top= 0 + "px"; } } function scroll_up(){ var divTop = document.getElementById("nscr_news").offsetTop; var maxTop = document.getElementById("nscr_news").offsetHeight; maxTop = maxTop - 98; //alert(maxTop); divTop = divTop - 1; if(divTop + maxTop <= 0 ) divTop= -maxTop; document.getElementById("nscr_news").style.top = divTop + "px"; //if(navigator.appVersion.indexOf("MSIE 5") != -1 && isMac) document.getElementById("nscr_news").style.left = 20 + "px"; scrollTimer = setTimeout("scroll_up()",10); } function scroll_down(){ var divTop = document.getElementById("nscr_news").offsetTop; var maxTop = document.getElementById("nscr_news").offsetHeight; divTop = divTop + 1; if(divTop >= 0) divTop = 0; document.getElementById("nscr_news").style.top = divTop + "px"; //if(navigator.appVersion.indexOf("MSIE 5") != -1 && isMac) document.getElementById("nscr_news").style.left = 20 + "px"; scrollTimer = setTimeout("scroll_down()",10); } function scroll_stop(){ if (scrollTimer) clearTimeout(scrollTimer); } //========================================= // Calendar-functions //========================================= // active month in calendar control var activeMonth = 0; function makeCalendar(){ //reading arrays this.months = new Array; for(var i = 0; i < arguments.length; i++){ this.months[i] = arguments[i]; this.months[i].name = this.months[i][0][0]; this.months[i].daysum = this.months[i][0][1]; this.months[i].start = this.months[i][0][2]; var startCount = this.months[i].start * 23; /*var startCount = 0; switch (this.months[i].start) { case 'mo': startCount = 0; break; case 'di': startCount = 1*23; break; case 'mi': startCount = 2*23; break; case 'do': startCount = 3*23; break; case 'fr': startCount = 4*23; break; case 'sa': startCount = 5*23; break; case 'so': startCount = 6*23; break; } */ this.months[i].completeDayList = new Array; for(var x = 1; x < this.months[i].length; x++){ var day = this.months[i][x][0]; var href = this.months[i][x][1]; var title = this.months[i][x][2]; var description = this.months[i][x][3]; var completeDescription = ''; completeDescription += '' + title + '' + description + ''; //if there are more than one event per day... if(this.months[i].completeDayList[day]){ var addDescription = '' + description + ''; var addCompleteDescription = this.months[i].completeDayList[day][2]; addCompleteDescription += addDescription; this.months[i].completeDayList[day][2] = addCompleteDescription; } else{ this.months[i].completeDayList[day] = [day,href,completeDescription]; } } this.months[i].divHTML = ''; this.months[i].divHTML += ''; for(var y = 1; y < this.months[i].daysum + 1; y++){ if(y < 10){ var numToString = "0" + y; } else{ var numToString = y; } if(!this.months[i].completeDayList[y]){ this.months[i].divHTML += '' + numToString + ''; } else{ var tempHTML = '' + numToString + ''; this.months[i].divHTML += tempHTML; } } //alert(this.months[i].html); } } /** * @param pIncludePassedEvents if true passed events shall be included */ function initCalendar(pIncludePassedEvents){ var actualDate = new Date() var month = actualDate.getMonth() + 1; var year = actualDate.getFullYear(); var checkDate = "m" + parseInt(month) + parseInt(year); var foundActiveMonth = false; for(var i = 0; i < calendar.months.length; i++){ if(checkDate == calendar.months[i].name){ activeMonth = i; foundActiveMonth = true; break; } } if(pIncludePassedEvents && !foundActiveMonth) { activeMonth = calendar.months.length -1; } var startHTML = calendar.months[activeMonth].divHTML; var startDate = getFullDateName(calendar.months[activeMonth].name); document.getElementById("calendarcontent").innerHTML = startHTML; if(navigator.appVersion.indexOf("MSIE 5") != -1 && isMac){ document.getElementById("chosenDate").style.width = 110 + "px"; } document.getElementById("chosenDate").innerHTML = startDate; document.getElementById("calendarcontent").style.width = 163 + "px"; document.getElementById("calendarcontent").style.display = "block"; document.getElementById("calendarcontent").style.visibility = "visible"; } function showEventDescription(whichEvent){ document.getElementById("eventdescription").innerHTML = whichEvent; document.getElementById("descriptioncontainer").style.display = "block"; document.getElementById("descriptioncontainer").style.visibility = "visible"; } function hideEventDescription(){ document.getElementById("eventdescription").innerHTML = ''; document.getElementById("descriptioncontainer").style.display = "none"; document.getElementById("descriptioncontainer").style.visibility = "hidden"; } function switchMonthForward(pRequestPrefix){ activeMonth = activeMonth + 1; if(activeMonth >= calendar.months.length) activeMonth = calendar.months.length -1; var newMonthName = calendar.months[activeMonth].name; newMonthName = getFullDateName(newMonthName); if(navigator.appVersion.indexOf("MSIE 5") != -1 && isMac){ document.getElementById("chosenDate").innerHTML = ''; } document.getElementById("chosenDate").innerHTML = newMonthName; document.getElementById("calendarcontent").innerHTML = calendar.months[activeMonth].divHTML; updateEvents(pRequestPrefix, calendar.months[activeMonth].name); } function switchMonthBack(pRequestPrefix){ activeMonth = activeMonth - 1; if(activeMonth <= 0) activeMonth = 0; var newMonthName = calendar.months[activeMonth].name; newMonthName = getFullDateName(newMonthName); if(navigator.appVersion.indexOf("MSIE 5") != -1 && isMac){ document.getElementById("chosenDate").innerHTML = ''; } document.getElementById("chosenDate").innerHTML = newMonthName; document.getElementById("calendarcontent").innerHTML = calendar.months[activeMonth].divHTML; updateEvents(pRequestPrefix, calendar.months[activeMonth].name); } /** * @param pRequestPrefix * @param pActiveMonth */ function updateEvents(pRequestPrefix, pActiveMonth) { var ajaxRequestUrl = pRequestPrefix + pActiveMonth + '.xml'; ajaxEngine.registerRequest(ajaxRequestUrl, ajaxRequestUrl); // update content ajaxEngine.sendRequest(ajaxRequestUrl); rewriteEventsPrintLink(printlink, pActiveMonth); } //get complete year and month out of array-name function getFullDateName(chosenMonth){ var dateString = chosenMonth; dateString = dateString.substr(1,dateString.length); var yearString = dateString.substr(dateString.length - 4,dateString.length); var monthString = dateString.substr(0,dateString.length - 4); var monthInt = parseInt(monthString) -1; monthString = monthFullnames[monthInt]; var fullName = monthString + " " + yearString; return(fullName); } function rewriteEventsPrintLink(pPrintLink, pCurrentSelection) { pPrintLink = pPrintLink.replace('PLACEHOLDER',pCurrentSelection); var linkAnchor = document.getElementById('content_functions_print_link'); if (linkAnchor!=null) { linkAnchor.href = 'javascript:'+pPrintLink; } var iconAnchor = document.getElementById('content_functions_print_icon'); if (iconAnchor!=null) { iconAnchor.href = 'javascript:'+pPrintLink; } } //----- glossary functions ------ /* Sets/ Resets the text of input field */ function setInputText(input, defaultText) { if(input.value == defaultText) { input.value=""; } else if(input.value == "") { input.value = defaultText; } } // holds the most recently selected letter var previuoslySelected; /* highlights index entry and abc-nav-element of selected letter * letter: selected letter * clearSelected: clear/ de-highlight most recent selection */ function highlightLetter(letter, clearSelected) { letter = letter.toUpperCase(); // assign highlighting css-styles document.getElementById('glossary_letter_headline_'+letter).className = "glossary_letter_headline_hi"; document.getElementById('glossary_letter_contents_'+letter).className = "glossary_letter_contents_hi"; document.getElementById('glossary_letter_head_'+letter).className = "glossary_letter_head_hi"; document.getElementById('glossary_abc_letter_'+letter).className = "glossary_abc_letter_hi"; document.getElementById('glossary_abc_link_'+letter).className = "glossary_abc_link_hi"; // undo highlighting of previously selected entry if(previuoslySelected&&clearSelected&&previuoslySelected!=letter) { dehighlightLetter(previuoslySelected); } if(clearSelected) { previuoslySelected = letter; } } /* de-highlights index entry and abc-nav-element of selected letter */ function dehighlightLetter(letter) { letter = letter.toUpperCase(); // assign non-highlighted css-styles document.getElementById('glossary_letter_headline_'+letter).className = "glossary_letter_headline"; document.getElementById('glossary_letter_contents_'+letter).className = "glossary_letter_contents"; document.getElementById('glossary_letter_head_'+letter).className = "glossary_letter_head"; document.getElementById('glossary_abc_letter_'+letter).className = "glossary_abc_letter"; document.getElementById('glossary_abc_link_'+letter).className = "glossary_abc_link"; } /* limit displayed select entries according to input */ function limitEntries(selectForm, currentInput){ var limitedEntries; var option; var title; var match; var lengthLimited; lengthLimited = 0; // compute length of limited Array for(i = 0; i < entries.length; i++) { title = entries[i][0]; match = title.toLowerCase().search(new RegExp(currentInput.toLowerCase())); if(match != -1) { lengthLimited++; } } limitedEntries = new Array(lengthLimited); // fill limited array for(i = 0; i < entries.length; i++) { title = entries[i][0]; match = title.toLowerCase().search(new RegExp(currentInput.toLowerCase())); if(match != -1) { limitedEntries.push(entries[i]); } } // fill select box with options out of limitedEntries clearSelect(selectForm); for(i = 0; i < limitedEntries.length; i++) { if(limitedEntries[i] != null) { option = new Option(limitedEntries[i][0], limitedEntries[i][1], false, false); selectForm.options[selectForm.options.length] = option; } } } // switches window.location to currently selected select-option function switchTo(currentSel){ window.location.href = currentSel.options[currentSel.selectedIndex].value; } // Clears the selectbox function clearSelect(selectForm) { var length; //length = document.glossaryForm.glossarySearchSelect.options.length; length = selectForm.options.length; if(length>0) { for (i = length; i >= 0; i--) { document.glossaryForm.glossarySearchSelect.options[i] = null; } } } //--------------END glossary functions------------------ /*--------------sitemap functions----------------------*/ function toggleSitemapCategory(theId, activate) { var styleClass; if(activate){ styleClass = 'sitemap_col_header_hi'; }else{ styleClass = 'sitemap_col_header'; } // apply if (document.all && document.all[theId].style.getAttribute) { document.all[theId].className = styleClass; } else if (document.getElementById) { document.getElementById(theId).className = styleClass; } } /** * toggles image of sitemap category headline. * @param theId * @param theUrl */ function toggleSitemapCategoryImage(theId, theUrl) { // apply if (document.all && document.all[theId].style.getAttribute) { document.all[theId].src = theUrl; } else if (document.getElementById) { document.getElementById(theId).src = theUrl; } } /*--------------END sitemap functions------------------*/ /* function for displaying / hiding optional back-button * * checks history, if not empty, display HTML-element with id theId * @param theId id of HTML element to display / hide */ function displayBackButton(theId) { if(history.length > 1) { if (document.all && document.all[theId].style.getAttribute) { document.all[theId].style.display = 'block'; } else if (document.getElementById) { document.getElementById(theId).style.display = 'block'; } } } /* END function for optional back-button */ /*dialog center functions */ /** * moves option from one select imput to another * @param pFromSelect select box from where to remove item * @param pToSelect select box where to add item */ function moveItem(pFromSelect, pToSelect) { var fromSelect = document.getElementById(pFromSelect); var toSelect = document.getElementById(pToSelect); var notSelectedItems = new Array(); var amountUnselected = 0; if(fromSelect && toSelect) { // detect and copy selected options for(i = 0; i < fromSelect.options.length; i++) { var newOpt = new Option(fromSelect.options[i].text, fromSelect.options[i].value, false, false); if(fromSelect.options[i].selected == true) { toSelect.options[toSelect.options.length] = newOpt; } else { notSelectedItems[amountUnselected++] = newOpt ; } } // clear from-select box for(i = fromSelect.options.length -1; i >= 0; i--) { fromSelect.options[i] = null; } // refill from select box for(i = 0; i < notSelectedItems.length; i++) { fromSelect.options[i] = notSelectedItems[i]; } } } /** * submits form to given url * Switches location to that URL. * @param pForm form to be submitted * @param pSel select to get values of * @param pUrl url to post form to * @param pMaxBrochures maximum number of brochures allowed to be ordered at once */ function submitBrochureForm(pForm, pSel, pUrl, pMaxBrochures) { var theSel = document.getElementById(pSel); var theForm = document.getElementById(pForm); if(theSel && theForm) { // if show downloads, check if a selection was made if(pUrl.indexOf('show_downloads')>-1 && !validateBrochureSelect(pSel, null, pMaxBrochures)) { return; } theForm.action = pUrl; theForm.submit(); } } /** * Validate controls of the given form against their validation rules. * @param pForm Form to validate */ function validateForm(pForm) { var messageBox = document.getElementById("message_box"); if (!messageBox) return; var isValidated = true; var errorFieldCount = 0; var errorHashes = ''; for(var i = 0; i < form_array.length; i+=7) { var name = form_array[i]; var caption = form_array[i+1]; var validation = form_array[i+2]; var errorMsg = form_array[i+3]; var isMandatory = form_array[i+4]; var maxLength = form_array[i+5]; var isTrimWhiteSpace = form_array[i+6]; var isMultiple = (typeof name != "string"); var message = null; if(isTrimWhiteSpace){ if (isMultiple) { var formElements = new Array(); for(var j = 0; j < name.length; j++ ){ var formElement = pForm.elements[name[j]]; trimFormElementValue(formElement); } } else { var formElement = pForm.elements[name]; trimFormElementValue(formElement); } } // if custom / multiple if (isMultiple) { var formElements = new Array(); for(var j = 0; j < name.length; j++ ){ formElements[j] = pForm.elements[name[j]]; } message = getMessageMultiple(formElements, validation, isMandatory); } else { var formElement = pForm.elements[name]; message = getMessage(formElement, validation, isMandatory, maxLength); } // output var cssClass = "akdform_label_dialog"; if (isMultiple) { name = name[0]; } if (message) { if (errorMsg) { message = errorMsg; } else { message = message.replace(/\{0\}/, caption); message = message.replace(/\{1\}/, maxLength); } message = "
" + message + "
"; if (isValidated) { messageBox.innerHTML = message; } else { messageBox.innerHTML += message; } isValidated = false; cssClass += "_error"; errorFieldCount++; // error hashes generation ITEM_OFFSET = 10; MAX_LENGTH = 100; if(errorHashes.length+ITEM_OFFSET<=MAX_LENGTH) { if(errorHashes.length>0) { errorHashes+=':'; } if(caption!=null&&caption.length>0){ errorHashes+=createHash(caption); } else { var hashVal = name; if(hashVal.indexOf('.')>=0&&hashVal.indexOf('.')<=hashVal.length-1) { hashVal=hashVal.substring(hashVal.indexOf('.')+1, hashVal.length); } errorHashes+=createHash(hashVal); } } // END error hashes generation } var controlBox = document.getElementById(name + "_box"); if (controlBox) { controlBox.className = cssClass; } } if (!isValidated) { messageBox.innerHTML = "
" + messageBox.innerHTML + "
"; // send custom user tracking event with error count fields if (typeof cms_UserTracking_sendCustomEvent == "function" && typeof usertracking_pageurl_default == "string" && typeof usertracking_pagetitle_default == "string") { if(typeof usertracking_pagetitle_customized == "string"){ usertracking_pagetitle_default=usertracking_pagetitle_customized; } cms_UserTracking_sendCustomEvent("FormValidationErrors", usertracking_pageurl_default, usertracking_pagetitle_default, null, null,{prop14:errorHashes}); } } //alert(errorHashes); return isValidated; } /** * Cuts of whitespace characters at start and end of given string */ function trimFormElementValue(pFormElement) { var untrimmed = getValue(pFormElement); if(untrimmed && untrimmed.length>0) { pFormElement.value = untrimmed.replace (/^\s+/, '').replace (/\s+$/, ''); } } /** * Trims element value when element is defined for trimming (see form_data[]) */ function checkElementForValueTrim(pElement) { var elementName = pElement.name; for(var i = 0; i < form_array.length; i+=7) { var name = form_array[i]; var isTrimWhiteSpace = form_array[i+6]; var isMultiple = (typeof name != "string"); if(isTrimWhiteSpace){ if (isMultiple) { for(var j = 0; j < name.length; j++ ){ if (name[j] == pElement.name){ trimFormElementValue(pElement); } } } else { if (name == pElement.name){ trimFormElementValue(pElement); } } } } } /** * */ function createHash(pHashValue) { hashKey = hex_md5(pHashValue); hashKey = pHashValue.substring(0,2)+parseInt(hashKey,16)%1000000; return hashKey; } /** * Return the value of the given form element. * @param pElement Element to get the value of */ function getValue(pElement) { if(!pElement){ return null; } var value = ""; if (pElement.length) { for (var x = 0; x < pElement.length; x++) { if (pElement[x].checked || pElement[x].selected) { value += (value ? "," : "") + pElement[x].value; break; } } } else { value = pElement.value; } return value; } var JS_IDENTIFIER = "javascript:"; /** * Get the validation message for the given form element. * @param pElement Form element to get the message for * @param pValidation Validation expression * @param pIsMandatory Whether the element is mandatory * @param pMaxLength Max length of the element */ function getMessage(pElement, pValidation, pIsMandatory, pMaxLength) { if(!pElement) { return null; } var message = null; var value = getValue(pElement); if (pIsMandatory && ((!value || value.length == 0) || (pElement.type == "checkbox" && pElement.checked == false))) { //&& (!value || value.length == 0)) { if (pElement.options) { message = lang['submit_error_selection_missing']; } else { message = lang['submit_error_field_missing']; } } else if (pValidation.length > 0) { var indexJs = pValidation.indexOf(JS_IDENTIFIER); if (indexJs == 0) { var jsMethodName = pValidation.substring(indexJs + JS_IDENTIFIER.length); var values = new Array(value); eval("message = " + jsMethodName + "(values)"); } else { var regExp = new RegExp(pValidation); if (!regExp.test(value)) { message = lang['submit_error_field_invalid']; } } } else if (pMaxLength > 0 && value.length > pMaxLength) { message = lang['submit_error_field_too_long']; } return message; } /** * Get the validation message for the given form elements. * @param pElement Form elements to get the message for * @param pValidation Validation expression * @param pIsMandatory Whether the elements are mandatory */ function getMessageMultiple(pElements, pValidation, pIsMandatory) { if(!pElements) { return null; } var message = null; var values = new Array(); var emptyVal = false; for (var k = 0; k < pElements.length; k++) { values[k] = getValue(pElements[k]); if(!values[k] || values[k].length == 0) { emptyVal = true; } } var jsMethodName; var paramCount = 0; if (pValidation.length > 0) { // Check whether validation expression contains javascript var indexJs = pValidation.indexOf(JS_IDENTIFIER); if(indexJs > -1) { jsMethodName = pValidation.substring(indexJs + JS_IDENTIFIER.length); paramCount = eval(jsMethodName + ".length"); } } // If the custom validation method accepts a second parameter it implements a custom mandatory validation var customMandatory = (paramCount > 1); if (!customMandatory && pIsMandatory && emptyVal) { message = lang['submit_error_field_missing']; } else if (jsMethodName && (!emptyVal || customMandatory)) { // Evalutate custom validation method message = eval(jsMethodName + "(values, pIsMandatory)"); } return message; } /** * TODO: comment */ function fillTravelSelects(pProgramSelect, pDestSelect, pIntervalSelect, pParicipantsSelect, pLevel, pStore){ var programSelect = document.getElementById(pProgramSelect); var destSelect = document.getElementById(pDestSelect); var intervalSelect = document.getElementById(pIntervalSelect); var participantsSelect = document.getElementById(pParicipantsSelect); var store = document.getElementById(pStore); if(programSelect && destSelect && intervalSelect && participantsSelect) { //var controls = new Array(programSelect, destSelect, intervalSelect, participantsSelect); var prgIndex = programSelect.selectedIndex -1; var dstIndex = destSelect.selectedIndex -1; var itvIndex = intervalSelect.selectedIndex -1; var pcpIndex = participantsSelect.selectedIndex -1; if(pLevel == 0) { destSelect.selectedIndex = 0; intervalSelect.selectedIndex = 0; participantsSelect.selectedIndex = 0; if(prgIndex < 0) { destSelect.disabled = true; intervalSelect.disabled = true; participantsSelect.disabled = true; } else { fillSelect(destSelect, programs[prgIndex][1]); destSelect.disabled = false; } return; } if(pLevel == 1) { intervalSelect.selectedIndex = 0; participantsSelect.selectedIndex = 0; if(dstIndex < 0) { intervalSelect.disabled = true; participantsSelect.disabled = true; } else { fillSelect(intervalSelect, programs[prgIndex][1][dstIndex][1]); intervalSelect.disabled = false; } return; } if(pLevel == 2) { participantsSelect.selectedIndex = 0; if(itvIndex < 0) { participantsSelect.disabled = true; } else { var maxVal = programs[prgIndex][1][dstIndex][1][itvIndex][1]; fillParticipantsSelect(participantsSelect, maxVal); participantsSelect.disabled = false; } } } // fill value store if(programSelect.selectedIndex > -1 && destSelect.selectedIndex > -1 && intervalSelect.selectedIndex > -1 && participantsSelect.selectedIndex > -1) { store.value = programSelect.options[programSelect.selectedIndex].value + ", " + destSelect.options[destSelect.selectedIndex].value + ", " + intervalSelect.options[intervalSelect.selectedIndex].value + ", " + participantsSelect.options[participantsSelect.selectedIndex].value; } } /** * fills select box with options from 2d array values (value=text). Leaves first option unchanged. * @param pSelect select box to be filled * @param pValues 2d array of values */ function fillSelect(pSelect, pValues) { // clear select box for(i = pSelect.options.length -1; i > 0; i--) { pSelect.options[i] = null; } // refill select box for(i = 0; i < pValues.length; i++) { pSelect.options[i+1] = new Option(pValues[i][0], pValues[i][0], false, false); } } /** * fills select box with options from 2d array values (value=text). Leaves first option unchanged. * @param pSelect select box to be filled * @param pValues 2d array of values */ function fillParticipantsSelect(pSelect, pMaxVal) { // clear select box for(i = pSelect.options.length -1; i > 0; i--) { pSelect.options[i] = null; } // refill select box for(i = 1; i <= pMaxVal; i++) { pSelect.options[i] = new Option(i, i, false, false); } } /** * validates travel event inputs * @param pParticipSelName name/id of input for participants, which must have selection > 0 (=default 'please choose' option) * @param pErrorMsg i18n error message */ function validateTravelEvent(pParticipSelName) { var errorMsgBox = document.getElementById('errorMsgBox'); if (!errorMsgBox) { return false; } var participantsSelect = document.getElementById(pParticipSelName); if(participantsSelect && participantsSelect.selectedIndex > -1) { errorMsgBox.style.display = 'none'; return true; } errorMsgBox.style.display = 'block'; errorMsgBox.className = 'dialog_error_txt'; var errMsg = "Please select an event!"; if(TRAVEL_EVENT_ERROR_MESSAGE) { errMsg = TRAVEL_EVENT_ERROR_MESSAGE } errorMsgBox.innerHTML = "
" + errMsg + "
"; return false; } /** * validates brochure select input. * @param pSelectSelectedName name/id of input with selected brochures * @param pSelectNotSelectedName name/id of input with not selected brochures * @param pMaxBrochures maximum number of brochures allowed to be ordered at once * @param pIsOnClick true if validation is invoked on click, false if on submit */ function validateBrochureSelect(pSelectSelectedName, pSelectNotSelectedName, pMaxBrochures, pIsOnClick) { var errorMsgBox = document.getElementById('errorMsgBox'); if (!errorMsgBox || !pMaxBrochures) { return false; } var theSelected = document.getElementById(pSelectSelectedName); // split up if-clause to increase readability // on click validation if(pIsOnClick) { var theNotSelected = document.getElementById(pSelectNotSelectedName); if(theSelected && theNotSelected && pMaxBrochures && getValidSelectOptions(theSelected, false) + getValidSelectOptions(theNotSelected, true) <= pMaxBrochures) { errorMsgBox.style.display = 'none'; return true; } }else { // on submit validation if(theSelected && pMaxBrochures && getValidSelectOptions(theSelected, false) > 0 && getValidSelectOptions(theSelected, false) <= pMaxBrochures) { errorMsgBox.style.display = 'none'; return true; } } errorMsgBox.style.display = 'block'; var errMsg = "Please select a brochure!"; if(BROCHURE_ERROR_MESSAGE) { errMsg = BROCHURE_ERROR_MESSAGE; } errorMsgBox.innerHTML = "
" + errMsg + "
"; return false; } /** * @param pSelect select object to be checked * @param pCheckSelection true if if only selected options shall be counted, false if not * @return # of options being not null */ function getValidSelectOptions(pSelect, pCheckSelection) { var countOptions = 0; if(pSelect) { for(i=0;i