function doOnLoad() {
    window.defaultStatus = "Welcome to Whitlow-Online!";
    cacheImages();
}

function hasImage() {
    return document.images;
}

function cacheImages() {
    if (hasImage()) {
        ImgArray = new Array(4);
        ImgArray[0] = new Image();
        ImgArray[0].src = "images/company_over.gif";
        ImgArray[1] = new Image();
        ImgArray[1].src = "images/updates_over.gif";
        ImgArray[2] = new Image();
        ImgArray[2].src = "images/inventory_over.gif";
        ImgArray[3] = new Image();
        ImgArray[3].src = "images/contact_over.gif";
    }
}

function set(pic) {
    if (hasImage()) {
        pic.src = "images/" + pic.name + "_over.gif";
    }
}

function unset(pic) {
    if (hasImage()) {
        pic.src = "images/" + pic.name + "_out.gif"
    }
}

// inventory functions: //////////////////////////////////////////////////

function getSubs() {
    document.coins.submit();
};

function showCoins() {
    document.f.submit();
}

function autoUpdate() {
    // stubbed out
}

function setCookie (cName, cVal) {
    document.cookie = cName + "=" + cVal;
}

function setCookieWithDate(cName, cVal, eDate) {
    document.cookie = cName + "=" + escape(cVal) + 
        "; expires=" + eDate.toGMTString();
}

function getCookie(cName) {

    if (document.cookie.length > 0) {

        cStart = document.cookie.indexOf(cName + "=");

        if (cStart != -1) {

            cStart = cStart + cName.length + 1;
            cEnd = document.cookie.indexOf(";", cStart);

            if (cEnd == -1) {
                cEnd = document.cookie.length;
            }

            CookieValue = document.cookie.substring(cStart, cEnd);

            return CookieValue;

        }
    }

    return null;

}

function deleteCookie(cName) {

    if (getCookie(cName)) {
        document.cookie = cName + "=" + ";expires=Thu, 01-Jan-70 00:00:01 GMT";
    }

}

function addToBasket(c) {

    if (c.checked) {

        curCoinCookie = getCookie("inqBasket");

        if ( (curCoinCookie) && (curCoinCookie != "") ) {
            curCoinCookie = curCoinCookie + c.name + ":";
        } else {
            curCoinCookie = c.name + ":";
        }

        setCookie("inqBasket", curCoinCookie);

    } else {

        CArr = new Array;

        var oldCookie = "";
        oldCookie = getCookie("inqBasket");

        CArr = oldCookie.split(":");

        NewCS = "";

        for (ii = 0; ii <= CArr.length - 1; ii++) {

            if (CArr[ii] != c.name) {

                NewCS += CArr[ii];

                if (ii < CArr.length - 1) {
                    NewCS += ":";
                }

            }

        }

        setCookie("inqBasket", NewCS);

    }

}

function addToBasket2(c) {

    curCoinCookie = getCookie("inqBasket");
    
    if ( (curCoinCookie) && (curCoinCookie != "") ) {
        curCoinCookie = curCoinCookie + c + ":";
    } else {
        curCoinCookie = c + ":";
    }

    setCookie("inqBasket", curCoinCookie);

    msg = "This coin has been added to your inquiry basket.";

    window.alert(msg);

}


function doNothing() { 
    dummy = 1;
}

// inquiry basket functions: /////////////////////////////////////////////

function readVals() {
    v = parent.parent.right.basketC;
    iBasket += v;
    alert("From inquiry.html---" + iBasket);
};

function showIt() {
    url = "http://" + location.host + "/cgi-bin/showBasket.pl";
    fString = "toolbar=no,location=no,directories=no,";
    fString += "status=no,menubar=no,width=600,";
    fString += "height=400,scrollbars=yes,resizable=yes";
    ibc = window.open(url, "basket", fString, true);
};

function goNow() {
    if (parent.IBWin.ibc) {
        showIt();
    };
};

function adv() {

    browser = navigator.appName;
    version = navigator.appVersion;

    if ( ( (browser.indexOf("Netscape") != -1) &&
           ( (version.indexOf("3.") != -1) || 
             (version.indexOf("4.") != -1) ) )
         ||
         ( (browser.indexOf("Microsoft") != -1) && 
           (version.indexOf("4.") != -1) ) ) {
        return true;
    } else { 
        return false; 
    };

};

function setVals() {

    setCookie("Name", document.f.name.value);
    setCookie("Phone", document.f.phone.value);
    setCookie("Email", document.f.email.value);

    return false;

}

function setVals2() {

    tempName = document.f.name.value;
    tempEmail = document.f.email.value;

    if (trim(tempName) == "" || trim(tempEmail) == "") {
        alert("The name and e-mail fields are required.");
        return false;
    } else {  
        eDate = new Date();
        eDate.setTime(eDate.getTime() + (24 * 60 * 60 * 1000 * 365 * 10));
        setCookieWithDate("Name", document.f.name.value, eDate);
        setCookieWithDate("Phone", document.f.phone.value, eDate);
        setCookieWithDate("Email", document.f.email.value, eDate);
        return true;
    }

}


function getPicOnLoad() {

    if (document.all || document.layers) { 
        self.moveTo(0,0); 
        self.resizeTo(screen.availWidth,screen.availHeight); 
    }

}

function trim(str) {

    // remove leading spaces
    while (str.charAt(0) == " ") {
        str = str.substring(1);
    }

    // remove trailing spaces
    while (str.charAt(str.length - 1) == " ") {
        str = str.substring(0,str.length - 1);
    }

    return str;

}

function clearContactForm() {

    var theForm = document.f;

    theForm.name.value = "";
    theForm.phone.value = "";
    theForm.email.value = "";
    theForm.comments.value = "";

    var numElements = theForm.elements.length;  
    for (var i = 0; i < numElements; i++) {
        if (theForm.elements[i].checked) {
            theForm.elements[i].checked = false;
        }
    }

    return false;

}

