/*public.js已经包含了2005-7-24号之前的CheckStr.js CheckStr.js 和 control.js 的函数

强调说明：
        载入该js应在HTML的<body>之前；
        <script language="JavaScript" src="/stmsres/js/public.js"></script>

*/


/**
 * @description 把全角数字转换为数字,并自动去掉不符合的字符
 * @parame String 
 * @return boolean
 */
function stringToNumber(str){//把全角数字转换为数字,并自动去掉不符合的字符
numberA = new Array('0','1','2','3','4','5','6','7','8','9');  //数字
numberB = new Array('０','１','２','３','４','５','６','７','８','９');//全角数字
outStrA="";
for(i=0;i<str.length;i++){
     for(j=0;j<numberB.length;j++){
        if(str.substring(i,i+1)==numberB[j] || str.substring(i,i+1)==numberA[j] ){
		outStrA+=numberA[j];
	    }
     }
} 
return outStrA; 
}
 
//打印一个等待层的HTML
function outPrintWaitLeyer(){//等待层的HTML
var leyerstr="";
	if(document.getElementById("waitLeyer")==null){//防止同一页面重复调用

			var _div = window.document.createElement("div");
				_div.id="waitLeyer";
				_div.style.position = "absolute";
				_div.style.width = "200";
				_div.style.height = "20";
				_div.style.zIndex = 10;
				_div.style.visibility = "";	

	        leyerstr+="<iframe src=\"\" style=\"position:absolute; width:200px; height:64x; z-index:-1; ";
            leyerstr+="filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';\"></iframe>";            
            leyerstr+="<table width=\"200\" height=\"64\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#FF9900\"><tr> ";
            leyerstr+="<td height=\"64\" align=\"center\" bgcolor=\"#FEFFF4\">";
            leyerstr+="<img src=\"/stmsres/images/wait.gif\" width=\"90\" height=\"20\"><br>";
            leyerstr+="请稍候 ... ... </td>";
            leyerstr+="</tr></table>";

				_div.innerHTML = leyerstr;
				window.document.body.appendChild(_div);

        }
}

//等待界面显示控制
function waitLeyerShow(){
outPrintWaitLeyer();
setleyerTopLeft();//设定显示位置
document.all.waitLeyer.style.visibility=''; //显示
}

//自动调整waitLeyer的位置，位于中间
function setleyerTopLeft(){
document.all.waitLeyer.style.left=document.body.offsetWidth/2+document.body.scrollLeft-100;
document.all.waitLeyer.style.top=document.body.offsetHeight/2+document.body.scrollTop-64;
}

//参数值是否为数值类型
function isNumbers(str) {	
	return !isNaN(str);
}
/**
 * @description 参数值是否为整型类型
 * @parame String 待测字符串
 * @return boolean
 */
function isInteger(str) {
	return isNumbers(str)&& str.indexOf(".")<0;
}

/**
 * @description 参数值是否为浮点类型
 * @parame String 待测字符串
 * @return boolean
 */
function isFloat(str) {    
   return !isNaN(str) && str.indexOf(".")>0;   
}

/**
 * @description 浮点数小数点精确位
 * @parame String 待测字符串
 * @parame String 小数点精密位
 * @return boolean
 */
function isFloatPointOverLan(str, len) {
   var POINT = ".";
   var i = 0, j = 0;
   var result = false;
   var isPoint = false;
   if (isFloat(str)) {
   for( i=0; i<str.length; i++) {
      if (str.charAt(i) == POINT) isPoint = true;
	  if (isPoint) j++;
   }result=(j-1)>len?true:result;
   } return result;
}

/**
 * @description 检测字符串是否为空(包括空格)
 * @parame String 待测字符串
 * @return boolean
 */
function isNone(str) {
    var result = true;
    str = trim(str);
    if (str!=null && str.length>0) {
        result = false;
    }   
    return result;
}

/**
 * @description 去掉左右空格符
 * @parame String 待测字符串
 * @return String
 */
function trim(str) {
    str = trimLeft(str);
    str = trimRight(str);
    return str;
}

/**
 * @description 去掉左空格符
 * @parame String 待测字符串
 * @return String
 */
function trimLeft(str) {   
  var SPACE = " ";
  while(str.charAt(0) == SPACE) {
     str = str.substring(1);
  }
  return str;
}

/**
 * @description 去掉右空格符
 * @parame String 待测字符串
 * @return String
 */
function trimRight(str) {   
  var SPACE = " ";
  while(str.charAt(str.length-1) == SPACE) {
     str = str.substring(0, str.length-1);
  }    
  return str;
}

/**
 * @description 用于表单的复位按钮
 * @parame 复位按钮所在表单
 * @return 无返回
 */
function do_reset(form) {
	form.reset();
}
/**
 *  @description 实现两select元素的各选项交换
 *  @parame obj1 源select元素 
 *  @parame obj2 目的select元素
 */
function toChangeItem(obj1, obj2) {  
     var j = null;
     var i = null;
	 var n = null; 
	 n = obj1.options.length - 1;
	 for(i=n; i>=0; i--)
	 {
	     if (obj1.options[i].selected)
		 { 


		     for(j=0; j<obj2.options.length; j++)  {
				 if (obj1.options[i].value==obj2.options[j].value) {
					 break;
				 }
			 }
			 			
			 if ( j==obj2.options.length ) {
		         obj2.options.add(new Option(obj1.options[i].text, obj1.options[i].value));
			     obj1.options.remove(i);
				 break;
			 }

		 }
	 }
}

/**
 *  @description 实现两select元素的各选项交换
 *  @parame _selectLeft 源select元素 
 *  @parame _selectRight 目的select元素
 *  @author: leijb 20060612
 */
function selectToSelect(_selectLeft,_selectRight){
	for(i=_selectLeft.length-1;i>=0;i--){
		if(_selectLeft.options[i].selected){		
			_selectRight.appendChild(_selectLeft.options[i]);
		}	
	}
}


/**
 * @description 反选select元素选项
 * @parame select元素选项
 */
function toConverseSelect(object) {
	var i = null;
    for(i=0; i<object.options.length; i++)
	{
	    object.options[i].selected = !object.options[i].selected;
	}
}
/**
 * @description 全选select元素选项
 * @parame select元素选项
 */
function toAllSelect(object) {
	var i = null;
    for(i=0; i<object.options.length; i++)
	{
	    object.options[i].selected =true;
	}
}
/**
 * @description 用于下拉列表框的定位
 * @parame 
 * @return 
 */
function toSelected(obj, value) {   
	obj = eval("document.all."+obj);
 	for (i=0;i<obj.options.length;i++){
  		if(obj.options[i].value == value) {
     		obj.options[i].selected=true;
     		break;
  		}
  	}
}

/**
 * @description:   用于检测复选框的选定情况
 * @param  obj:    复选框名称
 * @param  return: 复选框选中的个数
 * @author:        HanYongtao
 */
 function  getCheckedCount(obj) {
	if (null == obj) {
		 return 0;
	}
	if (null == obj.length) {
		if(obj.checked) {
			if(arguments.length >= 3) {
				for(var i = 1; i < arguments.length; i+=2) {
					if(arguments[i] != null) {
						if(arguments[i].indexOf('.') == 0) {
							if(eval('obj' + arguments[i])) {
								alert(arguments[i+1]);
								return -1;
							}
						} else {
							if(eval(arguments[i])) {
								alert(arguments[i+1]);
								return -1;
							}
						}
					}
				}
			}
			return 1;
		} else {
			return 0;
		}
	} else {
		var count = 0;
		for(var i = 0; i < obj.length; i++) {
			if(obj[i].checked) {
				if(arguments.length >= 3) {
					for(var j = 1; j < arguments.length; j+=2) {
						if(arguments[j] != null) {
							if(arguments[j].indexOf('.') == 0) {
								if(eval('obj[' + i + ']' + arguments[j])) {
									alert(arguments[j+1]);
									return -1;
								}
							} else {
								if(eval(arguments[j])) {
									alert(arguments[j+1]);
									return -1;
								}
							}
						}
					}
				}
				count++;
			}
		}
		return count;
	}
 }
 /**
 * @description:   全选所有的复选框
 * @param  obj:    复选框名称
 * @author:        HanYongtao
 */
 function  checkAll(obj) {
	if (null == obj) {
		 return;
	}
	if (null == obj.length) {
		if(!obj.checked) {
			obj.checked = true;
		} 
	} else {
		for(var i = 0; i < obj.length; i++) {
			if(!obj[i].checked) {
				obj[i].checked = true;
			}
		}
	} 
 }
/**
 * @description:   反选所有的复选框
 * @param  obj:    复选框名称
 * @author:        HanYongtao
 */
 function  converseCheckAll(obj) {
	if (null == obj) {
		 return;
	}
	if (null == obj.length) {
			obj.checked = !obj.checked;
	} else {
		for(var i = 0; i < obj.length; i++) {
			obj[i].checked = !obj[i].checked;
		}
	} 
 }
 
 /**
 * @description:   取消所有的复选框的选定
 * @param  obj:    复选框名称
 * @author:        HanYongtao
 */
 function  deCheckAll(obj) {
	if (null == obj) {
		 return;
	}
	if (null == obj.length) {
		obj.checked = false;
	} else {
		for(var i = 0; i < obj.length; i++) {
			obj[i].checked = false;
		}
	} 
 }
 
/**
 * @description:   用于检测复选框/单选按钮的选定情况
 * @param  obj_id: 复选框id
 * @param  return: 选中的个数
 * @author:        leijb
 */
function  getCheckSize(obj_id){
	var rv = 0;
	obj = eval("document.all."+obj_id);
	if(obj+""!="undefined"){
		  if(obj.length+""!="undefined"){
				for(i=0;i<obj.length;i++){if(obj[i].checked){rv++;}}
		  }else{
				if(obj.checked){rv++;}
		  }	
	}
	return rv;
}


/**
 * @description:   根据对象id 获得复选框/单选按钮的长度 
 * @param  obj_id: id
 * @param  return: 对象的数量
 * @author:        leijb
 */
function  getObjLen(obj_id){
	var rv = 0;
	obj = eval("document.all."+obj_id);
	if(obj+""!="undefined"){
		  if(obj.length+""!="undefined"){
				rv = obj.length;
		  }else{
				rv = 1;
		  }	
	}
	return rv;
}


/**
 * @description:  打开网页对话框，并返回相应的值，返回值可以为 str,array,object 
 * @param  : url弹出窗口的路径，winname弹出窗口的窗口名称，description弹出窗口的参数设置，如高度和宽度等。
 * @param  : 参考 getShowModalDialogValue('StaffAction.do?type=SELECT','newwin','center: yes;dialogWidth:800px; dialogHeight:600px; status:0')
 * @author:        leijb
 */
function  getShowModalDialogValue(url,winname,description){
	return showModalDialog(url,winname,description);
}

/*
* @description: 日期比较
* @param  :D1=开始日期 D2=结束日期
* @param  :返回相隔的天 
* @author :leijb 2006-04-03
*/
function dateCompare(D1,D2){
	try{
	D1Array = (D1.split("-"));
	D2Array = (D2.split("-"));	
	
	var firstDate = new Date(D1Array[0],getDateNumber(D1Array[1]),getDateNumber(D1Array[2]));
	var secondDate = new Date(D2Array[0],getDateNumber(D2Array[1]),getDateNumber(D2Array[2]));	
	return (secondDate-firstDate)/(1000*60*60*24); 	
	}catch(theException){
			//alert("public.js 日期比较dateCompare方法异常！\n"+theException.message);
			
	}
}
/**
辅助dateCompare
*/
function getDateNumber(str){
	if((str.substring(0,1)).indexOf("0")>-1){
	str = str.substring(1,str.length);
	}
	return str;
}

/*
* @description: 时间比较
* @param  :D1=开始时间 D2=结束时间
* @param  :返回相隔的秒 
* @author :leijb 2006-05-06
*/
function dateCompareSecond(D1,D2){
	try{
	D1Array = (D1.split(":"));
	D2Array = (D2.split(":"));	
	var firstDate = new Date(2006,12,12,D1Array[0],D1Array[1]);
	var secondDate = new Date(2006,12,12,D2Array[0],D2Array[1]);	
	return (secondDate-firstDate)/(60*60*24); 	
	}catch(theException){
			//alert("public.js 日期比较dateCompareSecond方法异常！\n"+theException.message);
			
	}
}

function isDateTime(D){
	returnV = true;
	try{
		D1Array = (D.split(":"));
		if(isNaN(D1Array[0])){
			returnV = false;
		}
		if(isNaN(D1Array[1])){
			returnV = false;
		}
		if(D1Array[0]>23 || D1Array[0]<0){
			returnV = false;	
		}
		if(D1Array[1]>59 || D1Array[1]<0){
			returnV = false;	
		}	
		return returnV;
	}catch (e){
	alert(e.message);
	return false;			
	}
}
function showError(obj,str){
	
	//if(document.getElementById("__ErrorMessagePanel")!=null){
	//	document.getElementById("__ErrorMessagePanel").style.display='none';
	//}

	try{
			var span = document.getElementById("__ErrorMessagePanel")==null?document.createElement("<DIV>"):document.getElementById("__ErrorMessagePanel");
			span.id = "__ErrorMessagePanel";
			span.name="__ErrorMessagePanel";
			span.style.position="absolute";
			span.style.width = "200";
			span.style.height = "30";
			span.style.zIndex = "1";
			span.onclick = function anonymous(){this.style.display='none';};
			var c = obj;
			var cy = 0;
			var cx = 0;
			while (c.offsetParent != null) {
				  cy += c.offsetTop;
				  cx += c.offsetLeft;
				  c = c.offsetParent;
					}					
					
					
				var outString = "";
				outString += '<table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">';
				outString += '<tr><td width="5" height="3"><img src="/stmsres/images/input_info_01.gif" width="5" height="4" alt=""></td><td background="/stmsres/images/input_info_02.gif">';
				outString += '<img src="/stmsres/images/input_info_02.gif" width="5" height="5" alt=""></td><td width="7">';
				outString += '<img src="/stmsres/images/input_info_04.gif" width="7" height="5" alt=""></td></tr><tr>';
				outString += '<td background="/stmsres/images/input_info_05.gif">';
				outString += '<img src="/stmsres/images/input_info_05.gif" width="5" height="19" alt=""></td><td bgcolor="#FFFDC6"><font color="#0033FF">';
				outString += str.replace(/\d+:/,"*");
				outString += '</font></td><td background="/stmsres/images/input_info_07.gif"><img src="/stmsres/images/input_info_07.gif" width="7" height="18" alt=""></td>';
				outString += '</tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
				outString += '<td width="37"><img src="/stmsres/images/input_info_08.gif" width="37" height="17" alt=""></td>';
				outString += '<td background="/stmsres/images/input_info_09.gif"><img src="/stmsres/images/input_info_09.gif" width="3" height="17" alt=""></td>';
				outString += '<td width="7"><img src="/stmsres/images/input_info_11.gif" width="7" height="17" alt=""></td></tr></table></td></tr></table>';
				span.innerHTML = outString;	
					

			    //alert(span.style.display+ obj.parentNode.);
					obj.parentNode.appendChild(span);			
					span.style.left = cx;
					span.style.top = cy-span.offsetHeight;
					
					var iframe = document.createElement("<IFRAME>");
					iframe.style.position = "absolute";
					iframe.style.height = span.offsetHeight;
					iframe.style.width = 160;
					iframe.style.zIndex = -10;
					iframe.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0,finishOpacity=0)";
					iframe.src = "javascript:false";
					iframe.style.left = 0;
					iframe.style.top = 0;

					
					span.appendChild(iframe);
					span.style.display="block";
					obj.focus();

					//alert(obj.parentNode.innerHTML);
					//testDIV.innerHTML=span.innerHTML;
			        // span.style.display="block";

					}
					catch(e){alert(e.description);}
}
function clearError(){
	if(document.getElementsByName("__ErrorMessagePanel")!=null){
	
		for(i=0;i<document.getElementsByName("__ErrorMessagePanel").length;i++)
		{
			document.getElementsByName("__ErrorMessagePanel")[i].style.display='none';
		}
	}
}
String.prototype.getLength=function()
{
	var cArr = this.match(/[^\x00-\xff]/ig);
	return this.length + (cArr == null ? 0 : cArr.length);
}
String.prototype.startsWith =function(prefix){return (this.substr(0,prefix.length)===prefix);}
String.prototype.trim =function(){return this.replace(/(^(\s|　)*)|((\s|　)*$)/g,'');}
String.prototype.trimEnd =String.prototype.rTrim =function(){return this.replace(/\s+$/,'');}
String.prototype.trimStart =String.prototype.lTrim =function(){return this.replace(/^\s+/,'');}


if (window.attachEvent) {
		window.attachEvent("onload", function(){try{parent.resizeFrame();}catch(e){};});
	}else{
		window.onload=function(){try{parent.resizeFrame();}catch(e){};};
	}

function dojoLayoutTabExchange(obj)
{
		var index = 0;
		var j=0;
		for(var i=0;i<obj.parentNode.childNodes.length;i++)
		{
			if(obj.parentNode.childNodes[i].tagName == "DIV")
			{
				obj.parentNode.childNodes[i].className = "dojoTabDiy";
				document.getElementById("dojoTab" + j).style.display = "none";
				if(obj.parentNode.childNodes[i] == obj)  index = j;
				j = j + 1;
			}
		}
		 
		obj.className = "dojoTabDiy current";
		document.getElementById("dojoTab" + index).style.display = "";
		try
		{
			top.resizeFrame();
		}
		catch(ex){}
}


function dojoTabTurnPagePrev(divParentId)
{
		var divParent = document.getElementById(divParentId);
		var curIndex = 0;
		var obj = null;
		var j=0;
		if(divParent)
		{
			for(var i=0;i<divParent.childNodes.length;i++)
			{
				if(divParent.childNodes[i].tagName == "DIV")
				{
					if(divParent.childNodes[i].className == "dojoTabDiy current")
					{
						curIndex = j;
						break;
					}
					
					j = j + 1;
				}
			}
			if(curIndex==0)
			{
				obj = divParent.childNodes[divParent.childNodes.length-1];
				if(obj.tagName != "DIV") obj = divParent.childNodes[divParent.childNodes.length-2];
				
				dojoLayoutTabExchange(obj);
				return;	
			}
			
			j = 0;
			for(var i=0;i<divParent.childNodes.length;i++)
			{
				if(divParent.childNodes[i].tagName == "DIV")
				{
					if(j==curIndex-1 && divParent.childNodes[i].style.display != "none")
					{
						dojoLayoutTabExchange(divParent.childNodes[i]);
						break;
					}
					j = j + 1;
				}
			}
		}
		
}

function dojoTabTurnPageNext(divParentId)
{
		var divParent = document.getElementById(divParentId);
		var curIndex = 0;
		var obj = null;
		
		var j=0;
		
		if(divParent)
		{
			for(var i=0;i<divParent.childNodes.length;i++)
			{
				if(divParent.childNodes[i].tagName == "DIV")
				{
				
					if(divParent.childNodes[i].className == "dojoTabDiy current")
					{
						curIndex = j;
						break;
					}
					
					j = j + 1;
				}
			}
			
			var len = 0;
			for(var i=0;i<divParent.childNodes.length;i++)
			{
				if(divParent.childNodes[i].tagName == "DIV")
				{
					len = len + 1;
				}
			}
			
			if(len == curIndex+1)
			{
				obj = divParent.childNodes[0];
				if(obj.tagName != "DIV") obj = divParent.childNodes[1];
				dojoLayoutTabExchange(obj);
				return;	
			}
			
			j = 0;
			for(var i=0;i<divParent.childNodes.length;i++)
			{
				if(divParent.childNodes[i].tagName == "DIV")
				{
					if(j==curIndex+1 && divParent.childNodes[i].style.display != "none")
					{
						dojoLayoutTabExchange(divParent.childNodes[i]);
						break;
					}
					
					j = j + 1;
				}
			}
		}
			
}

function isTagSpan(obj)
{
	if(!obj.tagName) return false;
	
	if(obj.tagName.toUpperCase()!="SPAN") return false;
	
	return true;
}

function isTagSelect(obj)
{
	if(!obj.tagName) return false;
	
	if(obj.tagName.toUpperCase()!="SELECT") return false;
	
	return true;
}

function isTagChkRadio(obj)
{
	if(!obj.type) return false;
			
	if(obj.type.toUpperCase()!="RADIO") return false;
			
	return true;
}

function getTagValueById(oTagName)
{
	var obj = document.getElementById(oTagName);
	if(obj) 
		return getTagValue(obj);
	else
		return "";
}	

function getTagValue(oTag)
{
	try
	{
		if(isTagSpan(oTag))
		{
			return irisTrim(oTag.innerText);
		}
		else if(isTagChkRadio(oTag))
		{
			var obj = document.getElementById(oTag.name+"_value");
			if(obj)
			{
				//alert(obj.value);
				return obj.value;
			}
			else
				return "";
		}
		else
		{
			return irisTrim(oTag.value);
		}
	}
	catch(ex)
	{
		return "";
	}
}

function setTagChkValue(obj,strvalue)
{
	var obj = document.getElementById(obj.name+"_value");
	if(obj)
		obj.value = strvalue;
}

function setTagValue(oTag,strValue)
{
	if(isTagSpan(oTag))
	{
		oTag.innerText = strValue;
	}
	else if(isTagSelect(oTag))
	{
		setDropDown(oTag,strValue);
	}
	else if(isTagChkRadio(oTag))
	{
		//alert(oTag.name);
		//alert(strValue);
		
		if(oTag.value==strValue)
		{ 
			oTag.checked=true;
			setTagChkValue(oTag,strValue);
		}
		else
			oTag.checked=false;
		//alert(oTag.checked);
	}	
	else
	{
		oTag.value = strValue;
	}
}

function setDropTextValue(obj)
{
	var strname = obj.name;
	var objt = document.getElementById(strname+"_name");
	if(!objt) return;
	
	if(obj.selectedIndex==-1)
	{
		setTagValue(objt,"");
	}
	else
	{
		setTagValue(objt,obj.options[obj.selectedIndex].text);
	}
}

function setDropTextValueByObjName(objname,strvalue)
{
	var obj = document.getElementById(objname);
	setDropDown(obj,strvalue);
}

function setDropDown(obj,strvalue)
{
	if(!obj) return;
	obj.value = strvalue;
	setDropTextValue(obj);
	
}

function irisTrim(strToDeal)
{
	var strTemp=strToDeal.toString();
	return strTemp.replace(/(^(\s|　)*)|((\s|　)*$)/g, "");
}

function isEmail(strEmail)
{
	if(strEmail.search(/^[_\.a-z0-9]+@[a-z0-9]+[\.][a-z0-9]{2,}$/i) == -1)
	{
		return false;
	}
	
	return true;
}

//显示单位信息
function showOrgMessageForReviewer(psn_code)
{
	OpenWin("/stms/organization.do?ActionType=showForReviewer&psn_code="+psn_code,"OrgDetail");
}

function showOrgMessage(orgCode)
{
	OpenWin("/stms/organization.do?ActionType=show&orgCode="+encodeURIComponent(orgCode),"OrgDetail");
}

function showPassWordEdit(psnCode,cname)
{ 
	OpenWin("/stms/organizationManage.do?action=oPassEdit&psnCode="+encodeURIComponent(psnCode)+"&cname="+cname,"oPassEdit","width=600,height=200");
}
function ShowPsnDetailForReviewer(psnCode)
{
	OpenWin("/stms/prvExpert.do?action=ViewForReviewer&psnCode="+encodeURIComponent(psnCode),"PsnDetail","width=600,height=400");
}

function ShowPsnDetail(psnCode)
{
	//Telligent_Modal.Open("/stms/userinfo.do?action=view&psnCode="+psnCode,600, 400);
	OpenWin("/stms/userinfo.do?action=view&psnCode="+encodeURIComponent(psnCode),"PsnDetail","width=600,height=400");
}
function ShowWorkHistory(billId,pid)
{
	Telligent_Modal.Open("/stms/prpWorkHistory.do?action=listHistory&billId="+billId+"&pid="+pid, 500, 300);
}

function ShowPrpDetailForReview(prpCode)
{
	OpenWin("/stms/prpPrepareEdit.do?Action=ShowDetail&review=1&prpCode="+encodeURIComponent(prpCode),"PrpDetail");
}
function ShowPrpDetail(posCode)
{
	OpenWin("/stms/prpPrepareEdit.do?Action=view&posCode="+encodeURIComponent(posCode),"PrpDetail");
}
function ShowPrjDetail(prjCode)
{
	OpenWin("/stms/arcProject.do?action=prjview&prjCode="+encodeURIComponent(prjCode),"PrjDetail");
}

function ShowOrgCrDetail(crGroupCode)
{
	OpenWinBig("/stms/orgCr.do?action=orgCrDetailView&cr_group_code="+encodeURIComponent(crGroupCode),"OrgCrDetail");
}
function ShowOrgCrDetailNoEncode(crGroupCode)
{
	OpenWinBig("/stms/orgCr.do?action=orgCrDetailView&cr_group_code="+crGroupCode,"OrgCrDetail");
}
function ShowPrjCrDetail(crGroupCode)
{
	OpenWinBig("/stms/prjCr.do?action=prjCrDetailView&cr_group_code="+encodeURIComponent(crGroupCode),"PrjCrDetail");
}
function ShowPrjCrDetailNoEncode(crGroupCode)
{
	OpenWinBig("/stms/prjCr.do?action=prjCrDetailView&cr_group_code="+crGroupCode,"PrjCrDetail");
}


function ShowActDetail(actCode)
{
	OpenWin("/stms/actPrepare.do?Action=view&actCode="+encodeURIComponent(actCode),"ActDetail");
}
function AdminViewProposal(posCode,isOnline)
{
	if(isOnline!='0')
	{
		OpenWin("/stms/prpPrepareEdit.do?Action=adminView&posCode="+encodeURIComponent(posCode),"PrpAdminDetail");
	}
	else
	{
		OpenWin("/stms/offlinePrpUpload.do?Action=adminView&posCode="+encodeURIComponent(posCode),"PrpAdminDetail");
	}
}
function ShowCtrDetail(ctrCode)
{
	OpenWin("/stms/ctrPrepare.do?Action=view&ctrCode="+encodeURIComponent(ctrCode),"ctrDetail");
}


function ShowPrpHistoryDetail(OrderID)//立项项目历史数据查询的申报书
{
	OpenWin("/stms/proListQuery.do?action=prpHistoryDetail&OrderID="+encodeURIComponent(OrderID),"prpHistoryDetail");
}

function ShowPrpCtrHistoryDetail(prpOrderID)//立项项目历史数据查询的合同
{
	OpenWin("/stms/proListQuery.do?action=prpCtrHistoryDetail&prpOrderID="+encodeURIComponent(prpOrderID),"prpHistoryDetail");
}

function ShowSbPsnDetail(posCode,sequence_no)//查看申报书上申报人信息
{	
	OpenWin("/stms/PrpPrepareJLEdit.do?action=prpSbPsnMsg&posCode="+encodeURIComponent(posCode)+"&sequence_no="+encodeURIComponent(sequence_no),"prpSbPsnDetail","width=600,height=400");
}

function ShowSbOrgDetail(posCode,sequence_no)//查看申报书上主要完成单位信息
{	
	OpenWin("/stms/PrpPrepareJLEdit.do?action=prpSbOrgMsg&posCode="+encodeURIComponent(posCode)+"&sequence_no="+encodeURIComponent(sequence_no),"prpSbOrgDetail","width=600,height=400");
}

function ShowCtrEditLog(ctrCode)
{
	//OpenWin("/stms/ctrApprove.do?action=viewlog&ctrCode="+encodeURIComponent(ctrCode),"ctrEditLog");
	
	Telligent_Modal.Open("/stms/ctrApprove.do?action=viewlog&ctrCode="+encodeURIComponent(ctrCode), 500, 300);
}
function showActResultDetail(actCode)
{
	OpenWin("/stms/actResult.do?action=view&actCode="+encodeURIComponent(actCode),"actResultView");
}
function ShowCtrDetailBtn(ctrCode)
{
	OpenWin("/stms/ctrPrepare.do?Action=view&ctrCode="+ctrCode,"ctrDetail");
}
function ShowPrdSubmitForm(prpCode)
{
	//OpenWin("/stms/prpProceeding.do?Action=load&prpCode="+encodeURIComponent(prpCode),"prdSubmit");
	var url="/stms/prpProceeding.do?Action=load&prpCode="+encodeURIComponent(prpCode);
	var name="prdSubmit";
	var newwin =window.open(url,name,"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		//newwin.resizeTo(screen.width,screen.height);
		
		newwin.resizeTo(800,600);
	}
}
function ShowPrdSubmitFormNoEncode(prpCode)
{
	var url="/stms/prpProceeding.do?Action=load&prpCode="+prpCode + "&EncodeType=NoEncode";
	var name="prdSubmit";
	var newwin =window.open(url,name,"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		//newwin.resizeTo(screen.width,screen.height);
		
		newwin.resizeTo(800,600);
	}
}
function ShowPrdBatchSaveForm(grantCode,proceeding_id,height)
{
	var url="/stms/prpProceeding.do?Action=BatchView&grantCode="+encodeURIComponent(grantCode)+"&proceeding_id="+encodeURIComponent(proceeding_id);
	var name="prdBatchSave";
	
	if(height=='')height=150;
		if(height>=600)height=600;
		
	window.showModalDialog(url,window,'dialogWidth:750px;dialogHeight:'+height+'px;status:no;help:no');
	
	/*var newwin =window.open(url,name,"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		
		newwin.resizeTo(800,height);
	}*/
}
function ShowPublicDetailView(detailCode)
	{
		if(detailCode=='')return false;
		var url="/stms/publicDetail.do?Action=viewdetail&detailCode="+detailCode;
		var name="publicDetailView";
	
	
		var newwin =window.open(url,name,"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
		if(document.all){
			newwin.moveTo(50,50)//新窗口的坐标
		
			newwin.resizeTo(800,440);
		}
	}

function ShowPrdDetail(prpCode)
{
	OpenWin("/stms/prpProceeding.do?Action=view&prpCode="+encodeURIComponent(prpCode),"prdShowDetail");
}
//项目组
function ShowEvExpertList(group_code,review_org_code)
{
	OpenWin("/stms/evProgress.do?action=expert&groupcode="+group_code+"&department="+review_org_code,"expert");
}
//项目组,专家
function ShowEvPrpList(group_code,psn_code)
{
	OpenWin("/stms/evProgress.do?action=unsubmit&groupcode="+group_code+"&psncode="+psn_code,"unsubmit");
}
function ShowGroupPrp(group_code,review_org_code)
{
	OpenWin("/stms/evProgress.do?action=prplist&groupcode="+group_code+"&department="+review_org_code,"prplist");
}
function ShowEvAvoidList(group_code,review_org_code)
{
	OpenWin("/stms/evProgress.do?action=avoid&groupcode="+group_code+"&department="+review_org_code,"avoid");
}
//分组详情
function ViewGroup(gid)
{
	window.showModalDialog("/stms/evGroup.do?action=viewGroup&mode=view&groupCode="+gid,window,'dialogWidth:380px;dialogHeight:300px;status:no;help:no');			
}
//项目,action_flag:1表示查看,2表示汇总
function ShowEvResultPrp(prp_code,action_flag)
{
	var action='';
	switch(action_flag)
	{
		case 1:
		  action='forView';
		  break;
		case 2:
		  //action='stat#_ev_comment'; 
		  action = 'forComment';
		  break;
		case 3:
		  action='verify#_dept_comment';
		  break;
		case 4:
		  action = 'forReviewerComment';
		  break;
		
	}
	var url="/stms/evResult.do?prpcode="+prp_code+"&action="+action;
	var name="";
	//OpenWin("/stms/evResult.do?prpcode="+prp_code+"&action="+action);
	var newwin =window.open(url,name,"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		//newwin.resizeTo(screen.width,screen.height);
		
		newwin.resizeTo(800,600);
		
	}
}
 
// objDiv          显示生成列表的容器
// prp_code        项目的prp_code
// endFunction     数据加载结束,调用的方法, null or "" 不执行.
// startFunction   开始加载数据调用的函数
function showEvResultPrpDetailList(objDiv,prp_code,commentType,pageIndex,pageSize,startFunction,endFunction)
{
	if(startFunction != null && startFunction != "") eval(startFunction);
			  
	createXmlHttpRequest();
	var url = "/stms/evResult.do?action=forAjaxView&prpcode=" + prp_code + "&page=" + pageIndex + "&objectsPerPage=" + pageSize + "&commentType=" + commentType;
	xmlHttpRequest.open('POST',url,true);
	xmlHttpRequest.send(null);
	
	xmlHttpRequest.onreadystatechange = function () 
	{
		  if(xmlHttpRequest.readyState == 4)
		  {
		     var rtnValue = xmlHttpRequest.responseText;
		     
			 objDiv.innerHTML = rtnValue;
			 if(endFunction != null && endFunction != "") eval(endFunction);
		  }
	}
}
//不分页的
function showEvResultPrpDetailListAll(objDiv,prp_code,commentType,startFunction,endFunction)
{
	if(startFunction != null && startFunction != "") eval(startFunction);
			  
	createXmlHttpRequest();
	var url = "/stms/evResult.do?action=forAjaxAllView&prpcode=" + prp_code + "&commentType=" + commentType;
	xmlHttpRequest.open('POST',url,false);
	xmlHttpRequest.send(null);
	
	//xmlHttpRequest.onreadystatechange = function () 
	//{
		  //if(xmlHttpRequest.readyState == 4)
		  //{
		     var rtnValue = xmlHttpRequest.responseText;
		     
			 objDiv.innerHTML = rtnValue;
			 if(endFunction != null && endFunction != "") eval(endFunction);
		  //}
	//}
}

function ShowFAQ()
{
	OpenWin("/stmscommon/helppage/faq.html","FAQ");
}

function OpenWin(url,name,params)
{
	if(!params) 
		params="";
	else
		params = params+",";
 	var newwin = window.top.open(url,name,params+"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		//newwin.resizeTo(screen.width,screen.height);
		if(params.indexOf("width")==-1)
		{
			newwin.resizeTo(800,600);
		} 
	}
}

function OpenWinBig(url,name,params)
{
	if(!params) 
		params="";
	else
		params = params+",";
 	var newwin = window.top.open(url,name,params+"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		//newwin.resizeTo(screen.width,screen.height);
		if(params.indexOf("width")==-1)
		{
			newwin.resizeTo(900,600);
		} 
	}
}

function OpenWinUserDefined(url,name,params,width,height)
{
	if(!params) 
		params="";
	else
		params = params+",";
 	var newwin = window.top.open(url,name,params+"scrollbars=yes,toolbar=no,menubar=no,titlebar=no,status=no,resizable=yes,menubar=no");
	if(document.all){
		newwin.moveTo(50,50)//新窗口的坐标
		//newwin.resizeTo(screen.width,screen.height);
		if(params.indexOf("width")==-1)
		{
			newwin.resizeTo(width,height);
		} 
	}
}

var xmlHttpRequest = null;
function createXmlHttpRequest()
{
	if(xmlHttpRequest == null)
	{
	   if(window.ActiveXObject)  //IE和其他的浏览器实现XMLHttpRequest的方式不同
	   {                   
	      xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   else
	   {
	      xmlHttpRequest = new XMLHttpRequest();
	   }
	}
}

function getNewXmlHttpRequest()
{
	var xmlHttp;
	if(window.ActiveXObject)  //IE和其他的浏览器实现XMLHttpRequest的方式不同
   {                   
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   else
   {
      xmlHttp = new XMLHttpRequest();
   }
	
	return xmlHttp;
}

function checkAttachType(f)
{
	f = f.toLowerCase();
	if ((f.indexOf(".jpg")!=f.length-4)
		&&(f.indexOf(".pdf")!=f.length-4)
		&&(f.indexOf(".tiff")!=f.length-5))
	{
		return false;
	}
	return true;
}

function setCalendarDate(obj,inputDesc)
{

                    var dateValue=obj.value.trim();
					var objid = obj.id.substring(5,obj.id.length);                    
					if(dateValue!=inputDesc)                     
						{ document.getElementById(objid).value=dateValue;}
					else 
						{document.getElementById(objid).value='';}

}
function setBillViewFlag(billid,processid,viewflagid)
{
	createXmlHttpRequest();
	var url = "/stms/ajax.do?DataType=SetBillViewFlag";
				
	var postdata="&billid="+encodeURIComponent(billid)+"&processid="+encodeURIComponent(processid);
	xmlHttpRequest.open('POST',url,false);
	xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlHttpRequest.send(postdata);
	var rtnValue = xmlHttpRequest.responseText;
	
	//alert(rtnValue);			
	if(parseFloat(rtnValue)>0)
	{
		var obj=document.getElementById(viewflagid);
		if(obj)
		{
			obj.innerHTML='已查看';
		}
	}
}

function getBillViewFlag(billid,processid)
{
	createXmlHttpRequest();
	var url = "/stms/ajax.do?DataType=GetBillViewFlag";
				
	var postdata="&billid="+billid+"&processid="+processid;
	xmlHttpRequest.open('POST',url,false);
	xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlHttpRequest.send(postdata);
	var rtnValue = xmlHttpRequest.responseText;
	
	//alert(rtnValue)			
	if(rtnValue=='1')
	{
		return '已查看';
	}
	else
	{
		return '未查看';
	}
}

		function showWorkSateGrid(workName,itemCode)
		{
				if(document.getElementById('item_griddiv'+itemCode))
				{
					createXmlHttpRequest();
					var url = "/stms/workState.do?action=ajaxGetDataGrid&itemCode="+itemCode;
					xmlHttpRequest.open('POST',url,false);
					xmlHttpRequest.send(null);
				
					var dataGrid=xmlHttpRequest.responseText;
				
					document.getElementById('item_griddiv'+itemCode).parentElement.innerHTML=dataGrid;
				}
				document.getElementById('item_grid'+itemCode).style.display='';
		}
		function showhideWorkSateGrid(workCode,itemCode)
		{
			var display=document.getElementById('item_grid'+itemCode).style.display;
			if(display=='')
			{
				document.getElementById('item_grid'+itemCode).style.display='none';
			}
			else
			{
				showWorkSateGrid(workCode,itemCode);
			}
		}
		function showWorkState(workCode)
		{
			OpenWin("/stms/jsp/WorkState/workState.jsp?workCode="+workCode,"workState");
		}

		
function checkAttachTypeNew(f)
{//alert(f);
	f = f.toLowerCase();
	if ((f.indexOf(".jpg")!=f.length-4)
		&&(f.indexOf(".pdf")!=f.length-4)
		)
	{
		return false;
	}
	return true;
}
function ClearCriteriaAndOrderBy()
{
	var obj = document.getElementById("_dyn_criteria1_field");
	if(obj!= null)
	{
		obj.options.selectedIndex = 0;
	}
	obj = document.getElementById("_dyn_criteria2_field");
	if(obj!= null)
	{
		obj.options.selectedIndex = 0;
	}
	obj = document.getElementById("_dyn_criteria1_c");
	if(obj!= null)
	{
		if(obj.tagName == "SELECT")
		{
			obj.children[0].options.selectedIndex = 0;
		}
		else
		{
			obj.children[0].value = "";
		}
	}
	obj = document.getElementById("_dyn_criteria2_c");
	if(obj!= null)
	{
		if(obj.tagName == "SELECT")
		{
			obj.children[0].options.selectedIndex = 0;
		}
		else
		{
			obj.children[0].value = "";
		}
	}
	obj = document.getElementById("_dyn_order_field_1");
	if(obj!= null)
	{
		obj.options.selectedIndex = 0;
	}
	obj = document.getElementById("_dyn_order_field_2");
	if(obj!= null)
	{
		obj.options.selectedIndex = 0;
	}
	
	
	/*document.getElementById("_dyn_criteria1_field").value = "";
	document.getElementById("_dyn_criteria2_field").value = "";
	var obj1 = document.getElementById("_dyn_criteria1_c");
	var obj2 = document.getElementById("_dyn_criteria2_c");
	obj1.children[0].value = "";
	obj2.children[0].value = "";

	document.getElementById("_dyn_order_field_1").value = 0;
	document.getElementById("_dyn_order_field_2").value = 0;*/
}

function getSpan(text)
{
	var node = document.createElement("span");
	node.innerHTML=text+"&nbsp;";
	return node;
}
	
function refreshBr()
{
	var allObj = document.getElementsByTagName("TEXTAREA");
	var len=allObj.length;
	for(var i = len-1; i >=0; i--)
	{
		
		var tag=allObj[i];
		var p = tag.parentElement;
		if(!p) p = document;

		if(/\r(\n)?/g.test(tag.value)==true)
			{
				newTag = getSpan(tag.value.replace(/\r(\n)?/g,"<br>"));
			}
			else
			{
				newTag = getSpan(tag.value);
			}
		
			p.replaceChild(newTag,tag);
	}
}
		function selectAll(cb)
		{
			var tb = document.getElementById("Table01");
			var rows = tb.rows;
			for(var i=0;i<rows.length;i++)
			{
				var tr = rows[i];
				var td = tr.childNodes[1];
				var c = td.childNodes[0];
				if(c && c.disabled==false)
				{
					c.checked = cb.checked;
				}
			}
		}
		//评审表查询项目承担单位性质
		function isBigOrg(){
 		try{
 			var spanObj = window.parent.document.frames("top");
 			var prpCode = "${prpCode}";
	 		var url="evaluation.do";
			var pars="action=isBigOrg&prpCode="+prpCode;
			var myAjax=new Ajax.Request(url,{method:'post',parameters:pars,onComplete:AjaxSetOption});
		 	}catch(exception){
	 			alert("本功能为专家提示评审项目的承担单位，此处本功能无效！");
	 			return false;
	 		}
	 	}
		function selectOne(cb)
		{
			var all = document.getElementById("cbAll");
			all.checked = cb.checked;
			if(cb.checked==false)
				return;
				
			var tb = document.getElementById("Table01");
			var rows = tb.rows;
			for(var i=0;i<rows.length;i++)
			{
				var tr = rows[i];
				var td = tr.childNodes[1];
				var c = td.childNodes[0];
				if(c && c.checked==false)
				{
					all.checked = false;
					return;
				}
			}
		}
		function GetSelectedValues()
		{
			var tb = document.getElementById("Table01");
			var rows = tb.rows;
			var codes = "";
			for(var i=1;i<rows.length;i++)
			{
				var tr = rows[i];
				var cb = tr.childNodes[1].childNodes[0];
				if(cb && cb.checked&&cb.disabled==false)
				{
					codes += ","+cb.value;
				}
			}
			if(codes!="")
			{
				codes = codes.substring(1);
				var hid = document.getElementById("selectedValues");
				hid.value = codes;
				return true;
			}
			return false;
		}
		function relationSwitch(aId,bId,cId,dId)
		{
			var obj1 = document.getElementById(aId);//必需
			var obj2 = document.getElementById(bId);//可选
			var obj3 = document.getElementById(cId);//必需
			obj3.length=0;

			var obj_hide = document.getElementById(dId);//隐藏域
			obj3.options[obj3.length] = new Option('','');
			
			for(var i=0;i<obj_hide.length;i++)
			{
				var v = obj_hide.options[i].value;
				var t = obj_hide.options[i].text;		
				var vs=v.split('-');

				//在dId存储的值的格式：code-obj1.value-obj2.value 在const_category里面配置
				if(obj2!=null)
				{
				    if(vs[1]==obj1.value&&vs[2]==obj2.value)
				    {
					    v = vs[0]; 
					    obj3.options[obj3.length] = new Option(t, v);
				    }
				    else
				    {
					    if(obj1.value == "")
					    {
						    if(vs[2]==obj2.value)
						    {
							    v = vs[0]; 
							    obj3.options[obj3.length] = new Option(t, v);
						    }
					    }
					    else if(obj2.value == "")
					    {
						    if(vs[1]==obj1.value)
						    {
							    v = vs[0]; 
							    obj3.options[obj3.length] = new Option(t, v);
						    }
					    }
				    }
				}
				else
				{
				    if(vs[1]==obj1.value)
				    {
					    v = vs[0]; 
					    obj3.options[obj3.length] = new Option(t, v);
				    }
				    else if(obj1.value=="")
				    {
				        v = vs[0]; 
					    obj3.options[obj3.length] = new Option(t, v);
				    }
				}
			}
		}


