//*************************************************
//模块名称：公用函数
//功能描述：
//初始创作：高小平
//初创日期：2005.5.28
//修改日期：
//*************************************************

function IsNull(objName)
{
	var i=0;
	var objLen=0;
	var strTemp=objName.value;
	if (strTemp.length==0)
		{return true;}
	else
		{
		for(i=0;i<strTemp.length;i++)
		{
			if (strTemp.charAt(i)!=" ")	objLen++;
		}
		if (objLen==0)
			{
			return true;
			}
		else
			return false;
		}
}

function IsEmpty(strObjName)
{
	var i=0;
	var objLen=0;
	var objName=document.all(strObjName);
	var strTemp=objName.value;
	if (strTemp.length==0)
		{return true;}
	else
		{
		for(i=0;i<strTemp.length;i++)
		{
			if (strTemp.charAt(i)!=" ") objLen++;
		}
		if (objLen==0)
			{
			return true;
			}
		else
			return false;
		}
}

function PrintContent(divPrint)
{
 var oldstr = document.body.innerHTML;
 var newstr = document.all(divPrint).innerHTML;
 document.body.innerHTML = newstr;
 window.print();
 document.body.innerHTML = oldstr;

}

function OnlyInputNumber(inAddition)
{
	var k=event.keyCode;
	var charKey=String.fromCharCode(k);
	if(inAddition)
	{
		if(inAddition.indexOf(charKey)!=-1) return;
	}
	if(48<=k&&k<=57)
		 {}
	else
		 event.keyCode=null;
}

function trim(str,bol)
{
	if(str && typeof(str) == "string")
	{
		var regStr = /\s+/g;
		if(bol&&bol.toUpperCase() == "R")
		{
			regStr = /\s+$/;
		}
		else if(bol&&bol.toUpperCase() == "L")
		{
			regStr = /^\s+/;
		}
		str = str.replace(regStr,"");
	}
		return str;
}



function GetPeriod(inObjName)
{
    var strURL = AbsPath+"/widget/calendar/period.html";
    var strStyle="dialogWidth=162pt;dialogHeight=182pt;status=off;help=off;scrollbars=off";
    var AryDate = window.showModalDialog(strURL,'unlimitday',strStyle);
	if(AryDate!="")	document.all(inObjName).value=AryDate;
}


function GetDate(inObjName)
{
    var strURL = AbsPath+"/widget/calendar/date.html";
    var strStyle="dialogWidth=158pt;dialogHeight=158pt;status=off;help=off;scrollbars=off";
    var AryDate = window.showModalDialog(strURL,'',strStyle);
	if(AryDate.length==4) document.all(inObjName).value=AryDate[0];
}

function OnlyPwdChar()
{
	var k=event.keyCode;
	var charKey=String.fromCharCode(k);
	var strAllow="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;,.*_()~!@$%"
	if(strAllow.indexOf(charKey)==-1)
		event.keyCode=null;
}

function ChangeBdColor(inEvent)
{
	Obj=event.srcElement;
	if(inEvent=="Over")  Obj.style.border="1 #FFCC66 solid";
	if(inEvent=="Out")  Obj.style.border="1 #88B9E9 solid";
}

function OnlyIdChar()
{
	var k=event.keyCode;
	var objInput=event.srcElement;
	var charKey=String.fromCharCode(k);
	var strAllow="1234567890";
	var strExpend="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	if(objInput.value.length==17)
		strAllow=strAllow+strExpend;
	if(strAllow.indexOf(charKey)==-1)
		event.keyCode=null;
}

function SetChkState(flag)
{
	var aryChk=document.all.tags("INPUT"),i;
	for(i=0;i<aryChk.length;i++)
	if(aryChk[i].type=="checkbox") aryChk[i].disabled=flag;
}

function CheckEmail()
{
	var objEmail=document.all("email");
	var strValue=objEmail.value;
	var iPoint=strValue.indexOf("@");
	var dotPoint=strValue.indexOf(".");
	if(iPoint==-1||iPoint==0||dotPoint==-1||dotPoint==0||dotPoint==strValue.length-1)
	{
		return "Email格式错误\n";

	}
	else
		return "";
}

function IsEmail(strObjName)
{
	var objEmail=document.all(strObjName);
	var strValue=objEmail.value;
	var iPoint=strValue.indexOf("@");
	var dotPoint=strValue.indexOf(".");
	if(iPoint==-1||iPoint==0||dotPoint==-1||dotPoint==0||dotPoint==strValue.length-1)
	{
		return false;
	}
	else
		return true;
}


function SetSelValue(inSelName,inData)
{
	var objSel=document.all(inSelName),i;
	for(i=0;i<objSel.options.length;i++)
	{
		objSel.options[i].selected=false;
		if(objSel.options[i].value==inData) objSel.options[i].selected=true;
	}
}

function ClearAllChk()
{
	var aryChk=document.all.tags("INPUT"),i;
	for(i=0;i<aryChk.length;i++)
	if(aryChk[i].type=="checkbox") aryChk[i].checked=false;
}


function isHaveInSel(inSelName,inKey,inFlag)
{
	var objSel=document.all(inSelName);
	var result=false,i;
	for(i=0;i<objSel.length;i++)
	{
		if((inFlag=="value"?objSel.options[i].value:objSel.options[i].text)==inKey)
		{
			result=true;
			break;
		}
	}
	return result;
}

function setButtonState(flag)
{
	var aryButton=document.all.tags("BUTTON");
	var i;
	for(i=0;i<aryButton.length;i++)
	{
			aryButton[i].disabled=flag;
	}
}

function ChangeReason()
{
	var objSel=document.all("selReason");
	var objTr=document.all("trReason");
	if(objSel.value=="other")
	{
		objTr.style.display="";
		document.all("othermessage").focus();
	}
	else
	{
		objTr.style.display="none";
	}
}

/*************************************************
函数功能：Mouse移到时变色
参    数：   类型         含义

返 回 值：
************************************************/
function ChangeBdColor(inEvent)
{
	Obj=event.srcElement;
	if(inEvent=="Over")  Obj.style.border="1 #FFCC66 solid";
	if(inEvent=="Out")  Obj.style.border="1 #88B9E9 solid";
}

/*************************************************
函数功能：取得日期区间
参    数：   类型         含义
返 回 值：
************************************************/
function GetPeriod(inObjName)
{
    var strURL = AbsPath+"/widget/calendar/period.html";
    var strStyle="dialogWidth=168pt;dialogHeight=200pt;status=off;help=off;scrollbars=off";
    var AryDate = window.showModalDialog(strURL,'',strStyle);
	if(AryDate.length==7)	document.all(inObjName).value=AryDate[0];
}

/*************************************************
函数功能：通过日期选择框选择日期
参    数：   类型         含义
inObjName
返 回 值：
************************************************/
function GetDate(inObjName)
{
    var strURL = AbsPath+"/widget/calendar/date.html";
    var strStyle="dialogWidth=158pt;dialogHeight=180pt;status=off;help=off;scrollbars=off";
    var AryDate = window.showModalDialog(strURL,'',strStyle);
    if(AryDate.length==4) 
	document.all(inObjName).value=AryDate[0];
}
