(function (_w) {
var w = _w;
//main namespace
CH = {};
CH.Zodiac = {};
//cookie设置 调用:$.Cookie.Set('abc');
$.Cookie = {
//写cookies并加密
SetCookie: function (name, value, option) {
//用于存储赋值给document.cookie的cookie格式字符串
var str = name + "=" + escape($.Cookie.CodeCookie(value));
if (option) {
//如果设置了过期时间
if (option.expireDays) {
var date = new Date();
var ms = option.expireDays * 24 * 3600 * 1000;
date.setTime(date.getTime() + ms);
str += ";expires=" + date.toGMTString();
}
if (option.path) str += ";path=" + path;
if (option.domain) str += ";domain=" + domain;
if (option.secure) str += ";true";
}
document.cookie = str;
}
,
//读cookie并解密
GetCookie: function (name) {
var cookieArray = document.cookie.split(";");
var cookie = new Object();
for (var i = 0; i < cookieArray.length; i++) {
var arr = cookieArray[i].split("=");
if ($.trim(arr[0]) == $.trim(name)) return $.Cookie.DecodeCookie(unescape(arr[1]));
};
return "";
}
,
//加密cookie
CodeCookie: function (str) {
var strRtn = "";
for (var i = str.length - 1; i >= 0; i--) {
strRtn += str.charCodeAt(i);
if (i) strRtn += "a"; //用a作分隔符
}
return strRtn;
}
,
//解码cookie
DecodeCookie: function (str) {
var strArr;
var strRtn = "";
strArr = str.split("a");
for (var i = strArr.length - 1; i >= 0; i--)
strRtn += String.fromCharCode(eval(strArr[i]));
return strRtn;
}
,
// write cookies
Set: function (name, value, hours) {
var expire = "";
if (hours != null) {
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire + ";path=/";
},
// read cookies
Get: function (name) {
var cookieValue = "";
var search = name + "=";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end));
}
}
return cookieValue;
}
,
// delete cookie
Del: function (name) {
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = name + "=''; expires=" + date.toGMTString();
}
},
//弹窗工具箱
$.Dialog = {
iframe: function (url, w, h) {
return '';
},
//弹出框
ShowDialog: function (title, id, w, h) {
if ($("#dialog").length != "0")
$("div#dialog").remove();
var tmp = "
";
$("body").append(tmp);
$('#dialog').dialog({
autoOpen: false,
modal: true,
height: h + 60,
width: w + 36,
close: function (event, ui) { $(this).dialog("destroy"); }
});
$('#dialog').dialog('open');
},
//弹窗框 IFrame
ShowIFrame: function (title, url, w, h) {
if ($("#dialog").length != "0")
$("div#dialog").remove();
var tmp = "" + $.Dialog.iframe(url, w, h) + "
";
$("body").append(tmp);
$('#dialog').dialog({
autoOpen: false,
modal: true,
height: h + 60,
width: w + 36,
close: function (event, ui) { $(this).dialog("destroy"); }
});
$('#dialog').dialog('open');
},
iframe: function (url, w, h) {
return '';
},
InsertMsgDiv: function (title, msg, id) {
if ($("#" + id).length == "0") {
var tmp = "";
$("body").append(tmp);
}
else
$("#" + id + " > p").attr("title", title).html(msg);
},
//显示文本消息
PrintMsg: function (title, msg, modal, time, topButton) {
var divID = "js_msg";
InsertMsgDiv(title, msg, divID, topButton);
$("#" + divID).dialog({ autoOpen: false, modal: modal });
if (typeof topButton == "boolean" && topButton)
$("a.ui-dialog-titlebar-close").remove();
$("#" + divID).dialog('open');
if (typeof time == 'number' && time > 0)
setTimeout("$('#" + divID + "').dialog('close')", time * 1000);
},
//显示文本消息,点击跳转
UpdateJump: function () {
divID = "js_msg";
InsertMsgDiv(title, msg, divID);
$("#" + divID).dialog(
{
autoOpen: false,
modal: modal,
buttons:
{
close: function () {
if (url == "")
window.parent.location.reload();
else if (url == "history(-1)")
window.history.back();
else
window.parent.location.href = url;
}
}
}
);
$("a.ui-dialog-titlebar-close").remove();
$("#" + divID).dialog('open');
},
//打开Windows弹窗
OpenWindow: function (u, w, h, t, n, top, left) {
if (u == "" || typeof (u) == "undefined")
u = that.attr("uri");
if (typeof t != 'undefined' && t == 'confirm') return false;
h = (h == "" || typeof h == 'undefined') ? 600 : h;
w = (w == "" || typeof w == 'undefined') ? 600 : w;
n = (n == "" || typeof n == "undefined") ? "newwindow" : n;
top = (top == "" || typeof top == "undefined") ? "90" : top;
left = (left == "" || typeof left == "undefined") ? "160" : left;
if ($.browser.msie) {
if ($.browser.version == "8.0")
window.open(u, n);
else
window.open(u, n, 'height=' + h + ',width=' + w + ',top=' + top + ',left=' + left + ',scrollbars=no,toolbar=no,menubar=no, Resizable=no,location=no,status=no');
}
else
window.open(u, n, 'height=' + h + ',width=' + w + ',top=' + top + ',left=' + left + ',scrollbars=no,toolbar=no,menubar=no, Resizable=no,location=no,status=no');
}
};
CH.Zodiac.Fun = {
//转换成字符串,防XSS攻击
ToStr: function (str) {
return str.replace("<", "<").replace(">", ">");
},
//搜索聚焦
SearchFocusContent: function () {
var hash = (!window.location.hash) ? "#content" : window.location.hash;
window.location.hash = hash;
},
CheckEmail:function(e)
{
var reg =/^([a-zA-Z0-9_-_\.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
return reg.test(String(e));
},
CheckDate:function(d)
{
var reg = /[01|02|03|04|05|06|07|08|09|10|11|12]\/[0-9]{2}\/[0-9]{4}$/;
return reg.test(String(d));
},
//载入Jquery UI
LoadUI: function () {
if ($("link[href='/css/smoothness/jquery-ui.css']").length == 0) {
var uicss = $("");
uicss.attr("type", "text/css").attr("rev", "Stylesheet").attr("rel", "Stylesheet").attr("href", "/css/smoothness/jquery-ui.css");
$("head").append(uicss);
}
if ($("script[src='/js/jquery-ui.js']").length == 0) {
var uijs = $("