//表格行高亮显示
function changebg(i, s) {
	if (s == "over") {
		i.style.backgroundColor = "#FFF7D1";
	} else {
		i.style.backgroundColor = "#FFFFFF";
	}
}
//表格行高亮显示+鼠标手形显示
function changeBgAndPointer(i, s) {
	if (s == "over") {
		i.style.backgroundColor = "#FFF7D1";i.style.cursor="pointer";
	} else {
		i.style.backgroundColor = "#FFFFFF";
	}
}


function formToRequestString(form_obj) {
	var query_string = "<table><row";
	for (i = 0; i < form_obj.length; i++) {
		e = form_obj[i];
		if (e.name != "") {
			if (e.type == "select-one") {
				element_value = e.options[e.selectedIndex].value;
			} else if (e.type == "checkbox" || e.type == "radio") {
				element_value = e.value;
			} else {
				element_value = e.value;
			}
			// 单引号转义时，用双引号符号
			element_value = element_value.replace(/\&/g, "&amp;").replace(
					/\</g, "&lt;").replace(/\>/g, "&gt;").replace(/\'/g,
					"&quot;");
			query_string += " " + e.name + "='" + element_value + "'";

		}

	}
	query_string += "/></table>";
	return query_string;
}

function encodeValue(str) {
	return str.replace(/\&/g, "&amp;").replace(/\</g, "&lt;").replace(/\>/g,
			"&gt;").replace(/\'/g, "&quot;");
}

function add(url) {
	window.location.href = url;
}

function goAction(url) {
	window.location.href = url;
}

window.alert = function(str) {
	if(top == null)
		top = self;
	str = str.replace(/\n/g, "<br/>");  // 文本内容换行
	var msgw, msgh, bordercolor;
	msgw = 400;// 提示窗口的宽度
	msgh = 110;// 提示窗口的高度
	titleheight = 25 // 提示窗口标题高度
	bordercolor = "#03A4F1";// 提示窗口的边框颜色
	titlecolor = "#99CCFF";// 提示窗口的标题颜色

	var sWidth, sHeight;
	sWidth = top.document.body.offsetWidth;
	sHeight = screen.height;

//	setSelectState('hidden');
	// 背景变黑色
	var bgObj = top.document.createElement("div");
	bgObj.setAttribute('id', 'bgDiv');
	bgObj.style.position = "absolute";
	bgObj.style.top = "0";
	bgObj.style.background = "#777";
	bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	bgObj.style.opacity = "0.6";
	bgObj.style.left = "0";
	bgObj.style.width = sWidth + "px";
	bgObj.style.height = "600px";
	bgObj.style.zIndex = "10000";
	// 屏蔽优先级比iframe低的tag, 如:select
	iframeHtml = "<iframe src=\"javascript:false\" style=\"position:absolute; visibility:inherit;top:0px; left:0px; width:100%; height:200%; z-index:-1; filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';\"></iframe>";
	bgObj.innerHTML = iframeHtml;
	top.document.body.appendChild(bgObj);

	// msgObj:消息框, desc:系统提示, txt:显示文本, check:确定按钮
	var msgObj = top.document.createElement("div")
	msgObj.setAttribute("id", "msgDiv");
	msgObj.setAttribute("align", "center");
	msgObj.style.background = "white";
	msgObj.style.border = "1px solid " + bordercolor;
	msgObj.style.position = "absolute";
	msgObj.style.left = "53%";
	msgObj.style.top = "50%";
	msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
	msgObj.style.marginLeft = "-225px";
	msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
	msgObj.style.width = msgw + "px";
	msgObj.style.height = msgh + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight = "25px";
	msgObj.style.zIndex = "10001";
	top.document.body.appendChild(msgObj);
	
	
	var desc = top.document.createElement("div");
	desc.innerHTML = "<table class='alertmsg'><tr><td align='left'><font color:#FFF;>[系统提示:]</font></td><td align='right'><input type='image' width='16' height='16' border='0' align='absmiddle' title='关闭' src=\"images/alertclose.GIF\" onclick='closeMsg();'></td></tr></table>";
	
	var check = top.document.createElement("div");
	check.innerHTML = "<table width='100%' border='0'><tr><td align='center'><input id='closeMsg' class='menu2' type='button' value='关  闭' onclick='closeMsg();'/></td></tr></table>";
	
	top.document.getElementById("msgDiv").appendChild(desc);
	var txt = top.document.createElement("p");
	txt.style.margin = "1em 0"
	txt.setAttribute("id", "msgTxt");
	txt.innerHTML = str;
	top.document.getElementById("msgDiv").appendChild(txt);
	top.document.getElementById("msgDiv").appendChild(check);
	top.document.getElementById("closeMsg").focus();
}

function closeMsg(){
//	setSelectState('');
	var bgObj = document.getElementById("bgdiv");
	var msgObj = document.getElementById("msgDiv");
	top.document.body.removeChild(bgObj);
//	document.getElementById("msgDiv").removeChild(title);
	top.document.body.removeChild(msgObj);
}

// 设置select的状态(是否可见)
function setSelectState(state) {
	var objl = document.getElementsByTagName('select');
	for ( var i = 0; i < objl.length; i++) {
		objl[i].style.visibility = state;
	}
}

String.prototype.getByteLength = function ()
{
  return this.replace(/[^\x00-\xff]/g,"00").length;
}

