
$(function(){
	if($("#navuinfo").size() > 0){
		$("#navuinfo .inp_text, #navuinfo .inp_sm").hover(function(){$(this).addClass("inp_text_active")},function(){$(this).removeClass("inp_text_active")}) 
	}
	
		
	$("#showswitch").hover(
		function(){$(this).addClass("nav_switch_active")},function(){$(this).removeClass("nav_switch_active");}
	)

	$("#quickmenu").hover(function(){$(this).addClass("nav_quicklick_active")},function(){$(this).removeClass("nav_quicklick_active")})

	$("#forumnav dt a").focus(function(){$(this).blur();})

	if($("#forumnav").size() > 0){$("#showitemnav").navgation({obj:"forumnav"})}


	$("#searchform input").removeAttr("checked").eq(1).attr("checked","checked");

	$("#searchform .inp_radio input").click(function(){
		$("#searchform .inp_radio").removeClass("inp_radio_active");
		$(this).parent().addClass("inp_radio_active")
	}).focus(function(){$(this).blur();});

	$("#announce .announce_closed").click(function(){
		$("#announce").animate({marginTop:"-30px"},800)
	})

	$("#headernav").hover(function(){
		var navTmp = $(this).find("#nav_tips");
		navTmp.find("div").css("width",navTmp.width()).end().show()
	},function(){$(this).find("#nav_tips").fadeOut()})

	$("body").click(function(){$("#forumnav dl").removeClass("active");})

	$("#closeNavgation").click(function(){$("#galaskin").attr("disabled","disabled");$(this).hide();})

	$("#show_navmsg").hover(function(){
		var msglist = $("#show_navmsg .nav_msglist");
		var diff = $(window).width() - $(this).offset().left;
		var width = msglist.outerWidth();
		if(diff < width){
			msglist.addClass("nav_msglist_right");
		}
		$(this).addClass("nav_msg_active");
	},function(){
		$(this).removeClass("nav_msg_active");
		$(this).find(".nav_msglist").removeClass("nav_msglist_right");
	})

	$("#version_showam, #version_showpm").click(function(){
		var className = $(this).attr("rel");
		$("#pub_main").attr("class","pub_main " + className);
		return false;
	})

	$("#gossip_tab a").click(function(){
		var str = $(this).attr("rel");
		$("#threadadd_gossip").attr("class","threadadd_main " + str);
		$("#gossip_tab span").removeClass("threadadd_active");
		$(this).parent().addClass("threadadd_active");
		return false;
	}).focus(function(){$(this).blur();})

	$("#show_tab a").click(function(){
		var str = $(this).attr("rel");
		$("#threadadd_show").attr("class","show_version " + str);
		$("#show_tab span").removeClass("threadadd_active");
		$(this).parent().addClass("threadadd_active");
		return false;
	}).focus(function(){$(this).blur();})

	//10楼层导航
	$("#nav_floor").find("h1").mouseover(function(){
		var i = parseInt($(this).attr("rel"));
		if(i == 2){$("#nav_floor dl").removeClass("sub_forum_select");$(this).attr("rel",0)}else{$(this).attr("rel", i+1);}
	}).end().find("dl").mouseover(function(){
		$("#nav_floor dl").removeClass("sub_forum_select");
		$(this).addClass("sub_forum_select");
	})
});

(function($){
	$.fn.navgation = function(options){
		var $this = $(this);
		var $obj = $("#"+ options.obj);
		var tmpHeight = ($obj.height() * (-1));
		var timeout = pause = "";
		if($obj.is(".nav_forum_club")){
			$this.hover(function(){
				if($obj.css("top") < 0 && $obj.css("top") > tmpHeight){return false;}
				$obj.animate({top:"0px"},80,function(){
					clearTimeout(timeout);
					$obj.hover(
						function(){
							pause = true;
							$(this).show()
						},
						function(){
							timeout = setTimeout(
								function(){
									pause = false;
									$obj.animate({top:tmpHeight + "px"},120)
								},200)
						}
					)
				})
			},function(){
				timeout = setTimeout(
					function(){
						if(pause != true){
							$obj.animate({top:tmpHeight + "px"},120)
						}
					},300)
			}).find("a").click(function(){return false;});
		}
	}
})(jQuery);

var dk = {};
	dk.showFooter = function(){
		if(arguments[0] == "index"){
			document.write('<div id="first_bottom"><dl><dt><a href="http://www.pingpinganan.gov.cn/web/index.aspx" target="_blank"><img width="53" height="53" border="0" title="杭州网络警察" alt="杭州网络警察" src="http://i3.dukuai.com/ui/channel/first/img/copyright_1.gif"></a><a href="http://www.pingpinganan.gov.cn/web/index.aspx" target="_blank"><img width="53" height="53" border="0" title="杭州网络警察" alt="杭州网络警察" src="http://i3.dukuai.com/ui/channel/first/img/copyright_2.jpg"></a><a href="http://www.idinfo.cn/SignHandle?userID=3301000000107101" target="blank"><img width="47" height="56" border="0" title="浙江省网络经济服务监管网" alt="浙江省网络经济服务监管网" src="http://i3.dukuai.com/ui/channel/first/img/copyright_3.jpg"></a></dt><dd class="bottom_dd1"><h4>了解19楼</h4><ul><li><a href="http://corp.dukuai.com/corp/page/intro.html" target="_blank">19楼介绍</a></li><li><a href="http://www.19lou.com/forum-196-filter-type-typeid-203-1.html" target="_blank">网友眼中的19楼</a></li><li><a href="http://www.19lou.com/forum-196-1.html" target="_blank">说说我眼中的19楼</a></li></ul></dd><dd class="bottom_dd2"><h4>使用19楼</h4><ul><li><a href="http://www.19lou.com/sitemap.php" target="_blank">详细导航地图</a></li><li><a href="http://www.19lou.com/help.php" target="_blank">19楼使用帮助</a></li><li><a href="http://www.19lou.com/forum-45-1.html" target="_blank">我要咨询/我要提意见</a></li></ul></dd><dd class="bottom_dd3"><h4>联系19楼</h4><ul><li>客服热线：<font>0571-85211919</font></li><li><a href="http://corp.dukuai.com/corp/page/contact.html" target="_blank">广告联系热线</a></li><li><a href="http://www.19lou.com/misc/links/more.html" target="_blank">友情链接交换</a></li></ul></dd></dl><div class="first_copyright"><span><a href="http://www.19lou.com/" target="_blank" title="19楼"><img src="http://i3.dukuai.com/ui/channel/first/img/logo_19lou.png" /></a></span><ul><li>2001-2009 <a href="http://corp.dukuai.com/" target="_blank">杭州十九楼网络传媒有限公司</a> <a href="http://corp.dukuai.com/corp/page/law.html" target="_blank">版权所有</a>   <a href="http://www.miibeian.gov.cn/" target="_blank">ICP证：浙B2-20070008</a></li><li>本网站常年法律顾问：浙江君安世纪律师事务所 王进 应振芳 律师</li></ul></div></div>');
			document.write('');
			
		}
		else if(arguments.length  == 0){
			document.write('<div class="layout foot"><div><a href="http://corp.dukuai.com/corp/page/intro.html" title="" target="_blank" rel="nofollow">公司简介</a> | <a href="http://corp.dukuai.com/corp/page/news.html" title="" target="_blank" rel="nofollow">公司动态</a> | <a href="http://corp.dukuai.com/corp/page/partners.html" title="" target="_blank" rel="nofollow">合作伙伴</a> | <a href="http://corp.dukuai.com/corp/page/join.html" title="" target="_blank" rel="nofollow">诚聘英才</a> | <a href="http://corp.dukuai.com/corp/page/law.html" title="" target="_blank" rel="nofollow">法律声明</a> | <a href="http://corp.dukuai.com/corp/page/contact.html" title="" target="_blank" rel="nofollow">联系我们</a> | <a href="http://www.19lou.com/help.php" title="" target="_blank" rel="nofollow">帮助中心</a> | <a href="http://www.19lou.com/misc/links/more.html" title="" target="_blank">友情链接</a></div><p>&copy;copyright2001-2009 杭州十九楼网络传媒有限公司 版权所有  ICP证：浙B2-20070008</p></div>');
			
			
		}
		else if(arguments[0] == "simple"){
			document.write('<div class="layout foot"><div><a href="http://corp.dukuai.com/corp/page/intro.html" title="" target="_blank" rel="nofollow">公司简介</a> | <a href="http://corp.dukuai.com/corp/page/news.html" title="" target="_blank" rel="nofollow">公司动态</a> | <a href="http://corp.dukuai.com/corp/page/partners.html" title="" target="_blank" rel="nofollow">合作伙伴</a> | <a href="http://corp.dukuai.com/corp/page/join.html" title="" target="_blank" rel="nofollow">诚聘英才</a> | <a href="http://corp.dukuai.com/corp/page/law.html" title="" target="_blank" rel="nofollow">法律声明</a> | <a href="http://corp.dukuai.com/corp/page/contact.html" title="" target="_blank" rel="nofollow">联系我们</a> | <a href="http://www.19lou.com/help.php" title="" target="_blank" rel="nofollow">帮助中心</a> | <a href="http://www.19lou.com/misc/links/more.html" title="" target="_blank">友情链接</a></div><p>&copy;copyright2001-2009 杭州十九楼网络传媒有限公司 版权所有  ICP证：浙B2-20070008</p></div>');
						
			
		}
	}


jQuery(function (){
String.prototype.trim=String.prototype.trim||function(){return this.replace(/(^\s*)|(\s*$)/g, "");};
var FORUM=FORUM||{};	
FORUM.searchBox=FORUM.searchBox||{};
FORUM.searchBox.isNewVersionForm=function(){
	  	  var hotKeywordsBox=document.getElementById("search_hot_keywords");	  	  	  	  
	  	  var searchUsedCountBox=document.getElementById("search_used_count");
	  	  var search_app_select_box=document.getElementById("search_app_select_box");
	  	  var search_app_selected=document.getElementById("search_app_selected");
	      return search_app_select_box&&search_app_selected&&hotKeywordsBox&&searchUsedCountBox;
};
FORUM.searchBox.form={
   init:function(){
   	$("#search_app_select_box").hide();
    $("#keywords").val("").focus(function(){$("#search_gif").html("")}).blur(function(){if($(this).val()==""){$("#search_gif").html("<img src='http://i3.dukuai.com/ui/search/img/sear_newst_16.gif' />")}});
    this.bindEvents();
   },
   bindEvents:function(){
   	 $("#siteSearchButton").click(function(){FORUM.searchBox.form.submit();});
     $("#keywords").keypress(function(e){if( (e.keyCode || e.which) == 13 ){FORUM.searchBox.form.submit();}});
     $("#search_app_select_box li").click(function(){
	      $("#search_app_selected").html($(this).html());
	      $("#search_app_select_box").hide();
	   });
	   var isIE6=!!window.ActiveXObject&&!window.XMLHttpRequest;
     if(isIE6){
     	 $(".select_chose_show li").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");})
     }
     $(".select_chose").toggle(
       function(){$(".select_chose_show").show();},
       function(){
       if($(".select_chose_show").css("display")=="block"){
       	 $(".select_chose_show").hide();
       }else{
       	 $(".select_chose_show").show();
       }
      });
	 $("body").click(function(){
		$(".select_chose_show").hide();					  
		});
    }
}
//this is a static function of FORUM.searchBox.form
FORUM.searchBox.form.submit=function(){
       var keywords = $("#keywords").val()!=$("#keywords").attr("title") ? $("#keywords").val() : "";
       var selectedText=$("#search_app_selected").text().trim();
			 if (selectedText == "店铺") {
						var searchAppUrl = "http://pk.19lou.com/shopsearch?keyword=" + keywords;
						location.href=searchAppUrl;
    	  } else {
    			 var appName="forum";
    			 if(selectedText == "版块"){
    			   appName="floor";
    			 }else if(selectedText == "住户"){
    			   appName="user";
    			 }else if(selectedText == "磨叽"){
    			 	 appName="miniblog"
    			 }
           if( typeof(cityIdForSearch) == "undefined"||isNaN(cityIdForSearch)){
	             cityIdForSearch=0;
           }
					 var searchAppUrl = "http://search.19lou.com/search/"+ appName +".htm?keywords=" + encodeURIComponent(keywords)+"&cityId="+cityIdForSearch+"&searchCity="+cityIdForSearch;
					 window.open(searchAppUrl);
				}
} 

FORUM.searchBox.displayPane={
	  bigHomePage:false,
	  hotKeywordsURL:"http://search.19lou.com/search/api/hotKeywords.htm?jsoncallback=?",
	  usedCountURL:"http://search.19lou.com/search/api/usedCount.htm?jsoncallback=?",
	  lessNumThenNormal:0,

	  updateInterval:3,//second
  	init:function(){
  		if(!this.bigHomePage){
          jQuery.getJSON(this.hotKeywordsURL,function(data){
          	 var searchHotKeywordsBox=$("#search_hot_keywords");
             for(var i=0;i<data.length;i++){
             	      searchHotKeywordsBox.append("<li><a target='_blank' href='http://search.19lou.com/search/forum.htm?keywords="+encodeURIComponent(data[i])+"'>"+data[i]+"</a></li>");
               }
           });
  		   }		
    },
    run:function(){
    	if(this.bigHomePage){
    	 var baseCount=$("#search_used_count").text()||"";
    	 var increment=document.getElementById("search_nono_factor").value||"";
       var digitExp=/^\d+\.?\d*$/;
    	 if(!digitExp.test(baseCount)||!digitExp.test(increment)){
    	   jQuery.getJSON(this.usedCountURL,function(data){
         	 $("#search_used_count").text(data[0]);
         	 FORUM.searchBox.displayPane.increaseNum(data[0],data[1]);
          })    	    	
    	 }else{
    	   FORUM.searchBox.displayPane.increaseNum(baseCount,increment);	
    	 }
    	}else{
    	  jQuery.getJSON(this.usedCountURL,function(data){
        	 $("#search_used_count").text(data[0]);
        	 FORUM.searchBox.displayPane.increaseNum(data[0],data[1]);
         })    	
      } 
    },
    increaseNum:function(baseNum,increment){
    	  baseNum=isNaN(baseNum)?baseNum:parseInt(baseNum);
    	  increment=isNaN(increment)?increment:parseFloat(increment);
    	  var swing=this.lessNumThenNormal+increment*this.updateInterval;
    	  var randomIncr=Math.round(Math.random()*swing);
    	  var less=increment*this.updateInterval-randomIncr;
    	  this.lessNumThenNormal+=less;	  
    	  baseNum+=randomIncr;
    	  $("#search_used_count").text(baseNum);
    	  window.setTimeout(function(){
    	  FORUM.searchBox.displayPane.increaseNum(baseNum,increment);
    	  },this.updateInterval*1000);
    }
}

 if(FORUM.searchBox.isNewVersionForm()){
 	   FORUM.searchBox.form.init();
 	   FORUM.searchBox.displayPane.init();
 	   FORUM.searchBox.displayPane.run();
 }		
});

