YAHOO.namespace("YAHOO.My.Nux");YAHOO.My.Nux={_atmMode:!!YAHOO.util.Dom.get("atm-box"),_busy:false,_closing:false,_curStep:0,_defaultLocation:"",_defaultShade:false,_lastLocationMatches:[],_initialized:false,_interestList:null,init:function(){var A=YAHOO.util.Event;A.addListener("nux-hd","click",this.handleHeaderClick,this,true);A.addListener("nux-locstep-back","click",this.reset,this,true);A.addListener("nux-intstep-back","click",this.handleInterestsButtonClick,this,true);A.addListener("nux-intstep-next","click",this.handleInterestsButtonClick,this,true);A.addListener("nux-donestep-back","click",this.showInterestsStep,this,true);A.addListener("nux-locstep-next","click",this.verifyLocation,this,true);A.addListener("txtNuxLoc","keypress",this.handleLocationKeyPress,this,true);A.addListener("nux-ulm-list","click",this.handleLocationListClick,this,true);A.addListener("nux-intstep-infolink","mouseover",this.showInterestsNotice,this,true);A.addListener("nux-intstep-infolink","mouseout",this.hideInterestsNotice,this,true);A.addListener("nux-donestep-done","click",this.handleDoneClick,this,true);A.addListener("nux-trythis-close","click",this.hideTryThisDialog,this,true);this._defaultShade=YAHOO.My.UI.isPageShaded()||YAHOO.My.UI.isSpotlightVisible();if(this._defaultShade&&!YAHOO.My.UI.isSpotlightVisible()){YAHOO.My.UI.shadePage();}this.tooltip=YAHOO.My.Application.getTooltip({disableMouseOut:true,classname:"ptrdlg"});},handleHeaderClick:function(A){var C=YAHOO.util.Event;A=C.getEvent(A);var B=C.getTarget(A);if(B.tagName.toLowerCase()=="strong"){B=B.parentNode;}if(B.href&&B.href.indexOf("#")>-1){C.preventDefault(A);}if(B.id==""){B=B.parentNode;}switch(B.id){case"nux-close":case"nux-no":this.close();break;case"nux-get-started":this.start();break;default:}},close:function(){if(!this._closing&&!this._busy){this._closing=true;if(this._atmMode){this.savePageViaATM(false,true);}else{var D=YAHOO.util.Dom;var C=YAHOO.My.Application;this.savePage(false,false);if(this.tooltip.isVisible()){this.tooltip.hide();var B=this.tooltip.getContent();D.setStyle(B,"display","none");document.body.appendChild(B);}if(YAHOO.My.UI.isSpotlightVisible()){YAHOO.My.UI.hideSpotlight();YAHOO.My.UI.shadePage();}var A=(navigator.userAgent.indexOf("WebKit")==-1);if(YAHOO.My.UI.isPageShaded()){YAHOO.My.UI.unshadePage({animate:true,onComplete:function(){if(A){YAHOO.My.UI.slideElementUp("nux-hd",{onComplete:function(){D.setStyle("nux-hd","display","none");this.showTryThisDialog();},scope:this});}else{D.setStyle("nux-hd","display","none");}},scope:this});}else{if(A){YAHOO.My.UI.slideElementUp("nux-hd",{onComplete:function(){D.setStyle("nux-hd","display","none");this.showTryThisDialog();},scope:this});}else{D.setStyle("nux-hd","display","none");}}}}},reset:function(B){var D=YAHOO.util.Event;var C=YAHOO.My.Application;var E=YAHOO.util.Dom;B=D.getEvent(B);if(B){D.preventDefault(B);}E.get("nux-hd").className="intro";if(this.tooltip.isVisible()){this.tooltip.hide();var A=this.tooltip.getContent();E.setStyle(A,"display","none");document.body.appendChild(A);}this._curStep=0;if(!this._defaultShade){YAHOO.My.UI.unshadePage();}},showStep:function(A){var I=YAHOO.util.Dom;var G=YAHOO.My.Application;I.removeClass("nux-hd","step1");I.removeClass("nux-hd","step2");I.removeClass("nux-hd","step3");I.addClass("nux-hd",A.cssClass);var E=I.get(A.dialogElement);var C=I.get(A.target);var H=I.getXY(C);var B=0;var F=0;switch(A.pos){case"bl":B=H[0]+Math.round(C.offsetWidth/2);F=H[1]+C.offsetHeight;break;case"lc":B=H[0];F=H[1]+Math.round(C.offsetHeight/2);break;case"rc":B=H[0]+C.offsetWidth;F=H[1]+Math.round(C.offsetHeight/2);break;default:throw new Error("Invalid NUX dialog alignment.");}if(this.tooltip.isVisible()){this.tooltip.hide();var D=this.tooltip.getContent();I.setStyle(D,"display","none");document.body.appendChild(D);}this.tooltip.show([B,F],{pos:[A.pos],offsetY:A.offsetY,width:A.dialogWidth},E);this._curStep=A.stepNum;},start:function(A){if(!this._busy){this._busy=true;var C=YAHOO.util.Event;var B=YAHOO.My.Application;A=A||window.event;if(A){C.preventDefault(A);}if(YAHOO.My.Components.addedContentInfo){YAHOO.My.Components.addedContentInfo.reset();}this.checkForNewUser({success:function(D,E){if(E.data.isNew){this.newUserStart();}else{this.existingUserStart();}},failure:this.newUserStart,scope:this});}},newUserStart:function(){var A=YAHOO.My.Application;YAHOO.util.Dom.replaceClass("nux-hd","intro","setup");if(!YAHOO.My.UI.isPageShaded()){YAHOO.My.UI.shadePage(true);}this.showLocationStep();this._busy=false;},existingUserStart:function(){var A={html:YAHOO.My.Dict["STR.NUX.OVERWRITE_CONFIRM"],callback:function(C,D,B){if(B){YAHOO.My.Nux.newUserStart();}},buttonText:[YAHOO.My.Dict["STR.NUX.YES_BTN"],YAHOO.My.Dict["STR.NUX.NO_BTN"]],target:null,minWidth:200,maxWidth:280};YAHOO.My.UI.Dialog.confirm(A);this._busy=false;},checkForNewUser:function(C){var B={modid:"myy",_create:1};var A=YAHOO.My.RequestFactory.createRequestObjByType("show","checkNU","pref",B);YAHOO.My.ArcadeRequest.makeRequest(C,A);},handleLocationKeyPress:function(A){var B=YAHOO.util.Event;var C=YAHOO.util.Dom;A=B.getEvent(A);if(B.getCharCode(A)==13){B.preventDefault(A);this.verifyLocation();}},handleLocationListClick:function(A){var C=YAHOO.util.Event;A=C.getEvent(A);var B=C.getTarget(A);if(B.tagName.toLowerCase()=="a"){C.preventDefault(A);YAHOO.util.Dom.get("txtNuxLoc").value=B.innerHTML;this.setULM(B.innerHTML,this._lastLocationMatches[B.locationId]);}},handleSetULMResponse:function(B,A){YAHOO.util.Dom.get("nux-interests").innerHTML=A.data.categoriesHtml;this._defaultLocation="";this._interestList=null;this.showInterestsStep();},handleVerifyLocationResponse:function(G,C){var H=YAHOO.util.Dom;H.get("nux-loc-entry").className="loc-entry";this.hideLocationProgress();if(G.query==""){this.handleSetULMResponse(G,C);}else{var A=C.data.locations;switch(A.length){case 0:H.addClass("nux-loc-entry","notice");H.addClass("nux-loc-entry","ulm-error");break;case 1:this.handleSetULMResponse(G,C);break;default:var D=document.createDocumentFragment();this._lastLocationMatches=A;for(var E=0;E<A.length;E++){var F=document.createElement("li");if(A[E].iso2countrycode!=226){F.innerHTML='<a href="#">'+A[E].town+", "+A[E].country+"</a>";}else{F.innerHTML='<a href="#">'+A[E].town+", "+A[E].stateshortcode+" "+A[E].zip+"</a>";}F.firstChild.locationId=E;D.appendChild(F);}var B=H.get("nux-ulm-list");while(B.hasChildNodes()){B.removeChild(B.firstChild);}B.appendChild(D);H.addClass("nux-loc-entry","notice");H.addClass("nux-loc-entry","ulm");}}},hideLocationProgress:function(){YUD.setStyle("nux-locstep-progress","display","none");YUD.setStyle("nux-locstep-main","display","block");},showLocationProgress:function(){YUD.setStyle("nux-locstep-progress","display","block");YUD.setStyle("nux-locstep-main","display","none");},showLocationStep:function(B){YAHOO.My.Instrumentation.fireUltBeacon({"t":"nlinks","cat":"loc"});var C=YAHOO.My.PortalMgr;var F=YAHOO.My.Application;var K=YAHOO.util.Event;var L=YAHOO.util.Dom;if(window.event||B){B=K.getEvent(B);if(B){K.preventDefault(B);}}L.get("nux-loc-entry").className="loc-entry";var J=L.get("txtNuxLoc");if(!this._initialized){var H=F.getPreference("nux.location.city");var A=F.getPreference("nux.location.state");var D=F.getPreference("nux.location.zip");var G=F.getPreference("nux.location.isdefault");var I=F.getPreference("nux.location.iso2countrycode");var E=F.getPreference("nux.location.country");if(H&&H!=""){if(I!="226"){this._defaultLocation=H+", "+E;}else{this._defaultLocation=H+", "+A+" "+D;}J.value=this._defaultLocation;J.isDefault=G;}L.get("chkNuxLoc").checked=G;this._initialized=true;}if(this._curStep==2){this.saveInterestCheckboxes();}this.showStep({cssClass:"step1",dialogElement:"nux-locstep-dlg",target:"nux-step1",pos:"bl",offsetY:0,dialogWidth:"24em",stepNum:1});J.select();J.focus();},setULM:function(B,A){var E=YAHOO.util.Dom;var D={location:B,locationRecord:A,setdefault:E.get("chkNuxLoc").checked?1:0};var C=YAHOO.My.RequestFactory.createRequestObjByType("show","setlocation","nux",D);var F={success:this.handleSetULMResponse,failure:this.handleSetULMResponse,scope:this};YAHOO.My.ArcadeRequest.makeRequest(F,C);},setUserLocation:function(A){var B=YAHOO.My.Application;B.setPreference("location.city",A.town);B.setPreference("location.state",A.state);B.setPreference("location.country",A.country);B.setPreference("location.zip",A.zip);B.setPreference("location.woeid",A.woeid);},verifyLocation:function(C){var E=YAHOO.util.Event;var F=YAHOO.util.Dom;C=E.getEvent(C);if(window.event||C){C=E.getEvent(C);if(C){E.preventDefault(C);}}var A=F.get("txtNuxLoc");if(A.value==this._defaultLocation){this.showInterestsStep();}else{var D={query:A.value,setdefault:F.get("chkNuxLoc").checked?1:0};var B=YAHOO.My.RequestFactory.createRequestObjByType("show","location","nux",D);var G={success:this.handleVerifyLocationResponse,failure:this.handleVerifyLocationResponse,scope:this,argument:{query:D.query}};YAHOO.My.ArcadeRequest.makeRequest(G,B);this.showLocationProgress();}},handleInterestsButtonClick:function(A){var C=YAHOO.util.Event;A=C.getEvent(A);C.preventDefault(A);var B=C.getTarget(A);while(B.tagName.toLowerCase()!="a"){B=B.parentNode;}switch(B.id){case"nux-intstep-back":this.showLocationStep();break;case"nux-intstep-next":this.saveInterestCheckboxes();this.showLastStep();break;}},hideInterestsNotice:function(A){var B=YAHOO.util.Event;A=B.getEvent(A);B.preventDefault(A);YAHOO.util.Dom.setStyle("nux-interests-notice","visibility","hidden");},initInterestCheckboxes:function(){if(this._interestList){for(var A=0,C=YUD.get("chkInt0");C!=null;A++,C=YUD.get("chkInt"+A)){if(C.value.indexOf("|")>-1){var B=C.value.split("|");if(this._interestList[B[0]]){C.checked=true;}}else{if(this._interestList[C.value]){C.checked=true;}}}}else{for(var A=0,C=YUD.get("chkInt0");C!=null;A++,C=YUD.get("chkInt"+A)){C.checked=true;}}},saveInterestCheckboxes:function(){var C=YAHOO.util.Dom;this._interestList={};var E={};for(var A=0,D=C.get("chkInt0");D!=null;A++,D=C.get("chkInt"+A)){if(D.checked){if(D.value.indexOf("|")>-1){var B=D.value.split("|");this._interestList[B[0]]=B[1];}else{this._interestList[D.value]=D.title;E[A]=D.value;}}}YAHOO.My.Instrumentation.fireUltBeacon({"t":"nlinks","int":E});},showInterestsNotice:function(A){var B=YAHOO.util.Event;A=B.getEvent(A);B.preventDefault(A);YAHOO.util.Dom.setStyle("nux-interests-notice","visibility","visible");},showInterestsStep:function(A){YAHOO.My.Instrumentation.fireUltBeacon({"t":"nlinks","cat":"int"});var C=YAHOO.util.Event;var B=YAHOO.My.Application;if(window.event||A){A=C.getEvent(A);if(A){C.preventDefault(A);}}if(YAHOO.My.UI.isSpotlightVisible()){YAHOO.My.UI.hideSpotlight();YAHOO.My.UI.shadePage();}this.showStep({cssClass:"step2",dialogElement:"nux-intstep-dlg",target:"nux-step2",offsetY:0,pos:"bl",dialogWidth:"24em",stepNum:2});this.initInterestCheckboxes();},handleDoneClick:function(A){YAHOO.My.Instrumentation.fireUltBeacon({"t":"nlinks","cat":"done"});var B=YAHOO.util.Event;if(window.event||A){A=B.getEvent(A);if(A){B.preventDefault(A);}}this.showLastStepProgress();if(this._atmMode){this.savePageViaATM(true,true);}else{this.savePage(true,true);}},handleSavePageFailure:function(B,A){location.href=A.data.errorurl;},handleSavePageSuccess:function(B,A){if(B.pageRefresh){YAHOO.My.PortalMgr.reloadPage(YAHOO.My.Application.getProperty("currentPage"),true);}},hideLastStepProgress:function(){YUD.setStyle("nux-donestep-progress","display","none");YUD.setStyle("nux-donestep-main","display","block");},savePage:function(A,B){var D={optype:"init"};if(A){D["interestList"]=this._interestList;}var C=YAHOO.My.RequestFactory.createRequestObjById("save","inituser","myy",D);var E={success:this.handleSavePageSuccess,failure:this.handleSavePageFailure,scope:this,argument:{pageRefresh:B}};YAHOO.My.ArcadeRequest.makeRequest(E,C);},savePageViaATM:function(A,B){var C=YAHOO.My.RequestFactory.createRequestObjFromForm("atm-form");if(A){C["interestList"]=this._interestList;}var D={success:this.handleSavePageSuccess,failure:this.handleSavePageFailure,scope:this,argument:{pageRefresh:B}};YAHOO.My.ArcadeRequest.makeRequest(D,C);},showLastStepProgress:function(){YUD.setStyle("nux-donestep-progress","display","block");YUD.setStyle("nux-donestep-main","display","none");},showLastStep:function(A){var C=YAHOO.util.Event;var B=YAHOO.My.Application;if(window.event||A){A=C.getEvent(A);if(A){C.preventDefault(A);}}this.saveInterestCheckboxes();YAHOO.My.UI.showSpotlight("my-personalize");this.showStep({cssClass:"step3",dialogElement:"nux-donestep-dlg",target:"my-personalize",pos:"rc",dialogWidth:"24em",stepNum:3});},hideTryThisDialog:function(){this.tooltip.hide();},showTryThisDialog:function(){var G=YAHOO.util.Dom;var C=YAHOO.My.Application;var A=G.get("nux-trythis-dlg");var F=G.get("my-personalize");var B=G.getXY(F);var E=0;var D=0;E=B[0]+F.offsetWidth;D=B[1]+Math.round(F.offsetHeight/2);this.tooltip.show([E,D],{pos:["rc"],width:"23em"},A);}};YAHOO.util.Event.addListener(window,"load",YAHOO.My.Nux.init,YAHOO.My.Nux,true);/* Copyright (c) 2008, Yahoo! Inc.  All rights reserved. */
