/*
 * 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),v=/msie/.test(f)&&!/opera/.test(f),u=/mozilla/.test(f)&&!/(compatible|webkit)/.test(f),w=parseFloat(v?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 w};this.isMSIE=function(){return v};this.isSafari=function(){return k};this.isOpera=function(){return n};this.isMozilla=function(){return u}});asual.util.Events=new (function(){var f=window,k=document,n=[],v=asual.util,u=v.Browser,w=u.isMSIE(),G=u.isSafari();this.toString=function(){return"[class Events]"};this.addListener=function(h,i,q){n.push({o:h,t:i,l:q});if(!(i=="DOMContentLoaded"&&(w||G)))if(h.addEventListener)h.addEventListener(i,q,false);else h.attachEvent&&h.attachEvent("on"+i,q)};this.removeListener=function(h,i,q){for(var H=0,I;I=n[H];H++)if(I.o==h&&I.t==i&&I.l==q){n.splice(H,1);break}if(!(i=="DOMContentLoaded"&&(w||G)))if(h.removeEventListener)h.removeEventListener(i,q,false);else h.detachEvent&&h.detachEvent("on"+i,q)};var P=function(){for(var h=0,i;i=n[h];h++)i.t!="DOMContentLoaded"&&v.Events.removeListener(i.o,i.t,i.l)};u=function(){if(k.readyState=="interactive"){function h(){k.detachEvent("onstop",h);P()}k.attachEvent("onstop",h);f.setTimeout(function(){k.detachEvent("onstop",h)},0)}};if(w||G)(function(){try{if(w&&k.body||!/loaded|complete/.test(k.readyState))k.documentElement.doScroll("left")}catch(h){return setTimeout(arguments.callee,0)}for(var i=0,q;q=n[i];i++)q.t=="DOMContentLoaded"&&q.l.call(null)})();w&&f.attachEvent("onbeforeunload",u);this.addListener(f,"unload",P)});asual.util.Functions=new (function(){this.toString=function(){return"[class Functions]"};this.bind=function(f,k){for(var n=2,v,u=[];v=arguments[n];n++)u.push(v);return function(){return f.apply(k,u)}}});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?U(D(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 z&&e.protocol=="file:"?b?_value.replace(/\?/,"%3F"):_value.replace(/%253F/,"?"):a},v=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=v(a.childNodes[b]))c=o}return c},u=function(a,b){for(var d=0;d<b.length;d++)if(a===b[d])return d;return-1},w=function(){if(j.title!=_title&&j.title.indexOf("#")!=-1)j.title=_title},G=function(){if(!_silent){var a=f(),b=_value!=a;if(E&&r<523){if(_length!=B.length){_length=B.length;if(typeof _stack[_length-1]!=g)_value=_stack[_length-1];i.call(this,t)}}else if(z&&r<7&&b)e.reload();else if(b){_value=a;i.call(this,t)}z&&w.call(this)}},P=function(){if(_popup.length>0){window.open(_popup[0],_popup[1],eval(_popup[2]));typeof _popup[3]!=g&&eval(_popup[3])}_popup=[]},h=function(a){this.dispatchEvent(new SWFAddressEvent(a));a=a.substr(0,1).toUpperCase()+a.substr(1);typeof this["on"+a]==L&&this["on"+a]()},i=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);h.call(this,SWFAddressEvent.CHANGE);h.call(this,a?SWFAddressEvent.INTERNAL_CHANGE:SWFAddressEvent.EXTERNAL_CHANGE);J(F.bind(q,this),10)},q=function(){var a=(e.pathname+(/\/$/.test(e.pathname)?"":"/")+this.getValue()).replace(/\/\//,"/").replace(/^\/$/,""),b=s[_opts.tracker];if(typeof b==L)b(a);else if(typeof _gaq!=g&&typeof _gaq.push==L)_gaq.push(["_trackPageview",a]);else if(typeof s.pageTracker!=g&&typeof s.pageTracker._trackPageview==L)s.pageTracker._trackPageview(a);else typeof s.urchinTracker==L&&s.urchinTracker(a)},H=function(){var a=p.contentWindow.document;a.open();a.write("<html><head><title>"+j.title+"</title><script>var "+x+' = "'+f()+'";<\/script></head></html>');a.close()},I=function(){var a=p.contentWindow;_value=typeof a[x]!=g?a[x]:"";if(_value!=f()){i.call(SWFAddress,t);e.hash=n(_value,l)}},T=function(){if(!_loaded){_loaded=l;if(z&&r<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)}J(function(){R.addListener(p,"load",I);typeof p.contentWindow[x]==g&&H()},50)}else if(E){if(r<418){j.body.innerHTML+='<form id="'+x+'" style="position:absolute;top:-9999px;" method="get"></form>';S=j.getElementById(x)}if(typeof e[x]==g)e[x]={};if(typeof e[x][e.pathname]!=g)_stack=e[x][e.pathname].split(",")}J(F.bind(function(){Q.Browser.isSafari()&&j.body.addEventListener("click",P);h.call(this,SWFAddressEvent.INIT);h.call(this,SWFAddressEvent.CHANGE);h.call(this,SWFAddressEvent.EXTERNAL_CHANGE);q.call(this)},this),1);if(z&&r>=8){j.body.onhashchange=F.bind(G,this);V(F.bind(w,this),50)}else V(F.bind(G,this),50)}},x="swfaddress",L="function",g="undefined",l=true,t=false,Q=asual.util,A=Q.Browser,R=Q.Events,F=Q.Functions,r=A.getVersion(),z=A.isMSIE(),W=A.isMozilla(),C=A.isOpera(),E=A.isSafari(),K=t,s=function(){try{return top.document!==undefined?top:window}catch(a){return window}}(),j=s.document,B=s.history,e=s.location,V=setInterval,J=setTimeout,D=decodeURI,U=encodeURI,p,S;_qi=(A=v(document))?A.indexOf("?"):-1;_title=j.title;_length=B.length;_loaded=_silent=t;_juststart=_justset=l;_updating=t;_ref=this;_stack=[];_ids=[];_popup=[];_listeners={};_value=f();_opts={autoUpdate:l,history:l,strict:l};if(z&&j.documentMode&&j.documentMode!=r)r=j.documentMode!=8?7:8;if(K=W&&r>=1||z&&r>=6||C&&r>=9.5||E&&r>=312){if(C)history.navigationMode="compatible";for(C=1;C<_length;C++)_stack.push("");_stack.push(f());if(z&&e.hash!=f())e.hash="#"+n(f(),l);if(_qi!=-1){var y;A=A.substr(_qi+1).split("&");for(C=0;y=A[C];C++){y=y.split("=");if(/^(history|strict)$/.test(y[0]))_opts[y[0]]=isNaN(y[1])?/^(true|yes)$/i.test(y[1]):parseInt(y[1])!=0;if(/^tracker$/.test(y[0]))_opts[y[0]]=y[1]}}z&&w.call(this);if(j.readyState=="complete")T.call(this);else{window==s&&R.addListener(document,"DOMContentLoaded",F.bind(T,this));R.addListener(s,"load",F.bind(T,this))}}else if(!K&&e.href.indexOf("#")!=-1||E&&r<418&&e.href.indexOf("#")!=-1&&e.search!=""){j.open();j.write('<html><head><meta http-equiv="refresh" content="0;url='+e.href.substr(0,e.href.indexOf("#"))+'" /></head></html>');j.close()}else q();this.toString=function(){return"[class SWFAddress]"};this.back=function(){B.back()};this.forward=function(){B.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){B.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 s.frames[b].location.href=a};this.popup=function(a,b,d,c){try{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 t};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=t};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=D(a);J(function(){_title=j.title=a;if(_juststart&&p&&p.contentWindow&&p.contentWindow.document){p.contentWindow.document.title=a;_juststart=t}if(!_justset&&W)e.replace(e.href.indexOf("#")!=-1?e.href:e.href+"#");_justset=t},10)}};this.getStatus=function(){return s.status};this.setStatus=function(a){if(!K)return null;if(typeof a!=g){if(a=="null")a="";a=D(a);if(!E){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}s.status=a}}};this.resetStatus=function(){s.status=""};this.getValue=function(){if(!K)return null;return D(k(n(_value,t),t))};this.setValue=function(a){if(!K)return null;if(typeof a!=g){if(a=="null")a="";a=U(D(k(a,l)));if(a=="/")a="";if(!(_value==a&&!_updating)){_justset=l;_value=a;if(_opts.autoUpdate||_updating){_silent=l;i.call(SWFAddress,l);_stack[B.length]=_value;if(E)if(_opts.history){e[x][e.pathname]=_stack.toString();_length=B.length+1;if(r<418){if(e.search==""){S.action="#"+_value;S.submit()}}else if(r<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="#"+D(n(_value,l));else e.replace("#"+D(_value));z&&r<8&&_opts.history&&J(H,50);if(E)J(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(),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=[],M=0;M<c.length;M++){var N=c[M],m=this.getParameter(N);if(typeof m=="string")m=[m];if(N==a)m=b===null||b==""?[]:d?m.concat([b]):[b];for(var O=0;O<m.length;O++)o.push(N+"="+m[O])}u(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];u(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 M=UFO.create;UFO.create=function(){a=arguments;M.apply(this,a);_ref.addId(a[0].id)}}if(typeof AC_FL_RunContent!=g){var N=AC_FL_RunContent;AC_FL_RunContent=function(){a=arguments;N.apply(this,a);for(var m=0,O=a.length;m<O;m++)a[m]=="id"&&_ref.addId(a[m+1])}}})()});