(function(){var window=this,undefined,$=YAHOO.util.Dom.get,$E=YAHOO.util.Event,$D=YAHOO.util.Dom,$C=YAHOO.util.Connect,Walkthrough=window.Walkthrough=function(scriptPath,walkfile){this._scriptPath=scriptPath.replace(/\/$/,"")+"/"||"";this._tour;this._onStep=0;this._listeners=[];this._running=false;this.events={};this.events.loaded=new YAHOO.util.CustomEvent("loaded",this);this.events.error=new YAHOO.util.CustomEvent("error",this);this.events.completed=new YAHOO.util.CustomEvent("completed",this);if(walkfile){this.load(walkfile)}};Walkthrough.prototype={load:function(walkfile){if(this._running){this.reset()}var tour;if(typeof walkfile=="string"){this._tour=null;YAHOO.util.Connect.asyncRequest("GET",this._scriptPath+walkfile,{success:function(o){var tour=YAHOO.lang.JSON.parse(o.responseText);this.load(tour)},failure:function(o){this.events.error.fire(o)},scope:this});return }else{tour=walkfile}var rtn=validateTour(tour);if(rtn.result){this._tour=tour;this.events.loaded.fire()}else{console.log(rtn.error);return false}return true},start:function(){var tour=this._tour;if(!tour||this._running){return false}console.log("Running Tour",tour.name);this._running=true;for(var i=0;i<tour.events.length;i++){var event=tour.events[i];if(event.step){var step=event.step;this.addListener(event,function(){this.jumpToStep(step)},true)}else{if(event.reset){this.addListener(event,this.reset,true)}}}this.runStep(tour.steps[this._onStep])},reset:function(){console.log("Resetting Tour");this.clearListeners(true);this._playing=false;this._onStep=0;if(this._tour.reset){this.runStep(this._tour.reset)}this._running=false;return true},nextStep:function(){var step=this._tour.steps[++this._onStep];if(!step){this.events.completed.fire();return this.reset()}return this.runStep(step)},prevStep:function(){var step=this._tour.steps[this._onStep-1];if(!step){return false}--this._onStep;return this.runStep(step)},jumpToStep:function(num){var step=this._tour.steps[num];if(!step){return false}this._onStep=num;return this.runStep(step)},runStep:function(step){for(var i=0;i<step.changes.length;i++){var elm,change=step.changes[i],parent=change.parent||document.body,elmStr=change.elm;if(!(elm=$(elmStr))){elm=document.createElement("DIV");elm.id=elmStr;$(parent).appendChild(elm)}for(var j in change.style){$D.setStyle(elm,j,change.style[j])}if(change.focus){$(elm).focus()}}if(step.next){this.addListener(step.next,this.doNextStep)}if(step.prev){this.addListener(step.prev,this.doPrevStep)}return true},addListener:function(o,callback,sticky){var sticky=!!sticky;if(o.elm&&o.on){if($E.on(o.elm,o.on,callback,this,true)){this._listeners.push({elm:o.elm,on:o.on,callback:callback,sticky:sticky})}}else{if(o.event){var objRef=o.event.replace(/(?:\(.*\))|(?:var )|(?:=)|(?:\s*)/ig,"");eval("var obj = "+objRef);obj.subscribe(callback,this,true);this._listeners.push({event:obj,callback:callback,sticky:sticky})}else{if(o.key){var kl=new YAHOO.util.KeyListener(document,{keys:o.key},{fn:callback,scope:this,correctScope:true},"keyup");kl.enable();this._listeners.push({keyListener:kl,sticky:sticky})}}}},clearListeners:function(clearSticky){var o,clearSticky=!!clearSticky,stickyListeners=[];while(o=this._listeners.shift()){if(!clearSticky&&o.sticky){stickyListeners.push(o);continue}if(o.elm&&o.on){$E.removeListener(o.elm,o.on,o.callback)}else{if(o.event){o.event.unsubscribe(o.callback)}else{if(o.keyListener){o.keyListener.disable()}}}}this._listeners=stickyListeners},doNextStep:function(e,o){this.clearListeners();this.nextStep()},doPrevStep:function(e,o){this.clearListeners();this.prevStep()}};function validateTour(tour){if(!((typeof tour=="object")&&tour.name&&tour.steps&&tour.steps.length)){return{result:false,error:"Invalid or missing properties."}}return{result:true}}function now(){return +new Date}})();