﻿$(function() {

    $.preloadImage = function(path) {
        $("#featured img").attr("src", path);
    }

    $('ul li img').click(function() {
        $('ul li img').removeClass('selected'); 					// removes the border from all the images 
        $(this).addClass('selected'); 							    // adds the border to the selected image

        var imageName = $(this).attr('alt'); 					    // grabs the alt value - which stores the file name

       $.preloadImage('images/featured/' + imageName);

        var chopped = imageName.split('.'); 						// Used to hack off the suffix of the file name.
        $('#featured h2').remove(); 								// Removes any h2 tags within the featured div
        $('#featured')												// Appends an h2 tag that has the file name of the image (without ".jpg")
		 .prepend('<h2 class="description">' + chopped[0] + '</h2>').children('h2').fadeIn(500).fadeTo(200, .6);
    });

    $('ul#options li a').click(function() {							//disables the anchor tag. (accessibility reasons)
        return false;
    });
});