$(document).ready(function(){
    initializeMenu();
    menuPositionFix();
}); 

function menuPositionFix() {

		var items = $(".menu > ul > li"), 
			menuWidth = $(".menu").width(),
			i,
			elementsWidth = 0,
			marginWidth;
		for (i = items.length - 1; 0 <= i; i--) {
			elementsWidth += $(items[i]).width();
		}

		marginWidth = Math.round((menuWidth - elementsWidth) / (items.length - 1));

		for (i = items.length - 3; 0 <= i; i--) {
			$(items[i]).css('margin-right',marginWidth);
		}

		items.filter(':last').css('float','right');

}

function initializeMenu() {
	$("#size-guide").hide();
	$(".widthProduct .col1 ul").show();
	$(".widthProduct .col1 div").show();

	$(".menu li").hover(function(){
	$(this).children('ul').show();
	$(this).css('backgroundColor','#faf4de');
	},function(){
	$(this).children('ul').hide();
	$(this).css('backgroundColor','#FFF');
	});
	
	$(".footer .form-text").focus(function(){
		$(this).select();
	});
	
	$(".width353b .col2 .form-text").focus(function(){
		$(this).select();
	});
	
	$(".widthProduct .col1 li a").click(function() {
		var imageS = $(this).children('img').attr("src");
		var imageM = $(this).attr("href");
		var imageL = $(this).attr("rel");
		var current = $(".widthProduct .col1 p a").attr("rel");
		var current2 = $(".widthProduct .col1 p a").attr("href");
		var current3 = $(".widthProduct .col1 p a img").attr("src");
		$(".widthProduct .col1 p a").attr({ rel: imageS });
		$(".widthProduct .col1 p img").attr({ src: imageM });
		$(".widthProduct .col1 p a").attr({ href: imageL });
		$(this).children('img').attr({ src: current });
		$(this).attr({ rel: current2 });
		$(this).attr({ href: current3 });
		
		return false;		
	});
	
	$(".widthProduct .col1 p a").click(function() {
		Shadowbox.open(this); 
		return false; 
	});
}
