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