//<!------------------------------------------------------------------
//-- PROJET : Méthodes communes au site
//--------------------------------------------------------------------
//-- AUTEUR           : Simon Billette (Simon.Billette@eclys.com)
//-- SOCIETE          : Billette et Devos
//-- DATE CREATION    : JUIN 2003
//-- OBJET            : common.js
//--------------------------------------------------------------------
//-- DATE MODIF       :
//-- OBJET            :
//-------------------------------------------------------------------->

IE4 = (document.all) ? 1:0;

lstart=100 		//the pixel value of where you want the layer to start
lstop=-400 		// where you want it to stop, set this lower for more content
			//(i know this isnt the ideal way of doing this, but it's the easiest way to it crossbrowser)
loop=true 		// set this to false if you just want it to go one time
speed=130 		// set the speed, lower value gives more speed
pr_step=2 		// set this to how many pixels you want it to go for each step, this also set's the speed.    

var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;

function makeObj(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'
	this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
		this.up=goUp
	this.obj = obj + "Object"
	eval(this.obj + "=this")
	return this
}

function goUp(speed){
	this.css.top=parseInt(this.css.top)-pr_step
	if(parseInt(this.css.top)>lstop) setTimeout(this.obj+".up("+speed+")",speed)
	else if(loop) {
		this.css.top=lstart
		eval(this.obj+".up("+speed+")")
	  }
}

function initScrollTxt(){
	newsObj=makeObj('newsbody','news')
	newsObj.css.top=lstart
	newsObj.up(speed)
}

function openNewsPopup(url){
	cePopupNews = window.open(url, 'cePopupNews', 'toolbar=no,menu=no,addressbar=no,resizable=no,width=281,height=277,left=0,top=0,scrollbars=yes');
	cePopupNews.focus();
	return false;
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++) {
		if(ok.indexOf(e.charAt(i))<0) {
			return (false);
		}
	}

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);
		}
	}
}

function checkFormSearch() {
	if ( (document.formSearch.formKeyword.value == '') ) {
		alert (' Veuillez entrer un mot clef pour effectuer la recherche / Please enter at least a keyword to start the search. ');
		if(IE4) {
			document.formSearch.formKeyword.style.background = "#FFBFC0";
			document.formSearch.formKeyword.focus();
		}
	}
	else {
		document.formSearch.submit();
		document.formSearch.formKeyword.value = '';
		if(IE4) 
			document.formSearch.formKeyword.style.background = "#FFFFFF";
	}
	return false;
}

function checkFormContact() {
	if (document.formContact.formNom.value == '') {
		alert (' Veuillez entrer votre nom ');
		if(IE4) {
			document.formContact.formNom.style.background = "#FFBFC0";
			document.formContact.formNom.focus();
		}
		return false;
	}
	else if (document.formContact.formSociete.value == '') {
		alert (' Veuillez entrer votre société ');
		if(IE4) {
			document.formContact.formSociete.style.background = "#FFBFC0";
			document.formContact.formSociete.focus();
		}
		return false;
	}
	else if (document.formContact.formAdresse.value == '') {
		alert (' Veuillez entrer votre adresse ');
		if(IE4) {
			document.formContact.formAdresse.style.background = "#FFBFC0";
			document.formContact.formAdresse.focus();
		}
		return false;
	}
	else if (document.formContact.formCP.value == '') {
		alert (' Veuillez entrer votre code postal ');
		if(IE4) {
			document.formContact.formCP.style.background = "#FFBFC0";
			document.formContact.formCP.focus();
		}
		return false;
	}
	else if (document.formContact.formVille.value == '') {
		alert (' Veuillez entrer votre ville ');
		if(IE4) {
			document.formContact.formVille.style.background = "#FFBFC0";
			document.formContact.formVille.focus();
		}
		return false;
	}
	else if (document.formContact.formTel.value == '') {
		alert (' Veuillez entrer votre téléphone ');
		if(IE4) {
			document.formContact.formTel.style.background = "#FFBFC0";
			document.formContact.formTel.focus();
		}
		return false;
	}
	else if(!check_email(document.formContact.formEmail.value)){
		alert(' Veuillez entrer une adresse email valide ');
		if(IE4) {
			document.formContact.formEmail.style.background = "#FFBFC0";
			document.formContact.formEmail.focus();
		}
		return false;
	}
	return true;
}

