var EXANIMO=EXANIMO||{};(function(){EXANIMO.managers=EXANIMO.managers||{};var f=false;var l;var g;var e;var a;var j=false;var c="EXANIMO-managers-StateManager-iFrame";var h;function i(){return EXANIMO.managers.StateManager}var g=navigator.appName.indexOf("Microsoft Internet")!=-1?"IFRAME":navigator.userAgent.indexOf("Safari")!=-1?"LINK":"HASH";function m(){return document.location.href.split("#")[1]||i().defaultStateID}function k(){var p=["object","embed"];for(var q=0;q<p.length;q++){var n=document.getElementsByTagName(p[q]);for(var o=0;o<n.length;o++){if(n[o].dispatchStateChangeEvents){return n[o]}}}}function d(p,n){p=p||i().defaultStateID;if(!e){h={id:p};var o;if(o=i().onstatechange){h.type="stateChange";o(h)}if(n){if(o=i().onstateset){h.type="stateSet";o(h)}}else{if(o=i().onstaterevisit){h.type="stateRevisit";o(h)}}h=null}else{if(!n){e.dispatchStateChangeEvents(p)}}}var b=(function(){switch(g){case"HASH":return function(n){document.location.hash=n==i().defaultStateID?"#":n;a=n};case"IFRAME":return function(o){j=true;var n=document.getElementById(c);frames[c].document.open();frames[c].document.write('<script>parent.document.location.hash = "'+(o==i().defaultStateID?"#":o)+'"; /* Wait for IE to impose its title before setting ours. */ setTimeout( function(){ parent.EXANIMO.managers.StateManager._updateIFrame("'+o+'"); }, 0);<\/script>');frames[c].document.close()};case"LINK":return function(p){j=true;var o=document.createElement("a");o.setAttribute("href",p==i().defaultStateID?"#":"#"+p);var n=document.createEvent("MouseEvents");n.initEvent("click",true,true);o.dispatchEvent(n);document.location.EXANIMO.managers.StateManager.stateList.push(p)}}})();EXANIMO.managers.StateManager={CHECK_RATE:100,onstatechange:null,onstateset:null,onstaterevisit:null,DEFAULT_STATE:"defaultState",defaultStateID:"defaultState",initialize:function(q){if(f){return}f=true;e=q==true?k():q;switch(g){case"HASH":a=m()==i().defaultStateID?i().defaultStateID:null;var o=function(){var t=m();if(t!=a){a=t;d(t)}};l=setInterval(o,i().CHECK_RATE);break;case"IFRAME":j=true;var p=document.createElement("iframe");p.setAttribute("src","about:blank");p.setAttribute("name",c);p.setAttribute("id",c);p.style.visibility="hidden";p.style.width="0";p.style.height="0";p.style.position="absolute";p.style.overflow="hidden";document.body.appendChild(p);var s=m();if(s!=i().defaultStateID){setTimeout(function(){d(s)},0)}frames[c].document.open();if(s){frames[c].document.write('<script>parent.document.location.hash = "'+(s==i().defaultStateID?"":s)+'"; parent.EXANIMO.managers.StateManager._updateIFrame("'+s+'");<\/script>')}else{frames[c].document.write('<script>parent.document.location.hash = ""; parent.EXANIMO.managers.StateManager._updateIFrame();<\/script>')}frames[c].document.close();break;case"LINK":document.location.EXANIMO=document.location.EXANIMO||{};document.location.EXANIMO.managers=document.location.EXANIMO.managers||{};document.location.EXANIMO.managers.StateManager=document.location.EXANIMO.managers.StateManager||{};var r=document.location.EXANIMO.managers.StateManager;window.onunload=function(){r.oldHistoryLength=-1};if(r.deepLink&&r.deepLink!=i().defaultStateID){r.oldHistoryLength=-1;r.deepLink=null}if(typeof r.stateList=="undefined"){r.stateList=[m()||i().defaultStateID];r.deepLink=r.stateList[0];r.offset=history.length-1;while(r.offset){r.stateList.unshift(null);r.offset--}delete r.offset;r.oldHistoryLength=document.location.hash?-1:history.length}var n=function(){var u=document.location.EXANIMO.managers.StateManager;if(j){j=false;u.oldHistoryLength=history.length;return}if(history.length!=u.oldHistoryLength){var t=u.stateList[history.length-1];d(t);u.oldHistoryLength=history.length}};l=setInterval(n,i().CHECK_RATE);break}},setState:function(o,n){if(n){i().setTitle(n)}if(h){return}b(o);d(o,true)},setTitle:function(n){window.document.title=n||" "},_updateIFrame:function(n){if(!j){d(n)}j=false}}})();
