/****************************************************************************/
//  DDX - dynamic data exchange
//
//  Description:
//  Validation wrappers for forms
//  
//  Author: Ralph Lorenc 
//  E-Mail: r.lorenc@it-system.pl	 
//  (c) 1999-2000, Internet Technology System Solutions Sp. z o.o. 
//  http://www.it-system.pl (.com) (.de)
//	   
//  All right reserved. Any portions of this code cannot be 
//  used in any form  without licence by IT-SYSTEM company.  
/****************************************************************************/

function DDXLen(control,minLen,maxLen,errmsg)
{
	var s = control.value;
	if ( s.length < minLen || s.length > maxLen ) 
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}
	return true;
}
	
function DDXInt(control,min,max,errmsg)
{
	var s = control.value;
	
	if ( isNaN (s,10)  )
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}
	
	if ( s.valueOf() < min || s.valueOf() > max )
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}
	return true;
}

function DDXEMail(control, errmsg)
{
	var s = control.value;
	var rE = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/;
	var mArr = s.match(rE);
	if (mArr == null) 
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}	

	return true;		
}

function DDXRExp(control, rE, errmsg)
{
	var s = control.value;
	var mArr = s.match(rE);
	if (mArr == null) 
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}	

	return true;		
}