/*
 * iOS.js v1.0 (compressed)
 * http://www.iOSjs.com/
 *
 * Developed by Empty Galaxy
 * http://www.emptygalaxy.com/
 *
 * Copyright (c) 2011
 * Dual-licensed under the BSD or MIT licenses.
 * http://www.iOSjs.com/license/
 */
iOS_addEventListener(window,"load",iOS_handleWindowLoad);iOS_addEventListener(window,"orientationchange",iOS_handleOrientationChange);iOS_addEventListener(window,"resize",iOS_handleReize);function iOS_addEventListener(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false);return true}else if(a.attachEvent){var r=a.attachEvent("on"+b,c);return r}else{return false}}function iOS_handleWindowLoad(e){iOS_initPage();iOS_updateOrientation();iOS_updateHeight();setTimeout("iOS_hideAddressBar();",100)}function iOS_handleOrientationChange(e){iOS_updateOrientation();iOS_resize();setTimeout("iOS_hideAddressBar();",100)}function iOS_handleReize(e){iOS_resize()}function iOS_initPage(){if(navigator.standalone)iOS_createWebappLinks();var a=navigator.userAgent;if(iOS_isiOSdevice()){var b=document.documentElement;var c=b.className.split(" ");if(c.indexOf("iOS")==-1)c.push("iOS");if(iOS_hasRetinaDisplay()&&c.indexOf("retina")==-1)c.push("retina");b.className=c.join(" ");if(a.indexOf("iPhone")>-1)b.setAttribute("device","iPhone");else if(a.indexOf("iPod")>-1)b.setAttribute("device","iPod");else if(a.indexOf("iPad")>-1)b.setAttribute("device","iPad");if(a.indexOf("iPhone")>-1||a.indexOf("iPod")>-1)b.setAttribute("deviceFamily","iPhone_iPod");else if(a.indexOf("iPad")>-1)b.setAttribute("deviceFamily","iPad")}}function iOS_updateOrientation(){var a="portrait";if(window.orientation==90||window.orientation==-90)a="landscape";document.documentElement.setAttribute("orientation",a)}function iOS_resize(){iOS_updateHeight()}function iOS_hideAddressBar(){if(window.pageYOffset<=1)window.scrollTo(window.pageXOffset,1)}function iOS_disableScrolling(){document.body.addEventListener("touchmove",iOS_preventScrolling,false)}function iOS_enableScrolling(){document.body.removeEventListener("touchmove",iOS_preventScrolling,false)}function iOS_preventScrolling(e){if(e.touches.length==1){e.preventDefault();iOS_hideAddressBar()}}function iOS_disableZooming(){document.body.addEventListener("touchmove",iOS_preventZooming,false)}function iOS_enableZooming(){document.body.removeEventListener("touchmove",iOS_preventZooming,false)}function iOS_preventZooming(e){if(e.touches.length==2)e.preventDefault()}function iOS_updateHeight(){var a=iOS_getViewportSize();document.body.style.minHeight=Math.round(a.height)+"px"}function iOS_createWebappLinks(){var b=document.getElementsByTagName("a");for(var i=0;i<b.length;i++){var a=b[i];if(a.href!=""&&a.target==""){a.onclick=function(){window.location=this.getAttribute("href");return false}}}}function iOS_isiOSDevice(){return navigator.userAgent.indexOf("iPhone")>-1||navigator.userAgent.indexOf("iPod")>-1||navigator.userAgent.indexOf("iPad")>-1}function iOS_isiPhone(){return navigator.userAgent.indexOf("iPhone")>-1}function iOS_isiPod(){return navigator.userAgent.indexOf("iPod")>-1}function iOS_isiPad(){return navigator.userAgent.indexOf("iPad")>-1}function iOS_hasRetinaDisplay(){return window.devicePixelRatio>1}function iOS_normalGetWindowSize(){var a=0;var b=0;if(typeof(window.innerWidth)=="number"){a=window.innerWidth;height=window.innerHeight}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){a=document.documentElement.clientWidth;height=document.documentElement.clientHeight}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){a=document.body.clientWidth;height=document.body.clientHeight}return{width:a,height:height}}function iOS_getWindowSize(){var a=0;var b=0;var c=navigator.userAgent;if(iOS_isiOSdevice()){a=screen.width;b=screen.height;if(window.orientation!=0){var d=a;a=b;b=d}if(!(navigator.standalone&&iOS_getMetaContent("apple-mobile-web-app-status-bar-style").toLowerCase()=="black-translucent"))b-=20;if(c.indexOf("iPhone")>-1||c.indexOf("iPod")>-1){if(!navigator.standalone){if(window.orientation==0)b-=44;else b-=32}}if(c.indexOf("iPad")>-1){if(!navigator.standalone)b-=58}}else{var e=iOS_normalGetWindowSize();a=e.width;b=e.height}return{width:a,height:b}}function iOS_getViewportSize(){var a=iOS_getWindowSize();var b=iOS_getElementSize(document.body);var c=b.width/a.width;return{width:(a.width*c),height:(a.height*c)}}function iOS_getPageSize(){var a=iOS_getElementSize(document.body);return a}function iOS_getElementSize(a){var b;if(b){var c=getObjNN4(document,a);return{width:c.clip.width,height:c.clip.height}}else{if(document.all)return{width:a.style.pixelWidth,height:a.style.pixelHeight};else return{width:a.offsetWidth,height:a.offsetHeight}}}function iOS_getMetaContent(a){a=a.toLowerCase();var b=document.getElementsByTagName("meta");for(var i=0;i<b.length;i++){var c=b[i];if(c.name.toLowerCase()==a){return c.content}}return null}function iOS_isiOSdevice(){var ua=navigator.userAgent;return(ua.indexOf("iPhone")>-1||ua.indexOf("iPod")>-1||ua.indexOf("iPad")>-1)}
