/*======================================================================================
 Home JS handler
 Created: TH - 03/11/2009
======================================================================================*/


set_switch_sub_nav = {
	builder: function() {
		var b = document.body;
		$('#nav>li').not('.prod, .main').click(function() {
			//在IE6下隐藏下拉框
			if ($.browser.msie && $.browser.version == 6) {$('select').css({visibility:'hidden'});}
			//--------------------------
			var c = this.className.split(' ')[0];  //防止将 hover 一起添加
			fnSetBodyClassName(c);
			//alert(b.className);
			this.getElementsByTagName('a')[0].blur();
			return false;
		});
		function fnSetBodyClassName(s) {
			if (b.className==s) {
				b.className = '';
				//在IE6下恢复下拉框
				if ($.browser.msie && $.browser.version == 6) {$('select').css({visibility:'visible'});}
			}
			else b.className = s;
		}
		$(document).click(function() {
			b.className = '';
			//在IE6下恢复下拉框
			if ($.browser.msie && $.browser.version == 6) {$('select').css({visibility:'visible'});}
		});
	},
	init: function() {
		set_switch_sub_nav.builder();
	}
}

//sub_nav
set_scroll_sub_nav = {
	builder: function() {
		checkButtons(true, "#sports_select_arrows .rev a", "#sports_select_arrows .fwd a", iSubNavSportsRight, iSubNavSportsTotal, 5);
		checkButtons(true, "#lifestyle_select_arrows .rev a", "#lifestyle_select_arrows .fwd a", iSubNavLifestyleRight, iSubNavLifestyleTotal, 5);
		checkButtons(true, "#fashion_select_arrows .rev a", "#fashion_select_arrows .fwd a", iSubNavFashionRight, iSubNavFashionTotal, 5);
		
		//sports_select_arrows
		$("#sports_select_arrows .rev a").click(function(event){
			iSubNavSportsRight = moveFrames("#sports_select_wrapper", 170, 'left', iSubNavSportsTotal, 5, iSubNavSportsRight);
			checkButtons(true, "#sports_select_arrows .rev a", "#sports_select_arrows .fwd a", iSubNavSportsRight, iSubNavSportsTotal, 5);
			return false;
		});
		$("#sports_select_arrows .fwd a").click(function(event){
			iSubNavSportsRight = moveFrames("#sports_select_wrapper", 170, 'right', iSubNavSportsTotal, 5, iSubNavSportsRight);
			checkButtons(true, "#sports_select_arrows .rev a", "#sports_select_arrows .fwd a", iSubNavSportsRight, iSubNavSportsTotal, 5);
			return false;
		});
		//lifestyle_select_arrows
		$("#lifestyle_select_arrows .rev a").click(function(event){
			iSubNavLifestyleRight = moveFrames("#lifestyle_select_wrapper", 170, 'left', iSubNavLifestyleTotal, 5, iSubNavLifestyleRight);
			checkButtons(true, "#lifestyle_select_arrows .rev a", "#lifestyle_select_arrows .fwd a", iSubNavLifestyleRight, iSubNavLifestyleTotal, 5);
			return false;
		});
		$("#lifestyle_select_arrows .fwd a").click(function(event){
			iSubNavLifestyleRight = moveFrames("#lifestyle_select_wrapper", 170, 'right', iSubNavLifestyleTotal, 5, iSubNavLifestyleRight);
			checkButtons(true, "#lifestyle_select_arrows .rev a", "#lifestyle_select_arrows .fwd a", iSubNavLifestyleRight, iSubNavLifestyleTotal, 5);
			return false;
		});
		//fashion_select_arrows
		$("#fashion_select_arrows .rev a").click(function(event){
			iSubNavFashionRight = moveFrames("#fashion_select_wrapper", 170, 'left', iSubNavFashionTotal, 5, iSubNavFashionRight);
			checkButtons(true, "#fashion_select_arrows .rev a", "#fashion_select_arrows .fwd a", iSubNavFashionRight, iSubNavFashionTotal, 5);
			return false;
		});
		$("#fashion_select_arrows .fwd a").click(function(event){
			iSubNavFashionRight = moveFrames("#fashion_select_wrapper", 170, 'right', iSubNavFashionTotal, 5, iSubNavFashionRight);
			checkButtons(true, "#fashion_select_arrows .rev a", "#fashion_select_arrows .fwd a", iSubNavFashionRight, iSubNavFashionTotal, 5);
			return false;
		});
	},
	
	init: function() {
		iSubNavSportsTotal = $("#sports_select_wrapper li").length;
		iSubNavSportsRight = 5;
		
		iSubNavLifestyleTotal = $("#lifestyle_select_wrapper li").length;
		iSubNavLifestyleRight = 5;
		
		iSubNavFashionTotal = $("#fashion_select_wrapper li").length;
		iSubNavFashionRight = 5;
		
		set_scroll_sub_nav.builder();
	}
}

$(document).ready(function() {
	set_switch_sub_nav.init();
	set_scroll_sub_nav.init();
	
});

