function ImgClose() {
	document.getElementById("alertFromAjax").style.display = 'none';
	document.getElementById("alertFromAjaxTop").style.display = 'none';
}

function doBreakAction(docForm){
	docForm.savebutton.value	= "Envoyer";
	docForm.savebutton.disabled= false;
	return true;
}

function checkForm(){
	var theForm = document.ajout_contact;
	theForm.savebutton.value	= "patientez...";
	theForm.savebutton.disabled= true;

	if (theForm.cof_nom.value=="") {
		alert("Veuillez remplir le champ 'Nom'");
		theForm.cof_nom.focus();
		doBreakAction(theForm);
		return;
	}
	if (theForm.cof_prenom.value=="") {
		alert("Veuillez remplir le champ 'Prénom'");
		theForm.cof_prenom.focus();
		doBreakAction(theForm);
		return;
	}
	if (theForm.cof_email.value!=""){
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;
		var bEmailCheck = true ;
		if(((theForm.cof_email.value.search(exclude) != -1)||(theForm.cof_email.value.search(check)) == -1)||(theForm.cof_email.value.search(checkend) == -1)){
			alert("L'adresse \'E-mail\' est incorrecte !");
			theForm.cof_email.focus();
			doBreakAction(theForm);
			return;
		}
	} else {
		alert('Le champ \'E-mail\' est obligatoire');
		theForm.cof_email.focus();
		doBreakAction(theForm);
		return;
	}
	if (theForm.cof_texte.value=="") {
		alert("Veuillez remplir le champ 'Message'");
		theForm.cof_texte.focus();
		doBreakAction(theForm);
		return;
	}

	theForm.action="contact.php";
	theForm.submit();
}


function doBreakAction2(){
	var docForm = document.recrute;
	docForm.savebutton.value	= "Envoyer";
	docForm.savebutton.disabled= false;
	return true;
}

function saveForm(){
	var docForm = document.recrute;
	docForm.savebutton.value	= "Patientez...";
	docForm.savebutton.disabled= true;

	if (docForm.recf_nom.value=="") { // nom
		alert("Veuillez rentrer votre nom !");
		docForm.recf_nom.focus();
		doBreakAction2();
		return;
	}
	if (docForm.recf_prenom.value=="") { // prenom
		alert("Veuillez rentrer votre prénom !");
		docForm.recf_prenom.focus();
		doBreakAction2();
		return;
	}
	
	if (docForm.recf_mail.value!=""){
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;
		var bEmailCheck = true ;
		if(((docForm.recf_mail.value.search(exclude) != -1)||(docForm.recf_mail.value.search(check)) == -1)||(docForm.recf_mail.value.search(checkend) == -1)){
			alert("L'adresse \'E-mail\' est incorrecte !");
			docForm.recf_mail.focus();
			doBreakAction2(docForm);
			return;
		}
	} else {
		alert('Le champ \'E-mail\' est obligatoire');
		docForm.recf_mail.focus();
		doBreakAction2(docForm);
		return;
	}
	
	if (docForm.recf_tel.value=="") { // tel
		alert("Veuillez rentrer votre numéro de téléphone !");
		docForm.recf_tel.focus();
		doBreakAction2();
		return;
	}

	if (docForm.recf_file.value!="") { // file
		if( check_files(docForm.recf_file.value, "pdf,doc,zip")==false ){
			alert ("Le fichier n'est pas au format autorisé");
			docForm.recf_file.select();
			doBreakAction2();
			return;
		}
	} else {
		alert("Veuillez joindre votre C.V. en fichier attaché !");
		docForm.recf_file.focus();
		doBreakAction2();
		return;
	}

	if (docForm.recf_file2.value!="") { // file 2
		if( check_files(docForm.recf_file2.value, "jpg,jpeg")==false ){
			alert ("Votre photo n'est pas au format autorisé");
			docForm.recf_file2.select();
			doBreakAction2();
			return;
		}
	}

	docForm.action = "recrutement.php";
	docForm.submit();
}

function check_files(file, extensions) {
	var extensOk= 0;
	extensTab	= extensions.split(",");

	filelink	= file;
	filelink	= filelink.toLowerCase();
	linksize	= filelink.length;
	sansExt	= (linksize-3);

	for (i=0; i<extensTab.length; i++){
		if (filelink.substr(sansExt,3) == extensTab[i]){
			extensOk++;
		}
	}
	if (extensOk<1) return false;
	return true;
}

function chkExt(oThis){
	return;
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
//
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {			
			var footerElement = document.getElementById('bottom_large');
			var footerHeight  = footerElement.offsetHeight;
			//footerElement.style.position = 'relative';
			var vposition = windowHeight - footerHeight;
			if (document.body.computedStyle) {
				footerElement.style.top = vposition;
			}else {
				footerElement.style.top = vposition+'px';
			}	
		}
	}
//	alert("getWindowHeight="+getWindowHeight()+" / vposition ="+vposition);
}
window.onload = function() {
	setFooter();
}
//
window.onresize = function() {
	setFooter();
}
//

