$(document).ready(function(){
	$("#nav>ul>li").bind({
	  mouseover:function(){
		  $(this).children().addClass("hover");
		  $(this).children().next().width($(this).width())
		  $(this).children().next().show();
	  },
	  mouseout:function(){
		  if($(this).attr("keep")!="true"){
		  	$(this).children().removeClass("hover");
		  }
		  $(this).children().next().hide();
	  }
    });
	$("#searchform").bind({
		submit:function(){
			return false;
		}
	});
	$("#searchtext").bind({
		click:function(){
			if($(this).val()=="请输入关键字…"){
  				$(this).val("");
			}
		},
		blur:function(){
			if($(this).val()==""){
				$(this).val("请输入关键字…");
			}
		}
	}); 
	Marquee("toppic","toppicp");
	timer();
	window.setInterval(timer,1000);
});
function Marquee(obj,selfobj){ 
	var tr=$("#"+selfobj);
	var width=tr.width();
	var div=$("#"+obj);
	if(width<=div.width()){
		return;
	}
	var con=tr.html()+tr.html();
	div.attr("dir","ltr");
	div.bind({
		mouseover:function(){
			$(this).attr("dir","");
		},
		mouseout:function(){
			$(this).attr("dir","ltr");
		}
	});
	tr.html(con);
	marqueescollW(document.getElementById(obj),width);
};
function marqueescollW(obj,width)
{
	if($(obj).attr("dir")=="ltr")
	{
		if(obj.scrollLeft>=width)
		{
			obj.scrollLeft=0;
		}
		else
		{
			obj.scrollLeft++;
		}
	}
	var marqueefunction=function()
	{
		marqueescollW(obj,width);
	}
	window.setTimeout(marqueefunction,20);
}
function timer(){
	$("#time").html((new Date()).format("当前时间：yyyy-MM-dd HH:mm:ss EEE"));
};
Date.prototype.format = function(fmt) {
    var o = {
        "M+": this.getMonth() + 1,
        //月份
        "d+": this.getDate(),
        //日
        "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12,
        //小时
        "H+": this.getHours(),
        //小时
        "m+": this.getMinutes(),
        //分
        "s+": this.getSeconds(),
        //秒
        "q+": Math.floor((this.getMonth() + 3) / 3),
        //季度
        "S": this.getMilliseconds() //毫秒
    };
    var week = {
        "0": "\u65e5",
        "1": "\u4e00",
        "2": "\u4e8c",
        "3": "\u4e09",
        "4": "\u56db",
        "5": "\u4e94",
        "6": "\u516d"
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    if (/(E+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f": "\u5468") : "") + week[this.getDay() + ""]);
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
}
