(function(){if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt){var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}for(;from<len;from++){if(from in this&&this[from]===elt){return from;}}return -1;};}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(elt){var len=this.length;var from=Number(arguments[1]);if(isNaN(from)){from=len-1;}else{from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}else{if(from>=len){from=len-1;}}}for(;from>-1;from--){if(from in this&&this[from]===elt){return from;}}return -1;};}if(!Array.prototype.every){Array.prototype.every=function(fun){if(typeof (fun)!="function"){throw new TypeError();}var len=this.length;var thisp=arguments[1];for(var i=0;i<len;i++){if(i in this&&!fun.call(thisp,this[i],i,this)){return false;}}return true;};}if(!Array.prototype.filter){Array.prototype.filter=function(fun){if(typeof (fun)!="function"){throw new TypeError();}var len=this.length;var res=new Array();var thisp=arguments[1];for(var i=0;i<len;i++){if(i in this){var val=this[i];if(fun.call(thisp,val,i,this)){res.push(val);}}}return res;};}if(!Array.prototype.forEach){Array.prototype.forEach=function(fun){if(typeof (fun)!="function"){throw new TypeError();}var len=this.length;var thisp=arguments[1];for(var i=0;i<len;i++){if(i in this){fun.call(thisp,this[i],i,this);}}};}if(!Array.prototype.map){Array.prototype.map=function(fun){if(typeof (fun)!="function"){throw new TypeError();}var len=this.length;var res=new Array(len);var thisp=arguments[1];for(var i=0;i<len;i++){if(i in this){res[i]=fun.call(thisp,this[i],i,this);}}return res;};}if(!Array.prototype.some){Array.prototype.some=function(fun){if(typeof (fun)!="function"){throw new TypeError();}var len=this.length;var thisp=arguments[1];for(var i=0;i<len;i++){if(i in this&&fun.call(thisp,this[i],i,this)){return true;}}return false;};}})();(function(){if(!String.prototype.trim){String.prototype.trim=function(){var s=this.replace(/^\s\s*/,"");var ws=/\s/;var i=s.length;while(ws.test(s.charAt(--i))){}return s.slice(0,i+1);};}if(!String.prototype.startsWith){String.prototype.startsWith=function(s){return(this.length>=s.length&&this.substring(0,s.length)===s);};}if(!String.prototype.endsWith){String.prototype.endsWith=function(s){return(this.length>=s.length&&this.substring(this.length-s.length)===s);};}if(!Array.prototype.lastObject){Array.prototype.lastObject=function(){return this[this.length-1];};}if(!Array.prototype.removeObject){Array.prototype.removeObject=function(obj){var n=this.length;for(var i=(n-1);i>=0;i--){if(this[i]===obj){this.splice(i,1);}}return(this.length===n)?null:obj;};}})();if(window.site9){throw"site9 Core loaded more than once";}(function(){var BOOLEAN_TYPE=typeof (true),NUMBER_TYPE=typeof (0),STRING_TYPE=typeof (""),FUNCTION_TYPE=typeof (parseInt),UNDEFINED_TYPE=typeof (window["undefined"]),OBJECT_TYPE=typeof ({}),NULL_TYPE="null",ARRAY_TYPE="array",NODE_TYPE="node";function typeOf(obj){var rawType=typeof (obj);switch(rawType){case BOOLEAN_TYPE:case NUMBER_TYPE:case STRING_TYPE:case FUNCTION_TYPE:case UNDEFINED_TYPE:return rawType;case OBJECT_TYPE:if(obj===null){return NULL_TYPE;}else{if((obj instanceof Array)){return ARRAY_TYPE;}else{if((typeof (obj.nodeName)==="string"&&typeof (obj.nodeType)==="number")||(obj instanceof Node)){return NODE_TYPE;}else{return OBJECT_TYPE;}}}}throw"Unexpected object type: "+rawType;}function isa(obj,type){return(typeOf(obj)===type);}var HTML_PARSER=jQuery("<div/>");var awakeListeners=[];var sleepListeners=[];var isAwake=false;window.site9={TYPES:{BOOLEAN:BOOLEAN_TYPE,NUMBER:NUMBER_TYPE,STRING:STRING_TYPE,FUNCTION:FUNCTION_TYPE,UNDEFINED:UNDEFINED_TYPE,OBJECT:OBJECT_TYPE,NULL:NULL_TYPE,ARRAY:ARRAY_TYPE,NODE:NODE_TYPE},typeOf:typeOf,isa:isa,locateCurrentEl:function(){var el=document;while(el.lastChild){el=el.lastChild;}while(el.nodeType!=1){el=el.parentNode;}while(el.tagName=="SCRIPT"){el=el.parentNode;}return el;},escapeHTML:function(str){if(str){str=str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");}return str;},unescapeHTML:function(str){if(str){str=HTML_PARSER.html(str).text();}return str;},escapeHtmlCommentJson:function(str){return(str&&str.split("--").join("-\\u002D"));},awake:function(document,rootEl){if(isAwake){throw"IllegalStateException: This page is already awake";}isAwake=true;document=(document||window.document);rootEl=(rootEl||document.body);this._notifyListeners({target:document,rootEl:rootEl},awakeListeners);awakeListeners.locked=true;if(site9.DomMgr){site9.DomMgr.domAdded(rootEl);}},sleep:function(document,rootEl){if(!(isAwake)){throw"IllegalStateException: This page is already asleep";}isAwake=false;document=(document||window.document);rootEl=(rootEl||document.body);if(site9.DomMgr){site9.DomMgr.domRmved(rootEl);}this._notifyListeners({target:document,rootEl:rootEl},sleepListeners);sleepListeners.locked=true;},addAwakeListener:function(handler,scope){if(awakeListeners.locked){throw"IllegalStateException: Cannot add an awake listener after awake() has been called. handler: "+handler+", scope: "+scope;}this._addListener(handler,scope,awakeListeners,"<site9.SleepMgr>");},removeAwakeListener:function(handler,scope){this._removeListener(handler,scope,awakeListeners,"<site9.SleepMgr>");},addSleepListener:function(handler,scope){if(awakeListeners.locked){console.warn("Adding sleep listener after awake() has been called. handler: ",handler,", scope: ",scope);}if(sleepListeners.locked){throw"IllegalStateException: Cannot add a sleep listener after sleep() has been called. handler: "+handler+", scope: "+scope;}this._addListener(handler,scope,sleepListeners,"<site9.SleepMgr>");},removeSleepListener:function(handler,scope){this._removeListener(handler,scope,sleepListeners,"<site9.SleepMgr>");},_addListener:function(handler,scope,list,_obj){if(!(handler)){throw"IllegalArgumentException: A handler function is required";}scope=scope||window;if(this._removeListener(handler,scope,list,_obj)){}list.push({scope:scope,handler:handler});},_removeListener:function(handler,scope,list,_obj){if(!(handler)){throw"IllegalArgumentException: A handler function is required";}scope=scope||window;var count=0;for(var i=list.length-1;i>=0;i--){if(list[i].scope===scope&&list[i].handler===handler){delete list[i].scope;delete list[i].handler;list.splice(i,1);count++;}}return count;},_notifyListeners:function(event,list){for(var i=0,n=list.length;i!==n;i++){try{list[i].handler.call(list[i].scope,event);}catch(e){console.error(e);}}},_clearListeners:function(list){for(var i=0;i<list.length;i++){delete list[i].scope;delete list[i].handler;}if(list.splice){list.splice(0,list.length);}}};jQuery(function(){site9.awake();jQuery(window).unload(function(){site9.sleep();site9._clearListeners(awakeListeners);site9._clearListeners(sleepListeners);});});})();(function(){try{site9.StateManager=(window.top.site9&&window.top.site9.StateManager);if(site9.StateManager){return ;}}catch(e){console.error(e);}var quirks={autoDecodesHash:(jQuery.browser.mozilla)};var listenerMap={};site9.StateManager={toString:function(){return"<site9.StateManager>";},addListener:function(key,handler,scope){var list=listenerMap[key];if(!list){list=listenerMap[key]=[];}site9._addListener(handler,scope,list,this);},removeListener:function(key,handler,scope){var list=listenerMap[key];if(list){site9._removeListener(handler,scope,list,this);}},pullStatesFromQuery:function(){var q=window.location.search;if(q.length<2){return ;}q=q.substring(1).split("&");var oldLength=q.length;for(var i=0;i<arguments.length;i++){this._pullStateFromQuery(arguments[i],q);}if(q.length!==oldLength){window.location.search=(q.length?("?"+q.join("&")):"");}},copyState:function(node,attr){attr=(attr||"href");node[attr]=node[attr].replace(/(#.*)|$/,this._getHash());},getState:function(key){key=encodeURIComponent(key);var hash=this._getHash();var matchExp=new RegExp(key+"=([^&]*)");var matches=hash.match(matchExp);if(matches&&matches.length==2){return decodeURIComponent(matches[1]);}},setState:function(key,value){var event={type:"statechange",key:key,from:(this.getState(key)||null),to:(value||null)};if(event.from===event.to){return ;}var hash=this._getHash();key=encodeURIComponent(key);value=event.to;var matchExp=new RegExp("([&]?)("+key+"=[^&]*)([&]?)");var matches=hash.match(matchExp);if(matches&&matches.length){var replaceString=matches[1]+matches[2];if(matches[1]==""){replaceString=replaceString+matches[3];}hash=hash.replace(replaceString,"");}if(value){value=encodeURIComponent(value);if(hash!="#"){hash+="&";}hash+=(key+"="+value);}this._setHash(hash);var list=listenerMap[key];if(list){site9._notifyListeners(event,list);}},migrateState:function(oldKey,newKey){var newValue=this.getState(newKey);if(newValue===undefined){this.setState(newKey,this.getState(oldKey));}this.setState(oldKey,null);},_getHash:function(){var h=(window.location.hash||"#");if(quirks.autoDecodesHash){h="#"+encodeURIComponent(h.substring(1));h=h.replace(new RegExp(encodeURIComponent("="),"g"),"=");h=h.replace(new RegExp(encodeURIComponent("&"),"g"),"&");}return h;},_setHash:function(hash){var url=window.location.href.replace(/#.*$/,"")+hash;window.location.replace(url);},_pullStateFromQuery:function(key,q){for(var i=q.length-1;i>=0;i--){var prefix=(encodeURIComponent(key)+"=");if(q[i].startsWith(prefix)){this.setState(key,decodeURIComponent(q[i].substring(prefix.length)));q.splice(i,1);}}}};jQuery(window).unload(function(){for(var key in listenerMap){site9._clearListeners(listenerMap);delete listenerMap[key];}});})();
