var width = document.body.clientWidth;
if (width >= 1200) {
$('.indexShowLeft').mouseover(function() {
$(this).width('70%');
$('.viewTop').css('left', '70%');
});
$('.indexShowLeft').mouseleave(function() {
$(this).width('50%');
$('.viewTop').css('left', '50%');
});
$('.indexShowRight').mouseover(function() {
$(this).width('70%');
$('.viewTop').css('left', '30%');
});
$('.indexShowRight').mouseleave(function() {
$(this).width('50%');
$('.viewTop').css('left', '50%');
});
}
/*全站搜索*/
var input = $("#keyword");
input.focus(function() {
if ($(this).val() == '请输入搜索关键词') {
$(this).val('');
}
});
input.blur(function() {
if ($(this).val() == '') {
$(this).val('请输入搜索关键词');
}
});
$("#s_btn").click(function() {
if (input.val() == '' || input.val() == '请输入搜索关键词') {
alert("请输入关键词!");
input.focus();
return false;
}
});
/* banner1效果 */
(function($) {
//默认参数
var defaluts = {
box: "box",
list: "list", //banner-img-list
buttom: "buttom",
left_btn: "left_btn", //左按钮
right_btn: "right_btn", //右按钮
speed: "speed", // 时间
};
$.fn.extend({
/* 带缩略图的轮播效果 */
"thumbnailImg": function(options) {
var opts = $.extend({}, defaluts, options); //使用jQuery.extend 覆盖插件默认参数
// console.log(opts);
//遍历匹配元素的集合
return this.each(function() {
// console.log(this);
var nav_num = '';
var count = $(opts.list).find("li").length;
$(opts.list).find("li").eq(0).css("display", "block");
$(opts.list).find("li").each(function() {
var index = $(this).index() + 1;
nav_num += '
' + index + '';
});
$(opts.buttom).append(nav_num);
$(opts.buttom).find("li").first().addClass("num_hover");
$(opts.buttom).find("li").hover(function() {
sw = $(opts.buttom).find("li").index(this);
myShow(sw);
});
$(opts.left_btn).click(function() {
clearInterval(myTime);
sw -= 1;
if (sw == -1) {
sw = count - 1;
}
myShow(sw);
});
$(opts.right_btn).click(function() {
clearInterval(myTime);
sw++;
if (sw == count) {
sw = 0;
}
myShow(sw);
myTime;
});
function myShow(i) {
$(opts.buttom).find("li").eq(i).addClass("num_hover").siblings().removeClass("num_hover");
$(opts.list).find("li").eq(i).stop(true, true).fadeIn(opts.speed).siblings("li").fadeOut(opts.speed);
}
var myTime = 0;
//滑入停止动画,滑出开始动画
$(opts.list).hover(function() {
if (myTime) {
clearInterval(myTime);
}
}, function() {
myTime = setInterval(function() {
myShow(sw);
sw++;
if (sw == count) {
sw = 0;
}
}, 3000);
});
//自动开始
var sw = 0;
myTime = setInterval(function() {
myShow(sw);
sw++;
if (sw == count) {
sw = 0;
}
}, 2000);
});
}
});
})(jQuery);
/* banner2效果 */
(function($) {
//默认参数
var defaluts = {
box: "box",
list: "list", //banner-img-list
buttom: "buttom",
left_btn: "left_btn", //左按钮
right_btn: "right_btn", //右按钮
speed: "speed", // 时间
};
$.fn.extend({
/* 带缩略图的轮播效果 */
"Direction": function(options) {
var opts = $.extend({}, defaluts, options); //使用jQuery.extend 覆盖插件默认参数
// console.log(opts);
//遍历匹配元素的集合
return this.each(function() {
// console.log(this);
var sWidth = $(opts.box).width(); //获取焦点图的宽度(显示面积)
var len = $(opts.list).find("li").length; //获取焦点图个数
var index = 0;
var picTimer = 0;
var nav_num = "";
//以下代码添加数字按钮和按钮后的半透明条,还有上一页、下一页两个按钮
$(opts.list).find("li").each(function() {
var index = $(this).index() + 1;
nav_num += '';
});
$(opts.buttom).append(nav_num);
//为小按钮添加鼠标滑入事件,以显示相应的内容
$(opts.buttom).find("span").css("opacity", 0.4).mouseenter(function() {
index = $(opts.buttom).find("span").index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
//上一页按钮
$(opts.left_btn).click(function() {
index -= 1;
if (index == -1) {
index = len - 1;
}
showPics(index);
});
//下一页按钮
$(opts.right_btn).click(function() {
index += 1;
if (index == len) {
index = 0;
}
showPics(index);
});
//本例为左右滚动,即所有li元素都是在同一排向左浮动,所以这里需要计算出外围ul元素的宽度
$(opts.list).css("width", sWidth * (len));
//鼠标滑上焦点图时停止自动播放,滑出时开始自动播放
$(opts.box).hover(function() {
clearInterval(picTimer);
}, function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if (index == len) {
index = 0;
}
}, 4000); //此4000代表自动播放的间隔,单位:毫秒
}).trigger("mouseleave");
//显示图片函数,根据接收的index值显示相应的内容
function showPics(index) { //普通切换
var nowLeft = -index * sWidth; //根据index值计算ul元素的left值
$(opts.list).stop(true, false).animate({
"left": nowLeft
}, 300); //通过animate()调整ul元素滚动到计算出的position
$(opts.buttom).find("span").stop(true, false).animate({
"opacity": "0.4"
}, 300).eq(index).stop(true, false).animate({
"opacity": "1"
}, 300); //为当前的按钮切换到选中的效果
}
}
);
}
});
})(jQuery);
/**
* 产品上下左右滚动
*/
(function($) {
$.fn.rollSlide = function(obj) {
var $self = this,
orientation = obj.orientation || 'left',
num = obj.num || 1,
v = (typeof obj.v === 'number') ? obj.v : 0,
minTime = (typeof obj.space === 'number') ? ((obj.space >= 100) ? obj.space : 100) : 100,
space = minTime + v || 5000 + v,
isRoll = obj.isRoll,
isStart = true,
roll = function(ori, n, v) {
var $ul = $self.find('.roll__list'),
$item = $ul.find('li'),
range = 0,
i, len = $item.length,
sliceItem = [],
cloneSliceItem = [],
startTime = (new Date()).getTime(),
memory = function() {
var arr = [];
if (ori === 'left' || ori === 'top') {
for (i = 0; i < n; i++) {
range += ori === 'left' ? $($item[i]).outerWidth(true) : $($item[i]).outerHeight(true);
arr.push($item[i]);
}
} else if (ori === 'right' || ori === 'bottom') {
for (i = len - n; n > 0; n--, i++) {
range += ori === 'right' ? $($item[i]).outerWidth(true) : $($item[i]).outerHeight(true);
arr.push($item[i]);
}
}
return arr;
};
isStart = false;
sliceItem = memory();
cloneSliceItem = $(sliceItem).clone();
switch (ori) {
case 'left':
$ul.append(cloneSliceItem);
$ul.animate({
'left': -range + 'px'
}, v, function() {
$(this).css({
'left': 0
});
$(sliceItem).remove();
isStart = true;
});
break;
case 'right':
$ul.prepend(cloneSliceItem);
$ul.css('left', -range + 'px');
$ul.animate({
'left': 0
}, v, function() {
$(sliceItem).remove();
isStart = true;
});
break;
case 'top':
$ul.append(cloneSliceItem);
$ul.animate({
'top': -range + 'px'
}, v, function() {
$(this).css({
'top': 0
});
$(sliceItem).remove();
isStart = true;
});
break;
case 'bottom':
$ul.prepend(cloneSliceItem);
$ul.css('top', -range + 'px');
$ul.animate({
'top': 0
}, v, function() {
$(sliceItem).remove();
isStart = true;
});
break;
}
},
init = function() {
var $ul = $self.find('.roll__list'),
$item = $ul.find('li'),
len = $item.length,
timer;
num = num <= len ? num : len;
if (len > 1) {
$self.on('click', '.pre', function() {
if (isStart) {
if (orientation === 'left' || orientation === 'right') {
roll('right', num, v);
} else {
roll('bottom', num, v);
}
}
}).
on('click', '.next9', function() {
if (isStart) {
if (orientation === 'left' || orientation === 'right') {
roll('left', num, v);
} else {
roll('top', num, v);
}
}
}).
hover(function() {
clearInterval(timer);
}, function() {
if (isRoll) {
timer = setInterval(function() {
roll(orientation, num, v);
}, space);
}
}).
trigger('mouseout');
}
};
init();
};
$.fn.rollNoInterval = function() {
var $self = this,
$ul = $self.find('.roll__list'),
$item = $ul.find('li'),
len = $item.length,
timer,
left = function() {
var offset, i,
range,
$sliceItem;
$sliceItem = $($item[0]);
range = $sliceItem.outerWidth(true);
timer = setInterval(function() {
offset = $ul.css('left');
offset = parseInt(offset);
if (offset > -range) {
i = offset - 1;
$ul.css('left', i + 'px');
offset = $ul.css('left');
} else {
$sliceItem.detach();
$ul.css('left', 0);
$ul.append($sliceItem);
$sliceItem = $($ul.find('li')[0]);
range = $sliceItem.outerWidth(true);
}
}, 50);
},
right = function() {
var offset, i,
range,
$sliceItem;
$sliceItem = $($item[len - 1]);
range = $sliceItem.outerWidth(true);
timer = setInterval(function() {
offset = $ul.css('right');
offset = parseInt(offset);
if (offset > -range) {
i = offset - 1;
$ul.css('right', i + 'px');
offset = $ul.css('right');
} else {
$sliceItem.detach();
$ul.css('right', 0);
$ul.prepend($sliceItem);
$sliceItem = $($ul.find('li')[len - 1]);
range = $sliceItem.outerWidth(true);
}
}, 50);
},
top = function() {
var offset, i,
range,
$sliceItem;
$sliceItem = $($item[0]);
range = $sliceItem.outerHeight(true);
timer = setInterval(function() {
offset = $ul.css('top');
offset = parseInt(offset);
if (offset > -range) {
i = offset - 1;
$ul.css('top', i + 'px');
offset = $ul.css('top');
} else {
$sliceItem.detach();
$ul.css('top', 0);
$ul.append($sliceItem);
$sliceItem = $($ul.find('li')[0]);
range = $sliceItem.outerHeight(true);
}
}, 50);
},
bottom = function() {
var offset, i,
range,
$sliceItem;
$sliceItem = $($item[len - 1]);
range = $sliceItem.outerHeight(true);
timer = setInterval(function() {
offset = $ul.css('bottom');
offset = parseInt(offset);
if (offset > -range) {
i = offset - 1;
$ul.css('bottom', i + 'px');
offset = $ul.css('bottom');
} else {
$sliceItem.detach();
$ul.css('bottom', 0);
$ul.prepend($sliceItem);
$sliceItem = $($ul.find('li')[len - 1]);
range = $sliceItem.outerHeight(true);
}
}, 50);
},
init = function() {
$self.hover(function() {
clearInterval(timer);
}, function() {
});
};
//init();
return {
left: left,
right: right,
top: top,
bottom: bottom
}
}
})(jQuery);
// tab多页签
(function($) {
$.fn.tabso = function(options) {
var opts = $.extend({}, $.fn.tabso.defaults, options);
return this.each(function(i) {
var _this = $(this);
var $menus = _this.children(opts.menuChildSel);
var $container = $(opts.cntSelect).eq(i);
if (!$container) return;
if (opts.tabStyle == "move" || opts.tabStyle == "move-fade" || opts.tabStyle == "move-animate") {
var step = 0;
if (opts.direction == "left") {
step = $container.children().children(opts.cntChildSel).outerWidth(true);
} else {
step = $container.children().children(opts.cntChildSel).outerHeight(true);
}
}
if (opts.tabStyle == "move-animate") {
var animateArgu = new Object();
}
$menus[opts.tabEvent](function() {
var index = $menus.index($(this));
$(this).addClass(opts.onStyle)
.siblings().removeClass(opts.onStyle);
switch (opts.tabStyle) {
case "fade":
if (!($container.children(opts.cntChildSel).eq(index).is(":animated"))) {
$container.children(opts.cntChildSel).eq(index).siblings().css("display", "none")
.end().stop(true, true).fadeIn(opts.aniSpeed);
}
break;
case "move":
$container.children(opts.cntChildSel).css(opts.direction, -step * index + "px");
break;
case "move-fade":
if ($container.children(opts.cntChildSel).css(opts.direction) == -step * index + "px") break;
$container.children(opts.cntChildSel).stop(true).css("opacity", 0).css(opts.direction, -step * index + "px").animate({
"opacity": 1
}, opts.aniSpeed);
break;
case "move-animate":
animateArgu[opts.direction] = -step * index + "px";
$container.children(opts.cntChildSel).stop(true).animate(animateArgu, opts.aniSpeed, opts.aniMethod);
break;
default:
$container.children(opts.cntChildSel).eq(index).css("display", "block")
.siblings().css("display", "none");
}
});
$menus.eq(0)[opts.tabEvent]();
});
};
$.fn.tabso.defaults = {
cntSelect: ".content_wrap",
tabEvent: "mouseover",
tabStyle: "normal",
direction: "top",
aniMethod: "swing",
aniSpeed: "fast",
onStyle: "current",
menuChildSel: "*",
cntChildSel: "*"
};
})(jQuery);
//详细页分页点击效果
$(".paging_num > a").click(function() {
var index = $(this).index();
location.hash = index + 1;
var hash = location.hash;
$(".total .paging").eq(hash.slice(1) - 1).css("display", "block").siblings().css("display", "none");
$(this).addClass("paging_hover").siblings().removeClass("paging_hover");
});
var hash = location.hash;
if (!hash) {
$(".total .paging").eq(0).css("display", "block").siblings().css("display", "none");
} else {
$(".total .paging").eq(hash.slice(1) - 1).css("display", "block").siblings().css("display", "none");
$(".paging_num > a").eq(hash.slice(1) - 1).addClass("paging_hover").siblings().removeClass("paging_hover");
}
//设为首页
function SetHome(obj, vrl) {
try {
obj.style.behavior = 'url(#default#homepage)';
obj.setHomePage(vrl);
} catch (e) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert("抱歉!您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”,点击“加入收藏”后忽略安全提示,即可设置成功。");
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', vrl);
} else {
alert('抱歉,您的浏览器不支持自动设置首页, 请使用浏览器菜单手动设置!');
}
}
}
// 新闻定时推送
(function() {
if (typeof(url) != 'undefined') {
$.get(url + "data/include/exectask.htmp?rand" + Math.random());
} else {
$.get("/data/include/exectask.htmp?rand" + Math.random());
}
})();
//百度自动推送代码
(function() {
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'http') {
bp.src = 'http://zz.bdstatic.com/linksubmit/push.js';
} else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
$(document).ready(function() {
var show = false
$(".banner_video").click(function() {
if (show == false) {
$(".banner_video_sp").fadeIn();
show = true;
} else {
$(".banner_video_sp").fadeOut();
show = false;
}
})
$(".banner_video").click(
function(event) { event.stopPropagation(); }
)
var h = $(window).height();
$(".banner").css("height", h);
var h2 = $(".ban_newslist_left").height();
$(".ban_newslist_right").css("height", h2);
$(".prev,.next").hover(function() {
$(this).stop(true, false).fadeTo("show", 0.9);
}, function() {
$(this).stop(true, false).fadeTo("show", 0.4);
});
$(".banner-box").slide({
titCell: ".hd ul",
mainCell: ".bd ul",
effect: "fold",
interTime: 3500,
delayTime: 500,
autoPlay: true,
autoPage: true,
trigger: "click"
});
$(window).resize(function() {
var h1 = $(window).height();
$(".banner").css("height", h1);
var h2 = $(".ban_newslist_left").height();
$(".ban_newslist_right").css("height", h2);
})
});
$(window).scroll(function() {
if ($(window).scrollTop() > 500) {
$(".banner ul").stop(true).css({
"display": "none",
}, 1000);
} else {
$(".banner ul").stop(true).css({
"display": "block",
}, 1000);
}
});
function bb1() {
var nav_num = '';
var obj_li = $(".bb li");
var count = obj_li.length;
obj_li.first().css("display", "block");
obj_li.each(function() {
var index = $(this).index() + 1;
nav_num += '0' + index + '';
});
$(".banner").append('');
$(".banner .num li").first().addClass("num_hover");
$(".banner .num li").hover(function() {
sw = $(".banner .num li").index(this);
myShow(sw);
});
function myShow(i) {
$(".banner .num li").eq(i).addClass("num_hover").siblings().removeClass("num_hover");
obj_li.eq(i).stop(true, true).fadeIn(600).siblings("li").fadeOut(600);
}
var myTime = 0;
//滑入停止动画,滑出开始动画
$(".bb").hover(function() {
if (myTime) {
clearInterval(myTime);
}
}, function() {
myTime = setInterval(function() {
myShow(sw);
sw++;
if (sw == count) {
sw = 0;
}
}, 3000);
});
//自动开始
var sw = 0;
myTime = setInterval(function() {
myShow(sw);
sw++;
if (sw == count) {
sw = 0;
}
}, 2000);
}