// javascript document /*输入框提示触发事件*/ function setinputfocus(_obj) { $.each($(_obj), function (i, e) { var _this = $(e); if (_this.val() == '') { _this.css('color', '#bdbdbd').val(_this.attr('prompt')); } else { _this.css('color', '#414141'); } _this.focus(function () { _this.css('color', '#414141'); if (_this.val() == _this.attr('prompt')) { _this.val(''); } }).blur(function () { _this.css('color', '#414141'); if (_this.val() == '' || _this.val() == _this.attr('prompt')) { _this.css('color', '#bdbdbd').val(_this.attr('prompt')); } }); }) }; /*列表页面tab切换*/ function settabs(_id) { var _obj = $('#' + _id); var _btn = _obj.find('.tabs-menus a'); var _item = _obj.find('.tabs-items .tabs-item'); var _tab_item = _obj.find('.tab_menu li'); var _tab_box_item = _obj.find('.tab_box div'); //初始化 _item.eq(0).show(); _btn.eq(0).addclass('act'); _tab_item.eq(0).addclass('current'); _tab_box_item.eq(0).removeclass('hide'); $.each(_btn, function (i, e) { var _this = $(e); _this.hover(function () { _btn.removeclass('act'); _this.addclass('act'); _item.hide(); _item.eq(i).show(); }); }); } /*图片滚动*/ function setgds(_id) { var _gds = $('#' + _id); var _next = _gds.find('.pics .next'); var _pre = _gds.find('.pics .prev'); var _obj = _gds.find('.pics li'); var _btns = $('
'); for (var i = 0; i < _obj.size(); i++) { if (i == _obj.size() - 1) { _btns.append(''); } _btns.append(''); }; _gds.append(_btns); var _item = _btns.find('a'); _item.eq(0).addclass('act'); _btns.css('margin', '-7px auto 0'); var _time = 6000; var _speed = 2000; var _t; var _num = 0; _obj.hide(); _obj.eq(0).show(); _item.click(function () { clearinterval(_t); _num = $(this).attr('num') - 1; _item.removeclass('act'); _obj.hide(); _obj.eq($(this).attr('num') - 1).fadein(_speed); $(this).addclass('act'); }) function start() { _t = setinterval(function () { _num++; if (_num == _obj.length) { _num = 0; } tab(); }, _time); } function tab() { $.each(_obj, function () { _obj.eq(_num).fadein(_speed); _obj.eq(_num).siblings().hide() _item.removeclass('act'); _item.eq(_num).addclass('act'); }) } _next.click(function () { _num++; if (_num == _obj.length) { _num = 0; } tab(); }) _pre.click(function () { _num--; if (_num == -1) { _num = _obj.length - 1; } tab(); }) _gds.hover(function () { clearinterval(_t); _next.fadein(); _pre.fadein(); }, function () { start(); _next.fadeout() _pre.fadeout(); }) start(); } /*广告 轮换*/ function setad() { var _obj = $('#ulnotice'); var _ul = _obj; var index = 0; var _dwell = 600; var t = null; /*初始化*/ var _total = math.ceil(_ul.find('li').size()); var _h = _ul.find('li').height(); _ul.height(_h * _total); function auto() { t = setinterval(function () { index++; if (index == _total) { _ul.animate({ 'margintop': '0' }, _dwell); index = 0; } else { _ul.animate({ 'margintop': -(_h * index) }, _dwell); }; }, 3000); } _obj.hover(function () { clearinterval(t); }, function () { auto(); }) auto(); } function nav() { var _nav = $('#nav'); var _btn = _nav.find('.lv1'); var timer; _btn.mouseenter(function () { var _box = $('#fly'); _nav.find('.lv1').removeclass('act'); $(this).addclass('act'); if ($(this).next('.box-nav').html() == null) { _box.hide(); } else { _box.html($(this).next('.box-nav').html()); _box.show(); } /*栏目之间切换*/ var _tabbtn = _box.find('.l-box a'); var _item = _box.find('.r-box .tabs-item'); _nav.find('.box-nav').find('.l-box a').removeclass('act'); _nav.find('.box-nav').find('.r-box .tabs-item').hide(); _item.eq(0).show(); _tabbtn.eq(0).addclass('act'); $.each(_tabbtn, function (i, e) { // var _this = $(e); var _this = $(this); _this.mouseenter(function () { _tabbtn.removeclass('act'); _this.addclass('act'); _item.hide(); _item.eq(i).show(); }) }); /*弹出框位置*/ var offset = $(this).offset(); var _width = $(window).width() / 2; if (offset.left < _width) { var _left = offset.left; _box.css({ 'left': _left, 'right': 'auto' }) } else if (offset.left >= _width) { var _left = offset.left; _box.css({ 'left': _left - _box.width() + 135, 'right': 'auto' }) }; return false; }); _nav.find('.box-nav').click(function () { return false; }); $('#fly').mouseleave(settimer); _nav.mouseleave(settimer); function settimer() { timer = settimeout(function () { $('#fly').hide(); _nav.find('.lv1').removeclass('act'); }, 300); return timer; }; $('#fly').mouseenter(function () { cleartimeout(timer); $('#fly').show(); }) _btn.mouseenter(function () { cleartimeout(timer); }) }; /*右侧 轮播图*/ function rightlunbo(_id) { var _orchard = $('#' + _id); var _ul = _orchard.find('ul'); var _li = _orchard.find('.anli li'); var n = _li.length; var w = _li.eq(0).width(); var _furit = _orchard.find('.anli a'); var _dot = _orchard.find('.dot a'); var c = 0; var t = null; _dot.eq(0).addclass('act'); $.each(_dot, function (i, e) { var _this = $(e); _this.click(function () { c = i; _dot.removeclass('act'); _this.addclass('act'); _ul.animate({ 'left': -i * w }) }); }) function getauto() { t = setinterval(function () { c++; if (c == n) { c = 0; _ul.css({ 'left': 0 }) } if (c == -1) { c = n - 1; _ul.css({ 'left': -c * w }) } _dot.removeclass('act'); _dot.eq(c).addclass('act'); _ul.animate({ 'left': -c * w }, 800); }, 3000); } _orchard.hover(function () { clearinterval(t); }, function () { getauto(); }) getauto(); } function setweixin() { var _dot = $('.h-dot'); var _ma = _dot.find('.show-ma'); var _weixin = _dot.find('.weixin'); var t; _weixin.hover(function () { clearinterval(t); _ma.show(); }, function () { t = setinterval(function () { _ma.hide(); }, 300) }) _ma.hover(function () { clearinterval(t); _ma.show(); }, function () { t = setinterval(function () { _ma.hide(); }, 300) }) } /*左侧菜单-1个参数*/ function setleftnav(_id) { var _main = $('#' + _id); var _left = _main.find('.main-l'); var _li = _left.find('li').not('.head'); var _h5 = _li.find('h5'); var _a = _li.find('div a'); _li.eq(0).addclass('show').find('h5').next('').show().find('a').eq(0).addclass('act'); $.each(_h5, function (i, e) { var _this = $(e); _this.click(function () { if ($(this).next().css('display') == 'block') { _this.next().stop().slideup(); _this.parent('li').removeclass('show'); } else { _li.children('div').slideup(); _li.removeclass('show'); _this.parent('li').addclass('show'); if (_this.next('div').length != 0) { _this.next().slidedown(); } } }) }) _a.click(function () { _a.removeclass('act'); $(this).addclass('act'); }) } /*左侧菜单-2个参数*/ function setleftnav(_id, _a_num) { var _main = $('#' + _id); var _left = _main.find('.main-l'); var _li = _left.find('li').not('.head'); var _h5 = _li.find('h5'); var _a = _li.find('div a'); //$('#' + _li_num).addclass('show').find('h5').next('').show().find('#' + _a_num).addclass('act'); // $('#' + _a_num).parent().addclass('show'); alert(_li.find('#' + _a_num)); $('#' + _a_num).parent('').parent('li').addclass('show').find('h5').next('').show(); $('#' + _a_num).addclass('act'); $.each(_h5, function (i, e) { var _this = $(e); _this.click(function () { if ($(this).next().css('display') == 'block') { _this.next().stop().slideup(); _this.parent('li').removeclass('show'); } else { _li.children('div').slideup(); _li.removeclass('show'); _this.parent('li').addclass('show'); if (_this.next('div').length != 0) { _this.next().slidedown(); } } }) }) _a.click(function () { _a.removeclass('act'); $(this).addclass('act'); }) //头部导航 样式控制 $(".p-main-title a:last-child").addclass('act'); } ///*左侧菜单-3个参数*/ //function setleftnav(_id,_li_num,_a_num){ // var _main = $('#'+_id); // var _left = _main.find('.main-l'); // var _li = _left.find('li').not('.head'); // var _h5 = _li.find('h5'); // var _a = _li.find('div a'); // //$('#'+_li_num).addclass('show').find('h5').next('').show().find('#'+_a_num).addclass('act'); // $('#' + _a_num).parent('div').parent('li').addclass('show').find('h5').next('').show(); // $('#' + _a_num).addclass('act'); // $.each(_h5,function(i,e){ // var _this = $(e); // _this.hover(function(){ // if($(this).next().css('display')=='block'){ // _this.next().stop().slideup(); // _this.parent('li').removeclass('show'); // }else{ // _li.children('div').slideup(); // _li.removeclass('show'); // _this.parent('li').addclass('show'); // if(_this.next('div').length!=0){ // _this.next().slidedown(); // } // } // },function(){ // }) // }) // _a.click(function(){ // _a.removeclass('act'); // $(this).addclass('act'); // }) //} /*图片放大*/ function changeimg(_id) { var _dyna = $('#' + _id); var _ul = _dyna.find('.a-img'); var _showimg = _dyna.find('.showimg'); var _bg = _showimg.find('.imgbg'); var _img = _ul.find('li img'); var _a = _showimg.find('a.close'); var _p = _showimg.find('p'); var n = _img.length; var _next = _showimg.find('.next'); var _prev = _showimg.find('.prev'); var _imgattr = _showimg.find('.imgattr'); var w = $(window).width(); var h = $(window).height(); var now = 0; var c = 0; var imgh, imgw; _next.css('right', (w - 1100) / 2 + 8); _prev.css('left', (w - 1100) / 2 + 8); $.each(_img, function (i, e) { var _this = $(e); _img.eq(i).attr('title', i); }) _img.click(function () { c = $(this).attr('title'); _showimg.show(); _imgattr.attr("src", _img.eq(c).attr('src')); _p.html($(this).parent('.img').next('p').html()); }); _next.click(function () { c++; if (c == n) { c = 0; } _imgattr.attr("src", _img.eq(c).attr('src')); _p.html(_img.eq(c).parent('.img').next('p').html()); }); _prev.click(function () { c--; if (c == -1) { c = n - 1; } _imgattr.attr("src", _img.eq(c).attr('src')); _p.html(_img.eq(c).parent('.img').next('p').html()); }); _bg.click(function () { _showimg.hide(); }); _a.click(function () { _showimg.hide(); }) } function setslidepeople(_id, _id2) { var _obj = $('#' + _id); var _ul = _obj.find('#' + _id2); var _li = _ul.find('li') var index = 0; var _dwell = 600; var _speed = 3000; var tt; var _sum = 0; /*初始化*/ var _total = _li.size(); var _h = _li.width() + 10; _ul.height(_li.height()); _ul.width(_total * _li.width()); if (_sum % 4 == 0) { _sum = _total / 4; } else { _sum = _total / 4 + 1; } function getauto() { tt = setinterval(function () { if (index == _sum - 1) { _ul.stop().animate({ 'marginleft': '0' }, _dwell); index = 0; } else { index++; _ul.stop().animate({ 'marginleft': -754 * index }, _dwell); }; }, 2000); } _ul.hover(function () { clearinterval(tt); }, function () { getauto(); }) getauto(); }