// JavaScript Document
function selProByBrandColor(b,m,n,p) {
	var url=location.href;
	if (url.indexOf("brandpro.php")) {
	    var url=url.split("brandpro.php");
	} else {
	    var url=url.split("brandproview.php");
	}
	var preurl=(url[0]=='http://'+window.location.host+'/shoptest/') ? '' : 'http://'+window.location.host+'/';
    location.href=preurl+'brandpro.php?bid='+b+'&types='+n+'&category='+p+'&color='+m;
}

function showBrandProByProperty(bid,n,part,property,category,types,color) {
	opens('showmsg');
	var obj=(part==0) ? 'pro_part_0' : 'pro_part_1';
	var m=(part==0) ? 5 : 7;
	for (var i=1;i<m;i++) {
		 $(obj+i).className='';
	}
	$(obj+n).className='currentTab';
	$(obj).innerHTML=getInfo('showBrandproperty.php?bid='+bid+'&ispart='+part+'&property='+property+'&category='+category+'&types='+types+'&color='+color);
	closes('showmsg');
}

/*卖场商品分类属性展示2009-04-28*/
function showBrandMallPro(bid,n,part,property,category,types,color) {
	switch (part) {
		case '0':
		 var obj='pro_part_0';
		 var framesrc='pro_full';
		 break;
		case '1':
		 var obj='pro_part_1';
		 var framesrc='pro_sell';
		 break;
	}
	var m=6;
	for (var i=1;i<m;i++) {
		 if ($(obj+i)!=null) $(obj+i).className='';
	}
	var urls = (8 == property) ? 'brand/brandsalearea.php' : 'brandmall.php';
	$(obj+n).className='currentTab';
	$(framesrc).src=urls+'?bid='+bid+'&ispart='+part+'&property='+property+'&category='+category+'&types='+types+'&color='+color;
}

/*特卖区商品分类属性展示2009-04-28*/
function showBrandSaleAreaPro(bid,n,part,property,category,types,color) {
	switch (part) {
		case '0':
		 var obj='pro_part_0';
		 var framesrc='pro_full';
		 break;
		case '1':
		 var obj='pro_part_1';
		 var framesrc='pro_sell';
		 break;
	}
	var m=4;
	for (var i=1;i<m;i++) {
		 if ($(obj+i)!=null) $(obj+i).className='';
	}
	$(obj+n).className='currentTab';//alert(framesrc);
	$(framesrc).src='brandsalearea.php?bid='+bid+'&ispart='+part+'&property='+property+'&category='+category+'&types='+types+'&color='+color;
}

function showBrandProBy(b,o,m,n,p,k) {
	opens('showmsg');
	if (m==0) {
		var obj='prolist_0';
		$('img0_0').src='/images/subtime.gif';
		$('img0_1').src='/images/subhit.gif';
		$('img0_2').src='/images/subcol.gif';
		for (i=1;i<7;i++) {
		   if ($('img0'+i)!=null) {	 
			 if (i % 2 !=0) {
			     $('img0'+i).src='/images/up.gif';
			 } else {
				 $('img0'+i).src='/images/down.gif';
			 }
		   }
		}
		if ($('img0'+o)!=null) {
		if (o % 2 ==0) {
			$('img0'+o).src='/images/down2.gif';
		} else {
			$('img0'+o).src='/images/up2.gif';
		}
		}
		if (n=='dates') {$('img0_0').src='/images/subtime2.gif';}
		if (n=='clicks') {$('img0_1').src='/images/subhit2.gif';}
		if (n=='fav') {$('img0_2').src='/images/subcol2.gif';}
	} else if (m==1) {
		var obj='prolist_1';
		$('img1_0').src='/images/subtime.gif';
		$('img1_1').src='/images/subhit.gif';
		$('img1_2').src='/images/subsold.gif';
		//$('img1_3').src='/images/suborder.gif';
		$('img1_4').src='/images/subprice.gif';
		$('img1_5').src='/images/subcol.gif';
		for (i=1;i<13;i++) {
		   if ($('img1'+i)!=null) {	 
			 if (i % 2 !=0) {
			     $('img1'+i).src='/images/up.gif';
			 } else {
				 $('img1'+i).src='/images/down.gif';
			 }
		   }
		}
		if ($('img1'+o)!=null) {
		if (o % 2 ==0) {
			$('img1'+o).src='/images/down2.gif';
		} else {
			$('img1'+o).src='/images/up2.gif';
		}
		}
		if (n=='dates') {$('img1_0').src='/images/subtime2.gif';}
		if (n=='clicks') {$('img1_1').src='/images/subhit2.gif';}
		if (n=='sales') {$('img1_2').src='/images/subsold2.gif';}
		//if (n=='team') {$('img1_3').src='/images/suborder2.gif';}
		if (n=='price') {$('img1_4').src='/images/subprice2.gif';}
		if (n=='fav') {$('img1_5').src='/images/subcol2.gif';}
	}
	//alert(getInfo('showBrandproby.php?bid='+b+'&ispart='+m+'&sorts='+n+'&x='+p+'&c='+k));
	$(obj).innerHTML=getInfo('showBrandproby.php?bid='+b+'&ispart='+m+'&sorts='+n+'&x='+p+'&c='+k);
	closes('showmsg');
}

function brandProList_page(obj,url) {
	opens('showmsg');
	var url=url.split("_");
	$(obj).innerHTML=getInfo('proBrandlistpage.php?ispart='+url[0]+'&sorts='+url[1]+'&x='+url[2]+'&property='+url[3]+'&category='+url[4]+'&types='+url[5]+'&color='+url[6]+'&page='+url[7]+'&bid='+url[8]);
	closes('showmsg');
}

function getBrandProMenu(id) {
	var obj_brand       = 'ProListArea';
	var acton_brand     = 'product';
	var obj_salearea    = 'saleArea';
	var action_salearea = 'brand';
	
	if ('' != id) {
		
		var brand_content    = getInfo('/brandProMenu.php?id='+id+'&action='+acton_brand);
		var salearea_content = getInfo('/brandProMenu.php?id='+id+'&action='+action_salearea);
		
		('' == brand_content) ? closes(obj_brand) : $(obj_brand).innerHTML = brand_content;
		('' == salearea_content) ? closes(obj_salearea) : $(obj_salearea).innerHTML = salearea_content;
		
	} else {
		
		$(obj_brand).innerHTML = '<div style="margin:10px;">参数错误，请联系客服</div>';
		$(obj_salearea).innerHTML = '<div style="margin:10px;">参数错误，请联系客服</div>';
		
	}
}

function showBrandList(letter,typen) {
	$('brand_list').innerHTML='<ul class="room" style="text-align:center">数据读取中，请稍等...</ul>';
	var list=getInfo('brandsign.php?typen='+typen+'&letter='+letter);
	$('brand_list').innerHTML=list;
}

function scroll_brand(obj) {
	this.obj=obj;
	this.scroll_speed=2;//滚动速度
	this.scroll_space=8;//滚动距离
	this.page_width=194;//翻页宽度
	this.scroll_fill=0;//填充距离
	this.switch_speed=6000;//切换时间间隔
	this.moveLock=false;//滚动锁定
	this.comp_width=0;//移动相对间距
	this.autoTimeID=null;
	this.moveTimeID;
	this.AutoPlay();
}

scroll_brand.prototype.AutoPlay=function() {//自动滚动
	clearInterval(this.autoTimeID);
	this.autoTimeID = setInterval(''+this.obj+'.Next();'+this.obj+'.NextStop();',this.switch_speed);
}

scroll_brand.prototype.Next=function() {//下翻
	clearInterval(this.moveTimeID);
	if (this.moveLock) {
		return;
	}
	clearInterval(this.autoTimeID);
	this.moveLock=true;
	if ($(list1).scrollWidth>this.page_width*4) {
		this.NextAction();
		this.moveTimeID=setInterval(this.obj+".NextAction();",this.scroll_speed);
	} else {
		clearInterval(this.autoTimeID);
		clearInterval(this.moveTimeID);
		//alert('当前内容已全部显示');
	}
}

scroll_brand.prototype.NextStop=function() {//下翻停止
	clearInterval(this.moveTimeID);
	if (eval($(cont).scrollLeft % this.page_width - this.scroll_fill)!=0){
		this.comp_width=this.page_width-$(cont).scrollLeft % this.page_width+this.scroll_fill;
		this.scrollAct();
	}else{
		this.moveLock=false;
	}
	this.AutoPlay();
}

scroll_brand.prototype.NextAction=function() {//下翻动作
	//alert($(cont).scrollLeft+'='+$(list1).scrollWidth);
	if ($(cont).scrollLeft >= $(list1).scrollWidth){
		$(cont).scrollLeft=$(cont).scrollLeft - $(list1).scrollWidth;
	}
	$(cont).scrollLeft += this.scroll_space;
}

scroll_brand.prototype.Prev=function() {//上翻
	if (this.moveLock) {
		return;	
	}
	clearInterval(this.autoTimeID);
	this.moveLock=true;
	if ($(list1).scrollWidth>this.page_width*4) {
		this.moveTimeID=setInterval(this.obj+".PrevAction()",this.scroll_speed);
	} else {
		clearInterval(this.autoTimeID);
		clearInterval(this.moveTimeID);
		//alert('当前内容已全部显示');
	}
}

scroll_brand.prototype.PrevStop=function() {//上翻停止
	clearInterval(this.moveTimeID);
	if (eval($(cont).scrollLeft % this.page_width - this.scroll_fill)!=0){
		this.comp_width=this.scroll_fill-($(cont).scrollLeft % this.page_width);
		this.scrollAct();
	}else{
		this.moveLock=false;
	}
	this.AutoPlay();
}

scroll_brand.prototype.PrevAction=function() {//上翻动作
	if ($(cont).scrollLeft <= 0){
		$(cont).scrollLeft=$(cont).scrollLeft + $(list1).offsetWidth;
	}
	$(cont).scrollLeft -= this.scroll_space;
}

scroll_brand.prototype.scrollAct=function() {
	var width=0;
	if (this.comp_width==0){
		this.moveLock=false;
		return;
	}
	if (this.comp_width<0){ //上翻
		if (Math.abs(this.comp_width)>this.scroll_space){
			this.comp_width+=this.scroll_space;
			width=this.scroll_space;
		} else {
			width=Math.abs(this.comp_width);
			this.comp_width=0;
		}
		$(cont).scrollLeft-=width;
		setTimeout(this.obj+".scrollAct()",this.scroll_speed);
	} else { //下翻
		if (this.comp_width>this.scroll_space) {
			this.comp_width-=this.scroll_space;
			width=this.scroll_space;
		} else {
			width=this.comp_width;
			this.comp_width=0;
		}
		$(cont).scrollLeft+=width;
		setTimeout(this.obj+".scrollAct()",this.scroll_speed);
	}
}