// JavaScript Document

jQuery(function () {
	// Stack initialize
	var openspeed = 300;
	var closespeed = 300;
	jQuery('.stack>img').toggle(function(){
		var vertical = 0;
		var horizontal = 0;
		var $el=jQuery(this);
		$el.next().children().each(function(){
			jQuery(this).animate({top: '-' + vertical + 'px', left: horizontal + 'px'}, openspeed);
			vertical = vertical + 85;
			horizontal = (horizontal+.75)*2;
		});
		$el.next().animate({top: '-50px', left: '10px'}, openspeed).addClass('openStack')
		   .find('li a>img').animate({width: '75px', marginLeft: '9px'}, openspeed);
		$el.animate({paddingTop: '0'});
	}, function(){
		//reverse above
		var $el=jQuery(this);
		$el.next().removeClass('openStack').children('li').animate({top: '85px', left: '-10px'}, closespeed);
		$el.next().find('li a>img').animate({width: '100px', marginLeft: '30'}, closespeed);
		$el.animate({paddingTop: '35'});
	});

	// Stacks additional animation
	jQuery('.stack li a').hover(function(){
		jQuery("img",this).animate({width: '85px'}, 100);
		jQuery("span",this).animate({marginRight: '30px'});
	},function(){
		jQuery("img",this).animate({width: '75px'}, 100);
		jQuery("span",this).animate({marginRight: '0'});
	});
});