// Title: Tigra Form Validator PRO
// URL: http://www.softcomplex.com/products/tigra_form_validator_pro/
// Version: 1.2
// Date: 02/25/2005 (mm/dd/yyyy)
// Notes: Registration needed to use this script legally. Visit official site for details.

var
var_date=/^(\d{1,2})\-(\d{1,2})\-(\d{4})$/,
var_time=/^(\d{1,2})\:(\d{1,2})\:(\d{1,2})$/,
regxp={'alpha':/^[a-zA-Z\.\-]*$/,
	 'alphanum':/^\w+$/,
	 'unsigned':/^\d+$/,
	 'integer':/^[\+\-]?\d*$/,
	 'real':/^[\+\-]?\d*\.?\d*$/,
	 'email':/^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/,
	 'phone':/^[\d\.\s\-]+$/,

	 'date':/^(0[1-9]|[12][0-9]|3[01])[- \ /\.](0[1-9]|1[012])[- \/\.](19|20)\d\d$/,

	 'time':function TV5(TV6){if(!var_time.test(TV6))return false;if(RegExp.$1>23||RegExp.$2>59||RegExp.$3>59)return false;return true;}
	};

function error_msg()
{
	this.alert=0;
	this.alert_class=[];
	this.to_disable=[];
	this.messages={'setup':['Pas de formulaire attribué à l\'objet Validator','Pas de données du formulaire "%form%" transmises à l\'objet validator','Le formulaire "%form%" n\'a pu être trouvé dans ce document','Pas de zone trouvée pour l\'affichage du message (id="error_%form%")','Incomplete "%n%" form field descriptor entry. Attribute "%attr%" is missing','Can not find form field "%n%" in the form "%form%"','Can not find label tag (id="%t%")','Can not verify match. Field "%m%" was not found'],'fill':['"%l%" est un champ obligatoire','"%v%" n\est pas une valeur valide pour "%l%"','La valeur pour "%l%" doit avoir une longueur de %mn% caractères ou plus','La valeur pour "%l%" doit faire moins de %mx% caractères','"%l%" doit correspondre à "%ml%"'],'boxes':['<table cellpadding="0" cellspacing="0" border="0" width="100%">'+'<tr><td><table cellpadding="15" cellspacing="1" border="0" width="100%">'+'<tr><td bgcolor="#E1BE7C" style="color: #901010;">%error%</td></tr>'+'</table></td></tr><tr><td height="10">&nbsp;</td></tr></table>','<table cellpadding="0" cellspacing="0" border="0" width="100%">'+'<tr><td><table cellpadding="15" cellspacing="1" border="0" width="100%">'+'<tr><td bgcolor="#E1BE7C" style="color: green; font-weight: bold;">Envoi du formulaire ...</td></tr>'+'</table></td></tr><tr><td height="10">&nbsp;</td></tr></table>'],'confirm':['Le formulaire "%form%" est sur le point d\'être envoyé. Confirmez-vous ?']}
}

function validator(TV8,TV9,TVA)
{
	this.TVB=TVC;
	var TVD=new error_msg();
	TVE(TVA,TVD);
	this.TVA=TVD;
	this.TVF=TVD.alert;
	this.TVG=this.TVF&4?function(TVH){alert(TVH);return false}:function(){return false};
	this.TVI=TVD.alert_class;
	if(!TV8)return this.TVG(this.TVB('setup',0));
	this.TV8=TV8;
	if(!TV9||typeof(TV9)!='object')return this.TVG(this.TVB('setup',1));
	this.TV9=TV9;
	this.TVJ=TVD.to_disable;this.exec=TVK;
}

function TVK()
{
	var TVL=document.forms[this.TV8];
	if(!TVL)return this.TVG(this.TVB('setup',2));
	var TVM=TVN('error_'+this.TV8),TVO=document.body&&document.body.innerHTML;
	if((this.TVF&2)||(this.TVF&8))
	{
		if(TVO&&!TVM)return this.TVG(this.TVB('setup',3));if(TVO)
		{
			TVM.style.display='none';TVM.innerHTML='';
		}
	}
	var TVP=['l'];
	for(var TVQ in this.TV9)
	{
		this.TV9[TVQ]['n']=TVQ;
		for(TVR in TVP)if(!this.TV9[TVQ][TVP[TVR]])return this.TVG(this.TVB('setup',4,this.TV9[TVQ],{'attr':TVP[TVR]}));
		TVS=TVL.elements[TVQ];
		if(!TVS)return this.TVG(this.TVB('setup',5,this.TV9[TVQ]));
		this.TV9[TVQ].TVS=TVS;
	}
	if(TVO)for(var TVQ in this.TV9)if(this.TV9[TVQ]['t'])
	{
		var TVT=this.TV9[TVQ]['t'],TVU=TVN(TVT);if(!TVU)return this.TVG(this.TVB('setup',6,this.TV9[TVQ]));this.TV9[TVQ].TVV=TVU;TVU.className=this.TVI[1];
	}
	for(var TVQ in this.TV9)
	{
		TVS=this.TV9[TVQ].TVS;this.TV9[TVQ]['v']=null;
		if(TVS.type=='checkbox')
		{
			if(TVS.checked&&TVS.value)this.TV9[TVQ]['v']=TVS.value;
		}
		else if(TVS.value)this.TV9[TVQ]['v']=TVS.value;
		else if(TVS.options&&TVS.selectedIndex>-1)this.TV9[TVQ]['v']=TVS.options[TVS.selectedIndex].value;
		else if(TVS.length>0)for(var TVW=0;TVW<TVS.length;TVW++)if(TVS[TVW].checked)
		{
			this.TV9[TVQ]['v']=TVS[TVW].value;
			break;
		}
	}
	var TVX=0,TVY,TVZ,TV_,TVa;
	for(var TVQ in this.TV9)
	{
		TVb=this.TV9[TVQ];
		TV_=TVb['f']?(regxp[TVb['f']]?regxp[TVb['f']]:TVb['f']):null;
		TVa=(TV_+'').indexOf('function')>-1;
		TVb.TVc=null;
		if(TVb['r']&&!TVb['v'])
		{
			TVb.TVc=1;TVX++;
		}
		else if(TVb['mn']&&String(TVb['v']).length<TVb['mn'])
		{
			TVb.TVc=3;
			TVX++;
		}
		else if(TVb['mx']&&String(TVb['v']).length>TVb['mx'])
		{
			TVb.TVc=4;TVX++;
		}
		else if(TV_&&((TVa&&(TVY=TV_(TVb['v'],TVL))!=true)||(!TVa&&TVb['v']&&!TV_.test(TVb['v']))))
		{
			TVb.TVc=typeof(TVY)!='string'?2:TVY;TVX++;
		}
		else if(TVb['m'])
		{
			for(var TVd in this.TV9)if(TVd==TVb['m'])
			{
				TVZ=TVd;
				break;
			}
			if(TVZ==null)return this.TVG(this.TVB('setup',7,TVb));
			if(this.TV9[TVZ]['v']!=TVb['v'])
			{
				TVb['ml']=this.TV9[TVZ]['l'];
				TVb.TVc=5;TVX++;
			}
		}
	}
	
	var TVe='',TVf='',TVg;
	
	if(TVX)
	{
		for(var TVQ in this.TV9)
		{
			var TVh=this.TV9[TVQ].TVc,TVi='';
			if(TVh)
			{
				TVi=this.TVB('fill',TVh-1,this.TV9[TVQ]);
				if(!TVi)TVi=TVh;
			}
			if(TVi)
			{
				if(!TVg)TVg=TVL.elements[TVQ];
				TVe+=TVi+'<br>';TVf+=TVi+"\n";
				if(TVO&&this.TVI&&this.TV9[TVQ].TVV)this.TV9[TVQ].TVV.className=this.TVI[0];
			}
		}
		
		TVe=this.TVB('boxes',0,{'error':TVe});
	
		if(typeof(this.TVF)!='function')
		{
			if(this.TVF&1)alert(TVf);
			if(TVO&&(this.TVF&2))
			{
				TVM.innerHTML=TVe;TVM.style.display='block';
			}
			if(TVg.focus&&TVg.type!='hidden')TVg.focus();return false;
		}
	}
	
	if(typeof(this.TVF)=='function')return this.TVF(TVf,TVe,TVM);
	else
	{
		if((this.TVF&16)&&!confirm(this.TVB('confirm',0)))return false;
		if(TVO&&(this.TVF&8))
		{
			TVM.innerHTML=this.TVB('boxes',1);
			TVM.style.display='block';
		}
		for(TVQ in this.TVJ)
		{
			var TVj=TVN(this.TVJ[TVQ]);
			if(TVj&&TVj.disabled!=null)TVj.disabled=true;
		}
	}
	return true;
}

function TVE(TVk,TVl)
{
	for(var TVm in TVk)if(TVk[TVm]!=null)
	{
		if(typeof(TVk[TVm])=='object')
		{
			if(typeof(TVl[TVm])!='object')alert("Type mismatch ("+TVm+"). Array in place of scalar.");
			TVE(TVk[TVm],TVl[TVm]);
		}
		else
		{
			if(typeof(TVl[TVm])=='object')alert("Type mismatch ("+TVm+"). Scalar in place of array.");
			TVl[TVm]=TVk[TVm];
		}
	}
}

function TVC(TVn,TVW)
{
	var TVm=this.TVA.messages[TVn][TVW],TVo=2,TVp;
	if(!TVm)return false;
	if(typeof(TVm)=='function')TVm=TVm(this.TV8);
	for(;TVo<arguments.length;TVo++)for(TVp in arguments[TVo])TVm=TVm.replace('%'+TVp+'%',arguments[TVo][TVp]);
	TVm=TVm.replace('%form%',this.TV8);
	return TVm
}

function TVN(TVq)
{
	return(document.all?document.all[TVq]:(document.getElementById?document.getElementById(TVq):null));
}

