function addfavorite(surl, stitle) {
try {
window.external.addfavorite(surl, stitle);
}
catch (e) {
try {
window.sidebar.addpanel(stitle, surl, " ");
}
catch (e) {
alert('加入收藏失败,请使用ctrl+d进行添加');
}
}
}
/**
* 获取指定url的参数值
* @param url 指定的url地址
* @param name 参数名称
* @return 参数值
*/
function geturlparam(url, name) {
var pattern = new regexp("[?&]" + name + "\=([^&]+)", "g");
var matcher = pattern.exec(url);
var items = null;
if (null != matcher) {
try {
items = decodeuricomponent(decodeuricomponent(matcher[1]));
} catch (e) {
try {
items = decodeuricomponent(matcher[1]);
} catch (e) {
items = matcher[1];
}
}
}
return items;
}
(function ($) {
$.extend({
urlupdateparams: function (url, name, value) {
var r = url;
if (r != null && r != 'undefined' && r != "") {
value = encodeuricomponent(value);
var reg = new regexp("(^|)" + name + "=([^&]*)(|$)");
var tmp = name + "=" + value;
if (url.match(reg) != null) {
r = url.replace(eval(reg), tmp);
}
else {
if (url.match("[\?]")) {
r = url + "&" + tmp;
} else {
r = url + "?" + tmp;
}
}
}
return r;
}
});
})(jquery);
var istouch = modernizr.touch,
ismobile = false,
mobile = false,
scrollnav = true,
navitem = 0,
w_width = jquery(window).width(),
w_height = jquery(window).height(),
$menubtn = jquery('.menubtn'),
$menubox = jquery(".menubox"),
$navmobile = jquery("#navmobile"),
$nava = $navmobile.find("a"),
$msubnav = $navmobile.find(".msubnav"),
$black = jquery(".black"),
$mtop = jquery(".mtop"),
$mtoph = $mtop.height(),
menuboxw = 540;
var _mousemove;
var _click;
var _mousedown;
var _mouseup;
if (modernizr.touch) {
_mousemove = "touchmove";
_click = "touchend";
_mousedown = "touchstart";
_mouseup = "touchend";
} else {
_mousemove = "mousemove";
_click = "click";
_mousedown = "mousedown";
_mouseup = "mouseup";
};
function pagebox() {
w_width = jquery(window).width();
w_height = jquery(window).height();
if (w_width <= 1024) {
ismobile = true;
} else if (w_width > 1024) {
ismobile = false;
};
if (w_width <= 640) {
mobile = true;
} else if (w_width > 640) {
mobile = false;
};
menuboxw = w_width - 52;
$mtoph = $mtop.height();
if (navitem == 1 && mobile) {
$menubox.width(menuboxw);
jquery(".pusher").css({ "transform": "translate(-" + menuboxw + "px,0px)" });
jquery(".topbox").css({ "transform": "translate(-" + menuboxw + "px,0px)" });
} else {
$menubtn.removeclass("menubtnshow");
$menubox.removeclass("menuboxshow");
jquery(".container").removeclass("menuopen");
jquery(".pusher").css({ "transform": "translate(0px,0px)" });
jquery(".topbox").css({ "transform": "translate(0px,0px)" });
navitem = 0;
};
};
function setimgmax(img, imgw, imgh, tw, th) {
var twidth = tw || w_width;
var theight = th || w_height;
var coe = imgh / imgw;
var coe2 = theight / twidth;
if (coe < coe2) {
var imgwidth = theight / coe;
img.css({ height: theight, width: imgwidth, left: -(imgwidth - twidth) / 2, top: 0 });
} else {
var imgheight = twidth * coe;
img.css({ height: imgheight, width: twidth, left: 0, top: -(imgheight - theight) / 2 });
};
};
function pagebanner() {
if (!ismobile) {
jquery('.pbanner').innerheight(jquery(".pbanner img").height());
} else {
jquery('.pbanner').css("height", "auto");
}
};
load();
function load() {
var maxnum = $(".pbanner img").size();
var curnum = 0;
jquery(".pbanner img").each(function () {
$(this).attr("src", $(this).attr("_src"));
jquery(this).load(function () {
curnum++;
if (curnum == maxnum) {
pagebanner();
$mtoph = $mtop.height();
}
});
});
};
pagebox();
jquery(window).resize(function () {
pagebox();
pagebanner();
});
jquery(function () {
setpopup($(".footbox .i3"), "官方微信");
function setpopup(obj, title) {
obj.click(function () {
var str = '
';
$("body").append(str);
$(".popup .close").click(function () {
$(".popup").remove();
});
return false;
});
}
//pc nav
jquery("#nav li").hover(function () {
if (jquery(this).find(".subnav").length > 0) {
$(this).children("a").addclass("hov");
$(this).children(".subnav").stop(false, false).fadein(250);
};
}, function () {
$(this).children("a").removeclass("hov");
$(this).children(".subnav").stop(false, false).fadeout(250);
});
jquery(".subnav a").click(function () {
var anchorcur = jquery(this).attr("href").split("#")[1];
if (anchorcur && jquery("#" + anchorcur).length == 1) {
setscroll("#" + anchorcur);
}
});
jquery(".msubnav a").click(function () {
var anchorcur = jquery(this).attr("href").split("#")[1];
if (anchorcur && jquery("#" + anchorcur).length == 1) {
jquery(this).removeclass("menubtnshow");
$menubox.removeclass("menuboxshow");
jquery(".container").removeclass("menuopen");
jquery(".pusher").css({ "transform": "translate(0px,0px)" });
jquery(".topbox").css({ "transform": "translate(0px,0px)" });
jquery("html").removeclass("open");
navitem = 0;
setscroll("#" + anchorcur);
}
});
function gethash() {
var hash = location.href.split("#")[1];
if (hash) {
setscroll("#" + hash);
}
};
gethash();
function setscroll(anchorcur) {
$mtoph = $mtop.height();
if (jquery(anchorcur).length >= 1)
jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top - $mtoph }, 800, 'easeinoutexpo');
};
//!pc nav
$menubtn.bind(_click, function () {
if (navitem == 0 && !mobile) {
jquery(this).addclass("menubtnshow");
$menubox.addclass("menuboxshow").width(340);
jquery(".container").addclass("menuopen");
jquery(".pusher").css({ "transform": "translate(-340px,0px)" });
jquery(".topbox").css({ "transform": "translate(-340px,0px)" });
jquery("html").addclass("open");
navitem = 1;
} else if (navitem == 1 && !mobile) {
jquery(this).removeclass("menubtnshow");
$menubox.removeclass("menuboxshow");
jquery(".container").removeclass("menuopen");
jquery(".pusher").css({ "transform": "translate(0px,0px)" });
jquery(".topbox").css({ "transform": "translate(0px,0px)" });
jquery("html").removeclass("open");
navitem = 0;
} else if (navitem == 0 && mobile) {
jquery(this).addclass("menubtnshow");
$menubox.addclass("menuboxshow").width(menuboxw);
jquery(".container").addclass("menuopen");
jquery(".pusher").css({ "transform": "translate(-" + menuboxw + "px,0px)" });
jquery(".topbox").css({ "transform": "translate(-" + menuboxw + "px,0px)" });
jquery("html").addclass("open");
navitem = 1;
} else if (navitem == 1 && mobile) {
jquery(this).addclass("menubtnshow");
$menubox.removeclass("menuboxshow");
jquery(".container").removeclass("menuopen");
jquery(".pusher").css({ "transform": "translate(0px,0px)" });
jquery(".topbox").css({ "transform": "translate(0px,0px)" });
jquery("html").removeclass("open");
navitem = 0;
};
});
//navmobile click
jquery("#navmobile>dd>p>a").bind("click", function (e) {
var hjcur = $(this);
var hjdd = $(this).parents("p").parents("dd");
if (hjdd.find(".msubnav").size() > 0) {
if (hjcur.hasclass("cur")) {
hjdd.find(".msubnav").stop(false, false).slideup();
hjcur.removeclass("cur");
} else {
$nava.removeclass("cur");
$msubnav.stop(false, false).slideup();
hjdd.find(".msubnav").stop(false, false).slidedown();
hjcur.addclass("cur");
e.preventdefault();
}
}
});
$black.click(function () {
$menubtn.removeclass("menubtnshow");
$menubox.removeclass("menuboxshow");
jquery(".container").removeclass("menuopen");
jquery(".pusher").css({ "transform": "translate(0px,0px)" });
jquery(".topbox").css({ "transform": "translate(0px,0px)" });
jquery("html").removeclass("open");
navitem = 0;
});
jquery(window).scroll(function () {
if (jquery(window).scrolltop() < w_height && !ismobile) {
jquery('.pbanner img').css('margin-top', $(window).scrolltop() / 2);
}
});
$(".search-txt,.searchm-txt").keyup(function (event) {
var keyvalue = event.which;
var vakes = $(this).val();
if (keyvalue == 13) {
if (vakes == '') {
$(this).focus();
return;
}
window.location = 'search.aspx?keyword=' + encodeuricomponent(vakes);
}
})
$('.search-btn').click(function () {
var vakes = $(this).prev().val();
if (vakes == '') {
$(".search-txt").focus();
return;
}
window.location = 'search.aspx?keyword=' + encodeuricomponent(vakes);
});
//弹出关闭
jquery(document).on('click', ".framehtml", function (e) {
if (!$(e.target).hasclass('framehtml')) {
return false;
} else {
jquery('html').removeclass('open');
settimeout(function () { jquery('.framehtml').remove(); }, 400);
}
});
jquery(document).on('click', ".frameclose", function (e) {
jquery('html').removeclass('open');
settimeout(function () { jquery('.framehtml').remove(); }, 400);
});
});