Existe=function(champici){
	return !((typeof champici == 'object' && !champici) || typeof champici == 'undefined');
}
if(!document.getElementById){
	if(document.all){
		Champ=function(){
			if(Existe(document.all[arguments[0]])){return document.all[arguments[0]]}else{return null}
		}
	}else if(document.layers){
		Champ=function(){
			if(Existe(document[arguments[0]])){return document[arguments[0]]}else{return null}
		}
	}
}else{
	Champ=function(){
		if(Existe(document.getElementById(arguments[0]))){
			return document.getElementById(arguments[0]);
		}else{
			if(Existe(document.getElementsByName(arguments[0])[0])){
				return document.getElementsByName(arguments[0])[0];
			}else{
				return null;
			}
		}
	}
}
function AfficherDiv(div,num){
	/**CACHER LES DIV**/
	var fois=num;
	if (num==1) {
		fois=fois+1;
	}
	for(i=1; i<fois; i++){
		div2="div"+i;
		document.getElementById(div2).style.visibility='hidden';
		document.getElementById(div2).style.display='none';
	}
	/**Afficher la div**/
	if (div!=0) {
		div="div"+div;
		document.getElementById(div).style.visibility='visible';
		document.getElementById(div).style.display='block';
	}
}

function VerifForm()
{
	adresse = Champ("email_contact").value;
	var place = adresse.indexOf("@",1);
	var point = adresse.indexOf(".",place+1);
	if ((place > -1)&&(adresse.length >2)&&(point > 1))
	{
		return true;
	}else{
		Champ("email_contact").style.color="#DB1934";
		return false;
		if (adresse!="") {
			Champ("email_contact").style.color="#DB1934";
			return false;
		}

	}
}

function tstchamps(){
	ChampValide=true;
	if (Champ("nom_contact").value=="" || Champ("nom_contact").value=="Nom *") {
		Champ("nom_contact").style.color="#DB1934";
		ChampValide=false;
	}
	if (Champ("email_contact").value=="" || Champ("email_contact").value=="E-mail *") {
		Champ("email_contact").style.color="#DB1934";
		ChampValide=false;
	}
	if (Champ("message").value=="" || Champ("message").value=="Message *") {
		Champ("message").style.color="#DB1934";
		ChampValide=false;
	}
	if (Champ("code").value=="" || Champ("code").value=="Inscrivez le code ci-dessus *") {
		Champ("code").style.color="#DB1934";
		ChampValide=false;
	}
	return (
		VerifForm()!=false &&
		ChampValide==true &&
		Champ("code").value!="" &&
		Champ("nom_contact").value!="" &&
		Champ("email_contact").value!="" &&
		Champ("message").value!=""
	);
}

Ext.onReady(function(){

    //Add these values dynamically so they aren't hard-coded in the html
    Ext.fly('info').dom.value = Ext.MessageBox.INFO;
    Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;
    Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;
    Ext.fly('error').dom.value = Ext.MessageBox.ERROR;

    Ext.get('mb8').on('click', function(){
    	if (VerifForm()==false || tstchamps()==false) {
	    	Ext.MessageBox.show({
	           title: 'Demande de contact',
	           msg: 'Veuillez saisir votre nom et une adresse e-mail valide.<BR>Le message est aussi obligatoire ainsi que la saisie du code secret.',
	           buttons: Ext.MessageBox.OK,
	           animEl: 'mb8',
	           fn: showResult,
	           icon: Ext.get('icons').dom.value
	       });
       }
    });


    function showResult(btn){
        Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
    };

    function showResultText(btn, text){
        Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text);
    };
});