// wait for the DOM to be loaded $(document).ready(function() { dateSetups(); $("#policyType").change(showOptions); if (isExisting(document.qeForm.furthestDestination)) { $("#area").change(showOptions); } if (isExisting(document.qeForm.additionalDestination)) { if (isExisting(document.qeForm.goingToOtherCountries)) { makeSearchList("additionalDestination"); updateGoingToOtherCountries(); } else { $("#area").change(showOptions); } } if (isExisting(document.qeForm.subCountryOfResidence)) { $("#subCountryOfResidence").change(showOptions); } if (isExisting(document.qeForm.countryOfResidence) && !isValidCOR()) { $("#countryOfResidence").val(document.qeForm.validCORs.value.substring(0, 3)); corRedirect(); } if (isExisting(document.qeForm.popUnderURL)) { $("#qeButtonNextStep").click(function () { jQuery.popunder(document.qeForm.popUnderURL.value,800,300);}); } if (isExisting(document.qeForm.ageGroupsLayoutType && document.qeForm.ageGroupsLayoutType == "list")) { showHideAgeGroups(); if (isExisting(document.qeForm.groupType)) { $("#groupType").change(showHideAgeGroups); $("#numberOfTravellers").change(showHideAgeGroups); } } }); function showHideAgeGroups() { partyMembersTMP = 0; groupTypeTMP = $("#groupType :selected").val(); nonAdultArray = document.qeForm.nonAdultList.value.split(","); if (groupTypeTMP == "IND") { partyMembersTMP = 1; $('#row_numberOfTravellers').hide(); } else if (groupTypeTMP == "CPL") { partyMembersTMP = 2; $('#row_numberOfTravellers').hide(); for(var i=0; i= 0) { return true; } else { return false; } } function corRedirect() { if (isValidCOR()) { showOptions(); } else { document.qeForm.qeEvent.value = "corRedirect"; document.qeForm.qeButtonNextStep.disabled=true; $('#qeForm').submit(); } } function makeSearchList(listID) { (function( $ ) { $.widget( "ui.combobox", { _create: function() { var self = this, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : ""; var input = this.input = $( "" ) .insertAfter( select ) .val( value ) .autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1" ), value: text, option: this }; }) ); }, select: function( event, ui ) { ui.item.option.selected = true; self._trigger( "selected", event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; } }); if ( !valid ) { // remove invalid value, as it didn't match anything $( this ).val( "" ); select.val( "" ); input.data( "ui-autocomplete" ).term = ""; return false; } } } }); input.data( "ui-autocomplete" )._renderItem = function( ul, item ) { ul.css('max-height','150px') ul.css('overflow-x','hidden') ul.css('padding-right','20px') return $( "
  • " ) .attr("style","text-align:left;") .data( "ui-autocomplete-item", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; //input.data( "ui-autocomplete" ).attr("style","text-align:left; max-height: 100px; overflow-x: hidden; padding-right: 20px;"); }, destroy: function() { this.input.remove(); this.element.show(); $.Widget.prototype.destroy.call( this ); } }); })( jQuery ); $(function() { $( "#"+listID ).combobox(); }); } function updateGoingToOtherCountries() { var goingToOtherCountries = ""; for(var i=0;i