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