// JavaScript Document
//截掉空格
function trim(str)
{
        if(!str)
            return "";
    	var i = 0;
        while ((i < str.length)&&((str.charAt(i) == " ")||(str.charAt(i) == "　")))
		{
			i++;
		}
    	var j = str.length-1;
    	while ((j >= 0)&&((str.charAt(j) == " ")||(str.charAt(j) == "　")))
		{
			j--;
		}
    	if( i > j ) 
    		return "";
    	else
    		return str.substring(i,j+1);
}
//用指定的XML数据初始化obj列表框
function inzSelect(obj,xmldoc)
{	
	var info=xmldoc.getElementsByTagName('info');
	var t,v;
	obj.length=0;
	obj.options[0]=new Option("请选择",'');
	for(var i=0;i<info.length;i++)
	{	
		t=info[i].getElementsByTagName('Text')[0].firstChild.data;
		v=info[i].getElementsByTagName('Value')[0].firstChild.data;
		obj.options[obj.length]=new Option(t,v);
		   //alert(t);
	}
}

function $(obj)
{
    return document.all?document.all[obj]:document.getElementById(obj);
    //return document.getElementById(obj);
}
//加数据加载到FCKeditor编辑器
function LoadFCKeditorData(inputText)
{
	var oEditor = FCKeditorAPI.GetInstance(this.Id); 
	oEditor.InsertHtml(inputText);
}

//返回指定元素在页面上的绝对坐标
function GetPoint(tmp)
{
	var pt=new Point(0,0);
	do 
	{
		pt.x += tmp.offsetLeft;
		pt.y += tmp.offsetTop;
		tmp = tmp.offsetParent;
	}while(tmp.tagName!="BODY"&&tmp.tagName!="HTML");	
	return pt;
}

function Point(iX,iY)
{
	this.x=iX;
	this.y=iY;
}

//切换当前页
function ReplaceUrl(url)
{
	window.location.replace(url);
}

//////
/////////////////////
function CheckKeyPress()
{
	if (event.keyCode < 46 || event.keyCode > 57) 
	   if(event.keyCode!=13)
	   {
		 alert("只能输入数字符号！");
		 event.returnValue = false;
      }
}
////////////////
function err()
{
	var sVar='输入有误';
	var obj=null;
	switch(arguments.length)
	{
		case 0:
		  // sVar='';
		   break;
		case 1:
		   obj=arguments[0];
		   if(typeof(obj)!='object')
		   	  obj=$(arguments[0]);
		   if(typeof(obj)!='object')
		   	  sVar=arguments[0];
		   break;
		case 2:
		   obj=arguments[0];
		   if(typeof(obj)!='object')
		   	 obj=$(arguments[0]);
		   sVar=arguments[1];
		   break;
	}

  alert(sVar);
  if(typeof(obj)=='object')
     obj.focus();
  return false;
}


/**********/
/*获取页面区域大小*/
function getBodySize()
{
   //var bodySize = [];
   var pt=new Point(0,0);
   with(document.documentElement)
   {
    //bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
	pt.x=(scrollWidth>clientWidth)?scrollWidth:clientWidth;
    //bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
	pt.y=(scrollHeight>clientHeight)?scrollHeight:clientHeight;
   }
   return pt;
}

/*获取页面工作区域大小*/
function getClientSize()
{
   var pt=new Point(0,0);
   with(document.documentElement)
   {
	pt.x=clientWidth;
	pt.y=clientHeight;
   }
   return pt;
}

/*获取页面滚动条当前位置*/
function getScrolPostion()
{
   var pt=new Point(0,0);
   with(document.documentElement)
   {
	pt.x=scrollLeft;
	pt.y=scrollTop;
   }
   return pt;
}

//新建对象
function $C(t)
{
	return document.createElement(t);
}

//去掉所有的html标记
function RemoveHtml(str)
{
    return str.replace(/<.+?>/g,"");
} 