var deviceIphone = "iphone"; var deviceIpod = "ipod"; var deviceIpad = "ipad"; var deviceAndroid = "android"; //Initialize our user agent string to lower case. var uagent = navigator.userAgent.toLowerCase(); function detectUserAgent(deviceName) { return (uagent.search(deviceName) > -1) } function isMobileDevice() { return (detectUserAgent(deviceIphone) || detectUserAgent(deviceIpod) || detectUserAgent(deviceIpad) || detectUserAgent(deviceAndroid)); } function updateLightboxTop() { var win_y = $(window).height(); var scroll_y = $(window).scrollTop(); if (isMobileDevice()) { $("#CB_Window").css({ top: (win_y * 0.5 + scroll_y) + "px" }); } } var showTimer = false; function updateLightboxTopWithTimer(evt) { if ( showTimer ) { clearTimeout( showTimer ); } showTimer = setTimeout( updateLightboxTop, 100 ); } $(window).bind( "scroll", updateLightboxTopWithTimer);