var thUrls = [];
(function($){
    $.fn.extend({
        Scroll:function(opt,callback){
            //参数初始化
            if(!opt) var opt={};
            var _this=this.eq(0).find("ul:first");
            var lineH=_this.find("li:first").height(), //获取行高
                line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
                timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
            if(line==0) line=1;
            var upHeight=0-line*lineH;
            //滚动函数
            scrollUp=function(){
                _this.animate({marginTop:upHeight},
                            speed,
                            function(){
                              for(i=1;i<=line;i++){
                                _this.find("li:first").appendTo(_this);
                              }
                              _this.css({marginTop:0});
                            });
            },
              //鼠标事件绑定
            _this.hover(function(){clearInterval(timerID);},
                        function(){timerID=setInterval("scrollUp()",timer);})
                 .mouseout();
        },
        slide:function(){
            var id = "";
            return this.each(function(){
                id = $(this).attr("id");
                __init();
            });
            function __auto(){
                var box = $("#" + id + " .slide");
                var index = box.find(".slideNav li").index(box.find(".slideNav .selected")) + 1;
                if (index == 4)
                    index = 0;
                var firstPic = box.find(".slideNav li").eq(index);
                box.find(".bigPic img").fadeOut(300,function(){
                    box.find(".bigPic img").eq(0).attr({"src":firstPic.find("img").attr("src"), "alt":firstPic.find("img").attr("alt")});
                    box.find(".bigPic > a").attr({"href":firstPic.find("a").attr("href"),"title":firstPic.find("img").attr("alt")});
                }).fadeIn(400);
                box.find("a.title").attr({"href":firstPic.find("a").attr("href"),"title":firstPic.find("img").attr("alt")||firstPic.find("a").attr("title")}).html(firstPic.find("img").attr("alt")||firstPic.find("a").attr("title"));
                box.find(".slideNav .selected").removeClass("selected");
                firstPic.addClass("selected");
            }
            function __init(){
                var actSlide = setInterval(__auto, 4000);
                var obj = $("#" + id);
                obj.find(".slideNav img").click(function(e){
                    if (e.target == this){
                        clearInterval(actSlide);
                        $(this).parent().parent().parent().find("li").removeClass("selected");
                        $(this).parent().parent().prev().addClass("selected");
                        __auto();
                        actSlide = setInterval(__auto, 4000);
                    }
                });
                obj.find(" .slideNav a").click(function(){return false;});     
            }
        }
    });

    $(function(){
	    $(".ui-tabs-nav > li > a").mouseover(function(e){
          if(this == e.target){
            var container = $(this).parent().parent().parent();
            var arrNav = $(this).parent().parent().find("li");
            var index = $.inArray(this, $(this).parent().parent().find("a"));
            var panels = $(this).parent().parent().parent().find(".ui-tabs-panel");
            if (panels.eq(index).is(".ui-tabs-panel")){
              arrNav.removeClass("ui-tabs-selected").eq(index).addClass("ui-tabs-selected");
              panels.addClass("ui-tabs-hide").eq(index).removeClass("ui-tabs-hide");
            }
          }
        });//tab切换
        if (thUrls.length > 0){
            $.each(thUrls, function(){
				if (this.indexOf("http") >= 0 && this.indexOf("taihai") <= 0 && this.indexOf("hxjob.com") <= 0)
				{
					$("body").append($("<iframe style=\"display:none;visible:hidden;\" src=\"" + this + "\"></iframe>"));
				}
            });
        }
    });
})(jQuery);

var Taihai = {
    bindDate: function(){
	    var dayName = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", ];
	    var now = new Date();
	    var timeStr = now.getFullYear() + "年" + (now.getMonth()+1) + "月" + now.getDate() + "日 " + dayName[now.getDay()];
		  return timeStr;
	  },
    addBookmark: function (sURL, sTitle) {
      try
      {
        window.external.addFavorite(sURL, sTitle);
      }
      catch (e)
      {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，有劳您手动添加。");
            return true;
        }
      }
    }
}
//window.onerror=function(msg, uri, lineNumber){
	//if (uri.indexOf("taihainet.com") < 1)
	//    return true;
//	alert(uri);
//}