//TAB页签
function setTab(name,cursel,n){
	for(i=1;i<=n;i++)
	{
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"tab_active":"tab_normal";
		con.style.display=i==cursel?"block":"none";
	}
}


//注册表单
$(function(){
		   
	$("#register .txt")
	.focus(function(event){
		$(this).css({"border":"1px solid #838183"})
		$(this).next("div").show();
	})
	.blur(function(event){
		$(this).css({ "border":"1px solid #A7A6AA"})
		$(this).next(".note").fadeOut(200);
	});
	

 }); 

//列表鼠标经过效果
$(function(){
	$(".table_con tr").hover(
		function () {
		$(this).addClass("hover");
	},
		function () {
		$(this).removeClass("hover");
	}
	); 
 }); 
//更多条件
$(function(){
	$("#s_cen").toggle(
		function () {
		$("#s_mores").addClass("show");
		$("#s_cen").addClass("s_cen2");
	},
		function(){
		$("#s_mores").removeClass("show");
		$("#s_cen").removeClass("s_cen2");
	}
	); 
 }); 
//家居更多条件
$(function(){
	$("#s_cen2").toggle(
		function () {
		$("#s_mores2").addClass("show");
		$("#s_cen2").addClass("s_cen2");
	},
		function(){
		$("#s_mores2").removeClass("show");
		$("#s_cen2").removeClass("s_cen2");
	}
	); 
 }); 
  //家居秀横向滚动
$(function(){

	var $num= $("#scrollcom ul li").length;//获取图片个数
	$('#scrollcom ul').width(130*$num);//计算ul总宽度

	var $scrollcom = $('#scrollcom');//获取宽度
	$('.show_scroll .left a').click(function(){ //向左按钮绑定单击事件
	   if(!$scrollcom.is(":animated")){//判断是否处于动画
		$scrollcom.animate({ scrollLeft  : "-=150" } , 600);//每次滚动3个图片
		return false;
		}
	})
	$('.show_scroll .right a').click(function(){//向右按钮绑定单击事件
	   if(!$scrollcom.is(":animated")){
		$scrollcom.animate({ scrollLeft  : "+=150" } , 600);
		return false;
		}
	});
	
	$("#scrollcom img").hover(
		function () {
		$(this).addClass("hover");
	},
		function () {
		$(this).removeClass("hover");
	}
	); 
	
});

  //家居秀横向滚动2
$(function(){

	var $num= $("#scrollcom2 ul li").length;//获取图片个数
	$('#scrollcom2 ul').width(116*$num);//计算ul总宽度

	var $scrollcom = $('#scrollcom2');//获取宽度
	$('.show_scroll .left a').click(function(){ //向左按钮绑定单击事件
	   if(!$scrollcom.is(":animated")){//判断是否处于动画
		$scrollcom.animate({ scrollLeft  : "-=116" } , 600);//每次滚动3个图片
		return false;
		}
	})
	$('.show_scroll .right a').click(function(){//向右按钮绑定单击事件
	   if(!$scrollcom.is(":animated")){
		$scrollcom.animate({ scrollLeft  : "+=116" } , 600);
		return false;
		}
	});
	
	$("#scrollcom2 img").hover(
		function () {
		$(this).addClass("hover");
	},
		function () {
		$(this).removeClass("hover");
	}
	); 
	
});
//家居秀按钮定位,图片大小限制
$(function(){
	var $h=$(".roomphoto_show").height();
	$(".roomphoto_show .left,.roomphoto_show .right").css({"top":$h/2-27});
	var $w=$(".roomphoto_show img").width();
	if($w>700){
		$(".roomphoto_show img").width(700)
		}
 });

//快照页面左右列高相等
$(function(){

	var div_h =$(".snapshot_l").height();
	$(".snapshot_r .con_c").height(div_h-28);
 });

//弹窗
$(function(){
	var $form_h=$(".pop_up form").height();//ie6下遮罩select bug,增加iframe
	$(".pop_up iframe").height($form_h);

	
	setInterval(function(){
	  $(".pop_up").each(function(){
		  $(this).css("top",$(window).scrollTop()+400);
	  });
	}, 100);

 });


//家居分类
$(function(){
	$("#result_class .box1").each(function(event){
										   
		$(this).children("li").children("a").click(function(){//分类点击后反色效果,并增加selected类
			$(this).parent().siblings().children("a").removeClass("selected"); 
			$(this).addClass("selected");
		});
		
		var $num=$(this).children("li").length;//获取分类个数
		if($num>12){//大于12个显示控制按钮
			$(this).css({"height":"102px"});
			$(this).parent(".con_r").after("<div class='more'><a href='#'>全部展开</a></div>")
			}
	 }); 

	$("#result_class .more").toggle(//控制按钮
		function () {
			$(this).children("a").text("全部收起");
			$(this).prev().children(".box1").css({"height":"100%"});
			 return false;
		},
		function () {
			$(this).children("a").text("全部展开");
			$(this).prev().children(".box1").css({"height":"102px"});
		 	return false;
		}
	); 


 });

//搜索感受弹窗
$(function(){
	//屏幕跟随
	setInterval(function(){
	  $(".msg_btn").each(function(){
		  $(this).css("top",$(window).scrollTop()+100);
	  });
	}, 100);
	
	
	//屏幕跟随
	setInterval(function(){
	  $(".msg_popup").each(function(){
		  $(this).css("top",$(window).scrollTop()+300);
	  });
	}, 100);
	
	
	
//	$(".msg_btn").toggle(
//		function () {
//				if(!$(".msg_popup").is(":animated")){
//					$(".msg_popup").animate({height:391,width:491,left:'50%'}, { duration:400 });
//				return false;
//				}
//			},
//		function () {
//				if(!$(".msg_popup").is(":animated")){
//					$(".msg_popup").animate({height:0,width:0,left:0}, { duration:400 });
//				return false;
//				}
//			}
//	); 

	//关闭弹窗
	$(".msg_popup .close").click(function(event){
		if(!$(".msg_popup").is(":animated")){
			$(".msg_popup").animate({height:0,width:0,left:0}, { duration:400 });
		return false;
		}
	});
	//点开弹窗
	$(".msg_btn").click(function () {
			if(!$(".msg_popup").is(":animated") & ($(".msg_popup").height()==0)  ){
				$(".msg_popup").animate({height:500,width:491,left:'50%'}, { duration:400 });
				return false;
			}
			else if(!$(".msg_popup").is(":animated") & ($(".msg_popup").height()==500)  ){
				$(".msg_popup").animate({height:0,width:0,left:0}, { duration:400 });
				return false;
			}
	}); 
	
 });
//下拉搜索框2 用于排序下拉
$(function(){
		   
	$("span.btn2")
	.click(function(event){
		$(".super_select2").fadeOut(200);
		$(this).next(".super_select2").show();
	});
	/*
	$(".super_select2 p").click(function(event){
		var selected = $(this).text()
		$(this).parents(".super_select2").fadeOut(200);
		$(this).parents(".super_select2").siblings(".btn2").html(selected);
		return false;
	});
	*/
	$(document).mouseup(function(event){
		$(".super_select2").fadeOut(200);
	});

 }); 

