/***************
* 数码商城portal
* -------------------------
* 备注
* -------------------------
* 修订记录：
* 20100419 brianliu	创建
****************/
//////////////////全局变量/////////////////////////////////////
//命名空间
$namespace('brand.spu3c.portal');
//页面初始化
brand.spu3c.portal.init=function(){
	//导航分类初始化
	this.initNav();
	//巨无霸广告
	this.slideAd();
	//排行榜list动作绑定
	this.initItemList();
	//tab切换
	this.initTabChange();
	
}
////////////////////功能实现区域代码////////////////////
//导航分类初始化
brand.spu3c.portal.initNav=function(){
	$$('#mainNav li').hover(function(){
		$$(this).addClass('current');
		$$(this).find('ul').show();
	},function(){
		$$(this).removeClass('current');
		$$(this).find('ul').hide();
	});
}
//排行榜list动作绑定
brand.spu3c.portal.initItemList=function(){
	
	$$('#hotSale li,#hotSearch li').mouseover(function(){
		$$(this).parent().find('li.current').removeClass('current');
		$$(this).addClass('current');
	});
}
//tab切换
brand.spu3c.portal.initTabChange=function(){
	$$('#specialSale li').mouseover(function(){
		$$('#specialSale li.current').removeClass('current');
		$$(this).addClass('current');
		$$('[tag="specialSaleContent"]').hide();
		var index=$$(this).attr('index');
		$$('#specialSaleContent'+index).show();
		return false;
	});
	$$('#hotItems li').mouseover(function(){
		$$('#hotItems li.current').removeClass('current');
		$$(this).addClass('current');
		$$('[tag="hotItemContent"]').hide();
		var index=$$(this).attr('index');
		$$('#hotItemContent'+index).show();
		return false;
	});
}
//巨无霸广告
brand.spu3c.portal.slideAd=function(){
	slider_p('#slideAd','#slideAdPic','#slideAdTab li',546,3000,'current');
	function slider_p(wId,sArea,tArea,w,t,cur){
		//sArea 滚动区域
		//tArea 文(数)字区域
		//w		每次滚动宽度
		//t		间隔时间 false不自动滚动
		//cur	当前状态class
		if(!$$(wId)) return;
		var index = 1,
		sliderLen = $$(tArea).length;
		$$(tArea).mouseover(function(){
			index  = $$(tArea).index(this);
			showSlider(index);
		});	
		$$(wId).hover(
			function(){
			if(MyTime){	clearInterval(MyTime);}
		 },function(){
			 if(t){
			if(MyTime){	clearInterval(MyTime);}
			MyTime = setInterval(function(){
			showSlider(index)
			index++;
			if(index==sliderLen){
			index=0;}
			},t);}
			else{return;}
		 });
		
		 if(t){
			if(MyTime){	clearInterval(MyTime);}
			var MyTime = setInterval(function(){
			showSlider(index)
			index++;
			if(index==sliderLen){index=0;}
		},t);
		}
		else{return;}
		
		function showSlider(i){
			$$(sArea).stop(true,false).animate({'marginLeft' : -w*i},500);		
			if($$(tArea)){
				$$(tArea).eq(i).addClass(cur).siblings().removeClass(cur);
			}
		}
	}
}

/*********** Begin Core Function ***********/
function $namespace(str){
	var arr=str.split(',');
	for(var i=0;i<arr.length;i++){
		// 将命名空间切成N部分, 比如mini、common等
		arr[i]=arr[i].split(".");
		str= "";
		var strEval= "";		
		for (var j = 0; j < arr[i].length; j++){
			if (j!= 0){str += "."};
			str += arr[i][j];
			// 依次创建构造命名空间对象（假如不存在的话）的语句
			// 比如先创建mini，然后创建mini.common依次下去
			strEval += "if (typeof(" + str + ") == 'undefined'){" + str + " = {}};";
		};
		if(strEval != ""){eval(strEval)};
	}
};
/***********  End Core Function  ***********/

window["brand.spu3c.portal.js"]=true;/*  |xGv00|5bac686aec7cf9cc7f8ffc2da9798f72 */