

function getMeteo(ville,nbjour)
{

	//recuperation des info du produit pour le mois donnée en AJAX
	var xhr = null;
	 if (window.XMLHttpRequest) // Firefox et autres
	 {
	  xhr = new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject) // Internet Explorer
	 {
	  try
	  {
	   xhr = new ActiveXObject("Microsoft.XMLHTTP" );
	  }
	  catch (e)
	  {
	   try
	   {
	    xhr = new ActiveXObject("Msxml2.XMLHTTP" );
	   }
	   catch (e1)
	   {
	    xhr = null;
	   }
	     }
	}
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
	         
              if(xhr.status  == 200) 
              {
				var rep = xhr.responseText;								
	              	if(rep.length > 0 )
	                {
	              		//document.getElementById("contenumeteo").innerHTML = rep;
	              		
	              		var browserName=navigator.appName; 
						if (browserName=="Microsoft Internet Explorer")
						{
						 	var browserVer=parseInt(navigator.appVersion); 
							if (browserVer < 7)
								imagepng();
						
						}
	          		}
	          		
              } 
         }
    }; 

   xhr.open("GET", "/meteo/meteo3.php?ville="+ville+"&nbjour="+nbjour,true);
   xhr.send(null);

}


function verifContact(form)
{
  if(!form.nom.value)
  {	alert ("Veuillez saisir votre nom.");
	form.nom.focus();
	return false;
  }
  if(!form.email.value)
  {
	 alert("Veuillez saisir votre email.");
	 form.email.focus();
	 return false;
  }
  if(form.email.value && !verifMail(form.email.value))
  {
	 alert("L'e-mail saisi n'est pas valide.");
	 form.email.focus();
	 return false;
  }
 
  var xhr2 = createXhr();
	xhr2.onreadystatechange  = function()
	{ 
	     if(xhr2.readyState  == 4)
	     {    
	          if(xhr2.status  == 200 || xhr2.status  == 0) 
	          {
			  	var rep = xhr2.responseText;
			  	rep = rep.replace("\t","");
			  	//alert("text"+rep+"fin");
			  	if(rep != "ok")
			  	{
			  		alert("Le code est inexact");
			  		return false;
		  		}
			  	else 
			  	{
				 	form.submit();
			  	}	
	          } 
	     }
	}; 
	
	xhr2.open("POST", "/ajax_verifcaptcha.php",true);
	xhr2.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
	xhr2.send("code="+form.code.value);
  
  return false;
}


function verifMail(email)
{ var b = true;
  if (!email) b = false;
  var filtre  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
  if(!filtre.test(email)) b = false;
  return b;
}	


function colorIt(obj)
{
	obj.style.backgroundColor = "C3D782";
}

function clearIt(obj)
{ 
	obj.style.backgroundColor = "";
}


function afficheCalendar(mois, annee)
{
	//recuperation des info du produit pour le mois donnée en AJAX
	var xhr = null;
	 if (window.XMLHttpRequest) // Firefox et autres
	 {
	  xhr = new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject) // Internet Explorer
	 {
	  try
	  {
	   xhr = new ActiveXObject("Microsoft.XMLHTTP" );
	  }
	  catch (e)
	  {
	   try
	   {
	    xhr = new ActiveXObject("Msxml2.XMLHTTP" );
	   }
	   catch (e1)
	   {
	    xhr = null;
	   }
	     }
	}
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
	         
              if(xhr.status  == 200) 
              {
				var rep = xhr.responseText;								
	              	if(rep.length > 0 )
	                {
	              		document.getElementById("calendrier").innerHTML = rep;
	              		
	              		var browserName=navigator.appName; 
						if (browserName=="Microsoft Internet Explorer")
						{
						 	var browserVer=parseInt(navigator.appVersion); 

							var tab = navigator.appVersion.split(";");
							var chaine = tab[1].substring("1", "9");

							if (chaine == "MSIE 6.0")
							{
								imagepng();
							}
						}
	          		} 
	          		
              } 
         }
    }; 

   xhr.open("GET", "/getCalendar.php?mois=" + mois + "&annee=" + annee,true);
   xhr.send(null);

}

function afficheActuCalendar(jour, mois, annee)
{
	//recuperation des info du produit pour le mois donnée en AJAX
	var xhr = null;
	 if (window.XMLHttpRequest) // Firefox et autres
	 {
	  xhr = new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject) // Internet Explorer
	 {
	  try
	  {
	   xhr = new ActiveXObject("Microsoft.XMLHTTP" );
	  }
	  catch (e)
	  {
	   try
	   {
	    xhr = new ActiveXObject("Msxml2.XMLHTTP" );
	   }
	   catch (e1)
	   {
	    xhr = null;
	   }
	     }
	}


    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {    
              if(xhr.status  == 200) 
              {
				var rep = xhr.responseText;
				/*var reg=new RegExp("\n", "g");
				rep = rep.replace(reg,"");	
				var reg=new RegExp("\t", "g");
				rep = rep.replace(reg,"");
				var reg=new RegExp("\r", "g");
				rep = rep.replace(reg,"");*/
				
	              	if(rep.length > 0 )
	                {
	              		document.getElementById("divAfficheInfoCalendrier").innerHTML = xhr.responseText;

						document.getElementById('divAfficheInfoCalendrier').style.display ='block';
	          		}
	          		
              } 
         }
    }; 

   xhr.open("GET", "/getActuCalendar.php?jour="+jour+"&mois="+mois+"&annee="+annee,true);
   xhr.send(null);
}

function cleanActuCalendar()
{
	if(document.getElementById('divAfficheInfoCalendrier'))
	{
		document.getElementById('divAfficheInfoCalendrier').innerHTML = ">> Survolez les dates surlignées pour connaître vos obligations fiscales et sociales du jour";
  			
	}
}

function createXhr()
{
	var xhr2 = null;
	 if (window.XMLHttpRequest) // Firefox et autres
	 {
	  xhr2 = new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject) // Internet Explorer
	 {
	  try
	  {
	   xhr2 = new ActiveXObject("Microsoft.XMLHTTP" );
	  }
	  catch (e)
	  {
	   try
	   {
	    xhr2 = new ActiveXObject("Msxml2.XMLHTTP" );
	   }
	   catch (e1)
	   {
	    xhr2 = null;
	   }
	     }
	}
	
	return xhr2;
}
