﻿jQuery.preloadImages = function () {
    for (var i = 0; i < arguments.length; i++) {
        jQuery("<img>").attr("src", arguments[i]);
    }
}

// preload images first (can run before page is fully loaded)
$.preloadImages("hp1.jpg", "hp2.jpg", "hp3.jpg", "hp4.jpg", "hp5.jpg");
$(
	function () {
	    // set up rollover
	    $("img.rollover").hover(
			function () {
			    this.src = this.src.replace("_off", "_on");
			},
			function () {
			    this.src = this.src.replace("_on", "_off");
			}
		);
	    $("input.rollover").hover(
			function () {
			    this.src = this.src.replace("_off", "_on");
			},
			function () {
			    this.src = this.src.replace("_on", "_off");
			}
		);
	}
)

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ($active.length == 0) $active = $('#slideshow IMG:last');

    var $next = $active.next().length ? $active.next()
    : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
    .addClass('active')
    .animate({ opacity: 1.0 }, 1000, function () {
        $active.removeClass('active last-active');
    });
}

$(function () {
    // Start slideshow
    setInterval("slideSwitch()", 5000);
});
