function fAddClass(XEle, XClass) {
  if(!XClass) throw new Error("XClass 不能为空!");
  if(XEle.className!="") {
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = XEle.className.replace(Re, "");
	var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
	if (OldClassName == "" ) {
		 XEle.className = XClass;
	}
	else {
		XEle.className = OldClassName + " " + XClass;
	}
  }
  else XEle.className = XClass;
}

function fRemoveClass(XEle, XClass) {
  if(!XClass) throw new Error("XClass 不能为空!");
  var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
  if(OldClassName!="") {
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = OldClassName.replace(Re, "");
  }
}

function $1(item){
	return document.getElementById(item);
}


//向左滚动
ScrollCrossLeft={interval:0,count:0,duration:0,step:0,srcObj:null,callback:null};
ScrollCrossLeft.doit=function(obj,b,c,d){
	var s=ScrollCrossLeft;
	obj.style.marginLeft=cpu(s.count,b,c,d)+'px';
	s.count++;
	if(s.count==d){
		clearInterval(s.interval);
		s.count=0;
		obj.style.marginLeft=b+c+'px';
		s.callback();
	}
	function cpu(t,b,c,d) {return c*((t=t/d-1)*t*t+1)+b;};
}
ScrollCrossLeft.scroll=function(obj,step,span,beign,callback,duration){
	var s=ScrollCrossLeft;
	s.duration=duration;
	s.callback=callback;
	s.interval=setInterval(function(){s.doit(obj,beign,step*span,duration)},10);
}


var Brand_column={current:0,step:0,a:'a_brand_column_',div:'div_brand_column_content',ul:'ul_brand_column'}

var Turn={}
Turn.pre=function(obj){
	if(obj.current==0){
		return;
	}else{
		Turn.go(obj,obj.current-1);
	}
}
Turn.next=function(obj){
	if(obj.current==2){
		return;
	}else{
		Turn.go(obj,obj.current+1);
	}
}
Turn.go=function(obj,index){
	if(obj.current==index){return;}
	var span=-index+obj.current;
	if(obj.clickflag > 0){return;}
	obj.clickflag=1;
	if(obj.step>0) {
		try {
			//showImage(index) ;
			if (obj.img) {
				setTimeout( function () {
							for (cnt=index*6;cnt<=((index+1)*6 -1 );cnt++ ) {
								var picobj = document.getElementById(obj.div　+ "_pic_" + cnt) ;
								//alert(obj.img[cnt]) ;
								//if (picobj.src == "http://images.movie.xunlei.com/img_default.gif"){
									picobj.src = obj.img[cnt] ;
								//}
							}
						}, 50) ;
			}
		}
		catch (e){}
		ScrollCrossLeft.scroll($1(obj.div),obj.step,span,parseInt($1(obj.div).style.marginLeft)||0,cb,10);
	}
	else{
		displayNOrY();
		cb();	
	}
	function showImage() {
		for (cnt=index*6;cnt<=((index+1)*6 -1 );cnt++ ) {
			var picobj = document.getElementById(obj.div　+ "_pic_" + cnt) ;
			//alert(obj.img[cnt]) ;
			if (picobj.src == "http://images.movie.xunlei.com/img_default.gif"){
				picobj.src = obj.img[cnt] ;
			}
		}
	}
	function imgSrc(index,id){
		var arr_img=$1(id+'_'+index).getElementsByTagName('img');
		for(var i=0;i<6;i++){
			arr_img[i].src=obj.imgs[index-1][i];
		}
	}
	function cb(){
		obj.current=index;
		obj.clickflag=0;
		for(var i=0;i<3;i++){
			$1(obj.a+i).className='';
		}
		$1(obj.a+index).className='currA';
	}
	function displayNOrY(){
		obj.current=index;
		for(var i=0;i<3;i++){
			if(i==index)
				$1(obj.ul+'_'+i).style.display='block';
			else
				$1(obj.ul+'_'+i).style.display='none';
		}
	}
}

