// JavaScript Document developed by Stuart Runyan for gendronarts.com
// http://www.stuartrunyan.com

$(document).ready(function(){
	//Adds subtitle to menu items 
	$('a[title="Artist"]').append('<br /><small>About Bonnie Gendron</small>');
	$('a[title="Gallery"]').append("<br /><small>View Bonnie's art</small>");
	$('a[title="Exhibits"]').append('<br /><small>Upcoming shows</small>');
	$('a[title="Contact"]').append('<br /><small>Contacting Bonnie</small>');

	//Handles loading large images in the galleries
	$("#img-container h2").append('<em></em>');
	$("#thumbs a").click(function(){
	
		var largePath = $(this).attr("href");
		var largeAlt = $(this).attr("alt");
		
		$("#largeImg").attr({ src: largePath, alt: largeAlt });
		$("#img-container h2 em").html(" (" + largeAlt + ")"); return false;
	});
	
	//Setting the description pop-up
	$("#thumbs a img").click(function(){
		
		var imgTitle = $(this).attr("title");
		var imgDesc = $(this).attr("alt");
		
		$("#imgTitle").html(imgTitle);
		$("#imgDesc").html(imgDesc);
	});
	
	//Displays image description on hover
	//var imgWidth = $('#largeImg').attr('width');
	//$('#img-desc-container').css("width", imgWidth)
	$('#img-desc-container').hide();
	$('#img-container').hover(
		function () {
			$('#img-desc-container').stop(true, true).fadeIn("slow");
		}, function () {
			$('#img-desc-container').stop(true, true).fadeOut("slow");
		}							  
	);
	
	//sets the first image and description on page load
	function loadFirstImage(){
		var firstImagePath = $("#thumbs a:first-child").attr("href");
		var firstImageAlt = $("#thumbs a img:first-child").attr("alt");
		var imgTitle = $('#thumbs a img:first-child"').attr("title");
		var imgDesc = $('#thumbs a img:first-child"').attr("alt");
		$('#largeImg').attr({ src: firstImagePath, alt: firstImageAlt });
		$("#imgTitle").html(imgTitle);
		$("#imgDesc").html(imgDesc);
	};
	loadFirstImage();
	
	//Don't display image description if "title" and "alt" are empty ---Still in progress
	/* if(attr('title')<0){
		$('#img-desc-container').hide();	
	};*/
	
	//Thumbnail slider
	$('#galleryLeft').click(function(){
		$('#thumbs').animate({marginTop: 0}, "slow");   
	});
	$('#galleryRight').click(function(){
		$('#thumbs').animate({marginTop: -100}, "slow");   
	});
		
	
	
	
	//Changes background color over time
	function backgroundChanger(){
		$('body').delay(4000)
		.animate({backgroundColor: "#a6cac3"}, 4000)//dark green
		.delay(2000)
		.animate({backgroundColor: "#d3dcf2"}, 4000)//light blue
		.delay(2000)
		.animate({backgroundColor: "#a7b8d9"}, 4000)//dark blue
		.delay(2000)
		.animate({backgroundColor: "#bdb1c9"}, 4000)//light purple
		.delay(2000)
		.animate({backgroundColor: "#9a8ca6"}, 4000)//dark purple
		.delay(2000)
		.animate({backgroundColor: "#d0dfdc"}, 4000, function(){
			backgroundChanger();//calls the function again to loop continuiusly															
		});//light green		
	};
	backgroundChanger();//starts the funciton onload
		

	$('#td_currimage').css("border", "none");
	




});
