function	check_number ( field, len1, len2 )
{
	var	re	= /^[0-9]{1,}\.{0,1}[0-9]{0,}0*$/;
	var js_value = field.value;
	if ( js_value.length == 0)
	{
		return true ;
	}
	if ( js_value.match(re) )
	{
		var dot_position = js_value.indexOf('.');
		var int_value, dec_value;
		if (dot_position >= 0)
		{
			int_value = js_value.substring(0,dot_position);
			dec_value = js_value.substring(dot_position + 1);
		}
		else
		{
			int_value = js_value;
			dec_value = "";
		}
		if (int_value.length > len1)
		{
			alert("The integer digits are too long! It should be " + len1 + "digits");
			field.value = "";
			field.focus();
			return false;
		}
		if (dec_value.length > len2)
		{
			alert("The decimal digits are too long! It should be " + len2 + "digits");
			field.value = "";
			field.focus();
			return false;
		}
		return true ;
	}
	alert("Please input a number!");
	field.value = "";
	field.focus();
	return false;
}


function	not_null ( js_obj )
{
	var	re, i;
	re = /^\s*$/ ;

  	if ( js_obj.length )
  	{
		if ( js_obj[0].type == "checkbox" )
		{
			for ( i=0; i<js_obj.length; i++ )
				if (js_obj[i].checked == true)
					return true ;
			return false ;
		}
		else if ( js_obj[0].type == "radio" )
		{
			for ( i=0; i<js_obj.length; i++ )
				if (js_obj[i].checked == true)
					return true ;
			return false ;
		}
  	}
 	else
  	{
		if ( js_obj.type == "select-multiple" )
		{
			if ( js_obj.selectedIndex < 0 )
				return false ;
		}
		else if ( js_obj.type == "select-one" )
		{
			if ( js_obj.selectedIndex < 0 )
				return false ;
		}
		else if ( js_obj.type == "text" )
		{
			if ( js_obj.value.match(re) )
				return false ;
		}
		else if ( js_obj.type == "checkbox" ) 
		{
			if ( js_obj.checked == false )
				return false ;
		}
		else if ( js_obj.type == "radio" )
		{
			if ( js_obj.checked == false )
				return false ;
		}
		else
			if (js_obj.value.match (re))
				return false ;
  	}
	return true ;
}

function	is_number ( js_value )
{
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if ( isNaN(js_value) )
	{
		return false ;
	}
	return true ;
}

function is_Chinese(str){
			var bool = eval(/^[\u4E00-\u9FA5]*$/gi).test(str);
			if(!bool){
				
				return false;
			}
			return true;
		}


function	is_integer ( js_value )
{
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if ( isNaN(js_value) || js_value.indexOf('.',0) >= 0 )	
	{
		return false ;
	}
	return true ;
}

function	is_phone (js_value)
{
	var	re = /^[0-9\*\-( )]*$/;

	if (js_value.match (re))
		return	true;
	return	false;
}

function	is_natural ( js_value )
{
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}

	re = /^\+{0,1}[0-9]*$/ ;
	if ( !js_value.match(re) ) return false ;
	return true ;
}

function	is_zip ( js_value )
{
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if ( !is_natural(js_value) || js_value.length!=6 )
	{
		return false ;
	}
	return true ;
}

function	is_id_card ( js_value )
{
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if ( !is_natural(js_value) || (js_value.length!=15&&js_value.length!=18) )
	{
		return false ;
	}
	return true ;
}

function	is_date ( y_val, m_val, d_val, h_val, mi_val, s_val )
{	
	var	month_val, year_val, day_val ;
	var	hour_val, minute_val, second_val;
	var	re ;
	re = /^\s*$/ ;
	
	if ( y_val.match(re) && m_val.match(re) && d_val.match(re)
		&& h_val.match (re) && mi_val.match (re) && s_val.match (re))
	{
		return true ;
	}

	if ( !is_natural(y_val) || !is_natural(m_val) || !is_natural(d_val) ) return false ;
	if (!is_natural (h_val) || !is_natural (mi_val) || !is_natural (s_val))	return	false;
	year_val	= parseInt (y_val, 10);
	month_val	= parseInt (m_val, 10);
	day_val		= parseInt (d_val, 10);
	hour_val	= parseInt (h_val, 10);
	minute_val	= parseInt (mi_val, 10);
	second_val	= parseInt (s_val, 10);
	
	if ( isNaN(year_val)  || isNaN(month_val) || isNaN(day_val)) return false;	
	
	if ( year_val<1900 || year_val>3000 ) return false ;
	if ( month_val<1 || month_val>12 ) return false ;
	switch ( month_val )
	{
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			if(day_val<1 || day_val>31) return false ;
			break ;
		case 4:
		case 6:
		case 9:
		case 11:
			if(day_val<1 || day_val>30) return false ;
			break ;
		case 2 :
			if( (year_val%4==0 && year_val%100!=0) || year_val%400==0 ) 
			{
				if (day_val<1 || day_val>29 ) return false ;
			}
			else
			{
				if (day_val<1 || day_val>28 ) return false ;
			}
			break ;
		default :

	}
	if (hour_val < 0 || hour_val > 23)	return	false;
	if (minute_val < 0 || minute_val > 59)	return	false;
	if (second_val < 0 || second_val > 59)	return	false;

	return true ;
}

function	is_age ( js_value )
{
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if ( ! is_natural(js_value) ) return false ;
	if ( parseInt(js_value, 10)<=0 || parseInt(js_value, 10)>=200 )
	{
		return false ;
	}
	return true ;
}

function	is_price ( js_value )
{
	var	re	= /^\s*$/ ;
	var	re1	= /^[0-9]{1,}\.{0,1}[0-9]{0,2}0*$/;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if (js_value.match (re1))
		return	true;
	return false;
}

function	is_double ( js_value )
{
	var	re	= /^\s*$/ ;
	var	re1	= /^[0-9]{1,}\.{0,1}[0-9]{0,4}0*$/;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if (js_value.match (re1))
		return	true;
	return false;
}

function	is_email ( js_value )
{
	var	pos ;
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}

	pos = js_value.indexOf( '@',0 ) ;
	if ( js_value.length <= 5 ) return false ;
	if ( pos==-1 || pos==0 || pos==(js_value.length-1) ) return false ;

	pos = js_value.indexOf( '.',0 ) ;
	if ( pos<=0 || pos==(js_value.length-1) ) return false ;

	return true ;
}

function	is_gendre ( js_value )
{
	return true ;
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}
	if ( js_value!='N' && js_value!='M' && js_value!='F' ) return false ;
	return true ;
}

function	is_url ( js_value )
{
	var pos, posdot ;
	var	re ;
	re = /^\s*$/ ;

	if ( js_value.match(re) )
	{
		return true ;
	}

	pos = js_value.indexOf('://',0) ;
	if ( pos<0 ) return false ;
	posdot = js_value.lastIndexOf('.') ;
	if ( posdot<pos ) return false ;
	if ( posdot == js_value.length-1 ) return false ;
	return true ;
}

function	is_equal (js_value, confm)
{
	if (js_value != confm.value)	return	false;
	return	true;
}

function	is_date_period ( s_y_val, s_m_val, s_d_val, s_h_val, s_mi_val, s_s_val, 
				 e_y_val, e_m_val, e_d_val, e_h_val, e_mi_val, e_s_val )
{	
	
	if ( !( is_date(s_y_val, s_m_val, s_d_val, s_h_val, s_mi_val, s_s_val) &&
	       is_date(e_y_val, e_m_val, e_d_val, e_h_val, e_mi_val, e_s_val)))
	       return false;
	       
	if ( parseInt( s_y_val, 10) > parseInt( e_y_val, 10))
	 	{	
	       return false; 
	       }
	       
	else if (parseInt( s_y_val, 10) == parseInt( e_y_val, 10))
			if (parseInt( s_m_val, 10) > parseInt( e_m_val, 10))
			{
			  	return false; 
			} 	
			
	     else if (parseInt( s_m_val, 10) == parseInt( e_m_val, 10))
			 
			if (parseInt( s_d_val, 10) > parseInt( e_d_val, 10))
			{	
		  		    return false;
		  	}	    
			 else if (parseInt( s_d_val, 10) == parseInt( e_d_val, 10))
				 
				if (parseInt( s_h_val, 10) > parseInt( e_h_val, 10))
				{	
						return false;
				}	    
				 else if (parseInt( s_h_val, 10) == parseInt( e_h_val, 10))
					 
					if (parseInt( s_mi_val, 10) > parseInt( e_mi_val, 10))
					{	
							return false;
					}	    
					 else if (parseInt( s_mi_val, 10) == parseInt( e_mi_val, 10))
						 
						if (parseInt( s_s_val, 10) > parseInt( e_s_val, 10))
						{	
								return false;
						}	    
		  	
	return true;	  	
				
}				   

function is_password ( js_value )				
{
	var pass_length, i;
	var parsed_char;
		
	pass_length = js_value.length ;
	
	//	check length first
	
	if ( pass_length < 4 || pass_length > 30)
		return false;
	
	
	//	check characters should be alphabet or numeric or under_score
	
	
	
	for ( i = 0; i < pass_length; i ++)
	{
		parsed_char = js_value.toUpperCase().charAt(i);
		
		if ( parsed_char >= 'A' && parsed_char <= 'Z' )
			continue;
		
		if ( parsed_char >= '0' && parsed_char <= '9' )
			continue;
		
//		if ( parsed_char == '_' )			
//			continue;
			
		if ( parsed_char == '-' )
			continue;	
				
			return false;
		
	}
			
	return true;			
}		

function is_loginname ( js_value )				
{
	var login_length, i;
	var parsed_char;
		
	login_length = js_value.length ;
	
	//	check length first
	
	if ( login_length < 4 || login_length > 30)
		return false;
	
	
	//	check characters should be alphabet or numeric or under_score
	
	
	for ( i = 0; i < login_length; i ++)
	{
		parsed_char = js_value.toUpperCase().charAt(i);

		if ( parsed_char >= 'A' && parsed_char <= 'Z' )
			continue;
		
		if ( parsed_char >= '0' && parsed_char <= '9' )
			continue;
		
//		if ( parsed_char == '_' )
//			continue;
			
		if ( parsed_char == '-' )
			continue;	
				
	return false;		
	}
			
	return true;			
}

function	select_all ( js_obj )
{
	var	i;

	if ( typeof(js_obj) == "object")
	{	
		for ( i=0; i<js_obj.length; i++ )
			 js_obj[i].checked = true;
	}	
	return true;
}	

function	cancel_all ( js_obj )
{
	var	i;
	
	if ( typeof(js_obj) == "object")
	{	
		for ( i=0; i<js_obj.length; i++ )
			 js_obj[i].checked = false;
	}		 
		
	return true;
}	

function window_open (url, win_name, win_prop)
{
	tmp	= window.open (url, win_name, win_prop);
	tmp.opener	= window;
	tmp.focus ();
}


function changeorder (obj) {
	document.all.order1.style.display="none";
	document.all.order2.style.display="none";
	if (obj.select3.value == 1) {
		document.all.order1.style.display="";
	} else if (obj.select3.value == 2) {
		document.all.order2.style.display="";
	};
}
function turnon(obj1){
obj1.style.background="#F1E9D6";
}
function turnoff(obj1){
obj1.style.background="#F8F3E9";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var click_no

function Config_Submit_Page ( p_cmd , inform )
{
	if ( click_no == "2" )
	{
		alert("已经按过一次了!");
	}
	else
	{
		inform.cmd.value = p_cmd ;
		if ( check_valid(inform))
		{
			click_no = "2";
			inform.submit();
		}
	}
}

function open_help(url)
{
	window.open(url,'help','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=1,resizable=1,height=190,width=350');
}



/**

VALIDATOR.JS by hide on 2002-12-23 1:23

version:1.1.3

*/

var errorMsg=""; // PUBLIC error message String
var focusElement=null; // PUBLIC focus Element
var checkVal=null; // PUBLIC check Value

/**
PUBLIC trim a String
2002-12-22 by hide
Modify by jason at 2003-03-10
*/
function trim(val) {
	val=ltrim(val);
	val=rtrim(val);
	return val;
}

/**
 * ltrim -- jason add
 */
function ltrim(val) {
	for(var l=0;l<val.length;) {
		if(val.charAt(l)==' ')
			val=val.substring(1);
		else
			break;
	}
	return val;
}

/**
 * rtrim -- jason add
 */
function rtrim(val) {
	for(var r=val.length-1;r>0;r--) {
		if(val.charAt(r)==' ')
			val=val.substring(0,val.length-1);
		else
			break;
	}
	return val;
}

/** END */


/**
 *	得到字符串的长度(增强了对汉字的识别,一个汉字的长度为2)
 *	Jason Add at 2003-03-10
 */
function getStringLength(val) {
	num=val.length
	var arr=val.match(/[^\x00-\x80]/ig)
	if(arr!=null) num += arr.length
	return num;
}
/** End */



/**
PUBLIC check and get a FORM object
2002-12-23 by hide
*/
function checkFormArg(form) {
	var obj;
	if(typeof(form)=="object")
		obj=form;
	else if(isNaN(form))
		obj=eval("document."+form);
	else
		obj=document.forms[form];

	if(typeof(obj)!="object")
		alert("error form!");
	else
		return obj
}
/** END */

/**
PUBLIC check and get a FORM object
2002-12-23 by hide
*/

function checkReturn() {
	if(errorMsg!="") {
		alert(errorMsg);
		errorMsg="";
		return false;
	}
}

/** END */


/**
PUBLIC set focus To Element
2002-12-23 by hide
*/
function focusToElement(obj) {
	if(errorMsg!="") {
		obj.select();
		obj.focus();
	}
	focusElement==null;
}
/** END */


/**
PUBLIC return Function is checkVal is Empty
2002-12-23 by hide
*/
function checkEmpty(objVal) {
	checkVal=trim(objVal);
	if(checkVal=="")
		return true;
}
/** END */



function validateRequired(form,element,argName) {
	with(checkFormArg(form)) {
		element = element.split(",");
		argName = argName.split(",");
		if(element.length!=argName.length) {
			alert("error arg!");
			return;
		}
		for(var i=0;i<element.length;i++) {
			if(trim(eval(element[i]+".value")=="")) {
				errorMsg+=argName[i]+" 不能为空.\n";
				if(focusElement==null)
					focusElement=element[i];
			}
		}
		focusToElement(eval(focusElement));
	}
	return checkReturn();
}


function validateNumber(form,element,argName) {
	with(checkFormArg(form)) {
		element = element.split(",");
		argName = argName.split(",");
		if(element.length!=argName.length) {
			alert("error arg!");
			return;
		}
		for(var i=0;i<element.length;i++) {
			if(checkEmpty(eval(element[i]+".value")))
				continue;
			if(isNaN(checkVal)) {
				errorMsg+=argName[i]+" 不是一个有效的数字.\n";
				if(focusElement==null)
					focusElement=element[i];
			}
		}
		focusToElement(eval(focusElement));
	}
	return checkReturn();
}


function validateInt(form,element,argName) {
	with(checkFormArg(form)) {
		if(checkEmpty(eval(element+".value")))
			return;
		if(parseInt(checkVal)!=checkVal) {
			errorMsg+=argName+" 不是一个有效的整数.";
			focusToElement(eval(element));
		}
	}
	return checkReturn();
}

/*
 *  modify by jason at 2003-03-10(support the chinese identify)
 */

function validateLengthRange(form,element,argName,minLength,maxLength) {
	with(checkFormArg(form)) {
		if(minLength>maxLength) {
			alert("error arg!");
			return;
		}
		if(checkEmpty(eval(element+".value")))
			return;
		if(minLength!=-1) {
			if(getStringLength(checkVal)<minLength)
				errorMsg+=argName+" 的长度不能小于 "+minLength+".\n";
		}
		if(maxLength!=-1) {
			if(getStringLength(checkVal)>maxLength)
				errorMsg+=argName+" 的长度不能大于 "+maxLength+".\n";
		}
		if(minLength!=-1 && maxLength!=-1) {
			if(errorMsg!="")
				errorMsg=argName+" 的长度必须在 "+minLength+" 到 "+maxLength+" 之间.\n";
		}
		focusToElement(eval(element));
	}
	return checkReturn();
}


function validateValRange(form,element,argName,minValue,maxValue) {
	with(checkFormArg(form)) {
		if(checkEmpty(eval(element+".value")))
			return;
		if(isNaN(checkVal))
			errorMsg+=argName+" 不是一个有效数字.\n";
		else {
			if(minValue!=-1) {
				if(checkVal<minValue)
					errorMsg+=argName+" 不能小于 "+minValue+".\n";
			}
			if(maxValue!=-1) {
				if(checkVal>maxValue)
					errorMsg+=argName+" 不能大于 "+maxValue+".\n";
			}
			if(minValue!=-1 && maxValue!=-1) {
				if(errorMsg!="")
					errorMsg=argName+" 必须在 "+minValue+" 到 "+maxValue+" 之间.\n";
			}
		}
		focusToElement(eval(element));
	}
	return checkReturn();
}


function validateEmail(form,element,argName) {
	with(checkFormArg(form)) {
		if(checkEmpty(eval(element+".value")))
			return;
		var emailPat=/([\-\_\w]+@[\-\_\w]+\.\w+)(\.{0,1}\w*)(\.{0,1}\w*)/i;
		if(checkVal.match(emailPat)==null) {
			errorMsg+=argName+" 不是一个有效的 E-Mail 格式.";
			focusToElement(eval(element));
		}
	}
	return checkReturn();
}


function validateDate(form,element,argName) {
	with(checkFormArg(form)) {
		var isDate=true;
		if(checkEmpty(eval(element+".value")))
			return;
		checkVal=checkVal.replace('/','');
		checkVal=checkVal.replace('-','/');
		checkVal=checkVal.replace('-','/');
		if(new Date(checkVal)=="NaN")
			isDate=false;
		else {
			var newDate=new Date(checkVal);
			var y=newDate.getFullYear();
			var m=newDate.getMonth()+1;
			if(m<10)
				m="0"+m
			var d=newDate.getDate();
			if(d<10)
				d="0"+d
			if((y+"-"+m+"-"+d)!=eval(element+".value"))
				isDate=false;
		}
		if(isDate==false) {
			errorMsg+=argName+" 不是一个有效的日期,\n日期格式应为 yyyy-mm-dd .";
			focusToElement(eval(element));
		}
	}
	return checkReturn();
}


/*2002-12-23 18:16 v0.9*/


function validateCheckBox(form,element,argName,minSele,maxSele) {
	with(checkFormArg(form)) {
		var seleCount=0;
		element=eval(element);
		if(typeof(element.length)=="undefined") {
			if(element.checked==true)
				seleCount++;
		}
		else {
			for(var i=0;i<element.length;i++) {
				if(element[i].checked==true)
					seleCount++;
			}
		}
		if(minSele!=-1) {
			if(seleCount<minSele)
				errorMsg=argName+" 不能选择少于 "+minSele+" 项.\n";
		}
		if(maxSele!=-1) {
			if(seleCount>maxSele)
				errorMsg+=argName+" 不能选择多于 "+maxSele+" 项.\n";
		}
		if(minSele!=-1 && maxSele!=-1) {
			if(errorMsg!="")
				errorMsg=argName+" 必须选择 "+minSele+" 到 "+maxSele+" 之间."
		}
	}
	return checkReturn();
}


function validateRadio(form,element,argName) {
	with(checkFormArg(form)) {
		var selected=false;
		element=eval(element);
		if(typeof(element.length)=="undefined") {
			if(element.checked==true) {
				selected=true;
				return selected;
			}
		}
		else {
			for(var i=0;i<element.length;i++) {
				if(element[i].checked==true) {
					selected=true;
					return selected;
				}
			}
		}
		if(!selected)
			errorMsg=argName+" 必须选择一项.";
	}
	return checkReturn();
}


function validateEquals(form,element1,element2,argName1,argName2) {
	with(checkFormArg(form)) {
		if(trim(eval(element1+".value"))!=trim(eval(element2+".value"))) {
			errorMsg=argName2+" 必须与 "+argName1+" 一致.";
			focusToElement(eval(element2));
		}
	}
	return checkReturn();
}


/*2002-12-24 12:21 v1.0*/


function validateLink(form,element,argName) {
	with(checkFormArg(form)) {
		if(checkEmpty(eval(element+".value")))
			return;
		var linkPat=/(http:\/\/\w+.\w+\.\w+)(\.{0,1}\w*)(\.{0,1}\w*)/i;
		if(checkVal.match(linkPat)==null) {
			errorMsg+=argName+" 不是一个有效的 连接 格式.";
			focusToElement(eval(element));
		}
	}
	return checkReturn();
}

/*2002-12-25 18:22 v1.1.1*/

function validateSelect(form,element,argName) {
	with(checkFormArg(form)) {
		if(eval(element).selectedIndex==0)
			errorMsg="请选择 "+argName+" .";
	}
	return checkReturn();
}

/*2002-12-29 18:17 v1.1.2*/


function validateCompareDate(form,element1,element2,argName1,argName2) {
	if(validateDate(form,element1,argName1)==false)
		return false;
	if(validateDate(form,element2,argName2)==false)
		return false;
	with(checkFormArg(form)) {
		date1=eval(element1+".value");
		date2=eval(element2+".value");
		date1=date1.replace('/','');
		date1=date1.replace('-','/');
		date1=date1.replace('-','/');
		date2=date2.replace('/','');
		date2=date2.replace('-','/');
		date2=date2.replace('-','/');
		if(new Date(date1)<new Date(date2)) {
			errorMsg=argName1+" 必须大于 "+argName2+" .";
			focusToElement(eval(element1));
		}
	}
	return checkReturn();
}

/*2002-12-31 4:17 v1.1.3b*/


/*2003-1-29 3:44 update checkFormArg() method v1.1.4b*/
/*2003-1-29 4:38 update checkFormArg() method v1.1.4*/



