/**
author:yuexinlin
date:2003-12-2
*/
var allSelectUser_status=false;
var rowID="";
var isHide = true;
/**
功能描述：打开对话框无返回值
参数说明:
	strUrl:file path 文件路径
	strWidth:dialog width 对话框宽度
	strHeight：dialog height 对话框高度
*/
function showDialog(strUrl,strWidth,strHeight){
	var strResult=showModalDialog(strUrl,null, 'dialogWidth='+strWidth+'px;dialogHeight='+strHeight+'px;center:1;scroll:1;help:0; status:0');
	if(strResult==null){return "";	}
	//txtName.value=strResult;
	//txtName.focus();
}
/**
功能描述：打开对话框并返回值
参数说明:
	txtName:需要被返回的Name值
	strUrl:文件路径
	strWidth:对话框宽度
	strHeight:对话框高度
*/
function returnShowDialog(txtName,strUrl,strWidth,strHeight)
{
	var strResult=showModalDialog(strUrl,null, 'dialogWidth='+strWidth+'px;dialogHeight='+strHeight+'px;center:1;scroll:1;help:0; status:0');
	if(strResult==null){
		return "";
	}
	txtName.value=strResult;
	txtName.focus();
}
/**
功能描述：打开新窗口,窗口居中,当窗口高度小于200时，窗口上移；窗口高度大于500时，窗口下移
参数说明:
	strUrl:文件路径
	strWidth:窗口宽度
	strHeight:窗口高度
	scrollTrue:滚动条是否滚动 0 不滚动，1 滚动
*/
function openWin(strUrl,strWidth,strHeight,scrollTrue){
		var screenHeight = screen.availHeight/2-strHeight/2-15;
		if (strHeight<200) {
			var screenHeight = screen.availHeight/2-strHeight/2-150;
		}
		if (strHeight>=500) {
			var screenHeight = screen.availHeight/2-strHeight/2-30;
		}
		var screenWidth = screen.availWidth/2-strWidth/2;
		window.open(strUrl,null,'WIDTH='+strWidth+',HEIGHT='+strHeight+',top='+screenHeight+',left='+screenWidth+',scrollbars='+scrollTrue+'');

}
/**
功能描述：表格某一行变色
参数说明：
	RowColor:表格颜色
	theRowID:行的object值
*/
function disRow(RowColor,theRowID){
  if(rowID!=theRowID) {
	theRowID.bgColor=RowColor;
  }
}
/**
功能描述：当某一行被选择时，颜色改变，在未选择前颜色始终不再改变，当重新选择行时，颜色恢复原值
参数说明：
	curTheRow:当前被选择行
	TheRowColor:被选择行颜色
	rowColor:原值
*/
function curRow(curTheRow,TheRowColor,rowColor){
	if (rowID!="") {
	 rowID.bgColor = rowColor;
	}
	rowID=curTheRow;
	curTheRow.bgColor=TheRowColor;
}
function getRadioSelectId(optValue)
{
	for(var i=0;i<optValue.length;i++){
		if(optValue[i].checked==true){
			return i;
		}
	}
}
/**
功能描述：返回复选框的选择值
参数说明：
	optValue：object值
*/
function getCheckBoxSelectedValue(optValue) {
	var varChk="";
	for(var i=0;i<optValue.length;i++){
		if (optValue[i].name!="checkbox") {
			if(optValue[i].checked==true) {
				varChk = varChk + optValue[i].value+ ","
			}
		}
	}
	return varChk
}
/**
功能描述：是否选择
参数说明：
	optValue：object值
备注：object的name属性的值未'id',否则将报错
*/
function isSelect(optValue){
    var i=0;
	for (j=0;j<optValue.length;j++) {
		if (optValue[j].checked==true) i++
	}
	if (i==0) return true;
	return false;
} 
/**
功能描述：对记录操作前进行是否选择判断，未选则不执行
参数说明：
	frm：object值
 strUrl: 操作该记录的文件路径
*/
function selRecord(frm,strUrl){
	if (isSelect(frm)){
		alert("请选择要操作的记录");
		return false;
	} else {
		frm.action=strUrl;
		frm.submit();
	}
}
/**
功能描述：对记录删除前进行是否选择判断，未选则不执行删除操作
参数说明：
	frm：object值
 strUrl: 操作该记录的文件路径
*/
function delRecord(frm,strUrl){
	if (isSelect(frm)){
		alert("请选择要删除的记录");
		return false;
	} 
	else {
			return delBut(frm,strUrl);
	}
}
/**
功能描述：按钮删除
参数说明：
	strValue：提示信息内容
*/
function delBut(frm,strUrl){
			if (confirm("确定要删除该权限信息吗?")) {
				frm.action=strUrl;
				frm.submit();
			} 
			else {return false;}
}
/**
/**
功能描述：按钮操作
参数说明：
	strValue：提示信息内容
*/
function handleBut(frm,strUrl,alertInfo){
			if (confirm(alertInfo)) {
				frm.action=strUrl;
				frm.submit();
			} 
			else {return false;}
}
/**
功能描述：给出提示信息
参数说明：
	strValue：提示信息内容
*/
function msgbox(strValue){
	alert(strValue);
	return;
} 
/**
功能描述：对复选框进行全选操作
参数说明：
	optValue：object值
	  status：boolean值
*/
function allSelect(optValue,status){
    var i=0;
	for (var j=0;j<optValue.length;j++ ) {
			if(optValue[j].checked==status)
			{optValue[j].checked=!status;}

	}
	return true;
} 
/**
功能描述：对复选框进行全选操作
参数说明：
	objForm：object值
	 status：boolean值
*/
function allSelectCheck(objForm,status){
	if (status!=null) {
		if(!allSelectUser_status) {
			 allSelect(objForm,allSelectUser_status);
		}
		else { allSelect(objForm,allSelectUser_status);	}
		allSelectUser_status = !allSelectUser_status;
	} 
	else {
		if(!allSelectUser_status) {
			 allSelect(objForm,allSelectUser_status);
		} 
		else { allSelect(objForm,allSelectUser_status);	}
		allSelectUser_status = !allSelectUser_status;
	}
 }
/**
功能描述：简单图层文字隐藏/显示
参数说明：
     objForm：层object值
     textObj: 文字object值
textHideInfo：隐藏时文字
 textDisInfo：显示时文字
*/
function disLayer(objForm,textObj,textHideInfo,textDisInfo){
    if (isHide) {
		objForm.style.display="";
		if (textHideInfo!="") textObj.innerHTML = textHideInfo;
    } 
	else {
		objForm.style.display="none";
		if (textHideInfo!="") textObj.innerHTML = textDisInfo;
	}
	isHide =!isHide
}
/**
功能描述：
参数说明：

*/
function changeImg(m,n,openUrl,closeUrl){
  	n = n-1;
	if (imglayer[n].src==openUrl){
		imglayer[n].src = closeUrl;
    } 
	else{ imglayer[n].src = openUrl;
	}
	for(var j=0;j<m;j++){
			if(j!=n) if (imglayer[n].src==openUrl) imglayer[j].src = closeUrl;  
	}
}
/**
功能描述：当鼠标移上时变换图片
参数说明：
*/
function ImgRestore() {
  var i,x,a=document.MM_sr;
   for(i=0;a && i<a.length && (x=a[i]) && x.oSrc;i++) x.src=x.oSrc;
}
function findObj(n, d) {
  var p,i,x; 
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0 && parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document;
	n=n.substring(0,p);
   }
  if(!(x=d[n]) && d.all) x=d.all[n]; 
  for (i=0;!x && i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x && d.layers && i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);
   return x;
}
function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){
   	document.MM_sr[j++]=x; 
	if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
 }
}
//结束当鼠标移上时变换图片
function popmenu(n,openUrl_1,closeUrl_1,openUrl_2,closeUrl_2) {
	n = n-1
	var lenVar = layer.length;
	if (lenVar<1) 	lenVar =1; 
	if (lenVar == 1) {
		if (layer.style.display=="none"){
			layer.style.display="";
			document.form1.imglayer01.src = openUrl_1;
			document.form1.imglayer02.src = openUrl_2;
		} else {
			layer.style.display="none";
			document.form1.imglayer01.src = closeUrl_1;
			document.form1.imglayer02.src = closeUrl_2;
		}
	 } else {
	  	if (layer[n].style.display=="none"){
			layer[n].style.display="";
			document.form1.imglayer01[n].src = openUrl_1;
			document.form1.imglayer02[n].src = openUrl_2;
		}else{
			layer[n].style.display="none";
			document.form1.imglayer01[n].src = closeUrl_1;
			document.form1.imglayer02[n].src = closeUrl_2;
		}
	 }
	for(var j=0;j<lenVar;j++){
		if(j!=n) {
			if (layer[n].style.display=="") {
				layer[j].style.display="none";
				document.form1.imglayer01[j].src = closeUrl_1;
				document.form1.imglayer02[j].src = closeUrl_2;
			} 
		} 
	}	
}	

function popmenuNoPicNoHide(n) {
	n = n-1
	var lenVar = document.all.layer.length;
	//parent.mainFrames.location.href=url;
	if (lenVar!=1) {
		if (lenVar>=2){ 
			lenVar =lenVar;
		}else{
			lenVar=1;
		}
	} 
	if (lenVar == 1) {
		if (layer.style.display=="none"){
			layer.style.display="";
		}else{
			layer.style.display="none";
		}
	 } else {
	  	if (layer[n].style.display=="none"){
			layer[n].style.display="";
		}else	{
			layer[n].style.display="none";
		}
	 }
		for(var j=0;j<lenVar;j++){
			if(j!=n) {
				if (layer[n].style.display=="") {
					layer[j].style.display="none";
				} 
			} 
		}
}
function SelectUserAccess1(v)
{
	for (var i=0;i<document.form1.elements.length;i++)
	{
	     var zl = document.form1.elements[i];
		 if ((zl.name == 'UserAccess')&&(zl.value==v))
		 {
		  if (zl.checked==Flag)
		  {
		  zl.checked=!Flag;
		  }
		 }
	}
}
function SelectUserAccess(v)
{
	for (var i=0;i<document.form1.elements.length;i++)
	{
	     var zl = document.form1.elements[i];
		 if ((zl.name == 'UserAccess1')&&(zl.value==v))
		 {
		  if (zl.checked==Flag)
		  {
		  zl.checked=!Flag;
		  }
		 }
	}
}


function doMouseOver(obj) {
	obj.style.backgroundColor="#A7CDFB";
}
function doMouseOut(obj) {
	obj.style.backgroundColor="#FFFFFF";
}

 
 var Flag=false;
function SelectAll()
{
	for (var i=0;i<document.form1.elements.length;i++)
	{
	     var zl = document.form1.elements[i];
		 if (zl.name == 'chkId')
		 {
		 zl.checked="true";
		 }
	}
	  Flag=!Flag;
}

function NewsDelete(sname,sort)
{
	var v;
	v="";
	for (var i=0;i<document.form1.elements.length;i++)
	{
      var zl = document.form1.elements[i];
	  	if ((zl.name == 'chkId') && (zl.checked==true))
		{
	    	if (v=="")
		    	v=zl.value;
	    	else
	    		v=v+","+zl.value;
		}
   	}	  
   	if (v=="")
    {
		alert("请选择要删除的文章信息!!");
		return false;
    }
    else
    {
		if (confirm("确实要删除选中的文章吗?"))
			self.location.href="news_Delete.asp?Id="+v+"&sort="+sort+"&page=Auditing";
	}
	return false;
}
