function AfficheForm(){
var formlivre="<br /><center><div id='idmsg'></div><br />Date&nbsp;&nbsp;mois/année<input type='text'  size='2' maxlength='2' id='idMois' onkeydown='ControleContenueDate(event)' onkeyup='SelSuiv(&quot;idMois&quot;,&quot;idAn&quot;)' onblur='ControlMois()'/>/<input type='text'  size='4' maxlength='4' id='idAn' onkeydown='ControleContenueDate(event)' onkeyup='SelSuiv(&quot;idAn&quot;,&quot;idFancais&quot;)'/><br />Langue&nbsp;&nbsp;<img src='images/France.gif' name='entrer' width='34' height='22' border='0'><input type='radio' name='Langue' id='idFancais' value='France.gif'/><img src='images/RoyaumeUni.gif' name='entrer' width='34' height='22' border='0' ><input type='radio' name='Langue' id='idRoyaumeUni' value='RoyaumeUni.gif'/><img src='images/Allemagne.gif' name='entrer' width='34' height='22' border='0' ><input type='radio' name='Langue' id='idAllemagne' value='Allemagne.gif'/><img src='images/Espagnol.gif' name='entrer' width='34' height='22' border='0' ><input type='radio' name='Langue' id='idEspagnol' value='Espagnol.gif'/><br />Studio <input type='checkbox' name='Gite' id='idGite'/> Chambre <input type='checkbox' name='Chambre' id='idChambre'/><br />Commentaires <textarea cols='50' rows='5' id='idcommentaire'></textarea><br />Nom&nbsp;<input type='text' id='idInvite'/>&nbsp;Originaire&nbsp;de&nbsp;<input type='text' id='idRegion'/><br /><input type='button' value='Envoyer' onclick='Inscripdatalivredor()'/></center>";
document.getElementById('idform').innerHTML=formlivre;	
}
function CacheForm(){
	document.URL="http://www.domainedutulipier.com/livre.php";
}

function Inscripdatalivredor(){

if(controlechamp()){
	httpConnectInscripdatalivredor=null
    //Création de l'objet de synchronisation XML
  	// code for Mozilla, etc.
    if (window.XMLHttpRequest)
    {
  		httpConnectInscripdatalivredor=new XMLHttpRequest();
  		if(httpConnectInscripdatalivredor.overrideMimeType)
  		{
  			httpConnectInscripdatalivredor.overrideMimeType('text/xml');																								
		}
    }
  		// code for IE
    else if (window.ActiveXObject)
    {
		try{
  			httpConnectInscripdatalivredor=new ActiveXObject("Msxml2.XMLHTTP");
  		}catch (e){
  			try{
  			    httpConnectInscripdatalivredor=new ActiveXObject("Microsoft.XMLHTTP");
  			}catch (e){}
  		}
    }
  	 if (httpConnectInscripdatalivredor!=null)
    {
	    httpConnectInscripdatalivredor.open("POST","gestion_bd/reservation.php5?",true);
		httpConnectInscripdatalivredor.onreadystatechange=function() { ChkReadyStateInscripdatalivredor(httpConnectInscripdatalivredor); };
		httpConnectInscripdatalivredor.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ArgumentInscripdatalivredor="mailLivreDor=1";
		ArgumentInscripdatalivredor+="&Mois="+document.getElementById('idMois').value;
		ArgumentInscripdatalivredor+="&An="+document.getElementById('idAn').value;
		if(document.getElementById('idGite').checked){
			ArgumentInscripdatalivredor+="&BoolGite=1";
		}else{
			ArgumentInscripdatalivredor+="&BoolGite=0";
		}
		if(document.getElementById('idChambre').checked){
			ArgumentInscripdatalivredor+="&BoolChambre=1";
		}else{
			ArgumentInscripdatalivredor+="&BoolChambre=0";
		}		
		
		ArgumentInscripdatalivredor+="&Commentaire="+encodeURIComponent(document.getElementById('idcommentaire').value);
		ArgumentInscripdatalivredor+="&Invite="+encodeURIComponent(document.getElementById('idInvite').value);
		ArgumentInscripdatalivredor+="&Region="+encodeURIComponent(document.getElementById('idRegion').value);
		
		//ArgumentSauvdata+="chambre"+document.getElementByName('chambre[]').value;
		if(document.getElementById('idFancais').checked){
			ArgumentInscripdatalivredor+="&Langue="+encodeURIComponent(document.getElementById('idFancais').value);
		}
		if(document.getElementById('idRoyaumeUni').checked){
			ArgumentInscripdatalivredor+="&Langue="+encodeURIComponent(document.getElementById('idRoyaumeUni').value);
		}
		if(document.getElementById('idAllemagne').checked){
			ArgumentInscripdatalivredor+="&Langue="+encodeURIComponent(document.getElementById('idAllemagne').value);
		}
		if(document.getElementById('idEspagnol').checked){
			ArgumentInscripdatalivredor+="&Langue="+encodeURIComponent(document.getElementById('idEspagnol').value);
		}
	    httpConnectInscripdatalivredor.send(ArgumentInscripdatalivredor);
		
    }
  	else
    {
		alert("Votre navigateur ne supporte pas XMLhttp. \n Essayer d'utiliser un autre navigateur");
    }
}
}
function ChkReadyStateInscripdatalivredor(httpConnectInscripdatalivredor)
{
	if(httpConnectInscripdatalivredor.readyState == 4)
  {
		if(httpConnectInscripdatalivredor.status == 200)
		{   
			//alert(httpConnectInscripdatalivredor.responseText);
			CacheForm();
		}
		else
		{
		  alert('Erreur lors du chargement des données : '+httpConnectInscripdatalivredor.statusText);
		  return false;
		}
  }
}
function controlechamp(){

document.getElementById('idmsg').innerHTML='Les données on bien été enregistrées';	
var boolNonErreur=true;
	if((document.getElementById('idMois').value.length<2)||(document.getElementById('idAn').value.length<4)){
		document.getElementById('idmsg').innerHTML+="Veuillez saisir correctement la date<br />";
		boolNonErreur=false;
	}
	
	if((!document.getElementById('idFancais').checked)&&(!document.getElementById('idRoyaumeUni').checked)&&(!document.getElementById('idAllemagne').checked)&&(!document.getElementById('idEspagnol').checked)){
		document.getElementById('idmsg').innerHTML="Veuillez séléctionner une langue<br />";
		boolNonErreur=false;
	}
	if((!(document.getElementById('idGite').checked))&&(!(document.getElementById('idChambre').checked))){
		document.getElementById('idmsg').innerHTML+="Veuillez séléctionner le(s) location(s)<br />";
		boolNonErreur=false;
	}
	if(navigator.appName=='Microsoft Internet Explorer') //pour Explorer 
    { 
		longtext=document.getElementById('idcommentaire').innerHTML.length;
	}else{
	     longtext=document.getElementById('idcommentaire').value.length;
	}
	if((longtext<3)){
		document.getElementById('idmsg').innerHTML+="Veuillez remplir la zone de &quot;Commentaire&quot;<br />";
		boolNonErreur=false;
	}
	if((document.getElementById('idInvite').value.length<2)){
		document.getElementById('idmsg').innerHTML+="Veuillez remplir la zone &quot;De&quot;<br />";
		boolNonErreur=false;
	}
	
	return boolNonErreur;
}
function ControleContenueDate(e){
/*
	var code='';
	var ptrevent;
	if(navigator.appName=='Microsoft Internet Explorer') //pour Explorer 
    { 
        ptrevent=event;
		code=event.keyCode;
    }else //pour Netscape
    {
		ptrevent=e;
		code=e.which;
    }
	if((code!=20)||!(ptrevent.shiftKey)){
	if(!((code>=96)&&(code<=105)||(ptrevent.shiftKey)||(code>=48)&&(code<=57)||(code==8)||(code==46)||(code==37)||(code==39))){
		ptrevent.cancelBubble;
		ptrevent.returnValue=0;
		ptrevent.keyCode=null;
	
	}
	}*/
}
function ControlMois(){

	if(document.getElementById('idMois').value.length==1){
		if((document.getElementById('idMois').value>=1)&&(document.getElementById('idMois').value<=9)){
			document.getElementById('idMois').value="0"+document.getElementById('idMois').value;	
		}
	}
	if(document.getElementById('idMois').value.length==2){
		if(!((document.getElementById('idMois').value>=01)&&(document.getElementById('idMois').value<=12))){
			document.getElementById('idMois').focus();
			document.getElementById('idMois').value ="";		
		}
	}
}
function SelSuiv(thiselement,elementsuiv){
	if(document.getElementById(thiselement).value.length==document.getElementById(thiselement).maxLength){
		document.getElementById(elementsuiv).focus();
	}

}
