jQuery(document).ready(function () { //menuBox_fun(); Banner(); liHover(); headerFun(); }); //打开网站的时候,首页的logo和导航分别从左右飞出来。(好奇怪的效果) var headerFun = function () { var logo = jQuery(".HBox .logo"); var menu = jQuery("#menuBox"); var width = document.documentElement.clientWidth; logo.animate({ left: 0, opacity: 1 }, 'slow'); menu.animate({ marginRight: (width - 950) / 2,opacity:1 }, 'slow', function () { menu.css("margin", "auto"); }); } //资讯页面鼠标经过列表改变样式 var liHover = function () { var list = $('.Box05 ul li'); if (list.length < 1) return; list.bind({ mouseenter: function () { $(this).addClass("hover"); }, mouseleave: function () { $(this).removeClass("hover"); } }); } var menuBox_fun = function () { var el = jQuery("#menuBox"); var ul = el.children("ul"); var list = ul.children("ul li"); var width = 0; for (var i = 0; i <= list.length; i++) { width += list.eq(i).width();//60为padding } ul.css('padding-left', 950 - width-1); } var Banner = function () { $(".Banner").each(function () { var t = $(this); if (!t) return; //取得各种参数 var ul = t.children('ul'); var list = t.find('ul li');//轮换列表 var indexList = t.find(".list a");//索引 var width = t.width(); var height = t.height(); var timer = setInterval(function () { auto(); }, 1000); t.hover(function () { clearInterval(timer); }); t.bind({ mouseenter: function () { clearInterval(timer); }, mouseleave: function () { timer = setInterval(function () { auto(); }, 1000) } }); indexList.mouseover(function () { var t = $(this); var index = indexList.index(t); indexList.removeClass('current'); t.addClass('current'); fxFun(index); }).eq(0).mouseover();; function auto() { var index = t.find('li.show').index(); if (index >= list.length - 1) { index = 0; } else { index++ } indexList.eq(index).mouseover(); } function fxFun(index) { var i = list.index($(t.find("ul li.show")));//当前显示 if (i < 0) { list.hide().removeClass("show"); list.eq(0).fadeIn().addClass('show'); } if (i == index) return; //上下 //list.eq(i).stop(true, true).animate({ top: height * -1 }, 600).css('z-index', 1).removeClass('show'); //list.eq(index).css({ top: height * 1 }).stop(true, true).show().animate({ top: 0 }, 600).css({ zIndex: 2, 'background': list.eq(index).attr('color') }).addClass('show'); //fadeIn and fadeOut list.eq(i).stop(true, true).fadeOut().removeClass('show'); list.eq(index).stop(true, true).fadeIn().css({ zIndex: 2, 'background': list.eq(index).attr('color') }).addClass('show'); } }); } function checkfrom() { var s = $("#keyword").val(); if (s == "" || s == "站内搜索") { alert("请输入关键字!"); $("#keyword").focus(); return false; } else { return true; } } window.onresize = window.onload = function () { var w, h if (!!(window.attachEvent && !window.opera)) { h = document.documentElement.clientHeight; w = document.documentElement.clientWidth; } else { h = window.innerHeight; w = window.innerWidth; } if (w <= 1000) { $(".banner img").css("width", "1000px"); $(".banner img").css("height", "250px"); } else { $(".banner img").css("width", "1441px"); } }