// JavaScript Document

$(function(){ 
	search_change();	//搜索框切换
	message_list();		//信息发布列表
	waytab_change ();	//功能列表
	fontSize();			//字体控制
	Marq('.web-placard','<span>【公告】：</span>','.web-business');
	Marq('.web-business','<span>【供求】：</span>','.web-placard');
})

/*-----信息发布列表------*/
function message_list() {
	$(".subfunction dl").hover( 
		function(){
			$(this).addClass("s");
			$(this).children('dt').addClass("s")
			$(".subfunction dd").show();
		}, 
		function(){
			$(this).removeClass("s");
			$(this).children('dt').removeClass("s")
			$(".subfunction dd").hide()
		} 
	) 
}


/*-----搜索框切换------*/
function search_change (){
	
	/* 初始值*/   
	var Tab_style =$('#searchNav .toptab ul');
	Tab_style.children('li:first').addClass('sel');
	Tab_style.parents('.toptab').next('div').css('display','block');
	
	/*鼠标经过的变化*/
	Tab_style.children('li').click(
		function(){
			Tab_style.children('li').removeClass("sel");
			$("#searchNav .bottomtab").hide();
			$('.'+this.id).show();
			$(this).addClass("sel");
			/*Tab_style.children('li').prev('li').css('background','none');*/
		}
	)
}



/*-----66网功能下拉菜单切换------*/
function waytab_change (){
	
	/* 初始值*/   
	var Tabs =$('#tools .helper .home_list');
	var con_mask = $('#tools .mask');
	
	/*鼠标经过的变化*/
	Tabs.hover(
		function(){
			Tabs.addClass("s");
			con_mask.show();
		},
		function(){}
	)
	/*移动mennu框时div消失*/
	Tabs.hover(
		function(){},
		function(){
			con_mask.hide();
			Tabs.removeClass("s");
		}
	)
}

//资讯详细页字体控制
function fontSize(){
	$("#big").click(
		function(){
			$("#text_nav .con").css({fontSize:"18px",fontFamily:"'微软雅黑'"});
			$("#normal").removeClass('s');
			$("#small").removeClass('s');
			$(this).addClass('s');
		}
	);
	$("#normal").click(
		function(){
			$("#text_nav .con").css({fontSize:"14px",fontFamily:"'宋体'"});
			$("#big").removeClass('s');
			$("#small").removeClass('s');
			$(this).addClass('s');
		}
	);
	$("#small").click(
		function(){
			$("#text_nav .con").css({fontSize:"12px",fontFamily:"'宋体'"});
			$("#normal").removeClass('s');
			$("#big").removeClass('s');
			$(this).addClass('s');
		}
	);
}


//滚动商机及公告
/*function Marq(ConBox,ConTit,OtherBox){
	var placard = $(ConBox+' marquee').text();
	var placardLen = placard.length;
	
	if(placardLen==0){
		$(ConBox).hide();
		$(OtherBox).css({width:"755px"});
		$(OtherBox+' marquee').css({width:"700px"});
	}
	else if (placardLen>0 & placardLen<26){
		$(ConBox+' marquee').remove();
		$(ConBox).html(ConTit+placard);
	}
}*/

function Marq(ConBox,ConTit,OtherBox){
	var Len = $(ConBox).length;
	for(var i=0; i<Len; i++){
		var placard = $(ConBox).eq(i).find("marquee").text().replace(/(^\s*)|(\s*$)/g,'');
		var placardHtml = $(ConBox).eq(i).find("marquee").html();
		var placardLen = placard.length;
		//alert(placardLen);
		
		
		if (placardLen>0&&placardLen<26){
			$(ConBox).eq(i).show();
			$(ConBox).eq(i).find("marquee").remove();
			$(ConBox).eq(i).html(ConTit+placardHtml);
		}
		else if(placardLen==0){
			$(ConBox).eq(i).hide();
		//	$(OtherBox).eq(i).show();
			$(OtherBox).eq(i).css({width:"750px"});
			$(OtherBox).eq(i).find("marquee").css({width:"680px"});
		}
		
	}
}