// JavaScript Document


$(function(){
		$("#select_com .current_com").live("mouseover",function(){
			$(this).siblings(".other_com").show();
		});
		$("#select_com").mouseleave(function(){
			$(this).children(".other_com").hide();
		});
});

//show and hide child element
$(function(){
		$("#select_com li").live("click", function(){
			$(this).siblings().children("div").hide();
			$(this).siblings().removeClass("t1");
			$(this).addClass("t1");
			$(this).children("div").show();
		});
});

$(function(){
		$("#show_area li").live("click", function(){
			$(this).siblings().children("div").hide();
			$(this).siblings().removeClass("t1");
			$(this).addClass("t1");
			$(this).children("div").show();
		});
});

//nav
function buildNodes(treeData,prefix){
	var html = [];
	prefix = prefix||'topnote_';
	html.push("<ul>");
	for(var _a=0,count=treeData.length;_a<count;_a++ ){	
		var _temp = treeData[_a];
		if(_temp.ifHide==1)continue;
		html.push("<li id='");
		html.push(prefix);
		html.push(_temp.id);
		html.push("'><a href='");
		html.push(_temp.url);
		html.push("'");
		if(_temp.target == "_blank"){
			html.push(" target='_blank'");
		}
		html.push(" >")
		html.push(_temp.name);
		html.push("</a>");
		if(_temp.children&&_temp.children.length>0){
			html.push(buildNodes(_temp.children,prefix));
		}		
		html.push('</li>');
	}
	html.push("</ul>");
	return html.join("");
}

function joinSearch(){
	var html = [];
	html.push('<div class="header_search">');
	html.push('<form id="form1" name="form1" method="post" action="/search/result.html" onSubmit="return checkKey(this);">');
	html.push('<input type="text" id="search_txt" name="keyword" class="search_txt" value="搜索" onfocus="if (value ==\'搜索\'){value =\'\'}" onblur="if (value ==\'\'){value=\'搜索\'}" maxlength="20" /><input type="submit" id="search_go" name="search_go" class="search_go" value="GO" />');
	html.push('</form>');
	html.push('</div>');
	return html.join("");

}
function navEffect(){
	$(".nav ul ul:has(ul)").addClass("nav3");
		$(".nav ul ul li:first-child").css("border-left","none");
		$(".nav ul ul li:last-child").css("border-right","none");
		$(".nav>ul>li").hover(function(){
			$(this).children("a").addClass("hover");
			$(this).children("ul").show();
		},function(){
			$(this).children("a").removeClass("hover");
			$(this).children("ul").hide();
		});
}


//set sidebar cannot beyond footer
$(function(){
		if($(".content").height()<$(".sidebar").height()){
			$(".content").height($(".sidebar").height());
		}
});

$(function(){
		window.setTimeout(function(){$(".right .sidebar").css("top",$(".banner").height()+7);},400);
});

//using div and input to instead of select element for rich style
$(function(){
		$("#mselect .arrow").click(function(){
			$(this).siblings("span").toggle();
		});
		$("#mselect span a").click(function(){
			$(this).parent().hide();
			$("#ntype").val($(this).text());
			return false;
		});
});


$(function(){
		$(".left_nav>ul>li:has(ul)").addClass("havesub");
		$(".left_nav li li.current").parent().parent().removeClass("current");
		$(".left_nav li li.current").parent().show();

});

$(function(){
		var noborder=$(".videolist li").eq($(".videolist li").length-3);
		noborder.nextAll().andSelf().css("border-bottom","none");
		$(".productlist .box_b li:last-child").css("border-bottom","none");
});

//pop
$(function(){
		$(".pop").hide();
		window.setTimeout(function(){$(".pop").fadeIn(1000);},30000);
		window.setTimeout(function(){$(".pop").fadeOut(1000);},42000);
		$(".pop .close_pop img").click(function(){
			$(".pop").fadeOut(1000);
		});
		$(".pop .pop_btn a").click(function(){
			$(".pop").hide();
		});
});
  
 function checkKey(form){
	 //alert();
	 if(form.keyword.value =='' || form.keyword.value =='搜索'){
		 return false;
	 }
	 return true;
 }
function areaPosion(currentId){
	$("#"+currentId).parent().parent().parent().children("div").hide();
	$("#"+currentId).parent().parent().parent().siblings().removeClass("t1");
	$("#"+currentId).parent().parent().parent().addClass("t1");
	$("#"+currentId).css("font-weight","bold");
	$("#"+currentId).parent().parent().parent().children("div").show();
}
