$(function () {
	// Preload all CSS images
//	$.preloadCssImages();
    // Add hover to nav li elements
    $('#nav ul li')
        .mouseover(function () {
            $(this).addClass('selected');
        })
        .mouseout(function () {
            $(this).removeClass('selected');
        });

    // Find the Link from current page 
    var thisURL = location.pathname;
    if (thisURL) {
        var i = 0;
        var x = 0;
        while (thisURL.indexOf("/") != -1) {
            x++;
            thisURL = thisURL.substring(i);
            i = thisURL.indexOf("/") + 1;
            if (x == 10) {
                thisURL = "index.htm";
                break;
            }
        }
		if (thisURL == "") {
			thisURL = "index.htm";
		}
        // Remove the Link element and set the span and parent LI's classes to staySelected
        $('#nav ul li a[href="' + thisURL + '"] span').unwrap().attr('class', 'staySelected').parent('li').attr('class', 'staySelectedLI');
    }
});

