//图片自适应 function DrawImage(ImgD, FitWidth, FitHeight) { var image = new Image(); image.src = ImgD.src; if (image.width > 0 && image.height > 0) { if (image.width / image.height >= FitWidth / FitHeight) { if (image.width > FitWidth) { ImgD.width = FitWidth; ImgD.height = (image.height * FitWidth) / image.width; } else { ImgD.width = image.width; ImgD.height = image.height; } } else { if (image.height > FitHeight) { ImgD.height = FitHeight; ImgD.width = (image.width * FitHeight) / image.height; } else { ImgD.width = image.width; ImgD.height = image.height; } } } } //图片滚动 调用方法 imgscroll({speed: 30,amount: 1,dir: "up"}); $.fn.imgscroll = function (o) { var defaults = { speed: 40, amount: 0, width: 1, dir: "left" }; o = $.extend(defaults, o); return this.each(function () { var _li = $("li", this); _li.parent().parent().css({ overflow: "hidden", position: "relative" }); //div _li.parent().css({ margin: "0", padding: "0", overflow: "hidden", position: "relative", "list-style": "none" }); //ul _li.css({ position: "relative", overflow: "hidden" }); //li if (o.dir == "left") _li.css({ float: "left" }); //初始大小 var _li_size = 0; for (var i = 0; i < _li.size(); i++) _li_size += o.dir == "left" ? _li.eq(i).outerWidth(true) : _li.eq(i).outerHeight(true); //循环所需要的元素 if (o.dir == "left") _li.parent().css({ width: (_li_size * 3) + "px" }); _li.parent().empty().append(_li.clone()).append(_li.clone()).append(_li.clone()); _li = $("li", this); //滚动 var _li_scroll = 0; function goto() { _li_scroll += o.width; if (_li_scroll > _li_size) { _li_scroll = 0; _li.parent().css(o.dir == "left" ? { left: -_li_scroll} : { top: -_li_scroll }); _li_scroll += o.width; } _li.parent().animate(o.dir == "left" ? { left: -_li_scroll} : { top: -_li_scroll }, o.amount); } //开始 var move = setInterval(function () { goto(); }, o.speed); _li.parent().hover(function () { clearInterval(move); }, function () { clearInterval(move); move = setInterval(function () { goto(); }, o.speed); }); }); }; //时间 function get_time1() { var date = new Date(); var year = "", month = "", day = "", week = "", hour = "", minute = "", second = ""; year = date.getYear(); month = add_zero1(date.getMonth() + 1); day = add_zero1(date.getDate()); week = date.getDay(); switch (date.getDay()) { case 0: val = "星期天"; break case 1: val = "星期一"; break case 2: val = "星期二"; break case 3: val = "星期三"; break case 4: val = "星期四"; break case 5: val = "星期五"; break case 6: val = "星期六"; break } hour = add_zero1(date.getHours()); minute = add_zero1(date.getMinutes()); second = add_zero1(date.getSeconds()); document.write(year + "年" + month + "月" + day + "日 " + " " + val); } function add_zero1(temp) { if (temp < 10) return "0" + temp; else return temp; } //焦点图片 $.fn.imgtransition = function (o) { var defaults = { speed: 5000, animate: 1000, stay: 10000 }; o = $.extend(defaults, o); return this.each(function (i) { var arr_e = $("li", this); arr_e.css({ position: "absolute" }); arr_e.parent().css({ margin: "0", padding: "0", "list-style": "none", overflow: "hidden" }); //按钮 for (var i = 0; i < arr_e.length; i++) { $(".fbtn").html($(".fbtn").html() + ""); } $(".fbtn a").eq(0).addClass("fbtn_a_h"); // $(".fbtn").offset({ "top": this.height() - $(".fbtn").height() - 20, "left": this.width() - $(".fbtn").width() - 10 }); $(".fbtn").width($(this).width() - 20).css("margin-top", $(this).height() - $(".fbtn").height() - 20); var active; var next; function shownext() { active = arr_e.filter(".active").length ? arr_e.filter(".active") : arr_e.first(); next = active.next().length ? active.next() : arr_e.first(); active.css({ "z-index": 9 }); next.css({ opacity: 0.0, "z-index": 10 }).addClass('active').animate({ opacity: 1.0 }, o.animate, function () { active.removeClass('active').css({ "z-index": 8 }); }); $(".fbtn a").removeClass('fbtn_a_h'); $(".fbtn a").eq(next.index()).addClass("fbtn_a_h"); } arr_e.first().css({ "z-index": 9 }); var fTimer; fTimer = setInterval(function () { shownext(); }, o.speed); $(".fbtn > a").click(function () { clearInterval(fTimer); arr_e.removeClass('active').css({ "z-index": 8 }); active = arr_e.eq($(this).index()).addClass('active'); active.css({ "z-index": 10 }); next = active.next().length ? active.next() : arr_e.first(); next.css({ "z-index": 9 }); $(".fbtn a").removeClass('fbtn_a_h'); $(".fbtn a").eq(active.index()).addClass("fbtn_a_h"); setTimeout(fTimer = setInterval(function () { shownext(); }, o.speed), stay); }); }); };