// JavaScript Document
coul_champ_error = "#FFDDDD";

function check_form(form_name){
	errors = '';
	switch (form_name.name){
		case 'inscnews': //formulaire d'inscription a la newsletter
			if(form_name.nom.value==''){
				errors += '- Nom requis!\n';
				form_name.nom.style.backgroundColor = coul_champ_error;
			}
			if(form_name.email.value==''){
				errors += '- Email requis!\n';
				form_name.email.style.backgroundColor = coul_champ_error;
			}
			val = form_name.email.value;
			p = val.indexOf('@');
			if (p<1 || p==(val.length-1)){
				errors += '- Adresse email incorrecte!\n';
				form_name.email.style.backgroundColor = coul_champ_error;
			}
			break;
		case 'contact': //formulaire de contact
			if(form_name.nom.value==''){
				errors += '- Nom requis!\n';
				form_name.nom.style.backgroundColor = coul_champ_error;
			}
			if(form_name.email.value==''){
				errors += '- Email requis!\n';
				form_name.email.style.backgroundColor = coul_champ_error;
			}
			val = form_name.email.value;
			p = val.indexOf('@');
			if (p<1 || p==(val.length-1)){
				errors += '- Adresse email incorrecte!\n';
				form_name.email.style.backgroundColor = coul_champ_error;
			}
			if(form_name.sujet.value==''){
				errors += '- Sujet requis!\n';
				form_name.sujet.style.backgroundColor = coul_champ_error;
			}
			if(form_name.comment.value==''){
				errors += '- Commentaire requis!\n';
				form_name.comment.style.backgroundColor = coul_champ_error;
			}
			break;
		case 'emploi': //formulaire de demande d'emploi
			if(form_name.nom.value==''){
				errors += '- Nom requis!\n';
				form_name.nom.style.backgroundColor = coul_champ_error;
			}
			if(form_name.email.value==''){
				errors += '- Email requis!\n';
				form_name.email.style.backgroundColor = coul_champ_error;
			}
			val = form_name.email.value;
			p = val.indexOf('@');
			if (p<1 || p==(val.length-1)){
				errors += '- Adresse email incorrecte!\n';
				form_name.email.style.backgroundColor = coul_champ_error;
			}
			break;
	}
	if(errors!=''){
		alert ('Veuillez corriger les erreurs suivantes :\n'+errors);
		return false;
	}else{
		return true;
	}
}

function goToURL() { //v3.0
  var i, args=goToURL.arguments; document.returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
