//内页
function total(h) {
try{
if(!indexType)
indexType = "ct";
}catch(e){
indexType="ct";
}
if (indexType == "daohao")
return;
$(".nav>ul>li:not(.clear)").eq(h - 1).addClass("on");
var nav_c = $(".nav>ul>li:not(.clear)");
var navli = $(".nav>ul>li");
navli.each(function (i) {
var theMenu = $(this).children("div");
var tarHeight = theMenu.height();
$(this).hover(
function () {
theMenu.stop().show().animate({ height: tarHeight, opacity: 1 }, 400);
$(this).addClass("on")
},
function () {
theMenu.stop().animate({ height: 0, opacity: 0 }, 400, function () { $(this).css({ display: "none" }); });
$(this).removeClass("on")
nav_c.eq(h - 1).addClass("on");
}
);
});
}
//首页
function totalIndex(v) {
var liselected = v;
var lis = $(".hNav>ul>li"); //获取导航栏列表
selectFun(lis, liselected) //设定默认首页
lis.each(function (n) {
var theMenu = $(this).children("div");
var tarHeight = theMenu.height();
$(this).hover(function () {
theMenu.stop().show().animate({ height: tarHeight, opacity: 1 }, 400);
},
function () {
theMenu.stop().animate({ height: 0, opacity: 0 }, 400, function () {$(this).css({ display: "none" });
});
}
)
});
}
//添加默认选中
function selectFun(obj, selectedIndex) {
obj.eq(selectedIndex).addClass('on')
}
$(function () {
total();
$(".tqList ul li:odd").css("background", "#f6f6f6");
$(".tf1 tr:odd").css("background", "#f6f6f6");
$(".tf4 tr:odd").css("background", "#f6f6f6");
/*天气工作室*/
//tab_1(".gzs1 .l3 p", ".gzs1 .l3 span");
//tab_1(".gzs1 .l5 p", ".gzs1 .l5 span");
//tab_1(".gzs1 .l7 p", ".gzs1 .l7 span");
//gzs2Left();
qxMenu();
qhfw();
area_div();
zhList();
$(".notice").Scroll({ line: 1, speed: 1000, timer: 3000 });
$(".notice_index").Scroll({ line: 1, speed: 1000, timer: 3000 });
});
var zhList = function () {
$(".zhList li").hover(
function () {
$(this).find("div").fadeIn("slow");
},
function () {
$(this).find("div").hide();
}
);
}
var area_div = function () {
$(".area_div").click(function () {
$(this).next("div").toggle();
});
$(".area1 li").click(function () {
var v = $(this).html();
var v1 = $(this).attr("data-src");
$(this).addClass("hover").siblings().removeClass("hover");
$(this).parent().parent().prev(".area_div").val(v);
$(this).parent().parent().prev().prev(".city_div").val(v1);
$(".area1").hide();
});
}
var qhfw = function () {
$(".qhfw dt li").click(function () {
$(this).addClass("hover").siblings().removeClass("hover");
var index = $(this).index();
$(".qhfw dd").hide();
$(".qhfw dd").eq(index).show();
})
}
var nMap = function(){
var d=$(".nMap span");var m=$(".mapZoom");d.bind({mouseover:function(e){m.show().stop(true,true).css({"left":e.pageX-m.width(),"top":e.pageY+20});},mouseout:function(){m.hide()}});
}
var showlodin = function (target) {
target.empty();
target.append("
![load](images/loading.gif)
");
}
var loadError = function (target) {
target.empty();
target.append("");
}
//鼠标点击切换 list:经过的列表; contents:对应切换的列表
var Tab_click = function (list, contents) {
if (!contents) {
list.bind("click", function () {
list.removeClass("hover");
$(this).addClass("hover");
})
return;
}
contents.css("display", "none");
for (var i = 0; i < list.length; i++) {
var link = $(list[i]);
if (contents[i] == undefined) { continue; }
if (link.hasClass("hover")) {
contents.eq(i).css("display", "");
}
link.data("content", contents.eq(i));
link.bind("click", function () { var t = $(this); list.removeClass("hover"); t.addClass("hover"); contents.css("display", "none"); t.data("content").css('display', ''); });
}
}
//气象应警 -弹出
var qxShow1 = function () {
var d = $(".qxShow1 span");
var m = $(".qxCon_zoom");
d.bind({mouseover:function(e)
{
var id = d.index($(this));
var l=$(".qxShow1").offset().left;
var t=$(this).offset().top;
if(t>780) t=700;
var h = m.eq(id).height();
var w = m.eq(id).width();
var pageX=e.pageX-l-w;
if (pageX < -250) pageX = -30;
m.eq(id).show().stop(true, true).css({ "left": pageX, "top": e.pageY - h - 80 });
}, mouseout: function () {
m.hide()
}
});
}
//气象应警 -
var qxMenu = function () {
$(".qxMenu li:not('.gdwarning')").click(function () {
$(this).addClass("hover").siblings().removeClass("hover");
var index = $(this).index();
$(".qxCon").hide();
$(".qxCon").eq(index).show();
})
}
var tab_1 = function (a, b) {
var tab_1_p = $(a);
var tab_1_s = $(b);
tab_1_p.click(function () {
if (!$(this).find("span").is(":visible")) {
tab_1_s.hide();
$(this).find("span").slideDown();
}
else {
tab_1_s.hide();
}
})
tab_1_s.children("a").click(function () {
var text = $(this).text();
$(this).parent().prev("i").html(text);
tab_1_s.hide();
return false;
})
}
var gzs2Left = function () {
$(".gzs2Left li").click(
function () {
$(this).addClass("hover").siblings().removeClass("hover");
var index = $(this).index();
$(".gzs2Left dd").hide();
$(".gzs2Left dd").eq(index).show();
}
);
}
//设为首页 调用 设为首页
function setHomePage(obj) {
var aUrls = document.URL.split("/");
var vDomainName = "http://" + aUrls[2] + "/";
try {//IE
obj.style.behavior = "url(#default#homepage)";
obj.setHomePage(vDomainName);
} catch (e) {//other
if (window.netscape) {//ff
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch (e) {
alert(" 此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]设置为'true'");
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', vDomainName);
}
}
}
//添加到收藏夹
function AddToFavorite() {
var url = window.location.href;
try {
window.external.addFavorite(url, document.title);
}
catch (e) {
try {
window.sidebar.addPanel(document.title, url, "");
}
catch (e) {
alert("浏览器不支持,请使用Ctrl+D进行添加");
}
}
}
//时间格式化 var d = new Date().format('yyyy-MM-dd');
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
function addDate(type, NumDay, dtDate) {
var date = new Date(dtDate)
type = parseInt(type) //类型
lIntval = parseInt(NumDay)//间隔
switch (type) {
case 6://年
date.setYear(date.getFullYear() + lIntval)
break;
case 7://季度
date.setMonth(date.getMonth() + (lIntval * 3))
break;
case 5://月
date.setMonth(date.getMonth() + lIntval)
break;
case 4://天
date.setDate(date.getDate() + lIntval)
break
case 3://时
date.setHours(date.getHours() + lIntval)
break
case 2://分
date.setMinutes(date.getMinutes() + lIntval)
break
case 1://秒
date.setSeconds(date.getSeconds() + lIntval)
break;
default:
}
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()
}
/*input提示*/
function getAttributeValue(o, key) {
if (!o.attributes) return null;
var attr = o.attributes;
for (var i = 0; i < attr.length; i++) {
if (key.toLowerCase() == attr[i].name.toLowerCase())
return attr[i].value;
}
return null;
}
function focusInputEle(o) {
if (o.value == getAttributeValue(o, 'defaultVal')) {
o.value = '';
}
}
function blurInputEle(o) {
if (o.value == '') {
o.value = getAttributeValue(o, 'defaultVal');
}
}
/*input提示*/
//双首页选择
function boxSize(t) {
var cur_style = getCookie("index_style");
if (cur_style == null) {//空 弹出选择框
var w = $(window).width();
var h = $(window).height();
var div = $(".boxDiv");
var boW = (w - div.width()) / 2
var boh = (h - div.height()) / 2
div.animate({ "left": boW, "top": boh }, 2);
if (t == 0) $(".bodyBg").fadeIn(200);
} else {
$(".bodyBg").remove();
}
}
function SetIndexStyle(t) {
setCookie("index_style", t);
if (t = "index.aspx")
$(".bodyBg").remove();
}
function Search_check() {
var keys = $("#all_web_key_text_id").val();
var keyBm = encodeURIComponent(keys);
var ext = /^[\w\_\-%]*$/;
if (keys == "" || keys == "Site Search") {
alert("Please enter your search keywords!");
return false;
} else if (!ext.test(keyBm)) {
alert("Search Keyword formatting errors! Please do not use special characters");
return false;
} else {
return true;
}
}
function setCookie(name, value)//两个参数,一个是cookie的名子,一个是值
{
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数
{
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return unescape(arr[2]); return null;
}
//滚动插件
(function ($) {
$.fn.extend({
Scroll: function (opt, callback) {
//参数初始化
if (!opt) var opt = {};
var _this = this.eq(0).find("ul:first");
var lineH = _this.find("li:first").height(), //获取行高
line = opt.line ? parseInt(opt.line, 10) : parseInt(this.height() / lineH, 10), //每次滚动的行数,默认为一屏,即父容器高度
speed = opt.speed ? parseInt(opt.speed, 10) : 500, //卷动速度,数值越大,速度越慢(毫秒)
timer = opt.timer ? parseInt(opt.timer, 10) : 3000; //滚动的时间间隔(毫秒)
if (line == 0) line = 1;
var upHeight = 0 - line * lineH;
//滚动函数
scrollUp = function () {
_this.animate({
marginTop: upHeight
}, speed, function () {
for (i = 1; i <= line; i++) {
_this.find("li:first").appendTo(_this);
}
_this.css({ marginTop: 0 });
});
}
//鼠标事件绑定
_this.hover(function () {
clearInterval(timerID);
}, function () {
timerID = setInterval("scrollUp()", timer);
}).mouseout();
}
})
})(jQuery);
//截取url
function GetLocationHead(parameStr)
{
//parame="mode";
var queryString = location.href.substring(location.href.indexOf('#') + 1); //获得URL传递的参数
var sIndex = queryString.indexOf(parameStr);
if (sIndex == -1)
return "";
sIndex += parameStr.length + 1;
var v = queryString.substring(sIndex)
v = v.substring(0, v.indexOf(":") == -1 ? v.length : v.indexOf(":"));
return v;
}
//设置url
function SetLocationHead(parameStr, newVal) {
newVal += "";
var _sIndexSharp = location.href.indexOf('#');
var queryStringPath = "";
var queryString="";
if (_sIndexSharp == -1) {//未有参数追加
queryStringPath = location.href + "#";
}
else{
queryStringPath = location.href.substring(0, _sIndexSharp + 1);
queryString = location.href.substring(_sIndexSharp + 1); //获得URL传递的参数
}
var sIndex = queryString.indexOf(parameStr);
var urlNew="";
var last="";
if (sIndex == -1) {
if (_sIndexSharp==-1)
urlNew = queryString + parameStr + "=";
else
urlNew = queryString +":"+parameStr + "=";
} else {
sIndex=sIndex+ parameStr.length + 1;
urlNew = queryString.substring(0, sIndex);
var lastStr=queryString.substring(sIndex);
var lastStartIndex = lastStr.indexOf(':');
if(lastStartIndex!=-1)
last = lastStr.substring(lastStartIndex);
}
urlNew += newVal+last;
location.href = queryStringPath + urlNew;
}
function TraveWeaPint(type) {
var WeaList = "";
$("ul.day li.day:not(.last)").each(function () {
var _div = $(this).find(".locationSelect")
var _province = _div.find("select:first");
var _city = _div.find("select:last");
var img = $(this).find("img").attr("rel");
var weat = $(this).find(".whe").html();
var tem = $(this).find(".hwd").html();
WeaList += _province.val() + " - " + _city.val() + "," + img + "," + weat + "," + tem + "|";
})
window.open('TravelWeaPint.aspx?v=' +escape(WeaList)+"&type="+type);
}
function preview(oper)
{
if (oper < 10) {
bdhtml=window.document.body.innerHTML;//获取当前页的html代码
sprnstr="";//设置打印开始区域
eprnstr="";//设置打印结束区域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;
window.print();
location.reload();
//window.document.body.innerHTML = bdhtml;
//$(".cityTarget").show();
//$(".choseVal").remove();
} else{
window.print();
}
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}