/*! A fix for the iOS orientationchange zoom bug.
 Script by @scottjehl, rebound by @wilto.
 MIT / GPLv2 License.
*/

(function(w){var a=navigator.userAgent;if(!(/iPhone|iPad|iPod/.test(navigator.platform)&&/OS [1-5]_[0-9_]* like Mac OS X/i.test(a)&&a.indexOf("AppleWebKit")>-1)){return}var b=w.document;if(!b.querySelector){return}var c=b.querySelector("meta[name=viewport]"),initialContent=c&&c.getAttribute("content"),disabledZoom=initialContent+",maximum-scale=1",enabledZoom=initialContent+",maximum-scale=10",enabled=true,x,y,z,aig;if(!c){return}function restoreZoom(){c.setAttribute("content",enabledZoom);enabled=true}function disableZoom(){c.setAttribute("content",disabledZoom);enabled=false}function checkTilt(e){aig=e.accelerationIncludingGravity;x=Math.abs(aig.x);y=Math.abs(aig.y);z=Math.abs(aig.z);if((!w.orientation||w.orientation===180)&&(x>7||((z>6&&y<8||z<8&&y>6)&&x>5))){if(enabled){disableZoom()}}else if(!enabled){restoreZoom()}}w.addEventListener("orientationchange",restoreZoom,false);w.addEventListener("devicemotion",checkTilt,false)})(this);