var xmlHttp
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
/**********************  Authentification  *********************/
function authentification(thisform)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="verifauth.php"
with(thisform){
login_utl=login.value;
ps=pass.value;
}
xmlHttp.onreadystatechange=function(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 var message= xmlHttp.responseText
 if(message==5) { window.location.href="ecole.php";  } 
 if(message==6) { 
   alert(" Veuillez verifier votre mot de passe "); 
   thisform.pass.focus();   
 } 
 if(message==7) { 
  alert(" Veuillez verifiez votre login "); 
  thisform.login.focus();
 } 
 }
} 
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send("login="+login_utl+"&pass="+ps);
}
/***********************************************************/
function Controlnumber(evt) {
var keyCode = evt.which ? evt.which : evt.keyCode;	
//alert("keycoe = " + keyCode);
	var interdit = '0123456789';
	if(keyCode==39 || keyCode==37 || keyCode==9 || keyCode==8 || keyCode==46){
		return true;
	}
	if ((interdit.indexOf(String.fromCharCode(keyCode)) <= -1))
	{
	 return false;
	}
}
//************************* Champ remplir ******************//
function validate_field(field,alerttxt){
if(field.value == ""){
alert(alerttxt); 
   return false; 
	 }
else { return true;}
}

//****************** validation email ***********************//
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt); 
   return false;}
else {return true;}
}
}
//*************************************************************//
function validate_contact(thisform)
{
with (thisform)
{ 
if (validate_field(nom,"Veuillez saisir votre nom !!!")==false)
  {nom.focus();return false;}
if (validate_field(prenom,"Veuillez saisir votre prenom !!!")==false)
  {prenom.focus();return false;}
if (validate_field(email,"Veuillez saisir votre email !!!")==false)
  {email.focus();return false;}
if (validate_email(email,"Veuillez verifier votre email !!!")==false)
  {email.focus();return false;}
if (validate_field(tel,"Veuillez saisir votre telephone !!!")==false)
  {tel.focus();return false;}  
if (validate_field(sujet,"Veuillez saisir votre sujet !!!")==false)
  {sujet.focus();return false;}    
if (validate_field(message,"Veuillez saisir votre message !!!")==false)
  {message.focus();return false;}  
if (validate_field(spam,"Veuillez copier le code antispam !!!")==false)
  {spam.focus();return false;}  
if(spam.value.toLowerCase()!='hibiscus' ) {
	alert('Veuillez verifier code antispam');
	spam.focus();return false;
}
}
}
//*************************************************************//
//*************************************************************//
function vider(thisform)
{
  with (thisform)
  { 
	nom.value='';
	email.value='';
	tel.value='';
	message.value='';
	sujet.value='';
	prenom.value='';
	spam.value='';  
  }
}
//*************************************************************//
function validate_contact_ang(thisform)
{
with (thisform)
{ 
if (validate_field(nom,"Please, check your name !!!")==false)
  {nom.focus();return false;}
if (validate_field(prenom,"Please, check your first name !!!")==false)
  {prenom.focus();return false;}
if (validate_field(email,"Please, check your email !!!")==false)
  {email.focus();return false;}
if (validate_email(email,"Please, check your email!!!")==false)
  {email.focus();return false;}
if (validate_field(tel,"Please, check your telephone number !!!")==false)
  {tel.focus();return false;}  
if (validate_field(sujet,"Please, check one subject !!!")==false)
  {sujet.focus();return false;}    
if (validate_field(message,"Please, check your message !!!")==false)
  {message.focus();return false;}  
if (validate_field(spam,"Please, copy the code antispam !!!")==false)
  {spam.focus();return false;}  
if(spam.value.toLowerCase()!='hibiscus' ) {
	alert('Please, verify code antispam');
	spam.focus();return false;
}
}
}
//*************************************************************//
function validate_photo(thisform)
{
with (thisform)
{ 
if (validate_field(petite,"Veuillez chosir une petite photo !!!")==false)
  {petite.focus();return false;}
if (validate_field(email,"Veuillez choisir une grande photo !!!")==false)
  {grande.focus();return false;}
}
}
/*********************************************************/
function validate_auth(thisform)
{
with (thisform)
{ 
if (validate_field(login,"Veuillez saisir votre login !!!")==false)
  {login.focus();return false;}
if (validate_field(pass,"Veuillez saisir votre mot de passe !!!")==false)
  {pass.focus();return false;}
}
}
/*********************************************************/


