window.onload = resizeDivs;

function resizeDivs()
{
  $('.button').each(function()
  {
    $(this).width($(this).find("img").width());
    $(this).height($(this).find("img").height());
  });
}

$(document).ready(function() 
{
	
	$('.button').hover(
		function(){
			var currentBtn = $(this);
			$('#container div.button').each(function(){
				$(this).removeClass('selectedBtn');
			});
			$(currentBtn).addClass('selectedBtn');
			
			$('#container div.button img.fade').each(function(){
				$(this).stop().animate({opacity:0.3}, 500);
			});
			
			$('#container .button .rollover').each(function(){
				//$(this).stop().animate({marginTop:"0px"}, 500);
				$(this).stop().animate({opacity:0.3}, 500);
			});
			
			//$(this).find('.rollover').stop().animate({marginTop:"-19px"}, 500);
			$(this).find('.rollover').stop().animate({opacity:1}, 500);
			$(this).find('img.fade').stop().animate({opacity:1}, 500);
		},
		function(){
			//$(this).find('.rollover').stop().animate({marginTop:"0px"}, 500);
			$(this).find('img.fade').stop().animate({opacity:0.3}, 500);
		}
	);
	
	$('#container').hover(
		function(){
			//
		},
		function(){
			$('#container div.button').each(function(){
				//$(this).find('.rollover').stop().animate({marginTop:"-19px"}, 500);
				$(this).find('.rollover').stop().animate({opacity:1}, 500);
				$(this).find('img.fade').stop().animate({opacity:1}, 500);
			});		
		}
	);
	
  $(".shop").FadeOpacity({opacity:0.7});
});

