// page init
$(function() {
	initLayout();
	ieHover('ul.nav li, div.div-class, span, #box, #nav li');
});

// hover for IE
function ieHover(_list) {
	if ($.browser.msie && $.browser.version < 7) {
		$(_list).hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
	}
}

// layout fix function
function initLayout() {
	// products page fix
	$('div#products').each(function(){
		var _holder = $(this);
		var _productWidth = _holder.find('ul.list-products > li').eq(0).outerWidth(true);
		function fixLayout() {
			_holder.css({
				margin:'0 4%',
				width:'auto'
			});
			var _itemsCount = Math.floor(_holder.width() / _productWidth);
			_holder.css({
				margin:'0 auto',
				width:_itemsCount*_productWidth+3
			});
		}
		$(window).resize(function(){
			fixLayout();
		});
		fixLayout();
	});

	// products detail page fix
	$('div#products-detail').each(function(){
		var _holder = $(this);
		var _holder1 = _holder.find('.aside1');
		var _holder2 = _holder.find('.holder-aside2');
		var _productWidth = _holder.find('.holder-aside2 > ul > li').eq(0).outerWidth(true);

		function fixLayout() {
			_holder.css({
				margin:'0 2%',
				width:'auto'
			});
			var _itemsCount = Math.floor(_holder2.width() / _productWidth);
			_holder.css({
				margin:'0 auto',
				width:_itemsCount*_productWidth + _holder1.width() + 37
			});
		}
		$(window).resize(function(){
			fixLayout();
		});
		fixLayout();
	});


}
