String.prototype.Trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function() {
	return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function() {
	return this.replace(/(\s*$)/g, "");
}

// 联系方式
function isLinker(str) {
	var patrn = /^0?1([0-9]{10})$/;
	var patrn1 = /^(([0\+]\d{2,3}-?)?(0\d{2,3})-?)?(\d{7,8})(-(\d{3,}))?$/;
	return patrn.test(str) || patrn1.test(str);
}

// email
function isEmail(v) {
	var patrn = /^([a-zA-Z0-9]+[_\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	return patrn.test(v);
}

// 中文
function isChinese(eleValue) {
	var patrn = /^([\u4E00-\u9FA5\uF900-\uFA2D]|[a-zA-Z])+$/;
	for (var i = 0; i < eleValue.length; i++) {
		code = eleValue.charCodeAt(i);// 获取当前字符的unicode编码
		if (code >= 65281 && code <= 65373) {
			return false;
		}
		if (parseInt(code) == 65374 || parseInt(code) == 65509
				|| parseInt(code) == 8230 || parseInt(code) == 8212) {
			return false;
		}
		if (parseInt(code) == 8220 || parseInt(code) == 8221) {
			return false;
		}
	}
	return patrn.test(eleValue.replace(/(^[\s\u3000]*)|([\s\u3000]*$)/g, ""));
}
//邮政
function isZipCode(eleValue){   
	var patrn = /^\d{6}$/;   
	return patrn.test(eleValue);   
    }
function tijiao() {
	var name = document.getElementById("name").value;
	var phone = document.getElementById("phone").value;
	var address = document.getElementById("address").value;
	var email = document.getElementById("email").value;
	var content = document.getElementById("content").value;
	var subject = document.getElementById("subject").value;
	if (name.Trim() == "" || name == null) {
		alert("请输入您的姓名！");
		document.getElementById("name").focus();
		return false;
	} else if (name.Trim().length > 0 && !isChinese(name)) {
		alert("姓名请输入中文或英文！");
		document.getElementById("name").focus();
		return false;
	} else if (phone.Trim() == "" || phone == null) {
		alert("请输入您的联系电话！");
		document.getElementById("phone").focus();
		return false;
	} else if (phone.Trim().length > 0 && !isLinker(phone)) {
		alert("请输入正确的联系电话！");
		document.getElementById("phone").focus();
		return false;
	} else if (email.Trim() == "" || email == null) {
		alert("请输入您的Email！");
		document.getElementById("email").focus();
		return false;
	} else if ((email.Trim() != "" && email != null) && !isEmail(email)) {
		alert("请输入正确的Email地址！");
		document.getElementById("email").focus();
		return false;
	} else if (address.Trim() == "" || address == null) {
		alert("请输入联系地址！");
		document.getElementById("address").focus();
		return false;
	} else if (subject.Trim() == "" || subject == null) {
		alert("请输入邮件的主题！");
		document.getElementById("subject").focus();
		return false;
	} else if (content.Trim() == "" || content == null) {
		alert("请输入邮件的内容！");
		document.getElementById("content").focus();
		return false;
	} else if(content.Trim().length>3000){
	   	alert("您输入邮件的内容超过3000个字符，请重新输入！");
		document.getElementById("content").focus();
		return false;
	}else {
		document.forms['mailForm'].submit();
	}
}
function consultup() {
	var name = document.getElementById("name").value;
	var phone = document.getElementById("phone").value;
	var address = document.getElementById("address").value;
	var email = document.getElementById("email").value;
	var content = document.getElementById("content").value;
	var unitname = document.getElementById("unitname").value;
	var address = document.getElementById("address").value;
	var postalcode = document.getElementById("postalcode").value;
	if (name.Trim() == "" || name == null) {
		alert("请输入您的姓名！");
		document.getElementById("name").focus();
		return false;
	} else if (name.Trim().length > 0 && !isChinese(name)) {
		alert("姓名请输入中文或英文！");
		document.getElementById("name").focus();
		return false;
	} else if (phone.Trim() == "" || phone == null) {
		alert("请输入您的联系电话！");
		document.getElementById("phone").focus();
		return false;
	} else if (phone.Trim().length > 0 && !isLinker(phone)) {
		alert("请输入正确的联系电话！");
		document.getElementById("phone").focus();
		return false;
	} else if (email.Trim() == "" || email == null) {
		alert("请输入您的Email！");
		document.getElementById("email").focus();
		return false;
	} else if ((email.Trim() != "" && email != null) && !isEmail(email)) {
		alert("请输入正确的Email地址！");
		document.getElementById("email").focus();
		return false;
	} else if (address.Trim() == "" || address == null) {
		alert("请输入联系地址！");
		document.getElementById("address").focus();
		return false;
	} else if (postalcode.Trim() == "" || postalcode == null) {
		alert("请输入邮政地址！");
		document.getElementById("postalcode").focus();
		return false;
	} else if (postalcode.Trim().length > 0 && !isZipCode(postalcode)) {
		alert("请输入正确的邮政地址！");
		document.getElementById("postalcode").focus();
		return false;
	}else if(unitname=="0"||unitname == null){
	    alert("请选择咨询部门名称！");
		document.getElementById("unitname").focus();
		return false;
	}
	else if (content.Trim() == "" || content == null) {
		alert("请输入咨询的内容！");
		document.getElementById("content").focus();
		return false;
	} else if(content.Trim().length>3000){
	   	alert("您输入咨询的内容超过3000个字符，请重新输入！");
		document.getElementById("content").focus();
		return false;
	}else {
		document.forms['mailForm'].submit();
	}
}
function rett() {
	document.forms['mailForm'].reset();
	  if(document.getElementById("content").value.Trim().length==0){
	         document.getElementById("content").value="";
	     }
	return false;
}

function diaocha() {
	alert("感谢您的投票！");
}

function aa() {
	var typeID;
	var type = document.URL.split("=")[1];
	if (type.indexOf("&") == -1) {
		typeID = document.URL.split("=")[1];
	} else {
		typeID = document.URL.split("=")[1].split("&")[0];
	}
	if (typeID == document.getElementById("geneInfoId").value) {
		
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zhlist.html?TypeID="+document.getElementById("geneInfoId").value+"'>综合信息</a></span> &gt;&gt;综合信息"
	} else if (typeID == document.getElementById("organPartyConsId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zhlist.html?TypeID="+document.getElementById("geneInfoId").value+"'>综合信息</a></span> &gt;&gt;机关党建"
	} else if (typeID == document.getElementById("discInspId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zhlist.html?TypeID="+document.getElementById("geneInfoId").value+"'>综合信息</a></span> &gt;&gt;纪检监察"
	} else if (typeID == document.getElementById("spirCiviId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zhlist.html?TypeID="+document.getElementById("geneInfoId").value+"'>综合信息</a></span> &gt;&gt;精神文明建设"
	} else if (typeID == document.getElementById("efficiencyBuildId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zhlist.html?TypeID="+document.getElementById("geneInfoId").value+"'>综合信息</a></span> &gt;&gt;效能建设"
	} 
	else {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zhlist.html?TypeID="+document.getElementById("geneInfoId").value+"'>综合信息</a></span> &gt;&gt;综合信息"
	}
}

/**
 * OA 导航文字信息
 */
function oa() {
	var typeID;
	if(document.URL.indexOf("=") == -1){
	document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;上级发文";
	}else{
		var type = document.URL.split("=")[1];
		if (type.indexOf("&") == -1) {
			typeID = document.URL.split("=")[1];
		} else {
			typeID = document.URL.split("=")[1].split("&")[0];
		}
		if (typeID == document.getElementById("supeDocumentId").value) {
			
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;上级发文";
		}else if (typeID == document.getElementById("counDocumentId").value) {
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;本局发文";
		} else if (typeID == document.getElementById("bullBoardId").value) {
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;公告栏";
		} else if (typeID == document.getElementById("chriDate").value) {
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;生日信息";
		}else if (typeID == document.getElementById("priceInfoId").value) {
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;物价信息专报";
		}
		else{
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='OA.jsp'>OA办公</a></span> &gt;&gt;上级发文";
		} 
    }
    
	
}

function bb() {
	var typeID;
	var type = document.URL.split("=")[1];
	if(typeof(type) == "undefined"){
			document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;政务公开";
	
	}
	else {
	if (type.indexOf("&") == -1) {
		typeID = document.URL.split("=")[1];
	} else {
		typeID = document.URL.split("=")[1].split("&")[0];
	}
    if (typeID == document.getElementById("poliReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;政策法规";
	}else if (typeID == document.getElementById("theroyId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;理论与实践";
	} else if (typeID == document.getElementById("liceFeesPublId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;收费许可证";
	} else if (typeID == document.getElementById("priceListId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;定价目录";
	}else if(typeID == document.getElementById("goveAffaUpgradeId").value){
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;政务公开深化年";	 
	} 
	else {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a></span> &gt;&gt;政务公开";
	}
	}
}

/***
 *
 */
function bb2(){
	document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwlist.html?TypeID="+document.getElementById("goveAffaId").value+"'>政务公开</a></span> &gt;&gt;政策法规";
}

function cc() {
	var typeID;
	var type = document.URL.split("=")[1];
	if (type.indexOf("&") == -1) {
		typeID = document.URL.split("=")[1];
	} else {
		typeID = document.URL.split("=")[1].split("&")[0];
	}
	if (typeID == document.getElementById("announcementId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;通知公告";
	} else if (typeID == document.getElementById("priceMonitor").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;价格监管";
	} else if (typeID == document.getElementById("lateFilesId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;最新文件";
	} else if (typeID == document.getElementById("windCountyId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;县区之窗";
	}else if (typeID == document.getElementById("priceCostId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;价格成本";
	} else if (typeID == document.getElementById("priceSupeId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;价格信息与监测";
	} else if (typeID == document.getElementById("goodColuId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;专题专栏";
	} else if (typeID == document.getElementById("eachConfirm").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;双认定";
	}else if (typeID == document.getElementById("priceAppreciationId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;价格鉴证";
	}else {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='gzlist.html?TypeID="+document.getElementById("priceMonitor").value+"'>工作动态</a></span> &gt;&gt;价格监管";
	}
}

function ee() {
	var typeID;
	var type = document.URL.split("=")[1];
	if (type.indexOf("&") == -1) {
		typeID = document.URL.split("=")[1];
	} else {
		typeID = document.URL.split("=")[1].split("&")[0];
	}
	if (typeID == document.getElementById("onliServId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='wblist.html?TypeID="+document.getElementById("pricRepoLineId").value+"'>网上服务</a></span> &gt;&gt;办事指南";
	}else if (typeID == document.getElementById("clearlyThepriceId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='wblist.html?TypeID="+document.getElementById("pricRepoLineId").value+"'>网上服务</a></span> &gt;&gt;商品住宅销售价格明码标价备案";
	}else if (typeID == document.getElementById("downloadId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='wblist.html?TypeID="+document.getElementById("pricRepoLineId").value+"'>网上服务</a></span> &gt;&gt;在线下载";
	} else if (typeID == document.getElementById("pricRepoLineId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='wblist.html?TypeID="+document.getElementById("pricRepoLineId").value+"'>网上服务</a></span> &gt;&gt;12358价格举报专线 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='consultcheck.jsp' ><font color='red'>12358价格咨询登记</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='reportcheck.jsp' ><font color='red'>12358价格举报受理登记</font></a>";
	}else if(typeID == document.getElementById("pricecomId").value){
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='wblist.html?TypeID="+document.getElementById("pricRepoLineId").value+"'>网上服务</a></span> &gt;&gt;价比三家";
	} 
	else {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='wblist.html?TypeID="+document.getElementById("pricRepoLineId").value+"'>网上服务</a></span> &gt;&gt;12358价格举报专线";
	}

}

function ff() {
	var typeID;
	var type = document.URL.split("=")[1];
	if (type.indexOf("&") == -1) {
		typeID = document.URL.split("=")[1];
	} else {
		typeID = document.URL.split("=")[1].split("&")[0];
	}
	if (typeID == document.getElementById("zongheReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt; 综合类";
	} else if (typeID == document.getElementById("priceMonitorReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;价格监管类";
	} else if (typeID == document.getElementById("priceManagerReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;价格管理类";
	}  else if (typeID == document.getElementById("priceServiceReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;行政事业性收费类";
	} else if (typeID == document.getElementById("adminReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt; 行政审批类";
	} else if (typeID == document.getElementById("costReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;成本监审类";
	} else if (typeID == document.getElementById("otherReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;其他";
	} else if (typeID == document.getElementById("legalReguId").value) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;法制专栏";
	}else {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a> &gt;&gt;<a href='zwgklist.jsp'>政务公开</a>&gt;&gt;<a href='govlist.html?TypeID="+document.getElementById("zongheReguId").value+"'>政策法规</a></span> &gt;&gt;综合类";
	}
}



function govinfo() {
		var typeID;
	var type = document.URL.split("=")[1];
	if (type.indexOf("&") == -1) {
		typeID = document.URL.split("=")[1];
	} else {
		typeID = document.URL.split("=")[1].split("&")[0];
	}
	if (typeID == 110226) {
		document.getElementById("crum").innerHTML = "<span style='font-weight: bold'>当前位置：<a href='../index.jsp'>首页</a></span> &gt;&gt;政府信息公开";
	}
}

function qiehuan(num) {
	for (var id = 0; id < 7; id++) {
		if (id == num) {
			document.getElementById("qh_con" + id).style.display = "block";
			document.getElementById("mynav" + id).className = "nav_on";
		} else {
			document.getElementById("qh_con" + id).style.display = "none";
			document.getElementById("mynav" + id).className = "";
		}
	}
}

function Jumping() {
	document.PageForm.submit();
	return;
}

function gotoPage(pagenum) {
	document.PageForm.jumpPage.value = pagenum;
	document.PageForm.submit();
	return;
}

var xmlHttp; // 用于保存XMLHttpRequest对象的全局变量

// 用于创建XMLHttpRequest对象
function createXmlHttp() {
	
	try {
		if (window.ActiveXObject) {
			for (var i = 5; i; i--) {
				try {
					if (i == 2) {
						xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					} else {
						xmlHttp = new ActiveXObject("Msxml2.XMLHTTP." + i + ".0");
						xmlHttp.setRequestHeader("Content-Type", "text/html");
						xmlHttp.setRequestHeader("Charset", "gb2312");
					}
					break;
				} catch (e) {
					xmlHttp = false;
				}
			}
		} else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
			if (xmlHttp.overrideMimeType) {
				xmlHttp.overrideMimeType('text/html');
			}
		}
	} catch (e) {
		xmlHttp = false;
	}
	
	// 根据window.XMLHttpRequest对象是否存在使用不同的创建方式
	/**
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest(); // FireFox、Opera等浏览器支持的创建方式
	} else {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");// IE浏览器支持的创建方式
	}
	**/
}

function submitVote() {
	var isSelect = false;
	var radioArray = document.getElementsByName("radio");
	for (var i = 0; i < radioArray.length; i++) {
		if(radioArray[i].checked){
			isSelect = true;
			createXmlHttp(); // 创建XmlHttpRequest对象
			var url = getPath() + "voteServlet?voteValue=" + radioArray[i].value;
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = handleVoteResult; // 设置回调函数
			xmlHttp.send(null);
		}
	}
	if(isSelect == false){
		alert("请选择投票！");
	}
}

function handleVoteResult() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var result = xmlHttp.responseText;
			if(result == "voted"){
				alert("您已经投过票，感谢您的参与！");
			}else if(result == "success"){
				alert("投票成功，感谢您的参与！");
			}else{
				alert("投票失败，感谢您的参与！");
			}
		}
	}
}

function loginOA(){
	var username = document.getElementById("usernameOA").value;
	var password = document.getElementById("passwordOA").value;
	
	if(username == ''){
		//alert("用户名不能为空！");
		ymPrompt.alert('用户名不能为空！',null,null,'信息提示');
		return;
	}
	if(password ==''){
	   	//alert("密码不能为空！");
	   	ymPrompt.alert('密码不能为空！',null,null,'信息提示');
	   	document.getElementById("passwordOA").focus();
		return;
	}
	createXmlHttp(); // 创建XmlHttpRequest对象
	var url = getPath() + "oaLoginServlet?username=" + username + "&password=" + password;
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = handleOALogin; // 设置回调函数
	xmlHttp.send(null);
}

function handleOALogin(){
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var result = xmlHttp.responseText;
			if(result == "failure"){
				//alert("登录失败，用户名或密码错误！");
				ymPrompt.alert('登录失败，用户名或密码错误！',null,null,'信息提示');
			}else if(result == 'success'){
				top.location = getPath() + "oa/oalist.html";
			}
		}
	}
}
/**
 * list all attaches by OA user.
 */
function listAttaches(){
	createXmlHttp(); // 创建XmlHttpRequest对象
	var url = getPath() + "listattachments";
	xmlHttp.onreadystatechange = handleListResult; // 设置回调函数
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function handleListResult(){
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var result = xmlHttp.responseText;
			document.getElementById("uploadedAttache").innerHTML = result;
		}
	}
}

/**
 * attaches down load.
 */
function downloadAttache(attachId){
	document.location = getPath() + "downattachments?id=" + attachId;
}

/***
 * delete attache by id.
 * @param {} attachId
 */
function deleteAttache(attachId){
	createXmlHttp(); // 创建XmlHttpRequest对象
	var url = getPath() + "deleteattachments?id=" + attachId;
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = handleDeleteAttache; // 设置回调函数
	xmlHttp.send(null);
}

/***
 * handle delete attache result.
 */
function handleDeleteAttache(){
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var result = xmlHttp.responseText;
			if(result == 'failure'){
				//alert("删除附件失败！");
				ymPrompt.alert('删除附件失败！',null,null,'信息提示');
			}else{
				document.getElementById("uploadedAttache").innerHTML = result;
				//alert('删除附件成功！');
				ymPrompt.alert('删除附件成功！',null,null,'信息提示');
			}
		}
	}
}


/**
 * obtain gobal path.
 * @return {String}
 */
function getPath(){
	var protocol = document.location.protocol;
	var host = document.location.host;
	var pathname = document.location.pathname;
	var search = document.location.search;
	var s = protocol + '//' + host + '/' + (pathname.split('/'))[1] + '/';
	return s;
}

/***
 * select all checkbox.
 */
function checkall(){
	var inputs = document.getElementsByTagName("input");
	for(var i=0;i < inputs.length;i++){
		if(inputs[i].type== "checkbox"){
			if(!inputs[i].checked){
				inputs[i].checked = true;
			}
		}
	}
}

/***
 * not select one checkbox.
 */
function checknone(){
	var inputs = document.getElementsByTagName("input");
	for(var i=0;i < inputs.length;i++){
		if(inputs[i].type== "checkbox"){
			if(inputs[i].checked){
				inputs[i].checked = false;
			}
		}
	}
}

/***
 * look message by msgId.
 */
function lookmsg(msgId){
	var form = document.getElementById("messagesListForm");
	form['msgId'].value = msgId;
	form.submit();
}

/***
 * move message by selected msg ids.
 */
function deleteMessages(){
	var inputs = document.getElementsByTagName("input");
	var isNull = false;
	for(var i=0;i < inputs.length;i++){
		if(inputs[i].type== "checkbox"){
			if(inputs[i].checked){
				isNull = true;
				break;
			}
		}
	}
	if(! isNull){
		//alert('请选择要删除的消息！');
		ymPrompt.alert('请选择要删除的消息！',null,null,'信息提示');
		return;
	}
	if(isNull){
		ymPrompt.confirmInfo('要将选中的消息删除吗？',null,null,"信息提示",function(data){
	    if(data=="ok")
	    document.getElementById("messages_form").submit();
	    });
	}
	
}

/**
 * clear all message by delType.
 */
function clearMessages(delType){
	ymPrompt.confirmInfo('要将所有邮件清空吗？',null,null,"信息提示",function(data){
	    if(data=="ok"){
	    var form = document.getElementById("messages_form");
		form['box'].value = delType;
		form.submit();
		}
	    });
}

/***
 * reply message.
 */
function replyLookedMessage(){
	var form = document.getElementById("dealMessageForm");
	form['dealType'].value = 'reply';
	form.submit();
}

/***
 * forward message.
 */
function forwardLookedMessage(){
	var form = document.getElementById("dealMessageForm");
	form['dealType'].value = 'forward';
	form.submit();
}

/***
 * delete message.
 */
function deleteLookedMessage(){

	ymPrompt.confirmInfo('要删除该消息吗?',null,null,"信息提示",function(data){
	    if(data=="ok"){
	    var form = document.getElementById("dealMessageForm");
	    form['dealType'].value = 'delete';
	    form.submit();
		}
	    });
}


