﻿   window.onload = function () {
        PopupForIPad();
        initbox();
        popup();
        bouncein();
        dismissbox();
        truebody();
    }

    function PopupForIPad() {
        var iPadPopup = document.getElementById("popup");
        if (navigator.userAgent.indexOf("iPad") >= 0) {
            iPadPopup.style.display = "";
        }
        else {
            iPadPopup.style.display = "none";
        }
    }

    var ie = document.all
    var dom = document.getElementById
    var ns4 = document.layers
    var calunits = document.layers ? "" : "px"

    var bouncelimit = 0 //(must be divisible by 8; 0 = no bouncin)
    var direction = "right"

    function initbox() {
        if (!dom && !ie && !ns4)
            return
        crossobj = (dom) ? document.getElementById("popup").style : ie ? document.all.popup : document.popup
        scroll_top = (ie) ? truebody().scrollTop : window.pageYOffset
        crossobj.top = scroll_top - 250 + calunits
        crossobj.visibility = (dom || ie) ? "visible" : "show"
        dropstart = setInterval("popup()", 50)
    }

    function popup() {
        scroll_top = (ie) ? truebody().scrollTop : window.pageYOffset
        if (parseInt(crossobj.top) < -10 + scroll_top)
            crossobj.top = parseInt(crossobj.top) + 40 + calunits
        else {
            clearInterval(dropstart)
            bouncestart = setInterval("bouncein()", 50)
        }
    }

    function bouncein() {
        crossobj.top = parseInt(crossobj.top) - bouncelimit + calunits
        if (bouncelimit < 0)
            bouncelimit += 8
        bouncelimit = bouncelimit * -1
        if (bouncelimit == 0) {
            clearInterval(bouncestart)
        }
    }

    function dismissbox() {
        if (window.bouncestart) clearInterval(bouncestart)
        crossobj.visibility = "hidden"
    }

    function truebody() {
        return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
    }
