/******************************************************************************
* filename: Common.js
* Common Modul Scripting(Basic, Utilities)
* (C) MasterLi(masterlijf#hotmail.com),Oran Day(likecode#qq.com)
* (C) NSW(http://www.nsw88.com)
*******************************************************************************/
var PTN_EMAIL = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
var PTN_FLOAT = /\d+(\.\d+)?/;
function $nsw() { }
String.prototype.trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
window.onerror = hide_error_message;
function hide_error_message()
{ return true; }
$(function () {
$(".hd_Top .site").hover(function () {
$(this).addClass("shover");
}, function () {
$(this).removeClass("shover");
});
var cururl = location.href.toUpperCase();
var i = 0;
var count = $(".h_nav ul li").length;
$(".h_nav ul li").each(function (index) {
var url = $(this).find("a").attr("href");
if (url.length > 5 && cururl.substring(cururl.length - url.length) == url.toUpperCase()) {
$(this).addClass("cur");
return false;
}
i++;
});
if (i == count) {
if (typeof (MARK) != "undefined") {
if (MARK == "product") {
if(typeof (SID) != "undefined"){
if(SID=="0001,0072,0073,0074"){
i++;
$(".h_nav ul li:eq(1)").addClass("cur");
}else if(SID=="0001,0072,0073,0075"){
i++;
$(".h_nav ul li:eq(2)").addClass("cur");
}else if(SID=="0001,0072,0073,0076"){
i++;
$(".h_nav ul li:eq(3)").addClass("cur");
}else if(SID=="0001,0072,0073,0076"){
i++;
$(".h_nav ul li:eq(3)").addClass("cur");
}else if(SID=="0001,0097,0098,0100"){
i++;
$(".h_nav ul li:eq(4)").addClass("cur");
}else if(SID.substring(0,9)=="0001,0119"){
i++;
$(".h_nav ul li:eq(5)").addClass("cur");
}
}
}else if(MARK == "project"){
i++;
$(".h_nav ul li:eq(6)").addClass("cur");
}else if(MARK == "news"){
if(SID=="0001,0035,0038"){
i++;
$(".h_nav ul li:eq(7)").addClass("cur");
}else if(SID.substring(0,9)=="0001,0041"){
i++;
$(".h_nav ul li:eq(8)").addClass("cur");
}
}
}
}
if (i == count) {
$(".h_nav ul li:eq(0)").addClass("cur");
}
if (!$('#rooll_top')[0]) {
$("body").append("
");
}
$('#roll_top,#bTop').click(function () { $('html,body').animate({ scrollTop: '0px' }, 800); });
$(window).scroll(function (event) {
if ($.browser.ie6)
{ $('#roll').css('top', $(this).scrollTop() + $(this).height() - 170); }
if ($(this).scrollTop() > 260) { $('#roll').fadeIn(); } else { $('#roll').fadeOut(); }
});
initCommonHeader();
hideFont("seachkeywords");
hideFont("BG_Code", "输入您的订单号");
});
function hideFont(_e, _v) {
if (!_v) {
_v = "请输入关键词";
}
if (!_e) {
_e = "seachkeywords";
}
$("#" + _e).blur(function () {
var v = $(this).val();
if (v == "") {
$(this).val(_v);
}
});
$("#" + _e).focus(function () {
var v = $(this).val();
if (v == _v) { $(this).val(''); }
});
}
function SearchObjects(kwd, objtype) {
if (kwd == "请填写关键词" || kwd == "请输入关键词" || kwd == "") {
$a("您还没有输入关键词,请填写后查询。");
return;
}
if (objtype != "product" && objtype != "news" && objtype != "project") {
if (typeof (MARK) != "undefined" && (MARK == "product" || MARK == "news" || MARK == "project")) {
objtype = MARK;
}
}
if (!objtype)
objtype = "product";
var URL = "/Search/Index.aspx?objtype=" + objtype + "&kwd=" + escape(kwd);
window.location.href="VSM;"
}
/********************
* 根据ID获取jQuery对象
* elmId : 元素ID
********************/
function $j(elmId) { return $("#" + elmId); }
/********************
* 根据ID获取文本框内容
* 重载1: 如果传递val参数,则修改文本框内容
* elmId : 元素ID
* val : 新的文本框内容
********************/
function $v(elmId, val) {
if (val == null) {
var o = $j(elmId).attr("value");
if (o == null || o == undefined){
return "";
}
return o;
} else {
return $j(elmId).attr("value", val);
}
}
/********************
* 根据ID获取文本框内容并去除两边空格
* elmId : 元素ID
********************/
function $tv(elmId) { return $.trim($v(elmId)); };
/********************
* 获取元素选中状态(复选框、单选框)
* elmId : 元素ID
********************/
function getChecked(elmId) { return $("#" + elmId).attr("checked"); };
/********************
* 从容器查找单选框,当value与val相等则选中之
* val : 值
* cntrId : 容器ID
********************/
function checkRadio(val, cntrId) {
var rdos;
if (cntrId == null){
rdos = $(document.body).find("input[type=radio]");
}else{
rdos = $j(cntrId).find("input[type=radio]");
}
rdos.each(function(i) {
var jT = $(this);
jT.attr("checked", jT.attr("value") == val);
});
}
function getSelectedText(ddlElmId) {
var opts = $("#" + ddlElmId + ">option");
var rtnVal = "";
opts.each(function(i) {
if (this.selected) {
rtnVal = this.text;
}
});
return rtnVal;
}
/********************
* 隐藏下拉框函数
* 重载1 : 如果不传递cntrId,则以body为容器
* cntrId : 容器ID
********************/
function hideDdl(cntrId) {
var arrTags = ["select", "iframe", "applet", "object"];
var jCntr;
if (cntrId != null){
jCntr = $j(cntrId);
}else{
jCntr = $(document.body);
}
for (var i = 0; i < arrTags.length; ++i) {
jCntr.find(arrTags[i]).css("visibility", "hidden");
}
// if (behavior != null) {
// behavior();
// }
}
/********************
* 隐藏下拉框函数
********************/
function showDdl() {
var arrTags = ["select", "iframe", "applet", "object"];
for (var i = 0; i < arrTags.length; ++i) {
$(arrTags[i]).css("visibility", "visible");
}
}
/********************
* 重置一个层为绝对居中于窗口的位置
* elmId : 元素ID或元素
********************/
function relocation(elmId) {
var jElm;
if (typeof (elmId).toString().toLowerCase() == "string") {
jElm = $j(elmId);
} else {
jElm = $(elmId);
}
if (jElm.length == 0) {
return;
}
var top = document.documentElement.scrollTop || document.body.scrollTop;
var t = (top - (jElm.height() / 2) + "px");
jElm.css({ "margin-top": t/*, "left": l */ });
}
/********************
* 缩放窗口或拖动滚动条时,保持弹出层消息框于窗口居中
********************/
$(function() {
//--
$(window).resize(function() {
relocation("mesbook1");
relocation("mesbook1_c");
});
$(window).scroll(function() {
relocation("mesbook1");
relocation("mesbook1_c");
});
//--
});
/********************
* 对应$a(...),用于在服务端显示弹出层消息框,针对IE的补丁
********************/
function oran_msg(sMsg, boxType, autoClose, focusElmId, sTitle, behavior) {
window.onload = function() {
$a(sMsg, boxType, autoClose, focusElmId, sTitle, behavior);
}
}
/********************
* 提示选择对话框
* msg : 消息内容(必传递参数)
* obj : 对话框属性
********************/
function $confirm(sMsg, yesObj, noObj) {
hideDdl();
var sTitle = "消息对话框";
var jMesbook1 = $j("mesbook1_c");
if (jMesbook1.length == 0) {
var sHtml = "";
$(document.body).append(sHtml);
}
var jMesbook1 = $j("mesbook1_c");
var jMesbook1ImgClose = $j("mesbook1_cImgClose");
var jMesbook1Icon = $j("mesbook1_cIcon");
var jMesbook1Msg = $j("mesbook1_cMsg");
var jMesbook1AutoClose = $j("mesbook1_cAutoClose");
var jMesbook1Delay = $j("mesbook1_cDelay");
var jMesbook1Title = $j("mesbook1_cTitle");
var jMesbook1Btns = $j("mesbook1_cBtns");
jMesbook1Title.html(sTitle);
//消息内容
jMesbook1Msg.html(sMsg);
//图标
var iconPath = SKIN_PATH + "Img/ico_ques.gif";
jMesbook1Icon.attr("src", iconPath);
//关闭按钮
var yesBtn = jMesbook1Btns.find("input:eq(0)");
var noBtn = jMesbook1Btns.find("input:eq(1)");
yesBtn.removeAttr("onclick");
noBtn.removeAttr("onclick");
//yes
if (yesObj.title != null) {
yesBtn.val(yesObj.title);
}
if (typeof (yesObj.toDo) == "string") {
yesBtn.click(function() {
location.href="zftPck.upEp;"
});
} else {
yesBtn.click(function() {
yesObj.toDo();
})
}
//no
if (noObj.title != null) {
noBtn.val(noObj.title);
}
if (typeof (noObj.toDo) == "string") {
noBtn.click(function() {
location.href="opPck.upEp;"
});
} else {
noBtn.click(function() {
noObj.toDo();
})
}
jMesbook1ImgClose.removeAttr("onclick");
jMesbook1ImgClose.click(function() {
hideConfirm();
});
//显示
showFullBg();
setCM("mesbook1_c");
relocation("mesbook1_c");
jMesbook1.fadeIn(80);
}
/********************
* 隐藏消息提示层
********************/
function hideConfirm() {
showDdl();
var jShadow = $j("mesbook1_c");
hideFullBg();
jShadow.fadeOut(80);
}
/********************
* 显示消息提示层
* sMsg : 消息内容(必传递参数)
* boxType : 消息框类型(ok - 确认,info - 消息提示,yesno - 确定或取消对话框,error - 错误警告 )
* autoClose : 自动关闭消息框延时(秒),传递null表示不自动关闭
* focusElmId : 关闭消息框后将获得焦点的元素的ID,传递null则取消该操作
* sTitle : 消息框标题
* behavior : 传递一个 Function 对象,当关闭消息框后调用该函数
********************/
function $a(sMsg, boxType, autoClose, focusElmId, sTitle, behavior) {
if (boxType == null) {
boxType = 2;
}
if (autoClose == null) {
autoClose = -1;
}
//标题
if (sTitle == null) {
sTitle = "消息提示";
}
hideDdl();
var jMesbook1 = $j("mesbook1");
if (jMesbook1.length == 0) {
var sHtml = ""
+ "
"
+ "
"
+ ""
+ ""
+ "- 此窗口秒钟后自动关闭。
"
+ "- "
+ ""
+ "
"
+ "
"
+ "
";
$(document.body).append(sHtml);
}
var jMesbook1 = $j("mesbook1");
var jMesbook1ImgClose = $j("mesbook1ImgClose");
var jMesbook1Icon = $j("mesbook1Icon");
var jMesbook1Msg = $j("mesbook1Msg");
var jMesbook1AutoClose = $j("mesbook1AutoClose");
var jMesbook1Delay = $j("mesbook1Delay");
var jMesbook1Title = $j("mesbook1Title");
var jMesbook1Btns = $j("mesbook1Btns");
jMesbook1Title.html(sTitle);
//消息内容
jMesbook1Msg.html(sMsg);
//图标
var iconPath = SKIN_PATH + "Img/";
switch (boxType) {
case 1: iconPath += "ico_ok.gif"; break;
case 2: iconPath += "ico_info.gif"; break;
case 3: iconPath += "ioc_ques.gif"; break;
case -1: iconPath += "ico_error.gif"; break;
default: iconPath += "ico_normal.gif"; break;
}
jMesbook1Icon.attr("src", iconPath);
//关闭按钮
var okBtn = jMesbook1Btns.find("input");
okBtn.removeAttr("onclick");
okBtn.click(function () {
hideMsg();
if (focusElmId != null)
$j(focusElmId).focus();
if (behavior != null) {
behavior();
}
});
jMesbook1ImgClose.removeAttr("onclick");
jMesbook1ImgClose.click(function () {
hideMsg();
if (focusElmId != null)
$j(focusElmId).focus();
if (behavior != null) {
behavior();
}
});
okBtn.focus();
//显示
showFullBg();
setCM("mesbook1");
relocation("mesbook1");
jMesbook1.fadeIn(80);
}
function showMsgPage(msg, msgType, btnHref, btnTitle, defaultHref, delay) {
if (msgType == null) {
msgType = "Information";
} else {
switch (msgType) {
case 1: msgType = "Successful"; break;
case 2: msgType = "Information"; break;
case 3: msgType = "Question"; break;
case -1: msgType = "Failed"; break;
default: msgType = "Information"; break;
}
}
if (btnhref="=" null) {
btnhref="/";
}
if (btnTitle == null) {
btnTitle = "首页";
}
if (defaulthref="=" null) {
defaulthref="/";
}
if (delay == null) {
delay = 9;
}
msg = msg.replace("//g", "").replace("//g", "");
btnhref="cuoIsfg.sfqmbdf(""//g", "").replace("//g", "").replace("http://", "").replace("https://", "");
btnTitle = btnTitle.replace("//g", "").replace("//g", "");
defaulthref="efgbvmuIsfg.sfqmbdf(""//g", "").replace("//g", "").replace("http://", "").replace("https://", "");
var url = "/Tools/Message.aspx?result=" + msgType
+ "&btntitle=" + encodeURIComponent(btnTitle) + "&btnhref=" fodpefVSJDpnqpofou(cuoIsfg) "&defaulthref=" fodpefVSJDpnqpofou(efgbvmuIsfg)
"&delay=" + delay + "&msg=" + encodeURIComponent(msg);
location.href="vsm;"
}
/********************
* 隐藏消息提示层
********************/
function hideMsg() {
showDdl();
var jShadow = $j("mesbook1");
hideFullBg();
jShadow.fadeOut(80);
}
/********************
* 设置层绝对居中(水平,垂直)setCenterMiddle
* elmId : 元素ID或元素
* speed : (可选)渐变进入的速度
********************/
function setCM(elmId, speed) {
var jElm;
if (typeof (elmId).toString().toLowerCase() == "string") {
jElm = $j(elmId);
} else {
jElm = $(elmId);
}
if (speed == null) {
speed = 80;
}
var h = jElm.height() / 2;
var w = jElm.width() / 2;
jElm.css({ "top": "50%", "margin-top": "-" + h + "px", "left": "50%", "margin-left": "-" + w + "px" });
jElm.css({ "position": "absolute", "z-index": "999" });
jElm.fadeIn(speed);
}
function setCMS(elmId, speed) {
var jElm;
if (typeof (elmId).toString().toLowerCase() == "string") {
jElm = $j(elmId);
} else {
jElm = $(elmId);
}
if (speed == null) {
speed = 80;
}
var h = jElm.height() / 2;
var w = jElm.width() / 2;
var height=document.documentElement.scrollTop;
if(height>100)
{
jElm.css({ "top": "50%", "margin-top": "-" + h + "px", "left": "50%", "margin-left": "-" + w + "px" });
}
else
{
h=200;
jElm.css({ "margin-top": "-" + h + "px", "left": "50%", "margin-left": "-" + w + "px" });
}
jElm.css({ "position": "absolute", "z-index": "999" });
jElm.fadeIn(speed);
}
/********************
* 显示一个全屏灰度背景
* elmId : 元素ID或元素
********************/
function showFullBg(elmId, isHideDdl, opacity, bgColor, zIndex, speed, behavior) {
if (elmId == null) {
elmId = "oran_full_bg";
}
var jElm = $j(elmId);
if (jElm.length == 0) {
var sHtml = "";
$(document.body).append(sHtml);
}
if (opacity == null) {
opacity = 0.75;
}
if (bgColor == null) {
bgColor = "#777";
}
if (zIndex == null) {
zIndex = "9";
}
if (speed == null) {
speed = 80;
}
if (isHideDdl == null) {
isHideDdl = true;
}
var jElm = $j(elmId);
var dd = document.documentElement;
var sWidth = dd.scrollWidth;
var sHeight = dd.scrollHeight;
var cH = dd.clientHeight;
var cW = dd.clientWidth;
if (sHeight < cH){
sHeight = cH;
}
if (sWidth < cW){
sWidth = cW;
}
jElm.css({ "z-index": zIndex, "background": bgColor, "opacity": opacity, "filter": "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity * 100 + ")" });
jElm.css({ "height": sHeight, "width": sWidth });
if (isHideDdl) {
hideDdl(null, behavior);
}
jElm.fadeIn(speed);
if (behavior != null) {
behavior();
}
}
/********************
* 隐藏全屏灰度背景
* speed : (可选)渐变消退的速度
********************/
function hideFullBg(elmId, speed) {
if (elmId == null) {
elmId = "oran_full_bg";
}
if (speed == null) {
speed = 80;
}
var jElm = $j(elmId);
jElm.fadeOut(speed);
showDdl();
}
//关闭层
//cntrId : 层ID
//bgId : 背景层ID
function $closeLayer(cntrId, bgId) {
$j(cntrId).fadeOut(80, function() { hideFullBg(bgId); });
}
/********************
* 限制文本框字符长度,一个中文占两个长度(该函数一般用于多行文本框)
* src : 触发事件的源元素
* 使用方法如
********************/
function limitLength(src) {
var value = src.value;
var byteLength = parseInt($(src).attr("max"));
var attribute = src.id;
var newvalue = value.replace(/[^\x00-\xff]/g, "**");
var length = newvalue.length;
//当填写的字节数小于设置的字节数
if (length * 1 <= byteLength * 1) {
return;
}
var limitDate = newvalue.substr(0, byteLength);
var count = 0;
var limitvalue = "";
for (var i = 0; i < limitDate.length; i++) {
var flat = limitDate.substr(i, 1);
if (flat == "*") {
count++;
}
}
var size = 0;
var istar = newvalue.substr(byteLength * 1 - 1, 1); //校验点是否为“×”
//if 基点是×; 判断在基点内有×为偶数还是奇数
if (count % 2 == 0) {
//当为偶数时
size = count / 2 + (byteLength * 1 - count);
limitvalue = value.substr(0, size);
} else {
//当为奇数时
size = (count - 1) / 2 + (byteLength * 1 - count);
limitvalue = value.substr(0, size);
}
alert("最大输入" + byteLength + "个字节(相当于" + byteLength / 2 + "个汉字)!");
document.getElementById(attribute).value = limitvalue;
return;
}
/********************
* 根据元素ID获取元素对象(document.getElementById)
* elmId : 元素ID
********************/
function $g(elmId) { return document.getElementById(elmId); };
/********************
* 根据元素名称获取元素对象集(document.getElementsByName)
* nm : 元素name
********************/
function $name(nm) { return document.getElementsByName(nm); };
/********************
* 根据元素标签从指定容器获取元素对象集(document.getElementsByTagName)
* cntr : 容器,可以是元素对象、元素ID
* tagName : 标签名称
********************/
function $tag(cntr, tagName) {
var o = cntr;
if (o != Object){ o = $g(cntr);}
return o.getElementsByTagName(tagName);
}
/********************
* 限制文本框只能输入数字(数字键)
* e : event
********************/
function digiKeyOnly(e) {
var key = window.event ? event.keyCode : e.which;
if (key < 27 || key > 128){
return true;
}else if (key >= 48 && key <= 57){
return true;
}else{
return false;
}
}
/********************
* 限制文本框只能输入数字
* src : 触发事件的源元素
* 使用方法如
********************/
function digiOnly(src) {
src.value = src.value.replace(/[^0-9]/g, '');
}
/********************
* 打开窗口
* url : URL
* w : 窗口宽度(不传递则默认为300px)
* h : 窗口高度(不传递则默认为300px)
* features : 关于窗口的更多属性(可先,不传递该参数或传递null则默认为无工具栏、无菜单栏、可拖放、有滚动条、纵横坐标为0)
********************/
function $o(url, w, h, features) {
if (url == null || url == ""){
return;
}
if (w == null){
w = "300";
}
if (h == null){
h = "300";
}
if (features == null){
features = "location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0;top=0,left=0";
}
if (w){
features += ",width=" + w;
}
if (h){
features += ",height=" + h;
}
window.open(url, "", features, false);
}
/********************
* 清空文本框内容
* cntrId : 容器ID,不传递则以body为容器
********************/
function emptyText(cntrId) {
var jTxts;
if (cntrId == null){
jTxts = $("body").find("input[type=text]");
}else{
jTxts = $j(cntrId).find("input[type=text]");
}
var jTxtss;
if (cntrId == null){
jTxtss = $("body").find("input[type=password]");
}else{
jTxtss = $j(cntrId).find("input[type=password]");
}
jTxts.each(function() {
$(this).attr("value", "");
});
jTxtss.each(function() {
$(this).attr("value", "");
});
if (cntrId == null)
jTxts = $("body").find("textarea");
else
jTxts = $j(cntrId).find("textarea");
jTxts.each(function() {
$(this).attr("value", "");
});
}
/********************
* COOKIE操作
* 重载1 只传递name : 根据键名获取cookie值
* 重载2 传递name, value : 设置cookie,默认过期时间为9986400000
* 重载3 传递name, value, expire : 设置cookie并指定过期时间
* 重载4 传递name, value(bool) : 根据键名删除cookie
* name : cookie 键名 :
* val : cookie值
* expire : cookie过期时间
********************/
$cookie = function(name, val, expire) {
if (val == null && expire == null) {
var search = name + "=";
begin = document.cookie.indexOf(search);
if (begin != -1) {
begin += search.length;
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return document.cookie.substring(begin, end);
}
return null;
} else if (typeof (val) == "boolean") {
$cookie(name, "", -999999);
} else {
if (expire == null){ expire = 9986400000;}
var today = new Date();
var expireDay = new Date();
var msPerMonth = expire;
expireDay.setTime(today.getTime() + msPerMonth);
document.cookie = name + "=" + val + ";expires=" + expireDay.toGMTString();
}
};
/********************
* 查询URL参数(查询失败则返回空字符串)
* paraNm : 参数名
********************/
function $qs(paraNm) {
var args = new Object();
var query = location.search.substring(1);
var pairs = query.split("&");
for (var i = 0; i < pairs.length; ++i) {
var pos = pairs[i].indexOf('=');
if (!pos) continue;
var paraNm2 = pairs[i].substring(0, pos);
var vlu = pairs[i].substring(pos + 1);
vlu = decodeURIComponent(vlu);
args[paraNm2] = vlu;
}
return args[paraNm] == null ? "" : args[paraNm];
}
/********************
* 全选复选框或取消全选(根据触发事件的源对象的选中状态而定)
* src : 触发事件的源对象
* cntrId : 容器ID
********************/
function selectAll(src, cntrId) {
var chks = $tag(cntrId, "input");
for (var i = 0; i < chks.length; ++i) {
chks[i].checked = src.checked;
}
}
/********************
* 反选复选框
* cntrId : 容器ID
********************/
function invertSelect(cntrId) {
var chks = $tag(cntrId, "input");
for (var i = 0; i < chks.length; ++i) {
chks[i].checked = !chks[i].checked;
}
}
function getPageFilename() {
var path = location.pathname;
var pos = path.lastIndexOf('/') + 1;
var filename = path.substring(pos, path.length);
return filename;
}
function getRawUrl() {
var path = location.href;
var pos = path.lastIndexOf('/') + 1;
var filename = path.substring(pos, path.length);
pos = filename.lastIndexOf('#');
filename = filename.substring(0, pos);
return filename;
}
function getIntactRawUrl() {
var path = location.href;
var pos;
pos = path.lastIndexOf('#');
path = path.substring(0, pos);
return path;
}
/********************
* 附加参数到现URl
* name : 参数名
* val : 参数值
********************/
function toggleArg(name, val) {
var url = $$.intactRawUrl();
var pos = url.indexOf('?');
if (pos == -1) {
return url + "?" + name + "=" + val;
} else {
var args = url.substring(pos);
var path = url.substring(0, pos);
var patten = new RegExp("&?" + name + "=?\\w*\\[?\\w*\\]?\\|?\\d?", "i");
args = args.replace(patten, "");
if (args.length == 1) {//没有任何参数,只有?
args += name + "=" + val;
} else {
args += "&" + name + "=" + val;
}
return path + args;
}
};
/********************
* 渐大/小,渐出/入一个元素
* elmId : 元素ID
* visibility : 显现或隐藏
********************/
function increase(elmId, visibility) {
if (visibility == null){
visibility = "show";
}
var jO = $j(elmId);
jO.animate({
height: visibility,
width: visibility,
opacity: visibility
}, "fast");
}
/********************
* 渐出/入一个元素(当元素可见则入,反之则出)
* elmId : 元素ID
* speed : 速度
********************/
function fadeToggle(elmId, speed) {
if (speed == null) {speed = "fast"};
if ($("#" + elmId).is(":visible")){ $("#" + elmId).fadeOut(speed)}
else{ $("#" + elmId).fadeIn(speed)};
}
/********************
* 当元素获得焦点时,高亮显示
* cntrId : 容器ID
* focusClass : 高亮时的样式我
********************/
function clearAllElms(cntrId, focusClass) {
clearDdls(cntrId, focusClass);
clearTextBoxes(cntrId, focusClass);
clearRdos(cntrId, focusClass);
clearChks(cntrId, focusClass);
}
function clearRdos(cntrId, focusClass) {
if (focusClass == null){
focusClass = "tfocus";
}
var txts = $j(cntrId).find("input[type=radio]");
txts.focus(function() { $(this).addClass(focusClass); });
txts.blur(function() { $(this).removeClass(focusClass); });
}
function clearChks(cntrId, focusClass) {
if (focusClass == null){
focusClass = "tfocus";
}
var txts = $j(cntrId).find("input[type=checkbox]");
txts.focus(function() { $(this).addClass(focusClass); });
txts.blur(function() { $(this).removeClass(focusClass); });
}
function clearDdls(cntrId, focusClass) {
if (focusClass == null){
focusClass = "tfocus";
}
var txts = $j(cntrId).find("select");
txts.focus(function() { $(this).addClass(focusClass); });
txts.blur(function() { $(this).removeClass(focusClass); });
}
function clearTextBoxes(cntrId, focusClass) {
if (focusClass == null){
focusClass = "tfocus";
}
var txts = $j(cntrId).find("input[type=text]");
txts.focus(function() { $(this).addClass(focusClass); });
txts.blur(function() { $(this).removeClass(focusClass); });
var txts = $j(cntrId).find("input[type=password]");
txts.focus(function() { $(this).addClass(focusClass); });
txts.blur(function() { $(this).removeClass(focusClass); });
txts = $j(cntrId).find("textarea");
txts.focus(function() { $(this).addClass(focusClass); });
txts.blur(function() { $(this).removeClass(focusClass); });
}
//加入收藏
function addBookmark(_this) {
var _title = document.title;
var url = document.URL;
try {
if (window.sidebar) { // Mozilla Firefox Bookmark
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("firefox") > -1 && window.sidebar.addPanel) {
window.sidebar.addPanel(url, _title);
} else {
_this.setAttribute('title', _title);
return true;
}
} else if (document.all && window.external) { // IE Favorite
window.external.AddFavorite(url, _title);
} else {
alert("浏览器不支持该操作,尝试快捷键 Ctrl + D !");
}
} catch (e) {
alert("浏览器不支持该操作,尝试快捷键 Ctrl + D !");
}
return false;
}
/********************
* 根据值选中下拉列表项
* ddlId : 下拉列表元素ID
* val : 值
********************/
function setSelectByValue(ddlId, val) {
var ddl = $g(ddlId);
for (var i = 0; i < ddl.options.length; ++i) {
var opt = ddl.options[i];
opt.selected = (opt.value == val);
}
}
/********************
* 显示验证码
********************/
function showVerifyCodes(elmId, imgId) {
if (elmId == null) {
elmId = "spVerCode";
}
if (imgId == null) {
imgId = "imgVerCode";
}
var jImg = $j(elmId);
if (jImg.html() == "") {
jImg.html("");
}
var jVerCode = $j(imgId);
jVerCode.load(function () {
jVerCode.show();
});
}
function changeVerCodes(elmId, imgId) {
if (elmId == null) {
elmId = "spVerCode";
}
if (imgId == null) {
imgId = "imgVerCode";
}
var jElm = $j(elmId);
var jImg = $j(imgId);
if (jElm.html() == "") {
jElm.html("");
jImg = $j(imgId);
} else {
jImg.attr("src", "/Tools/ValidCodes.aspx?t=" + Math.random());
jImg.hide();
}
jImg.load(function () {
jImg.show();
});
}
function showVerifyCode(elmId, msgElmId, imgId, chgLnkId, fontsize, bc, fc) {
if (elmId == null) {
elmId = "spVerCode";
}
if (msgElmId == null) {
msgElmId = "spVerCodeMsg";
}
if (imgId == null) {
imgId = "imgVerCode";
}
if (chgLnkId == null) {
chgLnkId = "spChgVerCode";
}
if (fontsize == null) {
fontsize = 20;
}
if (bc == null) {
bc = "ffffff";
}
if (fc == null) {
fc = "000000";
}
var jImg = $j(elmId);
var jMsg = $j(msgElmId);
var jChgLnk = $j(chgLnkId);
if (jImg.html() == "") {
jMsg.html("正在加载验证码...");
jMsg.show();
jImg.html("");
}
var jVerCode = $j(imgId);
jVerCode.load(function () {
jMsg.hide();
jVerCode.show();
//jChgLnk.show();
});
}
/********************
* 更换验证码
********************/
function changeVerCode(elmId, imgId, msgElmId, fontsize, bc, fc) {
if (elmId == null) {
elmId = "spVerCode";
}
if (imgId == null) {
imgId = "imgVerCode";
}
if (msgElmId == null) {
msgElmId = "spVerCodeMsg";
}
if (fontsize == null) {
fontsize = 20;
}
if (bc == null) {
bc = "ffffff";
}
if (fc == null) {
fc = "000000";
}
var jElm = $j(elmId);
var jMsg = $j(msgElmId);
var jImg = $j(imgId);
if (jElm.html() == "") {
jMsg.html("正在加载验证码...");
jMsg.show();
jElm.html("");
jImg = $j(imgId);
} else {
jMsg.html("正在刷新验证码...").show();
jImg.attr({ src: "/Tools/ValidCode.aspx?f=" + fontsize + "&bc=" + bc + "&fc=" + fc + "&x=" + Math.random(), alt: "验证码" });
jImg.hide();
}
jImg.load(function () {
jMsg.hide();
jImg.show();
});
}
/********************
* 显示正在处理的图标
* src : 触发事件的源对象
* show : 显示/隐藏
********************/
function showProc(src, show) {
var oImg = $j("imgProc");
if (show == null){
show = true;
}
if (show) {
$(src).hide();
if (oImg.length > 0){
oImg.remove();
}
$("").insertAfter(src);
} else {
$(src).show();
oImg.remove();
}
}
/********************
* 放大字体
* el : 放大/缩小
********************/
function enlarge(el, elmId) {
if (el == null){
el = true;
}
if (elmId == null) {
elmId = "Content";
}
var o = $j(elmId);
var fontSize = parseInt(o.css("font-size"));
var newFontSize = (el ? fontSize * 1.2 : fontSize / 1.2);
o.css("font-size", newFontSize + "px");
}
/********************
* 奇偶行变色
* el : 放大/缩小
* escapeRows : 忽略最首行数
* tabName : 表ID
* odd : 奇行的样式或样式类名
* even : 偶行的样式或样式类名
********************/
function altRow(escapeRows, tabName, odd, even) {
var rows = $tag(tabName, "tr");
for (var i = escapeRows; i < rows.length; ++i) {
var argSty;
if (i % 2 == 0) argSty = even;
else argSty = odd;
if (typeof (argSty) == "object") {
for (var sty in argSty) {
rows[i].style[sty] = argSty[sty];
}
} else {
rows[i].className = argSty;
}
}
}
/********************
* 获取容器里已选中复选/单选按钮的值
* cntrId : 容器ID
* escapeRows : 忽略最首行数
********************/
function getCheckedVal(cntrId, escapeRows) {
if (escapeRows == null) {
escapeRows = -1;
}
var chks = $j(cntrId).find("input:checked");
var rtnVal = "";
var flag = false;
chks.each(function(i) {
if (i > escapeRows) {
if (flag) {
rtnVal += ",";
}
rtnVal += $(this).val();
flag = true;
}
});
return rtnVal;
}
function checkAll(src, cntrId) {
var chks = $j(cntrId).find("input[type=checkbox]");
chks.each(function(i) {
this.checked = src.checked;
});
}
//根据字段列表获取查询页面路径字符串
//FieldList格式:控件ID名称,查询字段名称|控件ID名称1,查询字段名称1|..
function GetSearchURL(FieldList, URL) {
//1\定义变量
if (URL == null) {
URL = getIntactRawUrl();
}
//2\循环把变量列表取出来,组合成URL
var TempFieldList = FieldList.split("|");
for (var i = 0; i < TempFieldList.length; i++) {
//1>寻找控件
var control1 = TempFieldList[i].split(",");
var controlname;
var control = document.getElementById(control1[0]);
if (control1.length == 2) { controlname = control1[1]; } else { controlname = control1[0]; }
if (control != null) {
//2>取出控件的值
var controlvalue = control.value;
//3>设置URL
if (controlvalue != null) {
URL += "&" + controlname + "=" + encodeURIComponent(controlvalue);
}
}
}
return URL;
}
function SearchObjectByGet(FieldList, url, getUrlOnly) {
if (getUrlOnly == null) {
getUrlOnly = false;
}
var newUrl = GetSearchURL(FieldList, url);
if (getUrlOnly) {
return newUrl;
}
window.location.href="ofxVsm;"
}
//跳转到某页
//参数:参训参数
// 参数值
function GoToURL(FieldName, FieldValue) {
var URL;
URL = SetURLField(URL, FieldName, FieldValue);
location.href="VSM;"
}
//跳转到某页
//参数:参训参数
// 参数值
function GoToURLByGet(FieldName, FieldValue) {
//1\定义变量
var URL;
URL = location.href;
//2\获取地址参数
URL = SetURLField(URL, "page", "1");
URL = SetURLField(URL, FieldName, FieldValue);
//3\递交数据
}
//设置地址栏的参数
function SetURLField(URL, FieldName, FieldValue) {
//1\把当前的超链接地址取出来
var FindPlace;
//2\如果?号后面没有字符串,则在?后面添加查询的字段
FindPlace = URL.indexOf("?");
if (FindPlace == -1) {
URL += "?" + FieldName + "=" + FieldValue;
}
else {
//3\如果?后面有查询字符串,则检测有没有该字段,如果有,则重新付值
var search = FieldName + "=";
var offset = URL.indexOf(search);
if (offset != -1) {
offset += search.length;
end = URL.indexOf("&", offset);
if (end == -1) {
URL = URL.substring(0, offset) + FieldValue;
}
else {
URL = URL.substring(0, offset) + FieldValue + URL.substring(end);
}
}
else {
URL = URL + "&" + FieldName + "=" + FieldValue;
}
}
return URL;
}
//读取地址栏的参数值
//参数:参数名称
function readURLParameter(FieldName) {
var search = FieldName + "=";
var FieldValue = "";
var URL = location.href;
var offset = URL.indexOf(search);
if (offset != -1) {
offset += search.length;
end = URL.indexOf("&", offset);
if (end == -1) {
FieldValue = URL.substring(offset);
}
else {
FieldValue = URL.substring(offset, end);
}
}
return FieldValue;
}
/********************
* 当一个文本框第一次获得焦点时清空自己的文本,该文本框默认有一个属性和事件:hadfocused="0" onfocus="focusToRemoveText(this)"
* src : 触发事件的源元素
********************/
function focusToRemoveText(src) {
var jSrc = $(src);
var hadFocused = (jSrc.attr("hadfocused") == "1");
if (!hadFocused) {
jSrc.val("");
jSrc.attr("hadfocused", "1");
}
}
//输出动态表单
//surObj : 投票对象
function SUR_ShowTable(surObj) {
var sHtml = "";
//投票模式(单选/复选)
var inputType;
switch (surObj.SelectionMode) {
case 1: inputType = "radio"; break;
case 2: inputType = "checkbox"; break;
}
//输出内容
switch (surObj.ShowMode) {
case 1:
sHtml = ""
+ "
" + surObj.Title + "
"
+ "
";
for (var i = 0; i < surObj.Items.length; ++i) {
var obj = surObj.Items[i];
var inputId = "SUR_item_" + surObj.SubjectId + i;
sHtml += "
"
+ "
"
+ "
"
+ "
";
} // end for
sHtml += "
"
+ "
"
+ ""
+ ""
+ "
"
+ "
";
break;
} // end switch
document.write(sHtml);
}
//提交投票
//参数:src : 触发方法的源对象
//surObj : 投票对象
function SUR_senddata(src, subObj) {
var msgElmId = "SUR_post_msg_" + subObj.SubjectId;
var s = "正在提交,请稍后...";
var url = "/ajax.ashx?action=Survey&t=" + Math.random();
var checkedVla = getCheckedVal("SUR_itemTab_" + subObj.SubjectId);
if (checkedVla == null || checkedVla.length == 0) {
$a("您至少需要选中一个投票项。");
return;
}
$(src).after(s).hide();
$.post(url, {
_SUR_SubjectID: subObj.SubjectId,
_CheckedItems: checkedVla
}, function(rsp) {
var sta = gav(rsp, "state");
var sMsg = gav(rsp, "msg");
if (sta == "1") {
$confirm("投票成功,感谢您的参与。", { title: "确定", toDo: function() { hideConfirm(); } }, { title: "查看结果", toDo: function() { window.open("/tools/survey.aspx?oid=" + subObj.SubjectId); hideConfirm(); } });
} else {
$a(sMsg);
}
$j(msgElmId).remove();
$(src).show();
});
}
//输出留言表单
//surObj : 对象ID
function LEW_ShowTable() {
var sHtml = ""
+ "
留言
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
| "
+ "
"
+ " "
+ "
"
+ "
"
+ "
"
+ "
";
document.write(sHtml);
fillLeavewordCategories();
// //输出内容
// switch (surObj.ShowMode) {
// case 1:
// sHtml = "";
// break;
// } // end switch
}
////获取留言HTML
//function LEW_GetFields(fieldStr) {
// var template = ""
// + "
{$item_name$}:
"
// + "
"
// + "
";
// var rtnVal = "";
// var fieldsCrumb = fieldStr.split("||");
// for (var i = 0; i < fieldsCrumb.length; ++i) {
// var itemNameCrumb = fieldsCrumb[i].spalit("$$");
// var itemName;
// var itemReName;
// if (itemNameCrumb.length == 2) {
// itemName = itemNameCrumb[0];
// itemReName = itemNameCrumb[1];
// } else {
// itemName = itemNameCrumb[0];
// itemReName = itemNameCrumb[0];
// } // end if
// if (itemName != "留言内容" && itemName != "留言分类") {
// rtnVal += ""
// + "
" + itemReName + ":
"
// + "
"
// + "
";
// } else if (itemName == "留言内容") {
// rtnVal += ""
// + "
" + itemReName + ":
"
// + "
"
// + "
";
// } else if (itemName == "留言分类") {
// rtnVal += ""
// + "
" + itemReName + ":
"
// + "
"
// + "
";
// } // end if
// } // end for
//}
////根据留言字段名称获取元素ID
//function LEW_GetFieldId(itemName) {
// var rtnVal = "";
// var prefix = "LEAVEWORD_";
// switch (itemName) {
// case "标题": rtnVal = prefix + "txtTitle"; break;
// case "联系人": rtnVal = prefix + "txtContact"; break;
// case "联系电话": rtnVal = prefix + "txtTel"; break;
// case "手机号码": rtnVal = prefix + "txtMobile"; break;
// case "电子邮箱地址": rtnVal = prefix + "txtEmail"; break;
// case "留言分类": rtnVal = prefix + "ddlCats"; break;
// case "留言内容": rtnVal = prefix + "txtShortDesc"; break;
// }
// return rtnVal;
//}
//输出留言表单
//surObj : 对象ID
function PAY_ShowTable() {
var sHtml = ""
+ "
付款
"
+ "
"
+ "
"
+ "
"
+ "
* 付款方式: | "
+ "
"
+ "
"
+ "
"
+ "
* 付款人: | "
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
"
+ "
| "
+ "
"
+ " "
+ "
"
+ "
"
+ "
"
+ "
";
document.write(sHtml);
}
//用户登陆
function LoginCheck(_username, _password) {
var url = window.location;
if (_username == undefined || _username.length == 0) {
$a("请输入用户名", "错误提示", "txtUsername");
return;
}
if (_password == undefined || _password.length == 0) {
$a("请输入密码", "错误提示", "txtPassword");
return;
}
$.post("/ajax.ashx?action=logincheck&t=" + Math.random(), {
username: _username,
password: _password
},
function(msg) {
if (gav(msg, "state") == "1") {
$a(gav(msg, "msg"));
window.location.href="vsm;"
}
else {
$a(gav(msg, "msg"));
}
;
});
}
//获取URL参数
function getUrlParms() {
var args = new Object();
var query = location.search.substring(1); //获取查询串
var pairs = query.split("&"); //在逗号处断开
for (var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('='); //查找name=value
if (pos == -1) continue; //如果没有找到就跳过
var argname = pairs[i].substring(0, pos); //提取name
var value = pairs[i].substring(pos + 1); //提取value
args[argname] = unescape(value); //存为属性
}
return args;
}