1$.DF.behavior=function(options){var _countryId=$.DF.getOptionsValue(options.countryId),_regionId=$.DF.getOptionsValue(options.regionId),_cityId=$.DF.getOptionsValue(options.cityId),_postalCode=$.DF.getOptionsValue(options.postalCode),_postalCodeId=$.DF.getOptionsValue(options.postalCodeId),_postalCodeLookupMode=$.DF.getOptionsValue(options.postalCodeLookupMode),_sexId=options.sexId,_orientationId=options.orientationId,_lookingForSexId=options.lookingForSexId,_lookingForOrientationId=options.lookingForOrientationId,_genderId=options.genderId,_birthdayYearId=options.birthdayYearId,_ageFromId=options.ageFromId,_ageToId=options.ageToId;$.DF.behavior.isUsePostCodes=$.DF.getOptionsValue(options.usePostCodes,false);$.DF.behavior.isRegionsCitiesEnable=$.DF.getOptionsValue(options.isRegionsCitiesEnable,isRegionsCitiesEnable,true);$.DF.behavior.postalCodeLookupMode=$.DF.getOptionsValue(options.postalCodeLookupMode);$.DF.behavior.criteriaPrefix=$.DF.getOptionsValue(options.criteriaPrefix,"criteria");$.DF.behavior.isUseSimpleGeo=$.DF.getOptionsValue(options.isUseSimpleGeo,false);function getContext(query){var space=query.indexOf(" ");if(space>=0){return query.substr(0,space+1)}else{return""}}function addCityIdOption(cityId){var assocOption=$(Controls.behavior.City.id).find("option[value="+cityId+"]");!assocOption.length&&$(Controls.behavior.City.id).append('<option value="'+cityId+'">')}var Controls={context:getContext(_countryId),behavior:{}};Controls.behavior.Country={id:null,initialize:function(id){if(typeof id!="undefined"){this.id=id;$(this.id).change($.hitch(this,"onChange"));if($.DF.behavior.isUseSimpleGeo){$(this.id).closest("form").find('a[href*="setGeoMode"]').click(function(){$.DF.behavior.setGeoMode(Controls,1)}).attr("href","javascript:void(0)")}else{this.setBackwardCompatibilityMode();$("#linkPostCode").click(function(){$.DF.behavior.setGeoMode(Controls,4)});$("#enterPostCodeManually").click(function(){$.DF.behavior.setGeoMode(Controls,3)})}}},onChange:function(){if(!Controls.behavior.Region.id&&!Controls.behavior.City.id){return}Controls.behavior.Region.clear(msgChooseRegion);Controls.behavior.City.clear(msgChooseCity);Controls.behavior.PostCode.clear().flushCache();var countryId=this.getCountryId();if(countryId!=null){if($.DF.behavior.isUseSimpleGeo==true){Controls.behavior.PostCode.updateLabel(true)}else{this.setBackwardCompatibilityMode()}if(countryId>0){if(regionalCountriesJsMap[countryId]!==true){$(Controls.behavior.Region.id).empty().disable(true);Controls.behavior.City.loadByCountryId(countryId)}else{Controls.behavior.Region.loadByCountryId(countryId)}}}},getSelectedText:function(){return $(this.id).find("option:selected").text()},getCountryId:function(){var value=$(this.id).val();if(value==null){return}if($.isArray(value)){if(value.length>1){return null}else{value=value[0]}}return parseInt(value)},setBackwardCompatibilityMode:function(){var countryId=this.getCountryId();if($.DF.behavior.isUsePostCodes){if($.DF.isUsePostalCodes(countryId)){$.DF.behavior.setGeoMode(Controls,3)}else{$.DF.behavior.setGeoMode(Controls,4)}}}};Controls.behavior.Region={id:null,initialize:function(id){if(typeof id!="undefined"&&$(id).length>0){this.id=id;$(this.id).change($.hitch(this,"onChange"))}},onChange:function(){Controls.behavior.City.clear(msgChooseCity);Controls.behavior.City.loadByRegionId(parseInt($(this.id).val()))},clear:function(message){if(this.id){$(this.id).clear(message)}return this},getRegionId:function(){return $(this.id).val()},loadByCountryId:function(countryId){$.DF.REST.getRegionsListByCountryId(countryId,function(data){var regionsCount=(data.length||0);if(regionsCount==0){$(Controls.behavior.Region.id).disable(true);Controls.behavior.City.loadByCountryId(countryId)}
1else{$(Controls.behavior.Region.id).attach(data).disable($("body").hasClass("trial")).change()}})},getNameById:function(regionId){return $(this.id).find("option[value="+regionId+"]").html()||""}};Controls.behavior.City={id:null,type:1,AUTOCOMPLETE:0,SELECT:1,HIDDEN:2,initialize:function(id){if(typeof id!="undefined"&&$(id).length>0){this.id=id;switch($(this.id).get(0).tagName.toLowerCase()){case"select":this.type=this.SELECT;break;case"input":this.type=this.HIDDEN;break}$(this.id).change($.hitch(this,"onChange"))}},onChange:function(){},clear:function(message){if(this.id){if(this.type==this.SELECT){$(this.id).clear(message)}else{$(this.id).val(0)}}return this},getSelectedText:function(){return $(this.id).find("option:selected").text()},setSelectMode:function(){if(this.id&&this.type!=this.SELECT){var cityId=this.id.match(/#(.*)$/)[1];$(this.id).replaceWith('<select name="'+cityId+'" id="'+cityId+'"></select>');this.type=this.SELECT;this.clear(msgChooseCity);var countryId=Controls.behavior.Country.getCountryId();if(countryId!=null&&countryId>0){if(regionalCountriesJsMap[countryId]!==true){this.loadByCountryId(countryId)}else{this.loadByRegionId(Controls.behavior.Region.getRegionId())}}}return""},setHiddenMode:function(){if(this.id&&this.type!=this.HIDDEN){var cityId=this.id.match(/#(.*)$/)[1],cityId_value=$(this.id).val()||0,cityId_text=this.getSelectedText(); 2$(this.id).replaceWith('<input type="hidden" name='+cityId+" id="+cityId+" value="+cityId_value+" />");this.type=this.HIDDEN}return cityId_text},loadByCountryId:function(countryId){if(this.type==this.SELECT&&countryId>0){$.DF.REST.getCitiesListByCountryId(countryId,function(data){$(Controls.behavior.City.id).attach(data)})}},loadByRegionId:function(regionId){if(this.type==this.SELECT&®ionId>0){$.DF.REST.getCitiesListByRegionId(regionId,function(data){$(Controls.behavior.City.id).attach(data)})}}};Controls.behavior.PostCode={id:null,cityLabel:"",postCodeLabel:"",autocomplete:null,initialize:function(id){if(typeof id!="undefined"&&$(id).length>0){this.id=id;this.cityLabel=$.trim($("#cityIdBlock label").text().replace(":",""));this.postCodeLabel=$.trim($("#postalCodeBlock label").text().replace(":",""));if($.DF.behavior.isUseSimpleGeo){this.updateLabel(true);var cityId_text=Controls.behavior.City.getSelectedText();if($(Controls.behavior.City.id).val()!=0&&cityId_text!=""&&$(this.id).val()==""){$(this.id).val(cityId_text)}Controls.behavior.City.setHiddenMode();this.setAutocomplete();$("#postalCodeBlock a[data-city-id]").click(function(event){var a=$(this);var cityId=a.attr("data-city-id");$(Controls.behavior.PostCode.id).val(a.text());addCityIdOption(cityId);$(Controls.behavior.City.id).val(cityId);$(Controls.behavior.Region.id).val(a.attr("data-region-id"));$(Controls.behavior.Country.id).val(a.attr("data-country-id"))})}else{this.updateLabel(false)}}},updateLabel:function(usePostCodes){var value=$(this.id).val();var countryId=Controls.behavior.Country.getCountryId();var label=$("#postalCodeBlock label");label.text(this.cityLabel+":");if(usePostCodes&&$.DF.isUsePostalCodes(countryId)){if(value==""){label.text(this.cityLabel+"/"+this.postCodeLabel+":")}else{if(this.isPostCode(value)){label.text(this.postCodeLabel+":")}}}},setAutocomplete:function(){this.autocomplete=$(this.id).autocomplete("",{minChars:3,max:1500,resultsClass:"ac_results "+($(this.id).attr("class")||""),getter:function(term,callback){Controls.behavior.PostCode.updateLabel(true);var countryId=Controls.behavior.Country.getCountryId();if(Controls.behavior.PostCode.isPostCode(term)||countryId==0){$(Controls.behavior.City.id).val(0);$.DF.Form.invalidate(Controls.behavior.PostCode.id,false);callback("")}else{$.DF.REST.searchCitiesByMask(countryId,term,function(json){var data=[];if(json.success==true){$.DF.Form.invalidate(Controls.behavior.PostCode.id,false);if(!$.isArray(json.cities)){json.cities=[json.cities]}for(var i=0;i<json.cities.length;i++){var name=json.cities[i]["name"];var id=json.cities[i]["@id"];var regionId=json.cities[i]["regionId"];if((i<json.cities.length-1&&json.cities[i]["name"].toUpperCase()==json.cities[i+1]["name"].toUpperCase())||(i>0&&json.cities[i]["name"].toUpperCase()==json.cities[i-1]["name"].toUpperCase())){name+=(", "+Control
2s.behavior.Region.getNameById(regionId))}data.push([name,id,regionId].join("|"))}}else{$(Controls.behavior.City.id).val(0);$.DF.Form.invalidate(Controls.behavior.PostCode.id,json.messageText);$("#findMyLocationLink").click(function(event){$.DF.behavior.setGeoMode(Controls,2);event.preventDefault()})}callback(data.join("\n"))})}}}).bind("result",function(event,selected){$.DF.Form.invalidate(Controls.behavior.PostCode.id,false);var cityId=selected[1],regionId=selected[2],region=$(Controls.behavior.Region.id);addCityIdOption(cityId);$(Controls.behavior.City.id).val(cityId);region.val(regionId).prop("disabled",!region.children().length)}).change(function(){if($(this).val()==""){$(Controls.behavior.City.id).val(0)}})},clear:function(){$(this.id).val("").trigger("clearPreviousValue");return this},flushCache:function(){$(this.id).flushCache();return this},isPostCode:function(str){return(str.match(/\d+/)!=null)}};Controls.behavior.Sex={sexId:null,orientationId:null,lookingForSexId:null,lookingForOrientationId:null,genderId:null,initialize:function(sexId,orientationId,lookingForSexId,lookingForOrientationId,genderId){if(typeof sexId!="undefined"&&$(sexId).length>0){this.sexId=sexId;$(this.sexId).change($.hitch(this,"onSexChange"))}if(typeof orientationId!="undefined"&&$(orientationId).length>0){this.orientationId=orientationId}if(typeof lookingForSexId!="undefined"&&$(lookingForSexId).length>0){this.lookingForSexId=lookingForSexId;$(this.lookingForSexId).change($.hitch(this,"onLookingForSexChange"))}if(typeof lookingForOrientationId!="undefined"&&$(lookingForOrientationId).length>0){this.lookingForOrientationId=lookingForOrientationId}if(typeof genderId!="undefined"&&$(genderId).length>0){this.genderId=genderId;$(this.genderId).change($.hitch(this,"onGenderChange"))}if(countriesMap){this.useCountriesMap(this.getSexId())}},getSexId:function(){var sexId=0,seekingSexId=0;if($(this.sexId).length>0){sexId=$(this.sexId).val()}else{var genderId=$(this.genderId).val();if(typeof gendersMap!="undefined"&&gendersMap[genderId]!=null){sexId=gendersMap[genderId][0];seekingSexId=gendersMap[genderId][1]}}return sexId},onSexChange:function(){var sexId=parseInt($(this.sexId).val()); 3this.useOrientationsMap(sexId);this.useLookingForSexesMap(sexId);this.useAgesMapBySex(sexId);this.useCountriesMap(sexId);this.useCriteriaItemsMap(sexId)},onLookingForSexChange:function(){var lookingForSexId=$(this.lookingForSexId).val();this.useLookingForOrientationsMap(lookingForSexId);this.useAgesMapByLookingForSex(lookingForSexId)},onGenderChange:function(){var genderId=$(this.genderId).val();var sexId=0,seekingSexId=0;if(typeof gendersMap!="undefined"&&gendersMap[genderId]!=null){sexId=gendersMap[genderId][0];seekingSexId=gendersMap[genderId][1]}this.useAgesMapBySex(sexId);this.useCountriesMap(sexId);this.useCriteriaItemsMap(sexId)},useOrientationsMap:function(sexId){if(sexId>0&&typeof orientationsMap!="undefined"&&orientationsMap!=null&&this.orientationId){var sexInfoArray=sexesMap[sexId];var orientationsList=orientationsMap[sexId];var orientationsListControl=$(this.orientationId);var orientationsId=orientationsListControl.val();orientationsListControl.clear(msgChooseOrientation);if(orientationsList!=null){if(orientationsList.length<=1){orientationsListControl.clear(true)}orientationsListControl.disable(false).each(function(index,node){for(var i=0,length=orientationsList.length;i<length;i++){if(sexInfoArray[1]==orientationsList[i][1]&&$.DF.isFilteredValue(orientationsList[i][0],filteredOrientationsIdsArray)){$(node).addOption(orientationsList[i][0],orientationsList[i][2],true,(orientationsList[i][0]==orientationsId))}}})}else{orientationsListControl.disable(true)}}},useLookingForSexesMap:function(sexId){if(this.lookingForSexId&&typeof lookingForSexesMap!="undefined"&&lookingForSexesMap!=null){var lookingForSexListControl=$(this.lookingForSexId);if(sexId>0){var lookingForSexList=lookingForSexesMap[sexId];var clearMessage=(lookingForSexList.length>1)?msgChooseSex:true;var lookingForSexId=lookingForSexListControl.val();lookingForSexListControl.clear(clearMessage);if(lookingForSexList!=null){lookingForSexListControl.disable(false).each(function(index,node){for(var i=0;i<lookingForSexList.length;i++){if($.DF.isFilteredValue(lookingForSexList[i][0],filteredSexesIdsArray)){$(node).addOption(lookingForSexList[i][0],lookingForSexList[i][1],true,(lookingForSexList[i][0]==lookingForSexId))}}}).change()}else{lookingForSexListControl.disable(true)}}else{lookingForSexListControl.clear().change()}}},useLookingForOrientationsMap:function(lookingForSexId){if(this.lookingForSexId!=null&&this.lookingForOrientationId!=null){var lookingForSexListControl=$(this.lookingForSexId);var lookingForOrientationListControl=$(this.lookingForOrientationId);if(lookingForOrientationListControl.length>0){lookingForOrientationListControl.clear(msgChooseOrientation);if($.isArray(lookingForSexId)&&lookingForSexId.length>1){lookingForOrientationListControl.clear(true);var optionGroups=[];for(var i=0;i<lookingForSexId.length;i++){var id=parseInt(lookingForSexId[i]);if(id>0){var optionGroup=$('<optgroup label="'+lookingForSexListControl.find("option[value="+id+"]").text()+'"></optgroup>');var sexInfoArray=sexesMap[id];var lookingForOrientationsList=(lookingForOrientationsMap?lookingForOrientationsMap:orientationsMap)[id];if(lookingForOrientationsList!=null&&lookingForOrientationsList.length>0){for(var j=0,length=lookingForOrientationsList.length;j<length;j++){if(sexInfoArray[1]==lookingForOrientationsList[j][1]&&$.DF.isFilteredValue(lookingForOrientationsList[j][0],filteredOrientationsIdsArray)){optionGroup.append($('<option value="'+lookingForOrientationsList[j][0]+'">'+lookingForOrientationsList[j][2]+"</option>"))}}optionGroups.push(optionGroup)}}}lookingForOrientationListControl.disable(false).each(function(index,node){for(var i=0;i<optionGroups.length;i++){$(node).append(optionGroups[i])}})}else{lookingForSexId=parseInt(lookingForSexId);if(lookingForSexId>0){var sexInfoArray=sexesMap[lookingForSexId];var lookingForOrientationsList=(lookingForOrientationsMap?lookingForOrientationsMap:orientationsMap)[lookingForSexId];if(lookingForOrientationsList!=null){if(lookingForOrientationsList.length<=1){lookingForOrientationListControl.clear(true)}lookingForOrientationListControl.disable(false).each(function(index,node){for(var i=0,length=lookingForOrientationsList.length;i<length;i++){if(sexInfoArray[1]==lookingForOrientationsList[i][1]&&$.DF.isFilteredValue(lookingForOrientationsList[i][0],filteredOrientationsIdsArray)){$(node).addOption(lookingForOrientationsList[i][0],lookingForOrientationsList[i][2])}}})}else{lookingForOrientationListControl.disable(true)}}}}}}
3,useCountriesMap:function(sexId){var countryControl=$(Controls.behavior.Country.id);if(typeof countriesMap!="undefined"&&countriesMap!=null){if(sexId>0){var countriesList=countriesMap[sexId]||defaultCountriesArray;var countriesSelected=countryControl.val();var validCountry=false;for(var i=0;i<countriesList.length;i++){if(countriesList[i][0]==countriesSelected){validCountry=true}}if(!validCountry){$.DF.behavior.setGeoMode(Controls,1)}var clearMessage=(countriesList.length>1)?msgChooseCountry:true; 4countryControl.clear(clearMessage);if(countriesList!=null){countryControl.each(function(index,node){for(var i=0;i<countriesList.length;i++){if($.DF.isFilteredValue(countriesList[i][0],filteredCountriesIdsArray)){$(node).addOption(countriesList[i][0],countriesList[i][1],true,(countriesList[i][0]==countriesSelected))}}});if(countryControl.val()!=countriesSelected){countryControl.change()}}}else{countryControl.clear().attach(defaultCountriesArray).change()}}},useCriteriaItemsMap:function(sexId){var _criteriaPrefix=$.DF.behavior.criteriaPrefix;if(typeof criteriaItemsMap!="criteriaItemsMap"&&criteriaItemsMap!=null){if(sexId>0){var criteriaItems=criteriaItemsMap[sexId];$.each(criteriaItems,function(id,data){var ctrl=$('select[id="'+_criteriaPrefix+"["+id+']"]');if(ctrl.length>0){var selectedId=ctrl.val();ctrl.clear().attach(data,selectedId).change()}var ctrl=$('input:hidden[id="'+_criteriaPrefix+"["+id+']"]');if(ctrl.length>0){}})}else{$.each(criteriaItemsMap,function(sexId,criteriaItems){$.each(criteriaItems,function(id,data){$('[id="'+_criteriaPrefix+"["+id+']"]').clear().change()})})}}},useAgesMapBySex:function(sexId){if(typeof agesMap!="undefined"&&typeof defaultAgesArray!="undefined"){var years=[],values=null;if(agesMap!=null&&agesMap[sexId]!=null){values=agesMap[sexId]}else{values=defaultAgesArray}if($.isArray(values)){var fromValue=values[0];var toValue=values[values.length-1];var minValue=filteredAgesArray[0];var maxValue=filteredAgesArray[filteredAgesArray.length-1];for(var i=fromValue;i<=toValue;i++){if(minValue<=i&&i<=maxValue){years.push([currentYear-i,currentYear-i])}}Controls.behavior.Age.aplyYears(years)}}},useAgesMapByLookingForSex:function(lookingForSexId){if(typeof agesMap!="undefined"&&typeof defaultAgesArray!="undefined"){var values=null;if(!$.isArray(lookingForSexId)&&agesMap!=null&&agesMap[lookingForSexId]!=null){values=agesMap[lookingForSexId]}else{values=defaultAgesArray}Controls.behavior.Age.applyAgeLimit(values)}}};Controls.behavior.Age={birthdayYearId:null,ageFromId:null,ageToId:null,initialize:function(birthdayYearId,ageFromId,ageToId){if(typeof birthdayYearId!="undefined"&&$(birthdayYearId).length>0){this.birthdayYearId=birthdayYearId}if(typeof ageFromId!="undefined"&&$(ageFromId).length>0){this.ageFromId=ageFromId}if(typeof ageToId!="undefined"&&$(ageToId).length>0){this.ageToId=birthdayYearId}},aplyYears:function(years){if(this.birthdayYearId){var currentYearValue=$(this.birthdayYearId).val();$(this.birthdayYearId).clear(msgChooseYear,0).attach(years,currentYearValue)}},applyAgeLimit:function(values){if($.isArray(values)){var fromValue=values[0];var toValue=values[values.length-1];var minValue=filteredAgesArray[0];var maxValue=filteredAgesArray[filteredAgesArray.length-1];var ages=[];for(var i=fromValue;i<=toValue;i++){if(minValue<=i&&i<=maxValue){ages.push([i,i])}}if(ages.length>0){if(this.ageFromId){var currentAgeFromValue=$(this.ageFromId).val();if(currentAgeFromValue<ages[0][0]||currentAgeFromValue>ages[ages.length-1][0]){currentAgeFromValue=ages[0][0]}if(currentAgeFromValue==ages[ages.length-1][0]){currentAgeFromValue=ages[0][0]}$(this.ageFromId).clear(true).attach(ages,currentAgeFromValue)}if(this.ageToId){var currentAgeToValue=$(this.ageToId).val();if(currentAgeToValue<ages[0][0]||currentAgeToValue>ages[ages.length-1][0]){currentAgeToValue=ages[ages.length-1][0]}if(currentAgeToValue==ages[0][0]){currentAgeToValue=ages[ages.length-1][0]}$(this.ageToId).clear(true).attach(ages,currentAgeToValue)}}}}};Controls.behavior.Country.initialize(_countryId);if($.DF.behavior.isRegionsCitiesEnable==true){Controls.behavior.Region.initialize(_regionId);Controls.behavior.City.initialize(_cityId);if($.DF.behavior.isUsePostCodes){Controls.behavior.PostCode.initialize(_postalCode)}}
4Controls.behavior.Sex.initialize(_sexId,_orientationId,_lookingForSexId,_lookingForOrientationId,_genderId);Controls.behavior.Age.initialize(_birthdayYearId,_ageFromId,_ageToId)};$.DF.isUsePostalCodes=function(countryId){return((countriesWithZipCodesArray||[]).indexOf(parseInt(countryId)||0)>=0)};$.DF.isFilteredValue=function(value,filter){if(!filter||!$.isFunction(filter.indexOf)){return true}else{return(filter.indexOf(value)>=0)}};$.DF.getOptionsValue=function(){for(var i=0;i<arguments.length;i++){if(typeof arguments[i]!="undefined"&&arguments[i]!=null){return arguments[i]}}return null};$.DF.behavior.setGeoMode=function(Controls,mode){var modes=[["#countryLabelBlock","#postalCodeBlock"],["#countryIdBlock","#postalCodeBlock"],["#countryIdBlock","#regionIdBlock","#cityIdBlock"],["#countryIdBlock","#postalCodeBlock","#linkPostCodeBlock"],["#countryIdBlock","#regionIdBlock","#cityIdBlock"]];for(var i=0;i<modes.length;i++){if(i!=mode){var els=modes[i];for(var j=0;j<els.length;j++){$(Controls.context+els[j]).hide()}}}for(var i=0;i<modes.length;i++){if(i==mode){var els=modes[i];for(var j=0;j<els.length;j++){$(Controls.context+els[j]).show()}}}switch(mode){case 0:case 1:case 2:Controls.behavior.City.setSelectMode();break;case 3:case 4:break 5}};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.