/** * SWFAddress 2.4m: Deep linking for Flash and Ajax <http://www.asual.com/swfaddress/> * * SWFAddress is (c) 2006-2009 Rostislav Hristov and contributors * This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> * */if("undefined"==typeof asual)var asual={};"undefined"==typeof asual.util&&(asual.util={});asual.util.Browser=new function(){var b=navigator.userAgent.toLowerCase(),e=/webkit/.test(b),m=/opera/.test(b),k=/msie/.test(b)&&!/opera/.test(b),h=/mozilla/.test(b)&&!/(compatible|webkit)/.test(b),s=parseFloat(k?b.substr(b.indexOf("msie")+4):(b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1]);this.toString=function(){return"[class Browser]"};this.getVersion=function(){return s};this.isMSIE=function(){return k};this.isSafari=function(){return e};this.isOpera=function(){return m};this.isMozilla=function(){return h}};asual.util.Events=new function(){var b=window,e=document,m=[],k=asual.util,h=k.Browser,s=h.isMSIE(),L=h.isSafari();this.toString=function(){return"[class Events]"};this.addListener=function(b,x,e){m.push({o:b,t:x,l:e});"DOMContentLoaded"==x&&(s||L)||(b.addEventListener?b.addEventListener(x,e,!1):b.attachEvent&&b.attachEvent("on"+x,e))};this.removeListener=function(b,e,h){for(var k=0,G;G=m[k];k++)if(G.o==b&&G.t==e&&G.l==h){m.splice(k,1);break}"DOMContentLoaded"==e&&(s||L)||(b.removeEventListener?b.removeEventListener(e,h,!1):b.detachEvent&&b.detachEvent("on"+e,h))};var N=function(){for(var b=0,e;e=m[b];b++)"DOMContentLoaded"!=e.t&&k.Events.removeListener(e.o,e.t,e.l)},h=function(){if("interactive"==e.readyState){var h=function(){e.detachEvent("onstop",h);N()};e.attachEvent("onstop",h);b.setTimeout(function(){e.detachEvent("onstop",h)},0)}};(s||L)&&function(){try{(s&&e.body||!/loaded|complete/.test(e.readyState))&&e.documentElement.doScroll("left")}catch(b){return setTimeout(arguments.callee,0)}for(var h=0,k;k=m[h];h++)"DOMContentLoaded"==k.t&&k.l.call(null)}();s&&b.attachEvent("onbeforeunload",h);this.addListener(b,"unload",N)};asual.util.Functions=new function(){this.toString=function(){return"[class Functions]"};this.bind=function(b,e,m){for(var k=2,h,s=[];h=arguments[k];k++)s.push(h);return function(){return b.apply(e,s)}}};var SWFAddressEvent=function(b){this.toString=function(){return"[object SWFAddressEvent]"};this.type=b;this.target=SWFAddress;this.value=SWFAddress.getValue();this.path=SWFAddress.getPath();this.pathNames=SWFAddress.getPathNames();this.parameters={};for(var b=SWFAddress.getParameterNames(),e=0,m=b.length;e<m;e++)this.parameters[b[e]]=SWFAddress.getParameter(b[e]);this.parameterNames=b};SWFAddressEvent.INIT="init";SWFAddressEvent.CHANGE="change";SWFAddressEvent.INTERNAL_CHANGE="internalChange";SWFAddressEvent.EXTERNAL_CHANGE="externalChange";var SWFAddress=new function(){var b=function(){var a=c.href.indexOf("#");return-1!=a?Z(C(c.href.substr(a+1))):""},e=function(a,d){t.strict&&(a=d?"/"!=a.substr(0,1)?"/"+a:a:""==a?"/":a);return a},m=function(a,d){return w&&"file:"==c.protocol?d?j.replace(/\?/,"%3F"):j.replace(/%253F/,"?"):a},k=function(a){if(a.childNodes)for(var d=0,b=a.childNodes.length,c;d<b;d++)if(a.childNodes[d].src&&(O=String(a.childNodes[d].src)),c=k(a.childNodes[d]))return c},h=function(){i.title!=U&&-1!=i.title.indexOf("#")&&(i.title=U)},s=function(){if(!P){var a=b(),d=j!=a;D&&523>n?H!=z.length&&(H=z.length,typeof E[H-1]!=f&&(j=E[H-1]),x.call(this,!1)):w&&d?7>n?c.reload():this.setValue(a):d&&(j=a,x.call(this,!1));w&&h.call(this)}},L=function(){0<A.length&&(window.open(A[0],A[1],eval(A[2])),typeof A[3]!=f&&eval(A[3]));A=[]},N=function(){for(var a=0,d,b,c=SWFAddress.getValue();d=B[a];a++)if(b=document.getElementById(d))if(b.parentNode&&typeof b.parentNode.so!=f)b.parentNode.so.call("setSWFAddressValue",c);else{b&&typeof b.setSWFAddressValue!=f||(d=b.getElementsByTagName("object"),b=b.getElementsByTagName("embed"),b=d[0]&&typeof d[0].setSWFAddressValue!=f?d[0]:b[0]&&typeof b[0].setSWFAddressValue!=f?b[0]:null);try{b&&b.setSWFAddressValue(c)}catch(e){}}else(b=document[d])&&typeof b.setSWFAddressValue!=f&&b.setSWFAddressValue(c)},M=function(a){this.dispatchEvent(new SWFAddressEvent(a));a=a.substr(0,1).toUpperCase()+a.substr(1);if(typeof this["on"+a]==Q)this["on"+a]()},x=function(a){N();M.call(this,"change");a?M.call(this,"internalChange"):M.call(this,"externalChange");I(F.bind(T,this),10)},T=function(){var a=(c.pathname+(/\/$/.test(c.pathname)?"":"/")+this.getValue()).replace(/\/\//,"/").replace(/^\/$/,""),d=p[t.tracker];typeof d==Q?d(a):typeof p.pageTracker!=f&&typeof p.pageTracker._trackPageview==Q?p.pageTracker._trackPageview(a):typeof p.urchinTracker==Q&&p.urchinTracker(a)},Y=function(){var a=l.contentWindow.document;a.open();a.write("<html><head><title>"+i.title+"</title><script>var "+u+' = "'+b()+'";<\/script></head></html>');a.close()},G=function(){var a=l.contentWindow;j=typeof a[u]!=f?a[u]:"";j!=b()&&(x.call(SWFAddress,!1),c.hash=m(j,q))},ba=function(){if(!$){$=q;if(w&&8>n){var a=i.getElementsByTagName("frameset")[0];l=i.createElement((a?"":"i")+"frame");a?(a.insertAdjacentElement("beforeEnd",l),a[a.cols?"cols":"rows"]+=",0",l.src="javascript:false",l.noResize=!0,l.frameBorder=l.frameSpacing=0):(l.src="javascript:false",l.style.display="none",i.body.insertAdjacentElement("afterBegin",l));I(function(){V.addListener(l,"load",G);typeof l.contentWindow[u]==f&&Y()},50)}else D&&(418>n&&(i.body.innerHTML+='<form id="'+u+'" style="position:absolute;top:-9999px;" method="get"></form>',W=i.getElementById(u)),typeof c[u]==f&&(c[u]={}),typeof c[u][c.pathname]!=f&&(E=c[u][c.pathname].split(",")));I(F.bind(function(){R.Browser.isSafari()&&i.body.addEventListener("click",L);M.call(this,"init");N();M.call(this,"change");T.call(this)},this),1);w&&8<=n?(i.body.onhashchange=F.bind(s,this),aa(F.bind(h,this),50)):aa(F.bind(s,this),50)}},u="swfaddress",Q="function",f="undefined",q=!0,R=asual.util,r=R.Browser,V=R.Events,F=R.Functions,n=r.getVersion(),w=r.isMSIE(),ca=r.isMozilla(),S=r.isOpera(),D=r.isSafari(),J=!1,p=window,i=p.document,z=p.history,c=p.location,aa=setInterval,I=setTimeout,C=decodeURI,Z=encodeURI,l,W,O,U=i.title,H=z.length,P=!1,$=!1,X=q,da=q,K=this,E=[],B=[],A=[],y={},j=b(),t={history:q,strict:q};w&&(i.documentMode&&i.documentMode!=n)&&(n=8!=i.documentMode?7:8);if(J=ca&&1<=n||w&&6<=n||S&&9.5<=n||D&&312<=n){S&&(history.navigationMode="compatible");for(r=1;r<H;r++)E.push("");E.push(b());w&&c.hash!=b()&&(c.hash="#"+m(b(),q));k(document);r=O?O.indexOf("?"):-1;if(-1!=r)for(var v,S=O.substr(r+1).split("&"),r=0;v=S[r];r++)v=v.split("="),/^(history|strict)$/.test(v[0])&&(t[v[0]]=isNaN(v[1])?/^(true|yes)$/i.test(v[1]):0!=parseInt(v[1])),/^tracker$/.test(v[0])&&(t[v[0]]=v[1]);w&&h.call(this);window==p&&V.addListener(document,"DOMContentLoaded",F.bind(ba,this));V.addListener(p,"load",F.bind(ba,this))}else!J&&-1!=c.href.indexOf("#")||D&&418>n&&-1!=c.href.indexOf("#")&&""!=c.search?(i.open(),i.write('<html><head><meta http-equiv="refresh" content="0;url='+c.href.substr(0,c.href.indexOf("#"))+'" /></head></html>'),i.close()):T();this.toString=function(){return"[class SWFAddress]"};this.back=function(){z.back()};this.forward=function(){z.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){z.go(a)};this.href=function(a,d){d=typeof d!=f?d:"_self";"_self"==d?self.location.href=a:"_top"==d?c.href=a:"_blank"==d?window.open(a):p.frames[d].location.href=a};this.popup=function(a,d,b,c){try{window.open(a,d,eval(b)),typeof c!=f&&eval(c)}catch(e){}A=arguments};this.getIds=function(){return B};this.getId=function(){return B[0]};this.setId=function(a){B[0]=a};this.addId=function(a){this.removeId(a);B.push(a)};this.removeId=function(a){for(var d=0;d<B.length;d++)if(a==B[d]){B.splice(d,1);break}};this.addEventListener=function(a,d){typeof y[a]==f&&(y[a]=[]);y[a].push(d)};this.removeEventListener=function(a,d){if(typeof y[a]!=f){for(var b=0,c;(c=y[a][b])&&c!=d;b++);y[a].splice(b,1)}};this.dispatchEvent=function(a){if(this.hasEventListener(a.type)){a.target=this;for(var d=0,b;b=y[a.type][d];d++)b(a);return q}return!1};this.hasEventListener=function(a){return typeof y[a]!=f&&0<y[a].length};this.getBaseURL=function(){var a=c.href;-1!=a.indexOf("#")&&(a=a.substr(0,a.indexOf("#")));"/"==a.substr(a.length-1)&&(a=a.substr(0,a.length-1));return a};this.getStrict=function(){return t.strict};this.setStrict=function(a){t.strict=a};this.getHistory=function(){return t.history};this.setHistory=function(a){t.history=a};this.getTracker=function(){return t.tracker};this.setTracker=function(a){t.tracker=a};this.getTitle=function(){return i.title};this.setTitle=function(a){if(!J)return null;typeof a!=f&&("null"==a&&(a=""),a=C(a),I(function(){U=i.title=a;da&&(l&&l.contentWindow&&l.contentWindow.document)&&(l.contentWindow.document.title=a,da=!1);!X&&ca&&c.replace(-1!=c.href.indexOf("#")?c.href:c.href+"#");X=!1},10))};this.getStatus=function(){return p.status};this.setStatus=function(a){if(!J)return null;if(typeof a!=f&&("null"==a&&(a=""),a=C(a),!D)){a=e("null"!=a?a:"",q);"/"==a&&(a="");if(!/http(s)?:\/\//.test(a))var b=c.href.indexOf("#"),a=(-1==b?c.href:c.href.substr(0,b))+"#"+a;p.status=a}};this.resetStatus=function(){p.status=""};this.getValue=function(){return!J?null:C(e(m(j,!1),!1))};this.setValue=function(a){if(!J)return null;if(typeof a!=f&&("null"==a&&(a=""),a=Z(C(e(a,q))),"/"==a&&(a=""),j!=a)){X=q;j=a;P=q;x.call(SWFAddress,!0);E[z.length]=j;if(D)if(t.history)if(c[u][c.pathname]=E.toString(),H=z.length+1,418>n)""==c.search&&(W.action="#"+j,W.submit());else if(523>n||""==j){a=i.createEvent("MouseEvents");a.initEvent("click",q,q);var d=i.createElement("a");d.href="#"+j;d.dispatchEvent(a)}else c.hash="#"+j;else c.replace("#"+j);else j!=b()&&(t.history?c.hash="#"+C(m(j,q)):c.replace("#"+C(j)));w&&8>n&&t.history&&I(Y,50);D?I(function(){P=!1},1):P=!1}};this.getPath=function(){var a=this.getValue();return-1!=a.indexOf("?")?a.split("?")[0]:-1!=a.indexOf("#")?a.split("#")[0]:a};this.getPathNames=function(){var a=this.getPath(),b=a.split("/");("/"==a.substr(0,1)||0==a.length)&&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(-1!=b&&b<a.length)return a.substr(b+1)};this.getParameter=function(a){var b=this.getValue(),c=b.indexOf("?");if(-1!=c){for(var b=b.substr(c+1),c=b.split("&"),e=c.length,f=[];e--;)b=c[e].split("="),b[0]==a&&f.push(b[1]);if(0!=f.length)return 1!=f.length?f:f[0]}};this.getParameterNames=function(){var a=this.getValue(),b=a.indexOf("?"),c=[];if(-1!=b&&(a=a.substr(b+1),""!=a&&-1!=a.indexOf("="))){a=a.split("&");for(b=0;b<a.length;)c.push(a[b].split("=")[0]),b++}return c};this.onExternalChange=this.onInternalChange=this.onChange=this.onInit=null;var g;typeof FlashObject!=f&&(SWFObject=FlashObject);if(typeof SWFObject!=f&&SWFObject.prototype&&SWFObject.prototype.write){var ea=SWFObject.prototype.write;SWFObject.prototype.write=function(){g=arguments;8>this.getAttribute("version").major&&(this.addVariable("$swfaddress",SWFAddress.getValue()),("string"==typeof g[0]?document.getElementById(g[0]):g[0]).so=this);var a;(a=ea.apply(this,g))&&K.addId(this.getAttribute("id"));return a}}if(typeof swfobject!=f){var fa=swfobject.registerObject;swfobject.registerObject=function(){g=arguments;fa.apply(this,g);K.addId(g[0])};var ga=swfobject.createSWF;swfobject.createSWF=function(){g=arguments;var a=ga.apply(this,g);a&&K.addId(g[0].id);return a};var ha=swfobject.embedSWF;swfobject.embedSWF=function(){g=arguments;typeof g[8]==f&&(g[8]={});typeof g[8].id==f&&(g[8].id=g[1]);ha.apply(this,g);K.addId(g[8].id)}}if(typeof UFO!=f){var ia=UFO.create;UFO.create=function(){g=arguments;ia.apply(this,g);K.addId(g[0].id)}}if(typeof AC_FL_RunContent!=f){var ja=AC_FL_RunContent;AC_FL_RunContent=function(){g=arguments;ja.apply(this,g);for(var a=0,b=g.length;a<b;a++)"id"==g[a]&&K.addId(g[a+1])}}};