// JavaScript Document

<!--

function openPopup(theURL,winName,features) { 
  newPopup = window.open(theURL,winName,features);
  newPopup.focus()
}

/**********************************************************
      TEST DU FORMULAIRE D'ENVOI DE MAIL 
*********************************************************/
// Teste si le mail a une forme correcte
function checkMail(email) {
	var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
	return (reg.exec(email)!=null)
}
// Teste le contenu des champs du form avant submit
function checkForm(theMessage,theMail) {
	if(theMessage.value=="") {
		alert("Merci d'écrire un p'tit message !"); theMessage.focus(); return false;
	} else if(!checkMail(theMail.value)) {
		alert("email incorrect !"); theMail.focus(); return false;
	}
	return true;
}

/**********************************************************
      ANTISPAM : MASQUAGE D'EMAIL 
*********************************************************/
function antispam(name,at,dot) {
	var xcdf = 'ilto';
	var trc = 'ma';
	var trf = ':';
	var trouc =  name + '&#64;';
	trouc = trouc + at + '.' + dot;
	document.write('<a href=\"'+trc+xcdf+trf +trouc + '\">');
}
function antispam2() {
	document.write('</a>');
}

/**********************************************************
      DEFILEMENT TEXTE
*********************************************************/	

// Défilement 4 directions multiple

function Defilant(id, pos_init, pos_min, pos_max, delta, direction) {
	this.id = id;
	this.element = document.getElementById(id);
	this.pos_init = pos_init;
	this.pos_min = pos_min;
	this.pos_max = pos_max;
	this.pos_current = pos_init;
	this.delta = delta;
	this.direction = direction;
}

Defilant.prototype.defile = function() {

	if (!this.element) {
		this.element = document.getElementById(this.id);
	}

	if (this.element) {
		if(this.direction == 'vertical'){
			if(this.pos_current < (this.pos_min - this.element.offsetHeight) ){
				this.pos_current = this.pos_init;
			} else if (this.pos_current > this.pos_max ) {
				this.pos_current = this.pos_init - this.element.offsetHeight;
			} else {
	            this.pos_current += this.delta;
			}
			this.element.style.top = this.pos_current+"px";
		} else if(this.direction == 'horizontal') {
			if(this.pos_current < (this.pos_min - this.element.offsetWidth) ){
				this.pos_current = this.pos_init;
			} else if (this.pos_current > this.pos_max ) {
				this.pos_current = this.pos_init - this.element.offsetWidth;
			} else {
				this.pos_current += this.delta;
	        }
	        this.element.style.left = this.pos_current+"px";
		}
	}
}



//-->