$(document).ready(function(){
	 /* Preload Images for the Main Navigation Hover */

	temp = new Array;
	$("ul.navigation li").find("img").each(function(i) {
		temp[i] = this.src;
		var ind = temp[i].lastIndexOf('/');
		var before = temp[i].substring(0, ind);
		var after = temp[i].substring(ind+'/'.length);
		var finished = before + '/active/' + after;
		preload_image_object = new Image();
		preload_image_object.src = finished;
		
		$(this).parent().parent().bind("mouseenter", function(){
			$(this).find('ul').css('width', '180px');
			$(this).find('ul').css('left', '-7px');
			$(this).find('ul').css('display', 'block');
			$(this).find('img').attr({ src: finished});
			$(this).find('img').attr({ src: finished});
		});
		
		$(this).parent().parent().bind("mouseleave", function(){
			 $(this).find('img').attr({ src: temp[i]});
			 $(this).find('ul').css('display', 'none');
		});
		
		// $(this).parent().parent().hover(function() {
		// 	$(this).find('ul').css('width', $(this).find('img').width() + 14);
		// 	$(this).find('ul').css('left', '-7px');
		// 	$(this).find('img').attr({ src: finished});
		// 	$(this).find('img').attr({ src: finished});
		// }, function() {
		// 	 $(this).find('img').attr({ src: temp[i]});
		// });
	});
	
	
	temp2 = new Array;
	$(".rollover").find('img').each(function(i) {
		temp2[i] = this.src;
		var ind = temp2[i].lastIndexOf('/');
		var before = temp2[i].substring(0, ind);
		var after = temp2[i].substring(ind+'/'.length);
		var finished = before + '/active/' + after;
		preload_image_object = new Image();
		preload_image_object.src = finished;

		$(this).hover(function() {
			$(this).attr({ src: finished});
		}, function() {
			 $(this).attr({ src: temp2[i]});
		});
	});
});
