//By jquery
//from zhubajie
jQuery.fn.extend({
  zhubajie_select: function() {
	  var d=this;
	  var ced=false;
	  var f=d.find("select");
	  f.hide();
	  d.append('<div class="dropselectbox" style="display: block;"><h4 class="" style="width: '+ f.width() +'px;">'+ f.val() +'</h4><span class="FixSelectBrowserSpan"/><ul style="display: none; width: '+ d.find("h4").width() +'px;"/></div>');
	  d.find("h4").hover(function(){$(this).addClass("over");},function(){$(this).removeClass("over");});
	  d.blur(function(){d.find("li").remove();d.find("ul").hide();ced=false;});
	  d.find("div").click(function(){
		  if(ced){
			d.find("li").remove();
			d.find("ul").hide();
			ced=false;
		  }else{
			  d.find("li").remove();
			  d.find("ul").show();
			  
			  d.find("h4").toggleClass("current");
			  //d.find("span").toggleClass("over");
			  
			  f.find("option").each(function(){
					d.find("ul").append("<li>"+$(this).text()+"</li>");
				}); 

			  d.find('ul').css('width',d.find('h4').width());
			  d.find("ul li").each(function(){
				if($(this).text()==d.find("h4").text())$(this).addClass("over");
			  });

				d.find('ul li').hover(function(){d.find('ul li').removeClass("over");$(this).addClass("over");},function(){$(this).removeClass("over");});
				d.find('ul li').click(function(){
					var val=$(this).text();
					
					d.find('h4').html(val);f.val(val);
					
					if(d.attr('id')=='zhubajie_type'){
						$("#zhubajie_cat h4").html($("#zhubajie_cat select").val());
					}
				}); 

				ced=true;
			}
	  });
	  },
	 zhubajie_topmenu: function() {
		 var d=this;
		 var d_=$(".tabcon");
		 var did=this.attr("id");
		 var thisli=d.find(".currently");
		 var thislid=thisli.attr('id');
		 d.find(".topmenu_over").hover(function(){

				 var thisid=$(this).attr("id");
				 var thisid_=$("#"+thisid+"_");
				 if(thislid!=thisid)$(this).addClass("currently");
				 d_.find("ul").hide();
				 //d_.find("ul").hide('show');
				 //thisid_.show('show');
				 thisid_.fadeIn('show');
				 },function(){

				 var thisid=$(this).attr("id");
				 var thisid_=$("#"+thisid+"_");
				 if(thislid!=thisid)$(this).removeClass("currently");
				 //d_.find("ul").hide();
				 //thisid_.show();
				 });
	   }

});
