/*
 * SWFAddress 2.5: Deep linking for Flash and Ajax <http://www.asual.com/swfaddress/>
 *
 * SWFAddress is (c) 2006-2010 Rostislav Hristov and contributors
 * This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
 *
 */
if(typeof asual=="undefined")var asual={};if(typeof asual.util=="undefined")asual.util={};asual.util.Browser=new (function(){var g=navigator.userAgent.toLowerCase(),n=/webkit/.test(g),m=/opera/.test(g),q=/msie/.test(g)&&!/opera/.test(g),w=/mozilla/.test(g)&&!/(compatible|webkit)/.test(g),y=parseFloat(q?g.substr(g.indexOf("msie")+4):(g.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1]);this.toString=function(){return"[class Browser]"};this.getVersion=function(){return y};this.isMSIE=function(){return q};this.isSafari=function(){return n};this.isOpera=function(){return m};this.isMozilla=function(){return w}});asual.util.Events=new (function(){var g=window,n=document,m=[],q=asual.util,w=q.Browser,y=w.isMSIE(),D=w.isSafari();this.toString=function(){return"[class Events]"};this.addListener=function(i,k,u){m.push({o:i,t:k,l:u});if(!(k=="DOMContentLoaded"&&(y||D)))if(i.addEventListener)i.addEventListener(k,u,false);else i.attachEvent&&i.attachEvent("on"+k,u)};this.removeListener=function(i,k,u){for(var E=0,F;F=m[E];E++)if(F.o==i&&F.t==k&&F.l==u){m.splice(E,1);break}if(!(k=="DOMContentLoaded"&&(y||D)))if(i.removeEventListener)i.removeEventListener(k,u,false);else i.detachEvent&&i.detachEvent("on"+k,u)};var R=function(){for(var i=0,k;k=m[i];i++)k.t!="DOMContentLoaded"&&q.Events.removeListener(k.o,k.t,k.l)};w=function(){if(n.readyState=="interactive"){function i(){n.detachEvent("onstop",i);R()}n.attachEvent("onstop",i);g.setTimeout(function(){n.detachEvent("onstop",i)},0)}};if(y||D)(function(){try{if(y&&n.body||!/loaded|complete/.test(n.readyState))n.documentElement.doScroll("left")}catch(i){return setTimeout(arguments.callee,0)}for(var k=0,u;u=m[k];k++)u.t=="DOMContentLoaded"&&u.l.call(null)})();y&&g.attachEvent("onbeforeunload",w);this.addListener(g,"unload",R)});asual.util.Functions=new (function(){this.toString=function(){return"[class Functions]"};this.bind=function(g,n){for(var m=2,q,w=[];q=arguments[m];m++)w.push(q);return function(){return g.apply(n,w)}}});var SWFAddressEvent=function(g){this.toString=function(){return"[object SWFAddressEvent]"};this.type=g;this.target=[SWFAddress][0];this.value=SWFAddress.getValue();this.path=SWFAddress.getPath();this.pathNames=SWFAddress.getPathNames();this.parameters={};g=SWFAddress.getParameterNames();for(var n=0,m=g.length;n<m;n++)this.parameters[g[n]]=SWFAddress.getParameter(g[n]);this.parameterNames=g};SWFAddressEvent.INIT="init";SWFAddressEvent.CHANGE="change";SWFAddressEvent.INTERNAL_CHANGE="internalChange";SWFAddressEvent.EXTERNAL_CHANGE="externalChange";var SWFAddress=new (function(){var g=function(){var a=f.href.indexOf("#");return a!=-1?V(K(m(f.href.substr(a+1),t))):""},n=function(a,b){if(j.strict)a=b?a.substr(0,1)!="/"?"/"+a:a:a==""?"/":a;return a},m=function(a,b){if(j.crawlable&&b)return(a!=""?"!":"")+a;return a.replace(/^\!/,"")},q=function(a,b){var e,c=a.ownerDocument;if(c&&c.defaultView&&c.defaultView.getComputedStyle)e=c.defaultView.getComputedStyle(a,"")[b];else if(a.currentStyle)e=a.currentStyle[b];return parseInt(e,10)},w=function(a){for(var b=0,e=a.childNodes.length,c,r;b<e;b++){if(a.childNodes[b].src)c=String(a.childNodes[b].src);if(r=w(a.childNodes[b]))c=r}return c},y=function(a,b){for(var e=0;e<b.length;e++)if(a===b[e])return e;return-1},D=function(){if(!_silent){var a=g(),b=_value!=a;if(z&&s<523){if(_length!=A.length){_length=A.length;if(typeof _stack[_length-1]!=h)_value=_stack[_length-1];k.call(this,t)}}else if(b)if(B&&s<7)f.reload();else{B&&s<8&&j.history&&C(_html,50);_value=a;k(t)}}},R=function(){if(_popup.length>0){window.popup=window.open(_popup[0],_popup[1],eval(_popup[2]));typeof _popup[3]!=h&&eval(_popup[3])}_popup=[]},i=function(a){this.dispatchEvent(new SWFAddressEvent(a));a=a.substr(0,1).toUpperCase()+a.substr(1);typeof this["on"+a]==L&&this["on"+a]()},k=function(a){for(var b=0,e,c,r=SWFAddress.getValue();e=_ids[b];b++)if(c=document.getElementById(e))if(c.parentNode&&typeof c.parentNode.so!=h)c.parentNode.so.call("setSWFAddressValue",r,a);else{if(!(c&&typeof c.setSWFAddressValue!=h)){e=c.getElementsByTagName("object");c=c.getElementsByTagName("embed");c=e[0]&&typeof e[0].setSWFAddressValue!=h?e[0]:c[0]&&typeof c[0].setSWFAddressValue!=h?c[0]:null}c&&c.setSWFAddressValue(r,a)}else if(c=document[e])typeof c.setSWFAddressValue!=h&&c.setSWFAddressValue(r,a);i.call(this,SWFAddressEvent.CHANGE);i.call(this,a?SWFAddressEvent.INTERNAL_CHANGE:SWFAddressEvent.EXTERNAL_CHANGE);C(G.bind(u,this),10)},u=function(){if(j.tracker!=="null"&&j.tracker!==null){var a=x[j.tracker],b=(f.pathname+(SWFAddress?SWFAddress.getValue():"")).replace(/\/\//,"/").replace(/^\/$/,"");if(typeof a==L)a(b);else if(typeof urchinTracker==L)urchinTracker(b);else if(typeof pageTracker!=h&&typeof pageTracker._trackPageview==L)pageTracker._trackPageview(b);else typeof _gaq!=h&&typeof _gaq.push==L&&_gaq.push(["_trackPageview",b])}},E=function(){var a="javascript:false;document.open();document.writeln('<html><head><title>"+d.title+"</title><script>var "+v+' = "'+g()+(d.domain!=f.host?'";document.domain="'+d.domain:"")+"\";<\/script></head></html>');document.close();";if(s<7)o.src=a;else o.contentWindow.location.replace(a)},F=function(){var a=o.contentWindow;_value=typeof a[v]!=h?a[v]:"";if(_value!=g()){k.call(SWFAddress,t);f.hash=m(_value,l)}},W=function(){if(M&&_qi!=-1){var a,b=M.substr(_qi+1).split("&");for(H=0;H<b.length;H++){a=b[H].split("=");if(/^(autoUpdate|crawlable|history|strict|wrap)$/.test(a[0]))j[a[0]]=isNaN(a[1])?/^(true|yes)$/i.test(a[1]):parseInt(a[1],10)!==0;if(/^tracker$/.test(a[0]))j[a[0]]=a[1]}M=null}},U=function(){if(!_loaded){_loaded=l;W();if(j.wrap){var a=d.createElement("div");for(a.style.padding=q(d.body,"marginTop")+q(d.body,"paddingTop")+"px "+(q(d.body,"marginRight")+q(d.body,"paddingRight"))+"px "+(q(d.body,"marginBottom")+q(d.body,"paddingBottom"))+"px "+(q(d.body,"marginLeft")+q(d.body,"paddingLeft"))+"px";d.body.firstChild;)a.appendChild(d.body.firstChild);d.body.appendChild(a);a=d.createElement("div");a.id=v;a.style.height="100%";a.style.overflow="auto";if(z&&x.statusbar.visible&&!/chrome/i.test(navigator.userAgent))a.style.resize="both";a.appendChild(d.body.firstChild);d.body.appendChild(a);a=[d.getElementsByTagName("html")[0],d.body];for(var b=0;b<a.length;b++){a[b].style.height="100%";a[b].style.margin=0;a[b].style.padding=0;a[b].style.overflow="hidden"}if(z){a=d.createElement("style");a.type="text/css";b=d.createTextNode("#"+v+"::-webkit-resizer { background-color: #fff; }");a.appendChild(b);d.getElementsByTagName("head")[0].appendChild(a)}}if(B&&s<8){a=d.getElementsByTagName("frameset")[0];o=d.createElement((a?"":"i")+"frame");if(a){a.insertAdjacentElement("beforeEnd",o);a[a.cols?"cols":"rows"]+=",0";o.noResize=l;o.frameBorder=o.frameSpacing=0}else{o.style.display="none";o.style.width=o.style.height=0;o.tabIndex=-1;d.body.insertAdjacentElement("afterBegin",o)}C(function(){I.addListener(o,"load",F);typeof o.contentWindow[v]==h&&E()},50)}else if(z){if(s<418){d.body.innerHTML+='<form id="'+v+'" style="position:absolute;top:-9999px;" method="get"></form>';T=d.getElementById(v)}if(typeof f[v]==h)f[v]={};if(typeof f[v][f.pathname]!=h)_stack=f[v][f.pathname].split(",")}C(G.bind(function(){S.Browser.isSafari()&&I.addListener(d.body,"click",R);i.call(this,SWFAddressEvent.INIT);i.call(this,SWFAddressEvent.CHANGE);i.call(this,SWFAddressEvent.EXTERNAL_CHANGE);u.call(this)},this),1);B&&s>7||!B&&"onhashchange"in x?I.addListener(x,"hashchange",G.bind(D,this)):Z(G.bind(D,this),50)}},v="swfaddress",L="function",h="undefined",l=true,t=false,j={autoUpdate:l,crawlable:t,history:l,strict:l,wrap:t},S=asual.util,N=S.Browser,I=S.Events,G=S.Functions,s=N.getVersion(),B=N.isMSIE(),X=N.isMozilla(),Y=N.isOpera(),z=N.isSafari(),J=t,x=function(){try{return top.document!==undefined?top:window}catch(a){return window}}(),d=x.document,A=x.history,f=x.location,Z=setInterval,C=setTimeout,K=decodeURI,V=encodeURI,o,T,M=w(document);_qi=M?M.indexOf("?"):-1;_title=d.title;_length=A.length;_loaded=_silent=t;_juststart=_justset=l;_updating=t;_ref=this;_stack=[];_ids=[];_popup=[];_listeners={};_value=g();if(B){if(d.documentMode&&d.documentMode!=s)s=d.documentMode!=8?7:8;I.addListener(document,"propertychange",function(){if(d.title!=_title&&d.title.indexOf("#"+g())!=-1)d.title=_title})}if(J=X&&s>=1||B&&s>=6||Y&&s>=9.5||z&&s>=312){for(var H=1;H<_length;H++)_stack.push("");_stack.push(_value);if(Y)history.navigationMode="compatible";if(document.readyState=="complete")var $=setInterval(function(){if(SWFAddress){U.call(SWFAddress);clearInterval($)}},50);else{W();I.addListener(document,"DOMContentLoaded",G.bind(U,this));I.addListener(window,"load",G.bind(U,this))}}else if(!J&&f.href.indexOf("#")!=-1||z&&s<418&&f.href.indexOf("#")!=-1&&f.search!=""){d.open();d.write('<html><head><meta http-equiv="refresh" content="0;url='+encodeURI(f.href.substr(0,f.href.indexOf("#")))+'" /></head></html>');d.close()}else u();this.toString=function(){return"[class SWFAddress]"};this.back=function(){A.back()};this.forward=function(){A.forward()};this.up=function(){var a=this.getPath();this.setValue(a.substr(0,a.lastIndexOf("/",a.length-2)+(a.substr(a.length-1)=="/"?1:0)))};this.go=function(a){A.go(a)};this.href=function(a,b){b=typeof b!=h?b:"_self";if(b=="_self")self.location.href=a;else if(b=="_top")f.href=a;else if(b=="_blank")window.open(a);else x.frames[b].location.href=a};this.popup=function(a,b,e,c){try{window.popup=window.open(a,b,eval(e));typeof c!=h&&eval(c)}catch(r){}_popup=arguments};this.getIds=function(){return _ids};this.getId=function(){return _ids[0]};this.setId=function(a){_ids[0]=a};this.addId=function(a){this.removeId(a);_ids.push(a)};this.removeId=function(a){for(var b=0;b<_ids.length;b++)if(a==_ids[b]){_ids.splice(b,1);break}};this.addEventListener=function(a,b){if(typeof _listeners[a]==h)_listeners[a]=[];_listeners[a].push(b)};this.removeEventListener=function(a,b){if(typeof _listeners[a]!=h){for(var e=0,c;c=_listeners[a][e];e++)if(c==b)break;_listeners[a].splice(e,1)}};this.dispatchEvent=function(a){if(this.hasEventListener(a.type)){a.target=this;for(var b=0,e;e=_listeners[a.type][b];b++)e(a);return l}return t};this.hasEventListener=function(a){return typeof _listeners[a]!=h&&_listeners[a].length>0};this.getBaseURL=function(){var a=f.href;if(a.indexOf("#")!=-1)a=a.substr(0,a.indexOf("#"));if(/\/$/.test(a))a=a.substr(0,a.length-1);return a};this.getStrict=function(){return j.strict};this.setStrict=function(a){j.strict=a};this.getAutoUpdate=function(){return j.autoUpdate};this.setAutoUpdate=function(a){j.autoUpdate=a};this.update=function(){_updating=l;this.setValue(_value);_updating=t};this.getHistory=function(){return j.history};this.setHistory=function(a){j.history=a};this.getTracker=function(){return j.tracker};this.setTracker=function(a){j.tracker=a};this.getCrawlable=function(){return j.crawlable};this.setCrawlable=function(a){j.crawlable=a};this.getWrap=function(){return j.wrap};this.setWrap=function(a){j.wrap=a};this.getTitle=function(){return d.title};this.setTitle=function(a){if(!J)return null;if(typeof a!=h){if(a=="null")a="";a=K(a);C(function(){_title=d.title=a;if(_juststart&&o&&o.contentWindow&&o.contentWindow.document){o.contentWindow.document.title=a;_juststart=t}if(!_justset&&X)f.replace(f.href.indexOf("#")!=-1?f.href:f.href+"#");_justset=t},10)}};this.getStatus=function(){return x.status};this.setStatus=function(a){if(!J)return null;if(typeof a!=h){if(a=="null")a="";a=K(a);if(!z){a=n(a!="null"?a:"",l);if(a=="/")a="";if(!/http(s)?:\/\//.test(a)){var b=f.href.indexOf("#");a=(b==-1?f.href:f.href.substr(0,b))+"#"+a}x.status=a}}};this.resetStatus=function(){x.status=""};this.getValue=function(){if(!J)return null;return K(n(_value,t))};this.setValue=function(a){if(!J)return null;if(typeof a!=h){if(a=="null")a="";a=V(K(n(a,l)));if(a=="/")a="";if(!(_value==a&&!_updating)){_justset=l;_value=a;if(j.autoUpdate||_updating){_silent=l;k.call(SWFAddress,l);_stack[A.length]=_value;if(z)if(j.history){f[v][f.pathname]=_stack.toString();_length=A.length+1;if(s<418){if(f.search==""){T.action="#"+m(_value,l);T.submit()}}else if(s<523||_value==""){a=d.createEvent("MouseEvents");a.initEvent("click",l,l);var b=d.createElement("a");b.href="#"+m(_value,l);b.dispatchEvent(a)}else f.hash="#"+m(_value,l)}else f.replace("#"+m(_value,l));else if(_value!=g())if(j.history)f.hash="#"+m(_value,l);else f.replace("#"+m(_value,l));B&&s<8&&j.history&&C(E,50);if(z)C(function(){_silent=t},1);else _silent=t}}}};this.getPath=function(){var a=this.getValue();return a.indexOf("?")!=-1?a.split("?")[0]:a.indexOf("#")!=-1?a.split("#")[0]:a};this.setPath=function(a){var b=this.getQueryString();this.value(a+(b?"?"+b:""))};this.getPathNames=function(){var a=this.getPath(),b=a.split("/");if(a.substr(0,1)=="/"||a.length==0)b.splice(0,1);a.substr(a.length-1,1)=="/"&&b.splice(b.length-1,1);return b};this.getQueryString=function(){var a=this.getValue(),b=a.indexOf("?");if(b!=-1&&b<a.length)return a.substr(b+1)};this.setQueryString=function(a){this.setValue(this.getPath()+(a?"?"+a:""))};this.getParameter=function(a){var b=this.getValue(),e=b.indexOf("?");if(e!=-1){b=b.substr(e+1);e=b.split("&");for(var c=[],r=0;r<e.length;r++){b=e[r].split("=");b[0]==a&&c.push(b[1])}if(c.length!=0)return c.length!=1?c:c[0]}};this.setParameter=function(a,b,e){for(var c=this.getParameterNames(),r=[],O=0;O<c.length;O++){var P=c[O],p=this.getParameter(P);if(typeof p=="string")p=[p];if(P==a)p=b===null||b==""?[]:e?p.concat([b]):[b];for(var Q=0;Q<p.length;Q++)r.push(P+"="+p[Q])}y(a,c)==-1&&r.push(a+"="+b);this.setQueryString(r.join("&"))};this.getParameterNames=function(){var a=this.getValue(),b=a.indexOf("?"),e=[];if(b!=-1){a=a.substr(b+1);if(a!=""&&a.indexOf("=")!=-1){a=a.split("&");for(b=b=0;b<a.length;b++){var c=a[b].split("=")[0];y(c,e)==-1&&e.push(c)}}}return e};this.onExternalChange=this.onInternalChange=this.onChange=this.onInit=null;(function(){var a;if(typeof FlashObject!=h)SWFObject=FlashObject;if(typeof SWFObject!=h&&SWFObject.prototype&&SWFObject.prototype.write){var b=SWFObject.prototype.write;SWFObject.prototype.write=function(){a=arguments;if(this.getAttribute("version").major<8){this.addVariable("$swfaddress",SWFAddress.getValue());(typeof a[0]=="string"?document.getElementById(a[0]):a[0]).so=this}var p;if(p=b.apply(this,a))_ref.addId(this.getAttribute("id"));return p}}if(typeof swfobject!=h){var e=swfobject.registerObject;swfobject.registerObject=function(){a=arguments;e.apply(this,a);_ref.addId(a[0])};var c=swfobject.createSWF;swfobject.createSWF=function(){a=arguments;var p=c.apply(this,a);p&&_ref.addId(a[0].id);return p};var r=swfobject.embedSWF;swfobject.embedSWF=function(){a=arguments;if(typeof a[8]==h)a[8]={};if(typeof a[8].id==h)a[8].id=a[1];r.apply(this,a);_ref.addId(a[8].id)}}if(typeof UFO!=h){var O=UFO.create;UFO.create=function(){a=arguments;O.apply(this,a);_ref.addId(a[0].id)}}if(typeof AC_FL_RunContent!=h){var P=AC_FL_RunContent;AC_FL_RunContent=function(){a=arguments;P.apply(this,a);for(var p=0,Q=a.length;p<Q;p++)a[p]=="id"&&_ref.addId(a[p+1])}}})()});
