/// /*--------------------------------------------------------------- * 网站基础脚本,所以页面均需要引用。 ---------------------------------------------------------------*/ var webSiteRootPath = ""; //网站根目录值。 var _____pagesize12698 = null; //页面尺寸信息。 var divWarning_default = null; var popupSourceElementID = null; //弹出div的对象的源对象ID。 var popupElements = new Array(); //弹出div的ID。 var panelZIndex = 500; //显示提示信息-----------------------------------------------// //在页面载入时,创建一个div。 $(document).ready(function() { //初始化页面布局。 initPageLayout(); }); //获取或创建默认的divWarning div。 function getdivWarning_default() { if (null == divWarning_default) { $("body").append("
"); divWarning_default = $("#divWarning_default"); } return divWarning_default; } //显示警告、提示信息。 //olID:信赖于显示位置的控件ID。 //msg:显示的消息(html)。 //extraX:增加额外的x轴(left)坐标。 //extraY:增加额外的Y轴(top)坐标。 function showWarning(olID, msg, extraX, extraY) { var divWarning = getdivWarning_default(); if (null != msg) divWarning.html(createMessage(msg)); showPanel(olID, divWarning[0].id, 350, null, extraX, extraY); } //显示内容。 //olID:信赖于显示位置的控件ID。 //msg:显示的消息(html)。 //extraX:增加额外的x轴(left)坐标。 //extraY:增加额外的Y轴(top)坐标。 function showContent(olID, msg, extraX, extraY) { var divWarning = getdivWarning_default(); divWarning.attr("class", "pop2_outer"); if (null != msg) divWarning.html(createMessage2(msg)); showPanel(olID, divWarning[0].id, 300, null, extraX, extraY); } //显示临时内容。 //olID:依赖于显示位置的控件ID。 //msg:显示的消息(html)。 //extraX:增加额外的x轴(left)坐标。 //extraY:增加额外的Y轴(top)坐标。 function showTempContent(olID, msg, extraX, extraY) { var id = "divTempWarningPanel_" + olID; if (null == $2(id)) $("body").append("
"); var tempPanel = $("#" + id); if (null != msg) tempPanel.html(createMessage(msg, id, "red")); showPanel(olID, tempPanel[0].id, 350, null, extraX, extraY, true); return id; } //隐藏警告、提示信息。 function hideWarning() { hidePanel("divWarning_default"); } //显示某一提示消息对象。 //olID 作为参照的对象ID。 //panelID div面板ID。 //width div面板宽。 //height div面板高。 //extraX:增加额外的x轴(left)坐标。 //extraY:增加额外的Y轴(top)坐标。 function showPanel(olID, panelID, width, height, extraX, extraY, alwaysDisplay) { //设置源对象。 popupSourceElementID = olID; if (null == alwaysDisplay || !alwaysDisplay) { //添加弹出的div编号。 var added = false; $.each(popupElements, function(i, item) { if (item == panelID) { added = true; return; } }); if (!added) popupElements.push(panelID); } //如果存在临时面板则close。 hidePanel("divTempWarningPanel_" + olID); //隐藏所有的弹出对象。 for (var i = 0; i < popupElements.length; i++) hidePanel(popupElements[i]); if (undefined == width || null == width) width = 250; if (undefined == height || null == height) height = 0; if (undefined == extraX || null == extraX) extraX = 0; if (undefined == extraY || null == extraY) extraY = 0; //获取指定对象的坐标。 var ol = $("#" + olID); var divWarning = null; var divWarning = $("#" + panelID); divWarning.css("width", width + "px"); if (height > 0) divWarning.css("height", height + "px"); _____pagesize12698 = ___getPageSize(); var offset = ol.offset(); var locationX = offset.left + ol[0].offsetWidth + extraX; var locationY = offset.top + extraY; panelZIndex += 1; divWarning.css("z-index", panelZIndex); divWarning.show(); divWarning.animate({ left: locationX, top: locationY }, "fast", null, function() { var top = eval(this.style.top.replace("px", "")); var xh = top + this.offsetHeight - _____pagesize12698[1]; if (xh > 0) top = top - xh - 5; var left = eval(this.style.left.replace("px", "")); var xw = left + this.offsetWidth - _____pagesize12698[0]; if (xw > 0) { left = left - xw - 5; top += document.getElementById(popupSourceElementID).offsetHeight; } if (xh > 0 || xw > 0) { $("#" + this.id).animate({ left: left, top: top }, "fast"); } }); } //隐藏警告信息。 function hidePanel(panelID) { if (null != panelID) { var p = $2(panelID); if (null != p) p.style.display = "none"; } } //隐藏所有弹出信息面板。 function hideAllPopupPanel() { $("div[class='Pop_Outer']").css("display", "none"); $("div[class='pop2_outer']").css("display", "none"); } //生成格式化后的消息(警告或信息)。 //msg 消息内容 //panelID 显示消息的div编号 function createMessage(msg, panelID, color) { var msgs = msg.split(";"); if (null != color) color = "color:" + color; var closeText = ""; if (null != panelID) closeText = "
 
"; var formatMsgs = "
" + closeText + "
"; for (var i = 0; i < msgs.length; i++) { if ($.trim(msgs[i]).length > 0) formatMsgs += "
" + msgs[i] + "
"; } formatMsgs += "
"; return formatMsgs; } //生成格式化后的消息(警告或信息)。 function createMessage2(msg) { var formatMsgs = "
"; formatMsgs += "
"; formatMsgs += "
"; formatMsgs += "
"; formatMsgs += msg; formatMsgs += "
"; formatMsgs += ""; return formatMsgs; } //注册TextBox。 //olID 文本框编号。 //warningMessage 当触焦时显示的警告信息。 //rfvID 服务于当前文本框的必填验证对象编号 //revIDs 服务于当前文本框的正则式验证对象编号集(以@@@分隔) //cvID 比较验证控件的编号 function regMyTextBox(olID, warningMessage, rfvID, revIDs, cvID) { $().ready(function() { var ol = $("#" + olID); if (null == warningMessage || $.trim(warningMessage).length == 0) warningMessage = null; if (null == warningMessage) { ol.attr("class", "TextBox"); ol.attr("originalClass", "TextBox"); } else { ol.attr("class", "TextBoxWaring"); ol.attr("originalClass", "TextBoxWaring"); } ol.bind("focus", function() { this.className = "TextBoxFocused"; if (null != warningMessage) showWarning(olID, warningMessage); //如果存在myTextBoxFocus这个函数,则调用。 if (window.myTextBoxFocus) myTextBoxFocus(ol[0]); }); ol.bind("blur", function() { this.className = this.getAttribute("originalClass"); hideWarning(); //如果验证成功。 if (regexValidateInput(olID, rfvID, revIDs, cvID)) { //如果存在myTextBoxBlur这个函数,则调用。 if (window.myTextBoxBlur) myTextBoxBlur(ol[0]); } }); }); } //olID 当前处于焦点状态的文本框编号。 //rfvID 服务于当前文本框的必填验证对象编号 //revIDs 服务于当前文本框的正则式验证对象编号集(以@@@分隔) //cvID 比较验证控件的编号 function regexValidateInput(olID, rfvID, revIDs, cvID) { //获取当前处于焦点的文本框。 var ol = $2(olID); //必填项判断。 if (null != rfvID && $.trim(rfvID).length > 0 && $.trim(ol.value).length == 0) { var rfv = eval(rfvID); if (null != rfv) { ol.className = "TextBoxError"; showTempContent(olID, rfv.errormessage); } return false; } if ($.trim(ol.value).length > 0) { //验证正则式。 var arr = revIDs.split("@@@"); for (var i = 0; i < arr.length; i++) { if ($.trim(arr[i]).length == 0) continue; var rev = eval(arr[i]); if (null == rev) continue; var r = new RegExp(rev.validationexpression); if (!r.test(ol.value)) { ol.className = "TextBoxError"; showTempContent(olID, rev.errormessage); return false; } } //比较验证。 if (null != cvID && $.trim(cvID).length > 0) { var cv = eval(cvID); if (null != cv) { if (ol.value != $2(cv.controltocompare).value) { ol.className = "TextBoxError"; showTempContent(olID, cv.errormessage); return false; } } } } //隐藏面板。 ol.className = ol.getAttribute("originalClass"); hidePanel("divTempWarningPanel_" + olID); return true; } //在一个IFRAME中打开某个网址。 function openNavigateUrl(frameID, url) { var n = false; try { var ev = window.event; if (ev.shiftKey) n = true; } catch (err) { } if (n) window.open(url, "newWindow"); else $("#" + frameID).attr("src", url); } //模拟生成GUID号。 function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++) { var n = Math.floor(Math.random() * 16.0).toString(16); guid += n; if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) guid += "-"; } return guid; } //设置某对象高度匹配页面高度。 function autoHeight_tabMain(oElementID) { var h = $(window).height(); $("#" + oElementID).css({ height: h + "px" }); } //获取某一对象的坐标。 function getElementLocation(oElementID) { var obj = new Object(); var ol = $("#" + oElementID); var offset = ol.offset(); obj.X = offset.left; obj.Y = offset.top; return obj; } //获取页面大小。 function ___getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if (document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if (yScroll < windowHeight) { pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if (xScroll < windowWidth) { pageWidth = xScroll; } else { pageWidth = windowWidth; } arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight); return arrayPageSize; } //初始化页面布局。 function initPageLayout() { var divFooter_mainOuter455122 = $("#divFooter_mainOuter455122"); if (null != divFooter_mainOuter455122[0]) { if (null == _____pagesize12698) _____pagesize12698 = ___getPageSize(); var h1 = divFooter_mainOuter455122.offset().top + divFooter_mainOuter455122[0].offsetHeight; //alert(_____pagesize12698[1] + "\n" + _____pagesize12698[3] + "\n" + h1); var h2 = _____pagesize12698[3] - h1; if (h2 > 0) document.getElementById("divFooter_holder12659855225").style.height = h2 + "px"; } } //当在LightBox中登陆成功后需要执行的方法。 function onLightBox_loginSuccess() { $.fn.lightbox_HXW.closeLightBox(); showModal("温馨提示:您已经登陆成功,请继续完成相关操作。", "登陆成功"); } //按回车键触发相关操作。 function inputKeydown(e, fun) { var ev = window.event || e; if (ev.keyCode == 13) { fun(); return false; } return true; } //转到特定的页面。 function go(url) { window.location.href = url; } //重新设置图片大小。 function resizeImage(imgID, maxWidth, maxHeight) { var imageArr = document.getElementById(imgID); if (null == imageArr) return; var imageRate = imageArr.offsetWidth / imageArr.offsetHeight; if (imageArr.offsetWidth > maxWidth) { imageArr.style.width = maxWidth + "px"; imageArr.style.Height = maxWidth / imageRate + "px"; } if (imageArr.offsetHeight > maxHeight) { imageArr.style.width = maxHeight * imageRate + "px"; imageArr.style.Height = maxHeight + "px"; } } //页面跳转到某个锚点。 function ToAnchor(anchorName) { window.location.href = '#' + anchorName; } //对字符串进行和asp.net Server.UrlEncode相同方式的编码。 function EncodeURI(unzipStr, isCusEncode) { if (isCusEncode) { var zipArray = new Array(); var zipstr = ""; var lens = new Array(); for (var i = 0; i < unzipStr.length; i++) { var ac = unzipStr.charCodeAt(i); zipstr += ac; lens = lens.concat(ac.toString().length); } zipArray = zipArray.concat(zipstr); zipArray = zipArray.concat(lens.join("O")); return zipArray.join("N"); } else { //return encodeURI(unzipStr); var zipstr = ""; var strSpecial = "!\"#$%&'()*+,/:;<=>?[]^`{|}~%"; var tt = ""; for (var i = 0; i < unzipStr.length; i++) { var chr = unzipStr.charAt(i); var c = StringToAscii(chr); tt += chr + ":" + c + "n"; if (parseInt("0x" + c) > 0x7f) { zipstr += encodeURI(unzipStr.substr(i, 1)); } else { if (chr == " ") zipstr += "+"; else if (strSpecial.indexOf(chr) != -1) zipstr += "%" + c.toString(16); else zipstr += chr; } } return zipstr; } } //对字符串进行和asp.net Server.UrlDecode相同方式的解码。 function DecodeURI(zipStr, isCusEncode) { if (isCusEncode) { var zipArray = zipStr.split("N"); var zipSrcStr = zipArray[0]; var zipLens; if (zipArray[1]) { zipLens = zipArray[1].split("O"); } else { zipLens.length = 0; } var uzipStr = ""; for (var j = 0; j < zipLens.length; j++) { var charLen = parseInt(zipLens[j]); uzipStr += String.fromCharCode(zipSrcStr.substr(0, charLen)); zipSrcStr = zipSrcStr.slice(charLen, zipSrcStr.length); } return uzipStr; } else { //return decodeURI(zipStr); var uzipStr = ""; for (var i = 0; i < zipStr.length; i++) { var chr = zipStr.charAt(i); if (chr == "+") { uzipStr += " "; } else if (chr == "%") { var asc = zipStr.substring(i + 1, i + 3); if (parseInt("0x" + asc) > 0x7f) { uzipStr += decodeURI("%" + asc.toString() + zipStr.substring(i + 3, i + 9).toString()); ; i += 8; } else { uzipStr += AsciiToString(parseInt("0x" + asc)); i += 2; } } else { uzipStr += chr; } } return uzipStr; } } function StringToAscii(str) { return str.charCodeAt(0).toString(16); } function AsciiToString(asccode) { return String.fromCharCode(asccode); } function getStringLength(str) { var sum = 0; for (var i = 0; i < str.length; i++) { if ((str.charCodeAt(i) >= 0) && (str.charCodeAt(i) <= 255)) sum += 1; else sum += 2; } return sum; } /* --------- 分页 -----------------------------------------------*/ function MyPager_Go(prefixTag, maxPageIndex, urlFormat) { var patrn = /^[1-9]\d*$/; var v = document.getElementById(prefixTag + "_txtPager").value; if (v.length == 0) { return; } if (!patrn.exec(v)) { alert("对不起,请输入正确的数字。"); return; } if (v > maxPageIndex || v < 1) { alert("对不起,页码必须介于1 ~ " + maxPageIndex + "之间。"); return; } window.location.href = urlFormat.replace("{0}", v); } function invokeClick(element) { if (element.click) element.click(); else if (element.fireEvent) element.fireEvent('onclick'); else if (document.createEvent) { var evt = document.createEvent("MouseEvents"); evt.initEvent("click", true, true); element.dispatchEvent(evt); } }