var animateX=-20,animateInterval=24,currentPage=null,currentDialog=null,currentWidth=0,currentHash=location.hash,hashPrefix="#_",pageHistory=[];addEventListener("load",function(){for(var a=document.getElementsByTagName("body")[0].firstChild;a;a=a.nextSibling)if(a.nodeType==1&&a.getAttribute("selected")=="true"){showPage(a);break}setInterval(checkOrientAndLocation,300);setTimeout(hideAddress,100)},false);function hideAddress(){window.scrollTo(0,1)}
addEventListener("click",function(a){var b=a.target;if(b&&(!b.hash||b.hash=="#"))return true;for(a.preventDefault();b&&b.localName&&b.localName.toLowerCase()!="a";)b=b.parentNode;if(b&&b.localName&&b.hash){a=document.getElementById(b.hash.substr(1));showPage(a)}},true);
function checkOrientAndLocation(){if(window.innerWidth!=currentWidth){currentWidth=window.innerWidth;var a=innerWidth==320?"portrait":"landscape";a=="portrait"?$("#id_slots").css("width","200px"):$("#id_slots").css("width","300px");document.body.setAttribute("orient",a);setTimeout(hideAddress,100)}}
function showPage(a,b){if(a!=null){if(currentDialog){currentDialog.removeAttribute("selected");currentDialog=null}if(a.className.indexOf("dialog")!=-1)showDialog(a);else{location.href=currentHash=hashPrefix+a.id;pageHistory.push(a.id);var d=currentPage;currentPage=a;document.getElementById("pageTitle").innerHTML=a.title||"";var c=document.getElementById("homeButton");if(c){c.style.display=a.id=="XXX"?"none":"inline";var e=a.getAttribute("parentName");if(e!=undefined){c.innerHTML=e||"";c.href="#"+
e}else{c.innerHTML="Exit";c.href=".."}}d&&setTimeout(swipePage,0,d,a,b)}}}function swipePage(a,b,d){b.style.left="100%";b.setAttribute("selected","true");scrollTo(0,1);var c=100,e=setInterval(function(){c+=animateX;if(c<=0){c=0;a.removeAttribute("selected");clearInterval(e)}a.style.left=(d?100-c:c-100)+"%";b.style.left=(d?-c:c)+"%"},animateInterval)}
function showDialog(a){currentDialog=a;a.setAttribute("selected","true");a.onsubmit=function(b){b.preventDefault();a.removeAttribute("selected");b=a.action.lastIndexOf("#");b!=-1&&showPage(document.getElementById(a.action.substr(b+1)))};a.onclick=function(b){b.target==a&&a.removeAttribute("selected")}};
