$.DF=$.DF||{};$.browser=$.browser||{};$.DF.Validation2=$.DF.Validation2||{initialize:function(){}};$.DF.scripts=$.DF.scripts||[];$.DF.require=function(src,version){if(this.scripts.indexOf(src)===-1){document.write('<script src="'+src+"?"+version+'"><\/script>');this.scripts.push(src)}};jQuery.hitch=function(scope,method,argv){return(function(){var _argv=(argv||[]).concat(jQuery.makeArray(arguments));if(typeof method=="string"&&typeof scope[method]=="function"){return scope[method].apply(scope,_argv)}else{if(typeof method=="function"){return method.apply(scope,_argv)}}})};function require(src,version,callback){if($.DF.scripts.indexOf(src)===-1){$.DF.scripts.push(src);var script=document.createElement("script");callback&&(script.onload=callback);script.src=src+"?v="+(version||"c707f99".replace(/[%{}]/g,""));document.querySelector("head").appendChild(script)}else{callback()}}document.addEventListener("DOMContentLoaded",function(){if(document.createElement("div").classList.toggle("a",0)!==false){DOMTokenList.prototype.toggle=function(val,toggle){if(arguments.length>1){return(this[toggle?"add":"remove"](val),!!toggle)}var oldValue=this.value;return(this.remove(oldValue),oldValue===this.value&&(this.add(val),true))}}if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector}if(!Element.prototype.closest){Element.prototype.closest=function(s){var el=this;do{if(Element.prototype.matches.call(el,s)){return el}el=el.parentElement||el.parentNode}while(el!==null&&el.nodeType===1);return null}}String.prototype.repeat=function(n){var str="";for(var i=0;i<n;i++){str+=this}return str};$.DF.Form={invalidate:function(control,message){var dd=$(control).closest("dd");dd.prevAll("p.error").remove();if(typeof message=="string"){$('<p class="error" style="display:none;"></p>').html(message).insertBefore(dd.prev("dt")).slideDown("fast")}}};$.DF.REST={_getUrl:function(path){return("/ws/rs/"+path.join("/")+".json").replace("%","")},_request:function _request(type,path,data,callback){req({type:type,url:this._getUrl(path),data:data,success:callback})},getCitiesList:function(path,callback){this._request("GET",["GeoService/cities"].concat(path),null,function(json){var cities=json.City.map(function(city){return[city["@id"],city.name]});callback&&callback(cities)})},getCitiesListByCountryId:function(countryId,callback){this.getCitiesList(["byCountry",countryId],callback)},getCitiesListByRegionId:function(regionId,callback){this.getCitiesList(["byRegion",regionId],callback)},searchCitiesByMask:function(countryId,cityName,callback){this._request("GET",["GeoService/cities",countryId,0,cityName],null,function(json){callback&&callback(json.SearchResult)})},getRegionsListByCountryId:function(countryId,callback){this._request("GET",["GeoService/regions/byCountry",countryId],null,function(json){var regions=json.Region.map(function(region){var name="&nbsp;&nbsp;".repeat(parseInt(region["@nestingLevel"])||0)+region.name;return[region["@id"],name,!!region.selectable]});callback&&callback(regions)})},};var lander={autocomplete:function autocomplete(){var postalCodeEl=document.querySelector("#postalCode");if(!postalCodeEl){return}$.fn.extend({disable:function(disable){return this.each(function(){if(disable==true){$(this).attr("disabled",true).addClass("disabled")}else{$(this).removeAttr("disabled").removeClass("disabled")}})},attach:function(data,selected){data=data||[];this.each(function(index,node){for(var i=0,length=data.length;i<length;i++){$(node).addOption(data[i][0],data[i][1],data[i][2])}if(selected!=null){$(node).val(selected)}});return this},clear:function(text,value){this.each(function(index,node){$(node).empty();if(text!==true){$(node).addOption(value||"0",text||"")}});return this},addOption:function(value,text,selectable,selected){var option=$("<option value="+value+">"+text+"</option>");if(selectable==false){option.attr("disabled","disabled")}if(selected==true){option.attr("selected","selected")}this.each(function(index,node){if(node.options){$(node).append(option)}});return this}});require("/scripts/dynamic/jquery.select.behavior.js",null,function(){require("/scripts/libs/jquery.autocomplete.js",null,function(){$.DF.behavior({countryId:"#countryId",regionId:"#regionId",cityId:"#cityId",usePostCodes:true,postalCode:"#postalCode",postalCodeId:"#postalCodeId",postalCodeLookupMode:"#postalCodeLookupMode",isRegionsCitiesEnable:true,sexId:"#sexId",orientationId:"#orientationIdPerson1",lookingForSexId:"#lookingForSexId",lookingForOrientationId:"#seekingOrientationId",genderId:"#genderId",masterCountryId:"#sexId",birthdayYearId:"#birthYearPerson1",masterCriteriaId:"#sexId",criteriaPrefix:"criteria",isUseSimpleGeo:document.querySelector(".RegistrationSimple")})})})},SwitchLocale:function SwitchLocale(){var switchLocale=document.querySelector(".SwitchLocale");switchLocale&&document.addEventListener("click",function(e){switchLocale.classList.toggle("active",e.target.closest(".SwitchLocale:not(.active)"))
})},registrationDefaults:function registrationDefaults(){var cn=document.body.className;if(cn.match(/trans|swingers/)){return}var orientation=cn.match(/gay/)?"1001":cn.match(/lesbian/)?"2002":"1002";var orientationField=document.querySelector("#genderId");if(orientationField){return(orientationField.value=orientation)}document.querySelector("#sexId").value=orientation[0];document.querySelector("#lookingForSexId").value=orientation[3]},formValidation:function formValidation(){var regForm=document.querySelector('[name="RegistrationCommand"]');regForm.addEventListener("change",onInputChange);regForm.addEventListener("keyup",onInputChange);regForm.addEventListener("paste",onInputChange);function onInputChange(e){e.target.classList.remove("invalid")}var email=regForm.querySelector("[name=email]"),emailError=document.querySelector(".submit-block .error"),regSelects=regForm.querySelectorAll("#birthDayPerson1,#birthMonthPerson1,#birthYearPerson1,#lookingForSexId"),termsCheckbox=document.querySelector('[name="agree"]');regForm.addEventListener("submit",function(e){e.preventDefault();var acceptedTerms=termsCheckbox.checked,emailVal=email.value||"empty",dateInvalid;termsCheckbox.classList.toggle("invalid",!acceptedTerms);[].forEach.call(regSelects,function(e){dateInvalid=e.classList.toggle("invalid",e.value==0)||dateInvalid});req({url:"/ws/rs/UtilityService/checkEmailDomain/"+emailVal+".json",type:"POST",success:function(res){res=res.ServiceOperationResult;if(!res.success){email.classList.add("invalid");emailError.textContent=res.messageText;return}acceptedTerms&&!dateInvalid&&regForm.submit()}})});return regForm},tipsy:function tipsy(form){if(document.querySelector("input[title]")){form.addEventListener("focusin",function(e){var input=e.target;var tooltipText=e.target.getAttribute("title");if(tooltipText){var tooltip=document.createElement("div");tooltip.className="tooltip";tooltip.textContent=tooltipText;input.parentElement.appendChild(tooltip)}});form.addEventListener("blur",function(e){var tooltip=e.target.parentElement.querySelector(".tooltip");tooltip&&tooltip.remove()},true)}},df:function df(){this.tipsy(this.formValidation());this.autocomplete()},init:function init(){["df","registrationDefaults","SwitchLocale"].forEach(function(file){document.querySelector('script[src*="'+file+'"]')||lander[file]()})}};lander.init();function req(options){options=options||{};if(!options.url){return console.error("Please supply an url - {url}")}var opts={type:"GET",followRedir:true,success:function(){},error:function(){},headers:{Accept:"application/json","Content-Type":"application/json",},};defaultsDeep(opts,options);var xhr=new XMLHttpRequest();xhr.open(opts.type,opts.url);Object.keys(opts.headers).forEach(function(header){xhr.setRequestHeader(header,opts.headers[header])});xhr.onreadystatechange=function(){if(xhr.readyState==4){var response=xhr.getResponseHeader("Content-Type")=="application/json"?JSON.parse(xhr.response):xhr.response;opts[xhr.status==200?"success":"error"](response,status,xhr)}};xhr.send(opts.data);function defaultsDeep(target,src){for(var i in src){if(typeof src[i]=="object"&&src[i]!=null){defaultsDeep(src[i],target[i]||{});continue}target[i]=src[i]}}}});