MySpace.UI._GeoLocation=function(){this.initialize()};MySpace.UI._GeoLocation.prototype={SPLITCHAR:"__",_geoFrame:null,_searchMode:null,displayMode:null,defaultOption:null,notifyParentScript:null,_isDropdown:null,_postalCountries:null,_regionCountries:null,initialize:function(){MySpace.UI._GeoLocation.initializeBase(this);this._geoFrame=$q(".geoFrame",null,true);this._countryList=$q(".ddlCountry",this._geoFrame,true);this._regionList=$q(".ddlRegion",this._geoFrame,true);this._regionTxt=$q(".txtRegion",this._geoFrame,true);this._searchRadius=$q(".ddlSearchRadius",this._geoFrame,true);this._postalCode=$q(".txtPostalCode",this._geoFrame,true);this._form=this._countryList.form;this._searchMode=this._form.hdnSearchMode;this._regionHandler=Function.createDelegate(this,this.validateRegion);this._submitHandler=Function.createDelegate(this,this.geoLocationValidate);$addHandler(this._regionList,"change",this._regionHandler);$addHandler(this._form,"submit",this._submitHandler);this.displayMode=MySpace.GeoLocation.displayMode.toLowerCase();this.defaultOption=(this.displayMode=="browse"?MySpaceRes.Common.Any:MySpaceRes.UserJoin.PleaseSelectRegion);this._isDropdown=MySpace.GeoLocation.isDropDown;this._currentCulture=MySpace.GeoLocation.currentCulture;this._postalCountries=MySpace.GeoLocation.postalCountries;this._regionCountries=MySpace.GeoLocation.regionCountries;this._smallCountries=MySpace.GeoLocation.smallCountries;this._addStyles();this.toggleDisplayType();var showRegionHandler=Function.createDelegate(this,this._showRegion);$addHandler(this._countryList,"change",showRegionHandler);if(MySpace.GeoLocation.notifyParentScript){var handler=eval(MySpace.GeoLocation.notifyParentScript);handler(this.isDistanceSearchEnabled());$addHandler(this._countryList,"change",Function.createCallback(handler,this.isDistanceSearchEnabled()))}},dispose:function(){MySpace.UI._GeoLocation.callBaseMethod(this,"dispose");this._regionHandler=null;this._submitHandler=null},geoLocationValidate:function(A){if(MySpace.GeoLocation.validate){if(!this._validatePostalCode()||!this.validateRegion()){if(A&&A.preventDefault){A.preventDefault()}return false}}return true},toggleDisplayType:function(){var D=this._getCurrCountry();var A=$q(".regionRowDD",this._geoFrame,true);var C=$q(".regionRowTxt",this._geoFrame,true);var B=$q(".postalRow",this._geoFrame,true);if(this.displayMode=="browse"){if(this._containsCountry(D,this._postalCountries)&&!this._containsCountry(D,this._regionCountries)){this._searchMode.value="distance";A.style.display="none";C.style.display="none";B.style.display="block"}else{if(!this._containsCountry(D,this._postalCountries)&&this._containsCountry(D,this._regionCountries)){this._searchMode.value="region";A.style.display="block";C.style.display="none";B.style.display="none"}else{this._searchMode.value="none";A.style.display="none";C.style.display="none";B.style.display="none"}}}else{if(this.displayMode=="profile"){if(typeof(imperialCultures)!="undefined"){if(imperialCultures.indexOf(this._currentCulture)>-1){this._showHeightDiv("FTIN")}else{this._showHeightDiv("CM")}}if(this._containsCountry(D,this._regionCountries)&&this._regionList.options.length>0){this._searchMode.value="region";A.style.display="block";C.style.display="none";B.style.display="none"}else{this._searchMode.value="region";C.style.display="block";A.style.display="none";B.style.display="none"}}}B.style.zoom="1"},_getCurrCountry:function(A){return this._countryList.options[this._countryList.selectedIndex].value},_getOptionIndex:function(D,C){var A=-1;for(var B=0;B<D.options.length;B++){if(D.options[B].value==C){return B}}return A},_updateDistanceDD:function(){var A=new Array("100","250");var C=this._getCurrCountry();for(i=0;i<A.length;i++){var B=this._getOptionIndex(this._searchRadius,A[i]);if(this._containsCountry(C,this._smallCountries)){if(B!=-1){this._searchRadius.remove(B)}}else{if(B==-1){this._searchRadius.options[this._searchRadius.options.length]=new Option(A[i],A[i])}}}},_showRegion:function(){if(this.displayMode=="browse"&&this.isDistanceSearchEnabled()){this._updateDistanceDD()}var A=this._getCurrCountry();if(this._containsCountry(A,this._regionCountries)==true){this._onCompleteHandler=Function.createDelegate(this,this._onComplete);this._onTimeoutHandler=Function.createDelegate(this,this._onTimeout);Sys.Net.WebServiceProxy.invoke("/Services/GeoLocation.asmx","GetStates",false,{countryID:this._getCurrCountry(),culture:this._currentCulture},this._onCompleteHandler,this._onTimeoutHandler)}this.toggleDisplayType();return false},_onComplete:function(C){var A;this._regionList.options.length=0;A=new Option(this.defaultOption,"0");this._regionList.options[0]=A;for(var D in C){var B=C[D].split(this.SPLITCHAR);A=new Option(D,B[0]);if(A.value.indexOf("function")!=0){this._regionList.options[this._regionList.options.length]=A}}this.toggleDisplayType()},_onTimeout:function(A){},isDistanceSearchEnabled:function(){var A=this._getCurrCountry();return this._containsCountry(A,this._postalCountries)},_validatePostalCode:function(){if(this._searchMode.value=="distance"){if(this._postalCode.value.length>0&&this._searchRadius.selectedIndex==0){alert(MySpaceRes.BrowsePage.SpecifyDistance);return false}if((this._postalCode.value.length<1)&&(this._searchRadius.selectedIndex>0)){alert(MySpaceRes.BrowsePage.SpecifyPostal);return false}}return true},validateRegion:function(){if(this._displayMode=="profile"&&this._isDropDown){var A=$q("select.cvRegionDD",this._geoFrame,true);if(this._regionList.value=="0"){Sys.UI.DomElement.removeCssClass(A,"hide");return false}else{Sys.UI.DomElement.addCssClass(A,"hide");return true}}else{return true}},_containsCountry:function(B,A){for(x in A){if(B==A[x]){return true}}return false},_showHeightDiv:function(B){var C;var A;C=$get("USHeight");divNonUs=$get("NonUSHeight");if(typeof C==="undefined"||typeof A==="undefined"||C===null||A===null){return}if(B=="CM"){divNonUs.style.display="";C.style.display="none"}else{if(B=="FTIN"){divNonUs.style.display="none";C.style.display=""}}},_addStyles:function(){if(MySpace.UI._GeoLocation.stylesAdded){return}MySpace.UI._GeoLocation.stylesAdded=true;MySpace.UI.addStyles(".regionRowDD,.regionRowTxt,.postalRow{display:none;}.txtPostalCode{height:auto;width:75px;}",true)}};MySpace.UI._GeoLocation.registerClass("MySpace.UI._GeoLocation",Sys.Component);MySpace.UI.GeoLocation=new MySpace.UI._GeoLocation();