(function(){
var _1=20;
var _2=0;
var _3=null;
var _4=null;
var _5=0;
var _6=location.hash;
var _7="#_";
var _8=[];
var _9=0;
var _a;
window.iui={showPage:function(_b,_c){
if(_b){
if(_4){
_4.removeAttribute("selected");
_4=null;
}
if(hasClass(_b,"dialog")){
showDialog(_b);
}else{
var _d=_3;
_3=_b;
if(_d){
setTimeout(slidePages,0,_d,_b,_c);
}else{
updatePage(_b,_d);
}
}
}
},showPageById:function(_e){
var _f=$(_e);
if(_f){
var _10=_8.indexOf(_e);
var _11=_10!=-1;
if(_11){
_8.splice(_10,_8.length);
}
iui.showPage(_f,_11);
}
},showPageByHref:function(_12,_13,_14,_15,cb){
var req=new XMLHttpRequest();
req.onerror=function(){
if(cb){
cb(false);
}
};
req.onreadystatechange=function(){
if(req.readyState==4){
if(_15){
replaceElementWithSource(_15,req.responseText);
}else{
var _18=document.createElement("div");
_18.innerHTML=req.responseText;
iui.insertPages(_18.childNodes);
}
if(cb){
setTimeout(cb,1000,true);
}
}
};
if(_13){
req.open(_14||"GET",_12,true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.setRequestHeader("Content-Length",_13.length);
req.send(_13.join("&"));
}else{
req.open(_14||"GET",_12,true);
req.send(null);
}
},insertPages:function(_19){
var _1a;
for(var i=0;i<_19.length;++i){
var _1c=_19[i];
if(_1c.nodeType==1){
if(!_1c.id){
_1c.id="__"+(++_9)+"__";
}
var _1d=$(_1c.id);
if(_1d){
_1d.parentNode.replaceChild(_1c,_1d);
}else{
document.body.appendChild(_1c);
}
if(_1c.getAttribute("selected")=="true"||!_1a){
_1a=_1c;
}
--i;
}
}
if(_1a){
iui.showPage(_1a);
}
},getSelectedPage:function(){
for(var _1e=document.body.firstChild;_1e;_1e=_1e.nextSibling){
if(_1e.nodeType==1&&_1e.getAttribute("selected")=="true"){
return _1e;
}
}
}};
addEventListener("load",function(_1f){
var _20=iui.getSelectedPage();
if(_20){
iui.auxiliaryParentId=_20.id;
iui.showPage(_20);
}
setTimeout(preloadImages,0);
setTimeout(checkOrientAndLocation,0);
_a=setInterval(checkOrientAndLocation,300);
},false);
addEventListener("click",function(_21){
var _22=findParent(_21.target,"a");
if(_22){
function unselect(){
_22.removeAttribute("selected");
}
if(_22.href&&_22.hash&&_22.hash!="#"){
_22.setAttribute("selected","true");
iui.showPage($(_22.hash.substr(1)));
setTimeout(unselect,500);
}else{
if(_22==$("backButton")){
history.back();
}else{
if(_22.getAttribute("type")=="submit"){
submitForm(findParent(_22,"form"));
}else{
if(_22.getAttribute("type")=="cancel"){
cancelDialog(findParent(_22,"form"));
}else{
if(_22.target=="_replace"){
_22.setAttribute("selected","progress");
iui.showPageByHref(_22.href,null,null,_22,unselect);
}else{
if(!_22.target){
_22.setAttribute("selected","progress");
iui.showPageByHref(_22.href,null,null,null,unselect);
}else{
return;
}
}
}
}
}
}
_21.preventDefault();
}
},true);
addEventListener("click",function(_23){
var div=findParent(_23.target,"div");
if(div&&hasClass(div,"toggle")){
div.setAttribute("toggled",div.getAttribute("toggled")!="true");
_23.preventDefault();
}
},true);
function checkOrientAndLocation(){
if(window.innerWidth!=_5){
_5=window.innerWidth;
var _25=_5==320?"profile":"landscape";
document.body.setAttribute("orient",_25);
setTimeout(scrollTo,100,0,1);
}
if(location.hash!=_6){
var _26=location.hash.substr(_7.length);
iui.showPageById(_26);
}
}
function showDialog(_27){
_4=_27;
_27.setAttribute("selected","true");
if(hasClass(_27,"dialog")&&!_27.target){
showForm(_27);
}
}
function showForm(_28){
_28.onsubmit=function(_29){
_29.preventDefault();
submitForm(_28);
};
_28.onclick=function(_2a){
if(_2a.target==_28&&hasClass(_28,"dialog")){
cancelDialog(_28);
}
};
}
function cancelDialog(_2b){
_2b.removeAttribute("selected");
}
function updatePage(_2c,_2d){
if(!_2c.id){
_2c.id="__"+(++_9)+"__";
}
location.href=_6=_7+_2c.id;
_8.push(_2c.id);
var _2e=$("pageTitle");
if(_2c.title){
_2e.innerHTML=_2c.title;
}
if(_2c.localName.toLowerCase()=="form"&&!_2c.target){
showForm(_2c);
}
var _2f=$("backButton");
if(_2f){
var _30=_2f.getAttribute("class");
var _31=_30.indexOf("buttonBack")>-1?true:false;
var _32=$(_8[_8.length-2]);
if(_32&&!_2c.getAttribute("hideBackButton")){
_2f.style.display="inline";
_2f.innerHTML=_32.title&&!_31?_32.title:"Back";
}else{
_2f.style.display="none";
}
}
var _33=$("searchButton");
if(_33){
var _34=_33.className.indexOf("buttonAuxiliary")==-1?false:true;
if(_34&&_2c.id!=iui.auxiliaryParentId){
_33.className=_33.className.replace("buttonAuxiliaryOn","buttonAuxiliaryOff");
}else{
if(_34&&_2c.id==iui.auxiliaryParentId){
_33.className=_33.className.replace("buttonAuxiliaryOff","buttonAuxiliaryOn");
}
}
}
}
function slidePages(_35,_36,_37){
var _38=(_37?_35:_36).getAttribute("axis");
if(_38=="y"){
(_37?_35:_36).style.top="100%";
}else{
_36.style.left="100%";
}
_36.setAttribute("selected","true");
scrollTo(0,1);
clearInterval(_a);
var _39=100;
slide();
var _3a=setInterval(slide,_2);
function slide(){
_39-=_1;
if(_39<=0){
_39=0;
if(!hasClass(_36,"dialog")){
_35.removeAttribute("selected");
}
clearInterval(_3a);
_a=setInterval(checkOrientAndLocation,300);
setTimeout(updatePage,0,_36,_35);
}
if(_38=="y"){
_37?_35.style.top=(100-_39)+"%":_36.style.top=_39+"%";
}else{
_35.style.left=(_37?(100-_39):(_39-100))+"%";
_36.style.left=(_37?-_39:_39)+"%";
}
}
}
function preloadImages(){
var _3b=document.createElement("div");
_3b.id="preloader";
document.body.appendChild(_3b);
}
function submitForm(_3c){
iui.showPageByHref(_3c.action||"POST",encodeForm(_3c),_3c.method);
}
function encodeForm(_3d){
function encode(_3e){
for(var i=0;i<_3e.length;++i){
if(_3e[i].name){
_40.push(_3e[i].name+"="+escape(_3e[i].value));
}
}
}
var _40=[];
encode(_3d.getElementsByTagName("input"));
encode(_3d.getElementsByTagName("select"));
return _40;
}
function findParent(_41,_42){
while(_41&&(_41.nodeType!=1||_41.localName.toLowerCase()!=_42)){
_41=_41.parentNode;
}
return _41;
}
function hasClass(_43,_44){
var re=new RegExp("(^|\\s)"+_44+"($|\\s)");
return re.exec(_43.getAttribute("class"))!=null;
}
function replaceElementWithSource(_46,_47){
var _48=_46.parentNode;
var _49=_46;
while(_48.parentNode!=document.body){
_48=_48.parentNode;
_49=_49.parentNode;
}
var _4a=document.createElement(_49.localName);
_4a.innerHTML=_47;
_48.removeChild(_49);
while(_4a.firstChild){
_48.appendChild(_4a.firstChild);
}
}
function $(id){
return document.getElementById(id);
}
function ddd(){
console.log.apply(console,arguments);
}
})();

