/*调用方法：
<script language="javascript" type="text/javascript" src="myJs.js"></script>
*/
// JavaScript Document

//会计科目，基础资料名称文字禁止出现的数据 arrban 列举的字符；
var arrban = new Array("-","/","数量外币","现金流量","客户","个人","存货","供应商","部门","核算项目");

//JS创建XMLHttpRequest对象
var request = false;
try {
   request = new XMLHttpRequest();
}
catch (trymicrosoft) {
   try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (othermicrosoft) {
       try {
           request = new ActiveXObject("Microsoft.XMLHTTP");
       }
       catch (failed) {
           request = false;
       }
   }
}
if (!request) alert("Error initializing XMLHttpRequest!");

//函数：表格隔行换色，鼠标经过高亮显示；
//在主体部分使用：mytable("mytable1");
function mytable(objid){
	var oldcolor;//设置鼠标移除前表格行颜色；
	var tbl=document.getElementById(objid);
	var tr=tbl.getElementsByTagName("tr");
	for(var i=0;i<tr.length;i++){
		if(i%2==0){
			tr[i].style.background="#CCC";
		}else{
			tr[i].style.background="white";
		}
		tr[i].onmouseover=doMouseover;
		tr[i].onmouseout=doMouseout;
	}
	function doMouseover(){
		oldcolor=this.style.background;
		this.style.background="yellow";
	}
	function doMouseout(){
		this.style.background=oldcolor;
	}
}

//函数：删除字符串前后空格；
function trim(s){
	s=s.replace(/(^\s*)/,"");//去左空格；
	return s.replace(/(\s*$)/,"");//返回去右空格后的值；
}

//给符合条件的控件成批添加获取或失去焦点事件，让可输入区域高亮；
function HighLight(){
	var inputs=document.getElementsByTagName("input");
	for(var i=0;i<inputs.length;i++){
		if(inputs.item(i).type!="button"){
			inputs.item(i).onfocus=function(){
				this.style.backgroundColor="yellow";
			}
			inputs.item(i).onblur=function(){
				this.style.backgroundColor="";
			}
		}
	}
	var textareas=document.getElementsByTagName("textarea");
	for(var i=0;i<textareas.length;i++){
		textareas.item(i).onfocus=function(){
			this.style.backgroundColor="yellow";
		}
		textareas.item(i).onblur=function(){
			this.style.backgroundColor="";
		}
	}
}

//最大化打开弹出窗口页面；
function openWin(strUrl){
	window.open(strUrl,'','left=0,top=0,width='+screen.availWidth+',height='+screen.availHeight+',scrollbars=yes');
}