function ResizeImages(obj, width, height) { var Pnw = width;//80 var Pnh = height;//80 var Pw = $(obj).width(); var Ph = $(obj).height(); if (Pw > Pnw && Ph > Pnh) { if (Pw / Ph >= Pnw / Pnh) { $(obj).css("height", Pnh + "px"); Ptw = parseInt($(obj).width()) var Psw = (Ptw - Pnw) / 2; $(obj).css('left', "-" + Psw + "px"); } else { $(obj).css("width", Pnw + "px"); Pth = parseInt($(obj).height()); var Psh = (Pth - Pnh) / 2; $(obj).css('top', "-" + Psh + "px"); } } } function isImgLoad(img, callback) { var timer = setInterval(function () { if (img.complete) { callback(img) clearInterval(timer) } }, 50) } function isImgsLoad(img, callback) { var timer = setInterval(function () { img.each(function (index) { if (this.complete && ($(this).parent().parent().css("display") != "none")) { callback(index) clearInterval(timer) return false } }) }, 50) } $(document).ready(function () { $(function () { $(".h").hover(function () { $(this).addClass("hover") }, function () { $(this).removeClass("hover") }) }) }); $(document).ready(function () { // 悬浮窗口 $(".yb_conct").hover(function () { $(".yb_conct").css("right", "5px"); $(".yb_bar .yb_ercode").css('height', '200px'); }, function () { $(".yb_conct").css("right", "-127px"); $(".yb_bar .yb_ercode").css('height', '53px'); }); // 返回顶部 $(".yb_top").click(function () { $("html,body").animate({ 'scrollTop': '0px' }, 300) }); $(".header-bottom .header-nav li").hover(function () { var n = $(this).index(); $(".header-bottom .sub-menu").stop(true, true).show(); $(this).children('.sub-box').show().parent().siblings('li').children('.sub-box').hide(); var left = parseFloat($(this).css('padding-left')) * n * 2; for (var i = 0; i < n; i++) { left += $('.header-bottom .header-nav li').eq(i).width(); } $('.nav_hover').stop().animate({ 'left': left }); }, function () { $(".header-bottom .sub-menu").stop(true, true).hide(); $(this).children('.sub-box').hide(); var n = $('.header-nav li.cur').index(); if (n == 0) { left = 0; } else { var left = parseFloat($('.header-bottom .header-nav li.cur').css('padding-left')) * n * 2; for (var i = 0; i < n; i++) { left += $('.header-bottom .header-nav li').eq(i).width(); } } $('.nav_hover').stop().animate({ 'left': left }); }); $(".header-bottom .sub-menu").hover(function () { $(this).stop(true, true).show(); }, function () { }); $(".header-bottom").hover(function () { }, function () { $(".header-bottom .sub-menu").hide(); $(".header-bottom .sub-menu .list li").hide(); }); });