
var EXANIMO=EXANIMO||{};(function()
{EXANIMO.managers=EXANIMO.managers||{};var _initialized=false;var _checkInterval;var _method;var _swf;var _oldStateID;var _preventPageRefresh=false;var _iframeID='EXANIMO-managers-StateManager-iFrame';var _e;function _self()
{return EXANIMO.managers.StateManager;}
var _method=navigator.appName.indexOf('Microsoft Internet')!=-1?'IFRAME':navigator.userAgent.indexOf('Safari')!=-1?'LINK':'HASH';function _getStateID()
{return document.location.href.split('#')[1]||_self().defaultStateID;};function _getSWF()
{var tags=['object','embed'];for(var i=0;i<tags.length;i++)
{var a=document.getElementsByTagName(tags[i]);for(var j=0;j<a.length;j++)
{if(a[j].dispatchStateChangeEvents)
{return a[j];}}}};function _dispatchEvent(stateID,manual)
{stateID=stateID||_self().defaultStateID;if(!_swf)
{_e={id:stateID};var f;if(f=_self().onstatechange)
{_e.type='stateChange';f(_e);}
if(manual)
{if(f=_self().onstateset)
{_e.type='stateSet';f(_e);}}
else
{if(f=_self().onstaterevisit)
{_e.type='stateRevisit';f(_e);}}
_e=null;}
else if(!manual)
{_swf.dispatchStateChangeEvents(stateID);}};var _setHash=(function()
{switch(_method)
{case'HASH':return function(stateID)
{document.location.hash=stateID==_self().defaultStateID?'#':stateID;_oldStateID=stateID;};case'IFRAME':return function(stateID)
{_preventPageRefresh=true;var iframe=document.getElementById(_iframeID);frames[_iframeID].document.open();frames[_iframeID].document.write('<script>parent.document.location.hash = "'+(stateID==_self().defaultStateID?'#':stateID)+'"; /* Wait for IE to impose its title before setting ours. */ setTimeout( function(){ parent.EXANIMO.managers.StateManager._updateIFrame("'+stateID+'"); }, 0);</script>');frames[_iframeID].document.close();};case'LINK':return function(stateID)
{_preventPageRefresh=true;var a=document.createElement('a');a.setAttribute('href',stateID==_self().defaultStateID?'#':'#'+stateID);var evt=document.createEvent('MouseEvents');evt.initEvent('click',true,true);a.dispatchEvent(evt);document.location.EXANIMO.managers.StateManager.stateList.push(stateID);};}})();EXANIMO.managers.StateManager={CHECK_RATE:100,onstatechange:null,onstateset:null,onstaterevisit:null,DEFAULT_STATE:'defaultState',defaultStateID:'defaultState',initialize:function(swf)
{if(_initialized)return;_initialized=true;_swf=swf==true?_getSWF():swf;switch(_method)
{case'HASH':_oldStateID=_getStateID()==_self().defaultStateID?_self().defaultStateID:null;var checkForHashChange=function()
{var stateID=_getStateID();if(stateID!=_oldStateID)
{_oldStateID=stateID;_dispatchEvent(stateID)}}
_checkInterval=setInterval(checkForHashChange,_self().CHECK_RATE);break;case'IFRAME':_preventPageRefresh=true;var iframe=document.createElement('iframe');iframe.setAttribute('src','about:blank');iframe.setAttribute('name',_iframeID);iframe.setAttribute('id',_iframeID);iframe.style.visibility='hidden';iframe.style.width='0';iframe.style.height='0';iframe.style.position='absolute';iframe.style.overflow='hidden';document.body.appendChild(iframe);var stateID=_getStateID();if(stateID!=_self().defaultStateID)
{setTimeout(function()
{_dispatchEvent(stateID)},0);}
frames[_iframeID].document.open();if(stateID)
frames[_iframeID].document.write('<script>parent.document.location.hash = "'+(stateID==_self().defaultStateID?'':stateID)+'"; parent.EXANIMO.managers.StateManager._updateIFrame("'+stateID+'");</script>');else
frames[_iframeID].document.write('<script>parent.document.location.hash = ""; parent.EXANIMO.managers.StateManager._updateIFrame();</script>');frames[_iframeID].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 loc=document.location.EXANIMO.managers.StateManager;window.onunload=function()
{loc.oldHistoryLength=-1;}
if(loc.deepLink&&loc.deepLink!=_self().defaultStateID)
{loc.oldHistoryLength=-1;loc.deepLink=null;}
if(typeof loc.stateList=='undefined')
{loc.stateList=[_getStateID()||_self().defaultStateID];loc.deepLink=loc.stateList[0];loc.offset=history.length-1;while(loc.offset)
{loc.stateList.unshift(null);loc.offset--;}
delete loc.offset;loc.oldHistoryLength=document.location.hash?-1:history.length;}
var checkForHistoryLengthChange=function()
{var loc=document.location.EXANIMO.managers.StateManager;if(_preventPageRefresh)
{_preventPageRefresh=false;loc.oldHistoryLength=history.length;return;}
if(history.length!=loc.oldHistoryLength)
{var stateID=loc.stateList[history.length-1];_dispatchEvent(stateID)
loc.oldHistoryLength=history.length;}}
_checkInterval=setInterval(checkForHistoryLengthChange,_self().CHECK_RATE);break;}},setState:function(stateID,title)
{if(title)_self().setTitle(title);if(_e)return;_setHash(stateID);_dispatchEvent(stateID,true);},setTitle:function(title)
{window.document.title=title||' ';},_updateIFrame:function(stateID)
{if(!_preventPageRefresh)
{_dispatchEvent(stateID);}
_preventPageRefresh=false;}}})();
