﻿// JavaScript Document


//Specify rate of display (1/freq)
var freq = 1

var random_num = Math.floor(Math.random() * freq)
if (random_num == 0)
    window.onload = initbox
var ie = document.all
var dom = document.getElementById
var ns4 = document.layers
var calunits = document.layers ? "" : "px"

var bouncelimit = 32 //(must be divisible by 8)
var direction = "up"

function initbox() {
    if (!dom && !ie && !ns4)
        return

    cookie = readCookie("stop_press");
    if (cookie == 1) {
        return
    } else {
        createCookie("stop_press", "1");
    }

    crossobj = (dom) ? document.getElementById("dropin").style : ie ?
document.all.dropin : document.dropin
    scroll_top = (ie) ? truebody().scrollTop : window.pageYOffset
    crossobj.top = scroll_top - 250 + calunits
    crossobj.visibility = (dom || ie) ? "visible" : "show"
    dropstart = setInterval("dropin()", 50)
}

function createCookie(name, value, hours) {
    if (hours) {
        var date = new Date();
        date.setTime(date.getTime() + (hours * 60 * 60));
        var expires = "; expires=" + date.toGMTString();
    }
    else expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";    
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function dropin() {
    scroll_top = (ie) ? truebody().scrollTop : window.pageYOffset
    if (parseInt(crossobj.top) < 100 + 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
}

