﻿// commented lines are for when full urls are used for the image source

// preload '_on' images with class of 'hover'
$(window).bind('load', function() {
    var preload = new Array();
    $(".hover").each(function() {
        s = $(this).attr("src").replace(/\.(.+)$/i, "_on.$1");
		//s = $(this).attr("src").replace(/.gif$/ig,"_on.gif");
        preload.push(s)
    });
    var img = document.createElement('img');
    $(img).bind('load', function() {
        if(preload[0]) {
            this.src = preload.shift();
        }
    }).trigger('load');
});
// apply mouseovers
$(document).ready(function() {
    $(".hover").each(function() {
        if ($(this).attr("src").match(/_on\.(.+)$/i)) {
		//if ($(this).attr("src").match(/_on.gif$/ig)) {
            $(this).removeClass("hover");
        }
    });
    $(".hover").hover(function() {
        s = $(this).attr("src").replace(/\.(.+)$/i, "_on.$1");
		//s = $(this).attr("src").replace(/.gif$/ig,"_on.gif");
        $(this).attr("src", s);
    }, function() {
        s = $(this).attr("src").replace(/_on\.(.+)$/i, ".$1");
		//s = $(this).attr("src").replace(/_on.gif$/ig,".gif");
        $(this).attr("src", s);
    });
});

$(document).ready(function() { 
	// initialize the menu
	$("#nav").superfish(); 
});
