﻿var preload = new Array();

function preloadImages() {
	for(i = 0; i < arguments.length; i ++) {
		preload[i] = document.createElement("img");
		preload[i].setAttribute("src", arguments[i]);
	}
}

onload = function() {
    preloadImages(
		"images/home-off.png",
		"images/home-on.png",
		"images/sermons-off.png",
		"images/sermons-on.png",
		"images/organisations-off.png",
		"images/organisations-on.png",
		"images/notices-off.png",
		"images/notices-on.png",
		"images/prayer-off.png",
		"images/prayer-on.png",
		"images/links-off.png",
		"images/links-on.png",
		"images/contact-off.png",
		"images/contact-on.png"
	);

	var homeBtn = document.getElementById("ctl00_MainMenu_imgHome");
    if(homeBtn) {
        homeBtn.onmouseover = function() { this.src = preload[1].src; }
        homeBtn.onmouseout = function() { this.src = preload[0].src; }
        homeBtn.onfocus = function() { this.src = preload[1].src; }
        homeBtn.onblur = function() { this.src = preload[0].src; }
    };

    var sermonsBtn = document.getElementById("ctl00_MainMenu_imgSermons");
    if(sermonsBtn) {
        sermonsBtn.onmouseover = function() { this.src = preload[3].src; }
        sermonsBtn.onmouseout = function() { this.src = preload[2].src; }
        sermonsBtn.onfocus = function() { this.src = preload[3].src; }
        sermonsBtn.onblur = function() { this.src = preload[2].src; }
    };

    var organisationsBtn = document.getElementById("ctl00_MainMenu_imgOrganisations");
    if(organisationsBtn) {
        organisationsBtn.onmouseover = function() { this.src = preload[5].src; }
        organisationsBtn.onmouseout = function() { this.src = preload[4].src; }
        organisationsBtn.onfocus = function() { this.src = preload[5].src; }
        organisationsBtn.onblur = function() { this.src = preload[4].src; }
    };

    var noticesBtn = document.getElementById("ctl00_MainMenu_imgNotices");
    if(noticesBtn) {
        noticesBtn.onmouseover = function() { this.src = preload[7].src; }
        noticesBtn.onmouseout = function() { this.src = preload[6].src; }
        noticesBtn.onfocus = function() { this.src = preload[7].src; }
        noticesBtn.onblur = function() { this.src = preload[6].src; }
    };

    var prayerBtn = document.getElementById("ctl00_MainMenu_imgPrayer");
    if(prayerBtn) {
        prayerBtn.onmouseover = function() { this.src = preload[9].src; }
        prayerBtn.onmouseout = function() { this.src = preload[8].src; }
        prayerBtn.onfocus = function() { this.src = preload[9].src; }
        prayerBtn.onblur = function() { this.src = preload[8].src; }
    };

    var linksBtn = document.getElementById("ctl00_MainMenu_imgLinks");
    if(linksBtn) {
        linksBtn.onmouseover = function() { this.src = preload[11].src; }
        linksBtn.onmouseout = function() { this.src = preload[10].src; }
        linksBtn.onfocus = function() { this.src = preload[11].src; }
        linksBtn.onblur = function() { this.src = preload[10].src; }
    };

    var contactBtn = document.getElementById("ctl00_MainMenu_imgContact");
    if(contactBtn) {
        contactBtn.onmouseover = function() { this.src = preload[13].src; }
        contactBtn.onmouseout = function() { this.src = preload[12].src; }
        contactBtn.onfocus = function() { this.src = preload[13].src; }
        contactBtn.onblur = function() { this.src = preload[12].src; }
    };
};
