$(function(){
	//$(document).pngFix(); 
	
	//make login dialog box
	$('#login').dialog({ autoOpen: false, title:"Log in" });
	$('#loginLink').attr('href','#').click(function(){
		$('#login').dialog('open');
		});
		
	//Make image popups
	$('a.fancy').fancybox({
		overlayColor: '#000',
		padding:0,
		transitionIn:'none', 
		transitionOut:'none'
	});
	
	//making the map popup
	$(".googlemaps").fancybox({
	width:425,
	height:350,
 	speedIn: 500, 
	speedOut: 500, 
	overlayColor:'#000',
	type : 'iframe',
	overlayShow: true }); 
	//make sure tab thingy stays when hovering over the menu
	$('#navMain ul').hover(function(){
		$(this).siblings('a').addClass('activeLink');
	}, function(){
		$(this).siblings('a').removeClass('activeLink');
	});
	$('#navMain a').hover(function(){
			$(this).parent('li').addClass('liHover');
		}, function(){
			$(this).parent('li').removeClass('activeLink');
		});
	//make menus work in ie6
	$('#navMain ul li').hover(function(){
		$(this).addClass('liHover');
	}, function(){
		$(this).removeClass('liHover')
	});
	//make the dropdown menus line up in the center
	$('#navMain li').each(function(){
		var linkWidth = $(this).children('a').first().innerWidth();
		var ulWidth = $(this).children('ul').first().outerWidth();
		var leftOffset = ((linkWidth - ulWidth )/2);
		$(this).children('ul').css('left',leftOffset+'px');
	});
	//make sure images don't exceed the size of their containers
	
	$('#productDescription img').each(function(){
		if($(this).width() > $('#productDescription').innerWidth()){
			$(this).removeAttr('height').attr('width', $('#productDescription').innerWidth());
		}
	});
});
