//网页中比较通用、常见的JS自定义函数

//以下代码在页面插入一个层，以备弹出信息框使用。
//var PW_x,PW_y;
//document.writeln("<div id=emedPopWin style='display:none;position:absolute;z-index:9999;cursor:move;' onmousedown='PW_x=event.x-emedPopWin.style.pixelLeft;PW_y=event.y-emedPopWin.style.pixelTop;setCapture();' onmouseup='releaseCapture();' onmousemove='movePopWin()'>");
//document.writeln("  <table cellpadding=0 cellspacing=0 width=100% height=100%>");
//document.writeln("    <tr>");
//document.writeln("      <td width=6 height=6><img src=images/popwin_lt.gif width=6 height=6></td>");
//document.writeln("      <td background=images/popwin_t.gif><img src=images/popwin_t.gif width=1 height=6></td>");
//document.writeln("      <td width=6><img src=images/popwin_rt.gif width=6 height=6></td>");
//document.writeln("    </tr>");
//document.writeln("    <tr>");
//document.writeln("      <td background=images/popwin_l.gif><img src=images/popwin_l.gif width=6 height=1></td>");
//document.writeln("      <td align=right valign=top bgcolor='#EBEEF3'>");
//document.writeln("        <img src=images/popwin_close.gif width=20 height=20 onclick=emedPopWin.style.display='none' style=cursor:hand;><br>");
//document.writeln("        <iframe frameborder=0 scrolling=no id=emedPopWinIframe></iframe>");
//document.writeln("      </td>");
//document.writeln("      <td background=images/popwin_r.gif><img src=images/popwin_r.gif width=6 height=1></td>");
//document.writeln("    </tr>");
//document.writeln("    <tr>");
//document.writeln("      <td height=6><img src=images/popwin_lb.gif width=6 height=6></td>");
//document.writeln("      <td background=images/popwin_b.gif><img src=images/popwin_b.gif width=1 height=6></td>");
//document.writeln("      <td><img src=images/popwin_rb.gif width=6 height=6></td>");
//document.writeln("    </tr>");
//document.writeln("  </table>");
//document.writeln("</div>");


function colorChange(obj,color)  //选择列表前面的复选框时，列表行的颜色变化
{
  if(obj.checked)
    obj.parentNode.parentNode.bgColor='#CFE1F5';
  else
    obj.parentNode.parentNode.bgColor=color;
}

function selectAll(obj,name)  //选择表头的复选框，对列表的复选框进行全部选中。
{
  var arr=document.getElementsByName(name);
  for(var i=0;i<arr.length;i++)
    if(arr[i].checked!=obj.checked&&arr[i].tagName=='INPUT'&&arr[i].type=='checkbox')
      arr[i].click();
}


// luocm 添加 2003-6-13 
// 注意在util.jsp中有函数 checkAll(name,status)
// 避免名字冲突这里取名CheckAll
function CheckAll(name)  // 本页全选
{
  var arr;
  if (CheckAll.arguments.length == 1)
    arr=document.getElementsByName(name);
  else 
    arr = document.all.operate.form.elements;
  for(var i = 0;i < arr.length;i++)
    if(arr[i].type == 'checkbox' && arr[i].checked != true)
    	arr[i].click();
}

function UnCheckAll(name) // 本页全消
{
  var arr;
  if (UnCheckAll.arguments.length == 1)
    arr=document.getElementsByName(name);
  else 
    arr = document.all.operate.form.elements;

  for(var i= 0;i < arr.length;i++)
    if(arr[i].type == 'checkbox' && arr[i].checked != false)
      arr[i].click();
}
// 添加结束

function popWin(fileName,width,height)  //“弹”出一个提示信息“层”
{
  emedPopWin.style.display='block';
  emedPopWin.style.width=width+'px';
  emedPopWin.style.height=height+'px';
  emedPopWin.style.pixelLeft=(document.body.clientWidth-width)/2+document.body.scrollLeft;
  emedPopWin.style.pixelTop=(document.body.clientHeight-height)/2+document.body.scrollTop;
  document.all('emedPopWinIframe').width=width-12;
  document.all('emedPopWinIframe').height=height-32;
  document.all('emedPopWinIframe').src=fileName;
}

function movePopWin()  //移动提示信息“层”
{
  if(event.button==1)
  {
    var X=emedPopWin.clientLeft;
    var Y=emedPopWin.clientTop;
    emedPopWin.style.pixelLeft=X+(event.x-PW_x);
    emedPopWin.style.pixelTop=Y+(event.y-PW_y);
  }

}

//忽略空格
function trim(inputVal)
{
	var	inputStr = inputVal;

	//inputStr = inputVal.toString();
	while ((inputStr.charAt(inputStr.length - 1) == " ") || (inputStr.charAt(0)== " ")) {
		if (inputStr.charAt(inputStr.length - 1) == " ")
			inputStr = inputStr.substring(0,inputStr.length - 1);
		if (inputStr.charAt(0) == " ")
			inputStr = inputStr.substring(1,inputStr.length);
	}
	return inputStr;
}