function chgBg(obj,color)
{
	if(document.all || document.getElementById)
	{
		obj.style.backgroundColor = color
	}
	else if(document.layer)
		obj.bgColor = color
	
}

function getElById(idVal) 
{
	if (document.getElementById != null)
		return document.getElementById(idVal)
	if (document.all != null)
		return document.all[idVal]
	return null
}
function validNumber(){
	if (event.keyCode < 45 || event.keyCode > 57){
		event.returnValue = false;	
	}else{
		event.returnValue = true;	
	}
}
function validNumeric(){
	e=window.event;
	var keyCode=e.keyCode;			
	if((!(keyCode>=48 && keyCode<=57)) && (!(keyCode==46)) && (!(keyCode==13))){	
		e.keyCode=0
	}
}
function validInt(){
	e=window.event;
	var keyCode=e.keyCode;			
	if((!(keyCode>=48 && keyCode<=57)) && (!(keyCode==13))){	
		e.keyCode=0
	}
}
function validTele(){
	e=window.event;
	var keyCode=e.keyCode;			
	if((!(keyCode>=48 && keyCode<=57)) && (!(keyCode==45)) && (!(keyCode==13))){	
		e.keyCode=0
	}
}

function moveFocus()
{
	if(event.keyCode==13)
	{ 
		event.keyCode=9;
	}
}

function ismail(mail) 
{ 
	//return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 
	if (mail.value.length>0)
	{
		i=mail.value.indexOf("@");
		j=mail.value.lastIndexOf("@");
		
		if (i==0 || i==-1 || i!=j || i==mail.value.length-1)
		{
			alert("mail address is invalid!");
			mail.focus();
			return false;
		}
	}
	return true;
} 

function   formatNumber(numberRound,roundDigit)   //四舍五入，保留位数为roundDigit
{

    if   (numberRound>=0)   
    {   
  	var tempNumber=parseInt((numberRound*Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);   
  	return   tempNumber;   
    }
    else     
    {   
        numberRound1=-numberRound   
        var tempNumber=parseInt((numberRound1*Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);   
        return  -tempNumber;   
    }   
}

function showWindowOpen(URL)
{
	window.open(URL,'_blank','width=800px,height=600px,reziable=no,status=no,top=50px,left=100px');
}
function showChildWindow(URL,title,widthValue,heightValue)
{
	window.open(URL,title,'width='+widthValue+',height='+heightValue+',reziable=no,stauts=no,top=50px,left=100px,scrollbars=yes');
}
function isDateString(sDate)
{	var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31]
	var iaDate = new Array(3)
	var year, month, day

	if (arguments.length != 1) return false
	iaDate = sDate.toString().split("-")
	if (iaDate.length != 3) return false
	if (iaDate[1].length > 2 || iaDate[2].length > 2) return false
	if (isNaN(iaDate[0])||isNaN(iaDate[1])||isNaN(iaDate[2])) return false

	year = parseFloat(iaDate[0])
	month = parseFloat(iaDate[1])
	day=parseFloat(iaDate[2])

	if (year < 1900 || year > 2100) return false
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1]=29;
	if (month < 1 || month > 12) return false
	if (day < 1 || day > iaMonthDays[month - 1]) return false
	return true
}
function check()
{
	var exp = /^\d+$/;
	var strValue = document.getElementById('txtPage').value;
	if(strValue == '')
	{
		window.alert('请输入页数');
		return event.returnValue = false;
	}
	if(!exp.test(strValue))
	{
		window.alert('请输入正确格式!');
		return event.returnValue = false;
	}
}
function check2()
{
	var exp = /^\d+$/;
	var strValue = document.getElementById('txtPage2').value;
	if(strValue == '')
	{
		window.alert('请输入页数');
		return event.returnValue = false;
	}
	if(!exp.test(strValue))
	{
		window.alert('请输入正确格式!');
		return event.returnValue = false;
	}
}
function stringToDate(sDate, bIgnore)
{	var bValidDate, year, month, day
	var iaDate = new Array(3)
	
	if (bIgnore) bValidDate = true
	else bValidDate = isDateString(sDate)
	
	if (bValidDate)
	{  iaDate = sDate.toString().split("-")
		year = parseFloat(iaDate[0])
		month = parseFloat(iaDate[1]) - 1
		day=parseFloat(iaDate[2])
		return (new Date(year,month,day))
	}
	else return (new Date(1900,1,1))
}

