/* ================================================================================
	prettyMobile v1.0
	Copyright 2009, Stéphane Caron
	Released under http://creativecommons.org/licenses/by/2.5/
	More information: http://www.no-margin-for-errors.com/projects/prettyMobile/
=================================================================================== */
var pageWidth=0;var animationDuration=1000;var hashHistory=new Array();var urlHistory=new Array();var titleHistory=new Array();var hashPrefix="#_";var bottomMargin=20;var isLoading=false;if(/Safari/i.test(navigator.userAgent)){var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer);documentReady()}},10)}window.$=function(a){return Sizzle(a)};function documentReady(){var a=new ajaxRequest("ajax/",function(b){location.hash="_home";hashHistory[hashHistory.length]="home";urlHistory[urlHistory.length]="ajax/";titleHistory[titleHistory.length]=$("h1")[0].innerHTML;$(".pm_in-viewport")[0].innerHTML=b;bindFunctions();updateOrientation();setInterval(checkHistory,1000)});a.loadPage()}function bindFunctions(){for(var a=$("a[rel*=next]").length-1;a>=0;a--){$("a[rel*=next]")[a].onclick=function(){this.className=this.className+" loading";changePage("next",this.href,this.id,this.title);return false}}for(var a=$("a[rel*=previous]").length-1;a>=0;a--){$("a[rel*=previous]")[a].onclick=function(){this.className=this.className+" loading";changePage("previous",this.href,this.id,this.title);return false}}for(var a=$("a[rel*=back]").length-1;a>=0;a--){$("a[rel*=back]")[a].onclick=function(){this.className=this.className+" loading";history.back();return false}}for(var a=$("a[rel*=tabs]").length-1;a>=0;a--){$("a[rel*=tabs]")[a].onclick=function(){this.className=this.className+" loading";changePage("tabs",this.href,this.id,this.title);return false}}for(var a=$("a[rel*=swipe]").length-1;a>=0;a--){$("a[rel*=swipe]")[a].onclick=function(){this.className=this.className+" loading";return false}}swipe()}changePage=function(d,b,c,e,f){isLoading=true;var a=new ajaxRequest(b,function(h){isLoading=false;for(var g=$(".loading").length-1;g>=0;g--){currentClass=$(".loading")[g].className;$(".loading")[g].className=currentClass.substr(0,currentClass.indexOf("loading"))+currentClass.substr(7+currentClass.indexOf("loading"),currentClass.length)}$pm_outofviewport=$(".pm_out-of-viewport")[0];$(".pm_out-of-viewport")[0].innerHTML=h;fixHeight(d);window.scrollTo(0,1);window.location.hash=hashPrefix+c;if(window.location.hash==""||window.location.hash==hashPrefix+"home"){$("#pm_header .pm_back")[0].style.display="none"}else{$("#pm_header .pm_back")[0].style.display="block"}if(e!=undefined&&e!=""&&e!=$(".pm_page-title")[0].innerHTML){fade($(".pm_page-title")[0]);setTimeout(function(){$(".pm_page-title")[0].innerHTML=e;fade($(".pm_page-title")[0])},(animationDuration/2))}hashHistory[hashHistory.length]=c;urlHistory[urlHistory.length]=b;titleHistory[titleHistory.length]=e;if(d=="next"){$(".pm_in-viewport")[0].className=$(".pm_in-viewport")[0].className+" pm_slideOutLeft";$(".pm_in-viewport")[0].style.left="-"+pageWidth;$(".pm_out-of-viewport")[0].className=$(".pm_out-of-viewport")[0].className+" pm_slideInLeft";$(".pm_out-of-viewport")[0].style.left=0;setTimeout(function(){$(".pm_slideOutLeft")[0].className="pm_out-of-viewport";$(".pm_slideInLeft")[0].className="pm_in-viewport";bindFunctions();if(f){f()}},animationDuration)}else{if(d=="previous"){$(".pm_in-viewport")[0].className=$(".pm_in-viewport")[0].className+" pm_slideOutRight";$(".pm_in-viewport")[0].style.left=pageWidth;$(".pm_out-of-viewport")[0].className=$(".pm_out-of-viewport")[0].className+" pm_slideInRight";$(".pm_out-of-viewport")[0].style.left=0;setTimeout(function(){$(".pm_slideOutRight")[0].className="pm_out-of-viewport";$(".pm_slideInRight")[0].className="pm_in-viewport";bindFunctions();if(f){f()}},animationDuration)}else{$(".pm_in-viewport")[0].style.left=pageWidth;$(".pm_in-viewport")[0].className="pm_out-of-viewport";$pm_outofviewport.className="pm_in-viewport";$pm_outofviewport.style.left=0;bindFunctions()}}});a.loadPage()};swipe=function(c){if($(".pm_in-viewport a[rel*=swipe]").length==0){return}setTimeout(function(){fade($(".pm_in-viewport .pm_gallery_count")[0])},2000);var a=0;var b=0;$(".pm_in-viewport a[rel*=swipe] img")[0].ontouchstart=function(d){d.preventDefault();touch=d.touches[0];a=touch.pageX};$(".pm_in-viewport a[rel*=swipe] img")[0].ontouchmove=function(d){d.preventDefault();touch=d.touches[0];b=a-touch.pageX};$(".pm_in-viewport a[rel*=swipe] img")[0].ontouchend=function(d){if(b>-10&&b<10){$(".pm_in-viewport #pm_gallery_count")[0].style.opacity=1;$(".pm_in-viewport #pm_gallery_count")[0].FadeState=2;setTimeout(function(){fade($(".pm_in-viewport .pm_gallery_count")[0])},2000)}if(b>50){if($(".pm_in-viewport a[rel*=last]").length!=0){return}changePage("next",this.parentNode.href,this.parentNode.id)}else{if(b<50){if($(".pm_in-viewport a[rel*=first]").length!=0){return}history.back()}}}};function fade(a){if(a==null){return}if(a.FadeState==null){if(a.style.opacity==null||a.style.opacity==""||a.style.opacity=="1"){a.FadeState=2}else{a.FadeState=-2}}if(a.FadeState==1||a.FadeState==-1){a.FadeState=a.FadeState==1?-1:1;a.FadeTimeLeft=(animationDuration/2)-a.FadeTimeLeft}else{a.FadeState=a.FadeState==2?-1:1;a.FadeTimeLeft=(animationDuration/2);setTimeout(function(){animateFade(new Date().getTime(),a)},33)}}function animateFade(c,b){var a=new Date().getTime();var e=a-c;if(b.FadeTimeLeft<=e){b.style.opacity=b.FadeState==1?"1":"0";b.FadeState=b.FadeState==1?2:-2;return}b.FadeTimeLeft-=e;var d=b.FadeTimeLeft/(animationDuration/2);if(b.FadeState==1){d=1-d}b.style.opacity=d;b.style.filter="alpha(opacity = "+(d*100)+")";setTimeout(function(){animateFade(a,b)},33)}function fixHeight(b){for(var a=$("#pm_container,.pm_content-container").length-1;a>=0;a--){$("#pm_container,.pm_content-container")[a].style.height=""}if(b=="next"||b=="previous"||b=="tabs"){($(".pm_out-of-viewport")[0].offsetHeight+$("#pm_header")[0].offsetHeight>window.innerHeight)?pageHeight=$(".pm_out-of-viewport")[0].offsetHeight+$("#pm_header")[0].offsetHeight+bottomMargin:pageHeight=window.innerHeight}else{($(".pm_in-viewport")[0].offsetHeight+$("#pm_header")[0].offsetHeight>window.innerHeight)?pageHeight=$(".pm_in-viewport")[0].offsetHeight+$("#pm_header").offsetHeight+bottomMargin:pageHeight=window.innerHeight}for(var a=$("#pm_container,.pm_content-container").length-1;a>=0;a--){$("#pm_container,.pm_content-container")[a].style.height=pageHeight+"px"}}function checkHistory(){if(window.location.hash!=hashPrefix+hashHistory[hashHistory.length-1]&&hashHistory.length!=0){for(var a=hashHistory.length-1;a>=0;a--){if(hashPrefix+hashHistory[a]==window.location.hash){if(!isLoading){changePage("previous",urlHistory[a],hashHistory[a],titleHistory[a])}}}}}function ajaxRequest(a,b){self=this;self.loadPage=function(){self.http_request=new XMLHttpRequest();self.http_request.onreadystatechange=this.loadDone;self.http_request.open("GET",a,true);self.http_request.send()};self.loadDone=function(){if(self.http_request.readyState==4){if(self.http_request.status==200){b(self.http_request.responseText)}else{alert("There was a problem with the request.")}}}}updateOrientation=function(){var a=window.orientation;switch(a){case 0:pageWidth=320;$("body")[0].className="pm_portrait";break;case 90:pageWidth=480;$("body")[0].className="pm_landscape";break;case -90:pageWidth=480;$("body")[0].className="pm_landscape";break;default:pageWidth=320;$("body")[0].className="pm_portrait";break}pageWidth+="px";$(".pm_out-of-viewport")[0].style.left=pageWidth;fixHeight()};
