(function(){var K=20;var R=0;var V=null;var L=null;var N=0;var T=location.hash;var D="#_";var J=[];var G=0;var X;window.iui={showPage:function(a,Z){if(a){if(L){L.removeAttribute("selected");L=null}if(C(a,"dialog")){S(a)}else{var b=V;V=a;if(b){setTimeout(B,0,b,a,Z)}else{P(a,b)}}}},showPageById:function(a){var c=I(a);if(c){var b=J.indexOf(a);var Z=b!=-1;if(Z){J.splice(b,J.length)}iui.showPage(c,Z)}},showPageByHref:function(a,b,e,c,Z){var d=new XMLHttpRequest();d.onerror=function(){if(Z){Z(false)}};d.onreadystatechange=function(){if(d.readyState==4){if(c){Q(c,d.responseText)}else{var f=document.createElement("div");f.innerHTML=d.responseText;iui.insertPages(f.childNodes)}if(Z){setTimeout(Z,1000,true)}}};if(b){d.open(e||"GET",a,true);d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.setRequestHeader("Content-Length",b.length);d.send(b.join("&"))}else{d.open(e||"GET",a,true);d.send(null)}},insertPages:function(Z){var b;for(var a=0;a<Z.length;++a){var d=Z[a];if(d.nodeType==1){if(!d.id){d.id="__"+(++G)+"__"}var c=I(d.id);if(c){c.parentNode.replaceChild(d,c)}else{document.body.appendChild(d)}if(d.getAttribute("selected")=="true"||!b){b=d}--a}}if(b){iui.showPage(b)}},getSelectedPage:function(){for(var Z=document.body.firstChild;Z;Z=Z.nextSibling){if(Z.nodeType==1&&Z.getAttribute("selected")=="true"){return Z}}}};addEventListener("load",function(Z){var a=iui.getSelectedPage();if(a){iui.showPage(a)}setTimeout(M,0);setTimeout(F,0);X=setInterval(F,300)},false);addEventListener("click",function(b){var a=A(b.target,"a");if(a){function Z(){a.removeAttribute("selected")}if(a.href&&a.hash&&a.hash!="#"){a.setAttribute("selected","true");iui.showPage(I(a.hash.substr(1)));setTimeout(Z,500)}else{if(a==I("backButton")){history.back()}else{if(a.getAttribute("type")=="submit"){O(A(a,"form"))}else{if(a.getAttribute("type")=="cancel"){E(A(a,"form"))}else{if(a.target=="_replace"){a.setAttribute("selected","progress");iui.showPageByHref(a.href,null,null,a,Z)}else{if(!a.target){a.setAttribute("selected","progress");iui.showPageByHref(a.href,null,null,null,Z)}else{return }}}}}}b.preventDefault()}},true);addEventListener("click",function(Z){var a=A(Z.target,"div");if(a&&C(a,"toggle")){a.setAttribute("toggled",a.getAttribute("toggled")!="true");Z.preventDefault()}},true);function F(){if(window.innerWidth!=N){N=window.innerWidth;var a=N==320?"profile":"landscape";document.body.setAttribute("orient",a);setTimeout(scrollTo,100,0,1)}if(location.hash!=T){var Z=location.hash.substr(D.length);iui.showPageById(Z)}}function S(Z){L=Z;Z.setAttribute("selected","true");if(C(Z,"dialog")&&!Z.target){U(Z)}}function U(Z){Z.onsubmit=function(b){b.preventDefault();O(Z)};Z.onclick=function(b){if(b.target==Z&&C(Z,"dialog")){E(Z)}};var a=document.getElementById("query");if(a!=null){a.focus()}}function E(Z){Z.removeAttribute("selected")}function P(c,d){if(!c.id){c.id="__"+(++G)+"__"}location.href=T=D+c.id;J.push(c.id);var b=I("pageTitle");if(c.title){b.innerHTML=c.title}if(c.localName.toLowerCase()=="form"&&!c.target){U(c)}var a=I("backButton");if(a){var Z=I(J[J.length-2]);if(Z&&!c.getAttribute("hideBackButton")){a.style.display="inline";a.innerHTML=Z.title?Z.title:"Back"}else{a.style.display="none"}}}function B(e,d,a){var b=(a?e:d).getAttribute("axis");if(b=="y"){(a?e:d).style.top="100%"}else{d.style.left="100%"}d.setAttribute("selected","true");scrollTo(0,1);clearInterval(X);var c=100;Z();var f=setInterval(Z,R);function Z(){c-=K;if(c<=0){c=0;if(!C(d,"dialog")){e.removeAttribute("selected")}clearInterval(f);X=setInterval(F,300);setTimeout(P,0,d,e)}if(b=="y"){a?e.style.top=(100-c)+"%":d.style.top=c+"%"}else{e.style.left=(a?(100-c):(c-100))+"%";d.style.left=(a?-c:c)+"%"}}}function M(){var Z=document.createElement("div");Z.id="preloader";document.body.appendChild(Z)}function O(Z){var a=document.getElementById("dummy");if(a!=null){a.focus()}iui.showPageByHref(Z.action||"POST",W(Z),Z.method)}function W(b){function a(c){for(var d=0;d<c.length;++d){if(c[d].name){Z.push(c[d].name+"="+escape(c[d].value))}}}var Z=[];a(b.getElementsByTagName("input"));a(b.getElementsByTagName("select"));return Z}function A(a,Z){while(a&&(a.nodeType!=1||a.localName.toLowerCase()!=Z)){a=a.parentNode}return a}function C(Z,a){var b=new RegExp("(^|\\s)"+a+"($|\\s)");return b.exec(Z.getAttribute("class"))!=null}function Q(Z,c){var b=Z.parentNode;var a=Z;while(b.parentNode!=document.body){b=b.parentNode;a=a.parentNode}var d=document.createElement(a.localName);d.innerHTML=c;b.removeChild(a);while(d.firstChild){b.appendChild(d.firstChild)}}function I(Z){return document.getElementById(Z)}function H(){console.log.apply(console,arguments)}function Y(Z){try{if(Z!=""){var a="";Z=Z.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){if(Z!==null){a+=arguments[1]+"\n"}return""});if(a){(window.execScript)?window.execScript(a):window.setTimeout(a,0)}}return false}catch(b){alert(b)}}})();