$(document).ready(function () {
	var cache = [];
    // Arguments are image paths relative to the current page.
    $.preLoadImages = function() {
      var args_len = arguments.length;
      for (var i = args_len; i--;) {
        var cacheImage = document.createElement('img');
        cacheImage.src = arguments[i];
        cache.push(cacheImage);
      }
    }
	$(".image_thumb ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)
	
	$(".image_thumb ul li").click(function(){
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		if ($(this).is(".active")) {  //If the list item is active/selected, then...
			return false; // Don't click through - Prevents repetitive animations on active/selected list-item
			startTimer();
		} else { //If not active then...
			//Animate the Description
			$(".main_image img").animate({ opacity: 0 }, 250 , function() { //fade out the current img
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 1 }, 250 ); //Switch the main image (URL + alt tag) and fade in the new img
			});
		}
		//Show active list-item
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all list-items
		$(this).addClass('active');  //Add class of 'active' on the selected list
		return false; 
	}).hover(function(){ //Hover effects on list-item 
		$(this).addClass('hover'); //Add class "hover" on hover 
		}, function() {
		$(this).removeClass('hover'); //Remove class "hover" on hover out
	});
});
