/* jQuery for http://www.michaeladamek.com */

/*
	Author: Michael Adamek
	Email: michael.adamek@gmail.com
	
	Idea: http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/
	
*/	

/* hover effect */

$(document).ready(function(){

	//thumbnail preview
	$("ul.thumb li").hover(function() {
		if($(this).find('img').hasClass("vert")) {
			animateWidth = "100px";
			imgWidth = "56px";
			animateTop = "-70px";
			returnTop = "0";
			animateLeft = "-55px";
			returnLeft = "25px";
		} else {
			animateWidth = "180px";
			imgWidth = "100px";
			animateTop = "-70px";
			returnTop = "0";
			animateLeft = "-110px";
			returnLeft = "0";
		}
		$(this).css({'z-index' : '10'});
		$(this).find('img').addClass("hover").stop()
		    .animate({
		    	marginTop: animateTop, 
		    	marginLeft: animateLeft, 
		    	top: '50%', 
		    	left: '50%', 
		    	width: animateWidth, 
		    	height: '135px',
		    	padding: '10px' 
		    }, 200);	
		    //alert(class + imgWidth);	
		} , function() {
		$(this).css({'z-index' : '0'});
		$(this).find('img').removeClass("hover").stop()
		    .animate({
		    	marginTop: returnTop, 
		    	marginLeft: returnLeft,
		    	top: '0', 
		    	left: '0', 
		    	width: imgWidth, 
		    	height: '75px', 
		    	padding: '5px'
		    }, 400);
	});
	
	//swap image, name, and description on click
	$("ul.thumb li a").click(function() {
	    
	    var mainImage = $(this).attr("href"); //find image source
	    var mainImageName = $(this).find('img').attr("alt"); //find image name/alt
	    var mainImageDesc = $(this).find('img').attr("longdesc");  //find image desc
	    
	    $("#slideshow_main img").attr({ src: mainImage , alt: mainImageName });		    
	    $("#slideshow_main h2").html(mainImageName);	    
	    $("#slideshow_main p").html(mainImageDesc);
	      
	    return false;		
	    
	});
	
	//thumbnail preview for homepage
	$("ul.homepage li").hover(function() {
		if($(this).find('img').hasClass("vert")) {
			animateWidth = "100px";
			imgWidth = "56px";
			animateTop = "-70px";
			returnTop = "0";
			animateLeft = "-50px";
			returnLeft = "25px";
		} else {
			animateWidth = "180px";
			imgWidth = "100px";
			animateTop = "-70px";
			returnTop = "0";
			animateLeft = "-110px";
			returnLeft = "0";
		}
		$(this).css({'z-index' : '10'});
		$(this).find('img').addClass("hover").stop()
		    .animate({
		    	marginTop: animateTop, 
		    	marginLeft: animateLeft, 
		    	top: '50%', 
		    	left: '50%', 
		    	width: animateWidth, 
		    	height: '135px',
		    	padding: '10px' 
		    }, 200);	
		    //alert(class + imgWidth);	
		} , function() {
		$(this).css({'z-index' : '0'});
		$(this).find('img').removeClass("hover").stop()
		    .animate({
		    	marginTop: returnTop, 
		    	marginLeft: returnLeft,
		    	top: '0', 
		    	left: '0', 
		    	width: imgWidth, 
		    	height: '75px', 
		    	padding: '5px'
		    }, 400);
	});
 
});

