function fullBody(id){//disp 差量
var disp=448;
var obj=document.getElementById(id);
obj.style.height=document.body.clientHeight-disp;
}

function showCalendar(objID){
  var curDate=document.getElementById(objID).value;
  var arr = showModalDialog("Calendar.jsp?curDate="+curDate,"","font-family:Verdana; font-size:10; dialogWidth:220px; dialogHeight:220px;scroll=no;status=no" );
  if(arr!=null && arr.length>0 && (arr+"") != "undefined"){
    document.getElementById(objID).value=arr;
  }
}

//动态添加页面载入事件(window.onload)
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//去除首尾空格
String.prototype.Trim  =  function()
{
return this.replace(/(^\s*)|(\s*$)/g,"");
}

//打开新窗口
function open_win(url,name,width,height,scrollbars,status,titlebar){
  p_left=(window.screen.width-width-40)/2;
  p_top=(window.screen.height-height-40)/2;
  handle=window.open(url,name,"left="+p_left+",top="+p_top+",height="+height+",width="+width+",status="+status+",scrollbars="+scrollbars+",location=no,titlebar="+titlebar);
  handle.focus();
  return handle;
}
function win_open(url,name,width,height,scrollbars,status,titlebar){
  p_left=(window.screen.width-width-40)/2;
  p_top=(window.screen.height-height-40)/2;
  handle=window.open(url,name,"left="+p_left+",top="+p_top+",height="+height+",width="+width+",status="+status+",scrollbars="+scrollbars+",titlebar="+titlebar);
  handle.focus();
  return handle;
}

//关闭窗口
function win_close(){
  try{
    top.opener=null;
    window.close();
    top.opener.window.focus();
  }catch(e){}
}
function close_win(){
  try{
    top.opener=null;
    window.close();
    top.opener.window.focus();
  }catch(e){}
}

//刷新窗口
function win_flush(){
  window.location.reload();
}
function flush_win(){
  window.location.reload();
}

function strReplace(str,str1,str2){
   while(str.search(str1) > -1) str=str.replace(str1,str2);
   return str;
}

function GetOffsetLeft(src){
	try{
		var l1,vParent1;
		l1 = src.offsetLeft;
		vParent1 = src.offsetParent;
		while (vParent1.tagName.toUpperCase() != "BODY")
		{
			l1 += vParent1.offsetLeft;
			vParent1 = vParent1.offsetParent;
		}
		return l1;		
	}catch(e){}
}
function GetOffsetTop(src){
	try{
		var t1,vParent1;
		h1 = src.offsetHeight;
		t1 = src.offsetTop + h1 ;
		vParent1 = src.offsetParent;
		while (vParent1.tagName.toUpperCase() != "BODY")
		{
			t1 += vParent1.offsetTop;
			vParent1 = vParent1.offsetParent;
		}
		return t1;	
	}catch(e){}
}

function boxSelAll(allID,boxName){
  var box=document.getElementById(allID);
  box.checked=true;
  var arr=eval("document.all."+boxName);
  if(!arr) return;
  for(i=0;i<arr.length;i++){
    if(!arr[i].checked){
      box.checked=false;
      break;
    }
  }
}

function selAllBox(selAll,names){
  var typeArr=eval("document.all."+names)
  if(!typeArr) return;
  if(selAll.checked){
    for(i=0;i<typeArr.length;i++) typeArr[i].checked=true;
  }else{
    for(i=0;i<typeArr.length;i++) typeArr[i].checked=false;
  }
}
function unCheckBox(element){
  try{
    document.getElementById(element).checked=false;
    var arr=eval("document.all."+element);
    for(i=0;i<arr.length;i++) arr[i].checked=false;
  }catch(e){}
}

function fixCheckBox(name,valueStr,seperator){
  var strArr=valueStr.split(seperator);
  var elementArr=eval("document.all."+name);
  for(i=0;i<elementArr.length;i++){
    for(j=0;j<strArr.length;j++){
      if(elementArr[i].value==strArr[j]){
        elementArr[i].checked=true;
        continue;
      }
    }
  }
}

function fixRadio(name,value){
  var elementArr=eval("document.all."+name);
  for(i=0;i<elementArr.length;i++){
    if(elementArr[i].value==value){
      elementArr[i].checked=true;
      break;
    }
  }
}

function fixSingleBox(id,v){
  var obj=document.getElementById(id);
  if(obj) obj.checked=(obj.value==v);
}

function fixSelect(id,v){
  var obj=document.getElementById(id);
  for(i=0;i<obj.options.length;i++){
    if(obj.options[i].value==v){
      obj.selectedIndex=i;
      break;
    }
  }
}

//获得复选框选中的内容
function getCheckBox(elementName){
	var selected="";
	var arr=eval("document.all."+elementName);
	if(arr && arr.length){
		for(i=0;i<arr.length;i++){
			if(arr[i].checked) selected+=arr[i].value+",";
		}
	}else{
		obj=eval("document.all."+elementName);
		if(obj && obj.checked) selected=obj.value+",";
	}
	if(selected.length>0) selected=selected.substring(0,selected.length-1);
	
	return selected;
}

//获得静态页面的url参数
function getQueryString(queryStringName)
{
   var returnValue="";
   var URLString=new String(document.location);
   var serachLocation=-1;
   var queryStringLength=queryStringName.length;
   do
   {
    serachLocation=URLString.indexOf(queryStringName+"\=");
    if (serachLocation!=-1)
    {
     if ((URLString.charAt(serachLocation-1)=='?') || (URLString.charAt(serachLocation-1)=='&'))
     {
      URLString=URLString.substr(serachLocation);
      break;
     }
     URLString=URLString.substr(serachLocation+queryStringLength+1);
    }

   }
   while (serachLocation!=-1)
   if (serachLocation!=-1)
   {
    var seperatorLocation=URLString.indexOf("&");
    if (seperatorLocation==-1)
    {
     returnValue=URLString.substr(queryStringLength+1);
    }
    else
    {
     returnValue=URLString.substring(queryStringLength+1,seperatorLocation);
    }
   }
   return returnValue;
}

//获得radio选中的值
function getRadioValue(elementsName)
{
      value="";
    if(!eval("document.all."+elementsName)) return;
    var arr=eval("document.all."+elementsName);
    for(i=0;i<arr.length;i++)
    {
      if(arr[i].checked){
        value=arr[i].value;
        break;
      }
    }
    return value;
}

function clearOptions(obj){
    var length=obj.options.length;
    for(i=length-1;i>=0;i--){
      obj.options.remove(i);
    }
}
function addOption(obj,label,value){
    obj.add(new Option(label,value));
}
function getCurrentOptionValue(obj){
    var value=obj.options[obj.selectedIndex].value;
    return value;
}
function getcurrentOptionLabel(obj){
    var label=obj.options[obj.selectedIndex].text;
    return label;
}

