// JavaScript Document

function winBRopen(theURL, Name, popW, popH, scroll) { // V 1.0
var winleft = (screen.width - popW) / 2;
var winUp = (screen.height - popH) / 2;
winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable=no'
Win = window.open(theURL, Name, winProp)
if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }
}

function redirect(selectItem) {
	if(selectItem.value !=0) {
	document.location.href = selectItem.value;
	}
}

function checkFormContact()
{
var errState = false;
var msg = "";

	if(document.form_contact.nom.value == "") {
	errState = true;
	msg = "\nVous devez indiquer votre nom";
	}
	if(document.form_contact.prenom.value == "") {
	errState = true;
	msg += "\nVous devez indiquer votre prénom";
	}
	if(document.form_contact.email.value == "") {
	errState = true;
	msg += "\nVous devez indiquer votre email";
	}
	else if(!checkEmail(document.form_contact)) {
	errState = true;
	msg += "\nFormat d'email incorrect";
	}
	if(document.form_contact.message.value == "") {
	errState = true;
	msg += "\nVous devez mettre un message";
	}
	
	if(!errState) {
	document.form_contact.submit();
	} else {
	alert(msg);
	}
}

function checkSearchForm() {
	var errState = false;
	document.form_recherche.action = document.form_recherche.url.value;
	
	if(!errState) {
	document.form_recherche.submit();
	} else {
	alert(msg);
	}
	
}

function checkNewsletterForm(){

document.newsletter.email.value = $("NewsEmail").value;

var errState = false;
var msg = "";

	if(document.newsletter.email.value == "" || !checkEmail(document.newsletter)) {
	errState = true;
	msg += "Email absent ou non conforme\n";
	}
	
	if(!errState) {
	document.newsletter.submit();
	} else {
	alert(msg);
	}
}

function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
return (true)
}
return (false)
}

function intMenus() {
	
		$('sousMenu1').set('opacity','.0'); 
		
		$('itemNav1').addEvent('mouseenter', function() {
		$('sousMenu1').fade('in');
		});
		
		$('sousMenu1').addEvent('mouseleave', function() {
		$('sousMenu1').fade('out');
		});
		
		$('itemNav0').addEvent('mouseenter', function() {
		$('sousMenu1').fade('out');
		});
		
		$('itemNav2').addEvent('mouseenter', function() {
		$('sousMenu1').fade('out');
		});
		
		$('itemNav3').addEvent('mouseenter', function() {
		$('sousMenu1').fade('out');
		});
		
}

function moveBloc(intIndex, intTotal, objItem, objItemBox, step) {
		var myFx = new Fx.Tween($(objItem), { property: 'left', transition: 'expo:in:out', duration:1000});
		if(intIndex > 1) { pos = (intIndex - 1) * step; } else { pos = 0; }
		
		myFx.start(-pos);
		
			for(i=1;i<=intTotal;i++) {
			
			obj = objItemBox + i;
			
				if(i==intIndex)  {
				
				$(obj).set('class','curBox');
				} else {
				$(obj).set('class','box');
				}
			}
}
