﻿function preloadImage(imagePath, imageWidth, imageHeight) {
    var newPreloadedImage = document.createElement("img");
    newPreloadedImage.setAttribute("src", imagePath);
    newPreloadedImage.style.position = "absolute";
    newPreloadedImage.style.visibility = "hidden";
    document.body.appendChild(newPreloadedImage);
}
function sirPreload() {
    if (document.images) {
        preloadImage("/images/SIR buttons/contact_us_rest.png", 175, 30);
        preloadImage("/images/SIR buttons/contact_us_hover.png", 175, 30);
        preloadImage("/images/SIR buttons/print_rest.png", 175, 30);
        preloadImage("/images/SIR buttons/print_hover.png", 175, 30);
        preloadImage("/images/SIR buttons/schedule_rest.png", 175, 52);
        preloadImage("/images/SIR buttons/schedule_hover.png", 175, 52);
    }
}
function imgButton(containerId, restImagePath, hoverImagePath, link, position) {
    var a = document.createElement("a");
    var restImage = document.createElement("img");
    var hoverImage;
    var container = document.getElementById(containerId);

    a.setAttribute("href", link);
    restImage.src = restImagePath;
    if(position == "left") {
        restImage.style.marginRight = "6px";
    }
    else if(position == "right") {
        restImage.style.marginLeft = "6px";
    }
    hoverImage = restImage.cloneNode(true);
    hoverImage.src = hoverImagePath;
    restImage.onmouseover = function() {
        this.parentNode.replaceChild(hoverImage, this);
    };
    hoverImage.onmouseout = function() {
        this.parentNode.replaceChild(restImage, this);
    };
    a.appendChild(restImage);
    container.appendChild(a);
}
