function $(A){return document.getElementById(A)}(function(){var L;var I="go_forward";var O="go_back";var M=[];var F=[];var R=location.href;var B="#__";var N=location.hash;var P=1;var D=20;var J=300;var K;var C;window.ciUI={initialize:function(){L=$("main");if(!L){return }this.setupPages();this.animating=false;setTimeout(scrollTo,100,0,1);return true},setupPages:function(){var S=document.createElement("div");var V=document.createElement("div");var U=document.createElement("div");var T=document.createElement("a");S.id="__page1__";S.className="iphone_page";S.style.left="0%";S.style.display="block";V.id="__page2__";V.className="iphone_page";V.style.left="100%";V.style.display="none";U.id="__home__";U.style.display="none";T.id="__scroll_top__";T.name="";S.innerHTML=U.innerHTML=L.innerHTML;L.innerHTML="";L.appendChild(S);L.appendChild(V);document.body.appendChild(U);document.body.insertBefore(T,document.body.firstChild);this.adjustBodyToEl(S);M[1]=$(S.id);M[0]=$(U.id);M[-1]=$(V.id)},goToPage:function(T,S){if(S===undefined){S=false}this.slidePages(S);if(S){N=location.hash;F.splice(F.indexOf(T)+1,F.length)}else{F.push(T)}this.updatePage(T)},updatePage:function(T){var S=B+(F.length);if(H(S)==0||!T){this.updatePageContent(M[0].innerHTML)}else{(new this.ajax(T.href,this.updatePageContent)).run()}},updatePageContent:function(T){var S=setInterval(U,0);function U(){if(!ciUI.animating){$("__scroll_top__").name=E(true);M[P].innerHTML=T;M[-P].innerHTML="";clearInterval(S);ciUI.adjustBodyToEl(M[P]);location.href=N=E();if(ciUI.callbackFunct){ciUI.callbackFunct()}}}},slidePages:function(S){this.animating=true;var W=M[P];var V=M[-P];var U=100;V.innerHTML=this.loadingPage();V.style.display="block";if(!S){V.style.left="100%"}clearInterval(navigationChangeTimer);setTimeout(scrollTo,100,0,1);var X=setInterval(T,0);function T(){U-=D;if(U<=0){clearInterval(X);navigationChangeTimer=setInterval(G,J);P*=-1;U=0;ciUI.animating=false}W.style.left=(S?(100-U):(U-100))+"%";V.style.left=(S?-U:U)+"%"}},ajax:function(U,W,T){var S=false;this.run=function(){if(T===undefined){T="TEXT"}T=T.toUpperCase();if(window.XMLHttpRequest){S=new XMLHttpRequest();if(S.overrideMimeType){S.overrideMimeType("text/xml")}}else{if(window.ActiveXObject){try{S=new ActiveXObject("Msxml2.XMLHTTP")}catch(X){try{S=new ActiveXObject("Microsoft.XMLHTTP")}catch(X){}}}}if(!S){console.log("Giving up, cannot create an XMLHTTP instance");return false}S.open("GET",U,true);S.onreadystatechange=V;S.setRequestHeader("X-Requested-With","XMLHttpRequest");S.send(null)};function V(){if(S.readyState==4){if(S.status==200){if(T=="XML"){W(S.responseXML)}else{W(S.responseText)}}else{console.log("There was a problem with the request: "+sourceUrl)}}}},submitForm:function(S){var T=new Object();T.href=S.actionURL.value+"&query="+S.query.value;T.title=S.title;this.goToPage(T)},cancel:function(S){F=[];location.reload(true);location.hash="";location.href=R;return false},loadingPage:function(){return $("loading_page").innerHTML},adjustBodyToEl:function(S){L.style.height=S.offsetHeight+"px"}};addEventListener("load",function(S){C=ciUI.initialize();if(C){navigationChangeTimer=setInterval(G,J)}},false);addEventListener("click",function(T){if(!C){return }var S=A(T.target,"a");if(S&&S.hasClass(I)){ciUI.goToPage(S);T.preventDefault()}else{if(S&&S.hasClass(O)){history.back();T.preventDefault()}}},true);function Q(T,S){if(S===undefined){S=20}return(T.length>S)?T.substring(0,S-3)+"...":T}function E(S){return(S)?B.substr(1,B.length)+(F.length):B+(F.length)}function G(){if(N!=location.hash){ciUI.goToPage(F[F.length-2],true)}}function H(S){return(S)?S.substr(S.lastIndexOf("_")+1,S.length):0}Element.prototype.hasClass=function(S){return this.className.indexOf(S)!=-1};Element.prototype.hide=function(){this.style.display="none";return this};Element.prototype.show=function(){this.style.display="block";return this};function A(T,S){while(T&&(T.nodeType!=1||T.localName.toLowerCase()!=S)){T=T.parentNode}return T}})();
