//**获取对象**
function getObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}

function getDocObj(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}

function showModalDlg(URL,Arguments,Width,Height)
{
	var sFeatures="status:no;help:no;resizable:no;scroll:no;dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;";
	
	var varReturn=window.showModalDialog(URL,Arguments,sFeatures);
	
	return varReturn;
}

//**************************  打印   ********************
//**************************  杨超   ********************
//************************** 2006-8-25 ****************** 
function Preview()
{
	//document.all.factory.printing.header = "&b&b" ;
	//document.all.factory.printing.footer = "&b第&p页/共&P页&b";
	document.all.factory.printing.portrait = true ; //纵向打印
	document.all.factory.printing.leftMargin = 7.5 ; //左边距
	document.all.factory.printing.topMargin = 7.5 ; //上边距
	document.all.factory.printing.rightMargin = 7.5 ; //右边距
	document.all.factory.printing.bottomMargin = 7.5 ; //下边距
	//alert('fdsfd');
	var pagetags = parent.main.document.all;
	//alert(noprintControl.length);
	for(var i=0;i<pagetags.length;i++)
	{
		if(pagetags[i].noprint)pagetags[i].style.display="none";
	}
	document.all.factory.printing.Preview(parent.main);
	for(var i=0;i<pagetags.length;i++)
	{
		if(pagetags[i].noprint)pagetags[i].style.display="block";
	}
}

//**************************  将网页导入到WORD   ********************
//**************************  杨超   ********************
//************************** 2006-8-25 ******************
function AllAreaWord(TabelName)
{
var oWD = new ActiveXObject("Word.Application");
var oDC = oWD.Documents.Add("",0,1);
var oRange =oDC.Range(0,1);
var sel = document.body.createTextRange();
sel.moveToElementText(TabelName);
sel.select();
sel.execCommand("Copy");
oRange.Paste();
oWD.Application.Visible = true;
//window.close();
}


function showModelessDlg(URL)
{
	var sFeatures="status:no;help:no;";
	
	var varReturn=window.showModelessDialog(URL,"",sFeatures);
	
	return varReturn;
}

function showOperatWin(URL)
{
	window.open(URL,"_blank","menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes");
}

function showInfoWin(URL,Width,Height)
{
	var sFeatures="menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=no;dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;"
	window.open(URL,"_blank",sFeatures);
}


function regInput(obj, reg, inputStr)
{
	var docSel = document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT") return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange = obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}



//example: onkeypress="CheckInterger();"
function CheckInterger()	{CheckDataType(/^[0-9]*$/);}						//只能输入数字
function CheckSignInt()		{CheckDataType(/^([-]{0,1})[0-9]*$/);}				//只能输入负号和数字
function CheckNumeric()		{CheckDataType(/^\d*\.?\d{0,3}$/);}					//可以输2位小数
function CheckNumFour()		{CheckDataType(/^\d*\.?\d{0,4}$/);}					//可以输2位小数
function CheckChinese()		{CheckDataType(/^$/);}								//只能输入中文
function ChekcCharacters()	{CheckDataType(/^[A-z]*$/);}						//只能输入字符
function CheckSmallDate()	{CheckDataType(/^(\d{0,4})-(\d{0,2})-(\d{0,2})$/);}	//只能输入日期
function CheckSmallABC()	{CheckDataType(/^[a-z]*$/);}						//只能输入小写英文字母
function CheckBigABC()		{CheckDataType(/^[A-Z]*$/);}						//只能输入大写英文字母
function CheckSmallTime()	{CheckDataType(/^(\d{0,2})\:?(\d{0,2})$/);}			//可以输时间

function CheckYear()		{CheckDataType(/^(\d{1,4})$/);}						//可以输年份
function CheckDate()		{CheckDataType(/^(\d{0,4})(\d{0,2})(\d{0,2})$/);}	//只能输入日期
//function CheckSmallTime()		{CheckDataType(/^(20|21|22|23|[0-1]?\d):[0-5]?\d$/);}								//可以输时间

//匹配表达式
function CheckNum(strData,InputType)
{
 	return InputType.test(strData);
}

//数据类型验证
function CheckDataType(InputType)
{
	var srcElem	= event.srcElement
	
	if (srcElem.style.imeMode != "disabled" && srcElem != null)
	{
		srcElem.style.imeMode = "disabled";
		srcElem.blur();
		srcElem.focus();
	}
	var oSel	= document.selection.createRange()
	var srcRange	= srcElem.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var num = oSel.text + String.fromCharCode(event.keyCode) + srcRange.text.substr(oSel.text.length)
	event.returnValue = InputType.test(num)
}

function schReplace(str)
{
	var str2 = str.replace(/\[/g,"[[]");
	var str3 = str2.replace(/_/g,"[_]");
	var str4 = str3.replace(/%/g,"[%]");
	
	return str4
}
function schRevReplace(str)
{
	var str2 = str.replace(/\[\[\]/g,"[");
	var str3 = str2.replace(/\[_\]/g,"_");
	var str4 = str3.replace(/\[%\]/g,"%");
	
	return str4
}

