var AntiSpam=function(imgPath, jsonPath, textName, occurence){
	this.imgPath=imgPath;
	this.jsonPath=jsonPath;
	this.textName=textName;
	this.occurence=occurence;
};

AntiSpam.prototype={
	run: function(_submit, formName){	
		this.setJSON(_submit, formName);
	},
	
	setJSON: function(_submit, formName){
		searchData(this.jsonPath+"AntiSpam.js", this.isNotRobot, [this.occurence, this.textName, _submit, formName]);
	},
	
	isNotRobot: function(txt, options){
		res=eval('('+txt+')');
		letter='';
		result=false;
		for(i=1;i<=options[0];i++)
		{			
			for(j=0;j<res.AntiSpam.length;j++)
				if(res.AntiSpam[j].file.substring(0, res.AntiSpam[j].file.length-4)==document.getElementById('keys'+i).value)
				{
					letter+=res.AntiSpam[j].letter;
					break;
				}
		}
		if(letter==document.getElementById(options[1]).value)
			result=true;
		else
			alert('Les caractères de la vérification anti-spam ne concorde pas.');
		if(result && options[2])
			document.getElementById(options[3]).submit();
		return(result);
	}
};
