function init(){ }

// Alias de document.getElementById()
function $(e){
	return document.getElementById(e);
}

/** Cette fonction renvoie TRUE si l'email est valide, sinon FALSE **/
function isValidMail(str){
	var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/	// Pattern à  valider
	return (reg.exec(str)!=null)
}

function verifForm() {
	if(($('emetteur').value=='') || ($('sujet').value=='') || ($('message').value=='')){	
		alert('Vous devez remplir tout les champs');
		return false;
	}
	if (!isValidMail($('emetteur').value)) {
		alert("Merci d'entrer un email correct pour la réponse")
		return false;
	}
	return true;
}


function showLoader(){
	$("loader").style.display="block";
}
function hideLoader(){
	$("loader").style.display="none";
}

function showAlert(title,str){
	
	showLoader();
	$("alertBox").style.display="block";
	if( arguments.length >= 4 ){
		
		switch( arguments[3] ){
			case "locked" :
				$("alertBox").className='lockedBox';
				break;
			case "valid" :
				$("alertBox").className='validBox';
				break;
			case "error" :
				$("alertBox").className='errorBox';
				break;
			case "question" :
				$("alertBox").className='questionBox';
				break;
			default :
				$("alertBox").className='warningBox';
				break;
		}
		/****/
	}/****/
	$("alertBox").innerHTML = "<h1>"+title+"</h1>" + str;
	if(arguments.length > 2){
		if( arguments[2] )  {
			var loc = " onClick=\"hideAlert();\"";
			if( arguments.length == 5 ){
				var loc = " onClick=\"document.location.replace('" +arguments[4] +"');hideAlert();\"";
			}
				$("alertBox").innerHTML += "<hr /><p align=\"center\"><input type=\"button\" class=\"alertBout\" value=\"FERMER\" "+loc+"/></p>"; 
		}
	}
	
	if(jck_navdetect=="ms"){
		var tabSelect = document.getElementsByTagName("select");
		//pour ie avant 7, on cache les SELECT et les IFRAMES qui restent au 1er plan (pb de windowless)
		//Pour + d'infos : http://download.microsoft.com/download/f/e/a/fea64d9a-7658-4939-84e9-186b8d16d52a/IEPlansAffichage.doc
		for (var indexSelect = 0;indexSelect<tabSelect.length;indexSelect++){
			tabSelect[indexSelect].style.display="none";
		}
	}
}

function hideAlert(){
	$("loader").style.display="none";
	$("alertBox").style.display="none";
	
	if(jck_navdetect=="ms"){
		var tabSelect = document.getElementsByTagName("select");
		//pour ie avant 7, on cache les SELECT et les IFRAMES qui restent au 1er plan (pb de windowless)
		//Pour + d'infos : http://download.microsoft.com/download/f/e/a/fea64d9a-7658-4939-84e9-186b8d16d52a/IEPlansAffichage.doc
		for (var indexSelect = 0;indexSelect<tabSelect.length;indexSelect++){
			tabSelect[indexSelect].style.display="block";
		}
	}
}
