function chargerSelectDDN()
{
    // Jour
    document.write('<div><select name="DDNJ">')
    for(i=1;i< 32;i++)
    {
        document.write('<option value="'+i+'">'+i+'</option>')
    }

    document.write('</select><select name="DDNM"')
    // Mois
    var tab=new Array("Janvier", "F&eacute;vrier", "Mars","Avril", "Mai", "Juin", "Juillet","Aout","Septembre","Octobre","Novembre","D&eacute;cembre");
    for(i=1;i< 13;i++)
    {
        document.write('<option value="'+i+'">'+tab[i-1]+'</option>')
    }

    // Année
    document.write('</select><select name="DDNA">')
    for(i=1900;i< 2008;i++)
    {
        document.write('<option value="'+i+'">'+i+'</option>')
    }
    document.write("</select></div>")
}

function chargerSelectPays()
{
    document.write('<div><select name="Pays">')

    // Mois
    var tab=new Array("Afganistan", "Belgique", "Cor&eacute;e","Danemark", "Espagne", "France");
    for(i=0;i< tab.length;i++)
    {
        document.write('<option value="'+tab[i]+'">'+tab[i]+'</option>')
    }
    document.write("</select></div>")
}


function testWeb()
{
    var url = "";
	request = new XMLHttpRequest();
	request.onreadystatechange = changementStatut;
	request.open( "GET", url, true );
	request.send();

}

function changementStatut()
{
    if(request.readyState == 4)
    {
    // Content
    }
}


function webServ1()
{
	if ( ( this.document.FormPassConnect.email.value == '' ) && ( this.document.FormPassConnect.password.value == '' ) )
    {
        document.getElementById('affiche_erreur').style.display = "block";
        document.getElementById('affiche_erreur').innerHTML = 'Veuillez saisir vos identifiants';
        return false;
    }
	if ( this.document.FormPassConnect.email.value == '' )
    {
        document.getElementById('affiche_erreur').style.display = "block";
        document.getElementById('affiche_erreur').innerHTML = 'Veuillez saisir votre email';
        return false;
    }
    if ( this.document.FormPassConnect.password.value == '' )
    {
        document.getElementById('affiche_erreur').style.display = "block";
        document.getElementById('affiche_erreur').innerHTML = 'Veuillez saisir votre mot de passe';
        return false;
    }

    // The full path to the proxy
	var url = 'http://www.saveur-biere.com/AccesServiceSpoonkey.php?type=liste_spoonkey&Email=' + this.document.FormPassConnect.email.value + '&Passwd=' + this.document.FormPassConnect.password.value;

	// Create xmlhttprequest object
	var xmlhttp = null;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		//make sure that Browser supports overrideMimeType
		if ( typeof xmlhttp.overrideMimeType != 'undefined') { xmlhttp.overrideMimeType('text/xml'); }
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}  else {
		alert('Perhaps your browser does not support xmlhttprequests?');
	}
	// Create an HTTP GET request
	xmlhttp.open('GET', url, true);


	// Set the callback function
	xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {

                  var valSplit = xmlhttp.responseText;
                  if ( valSplit != '' )
                  {
                    //alert('Chaîne de caractères' + valSplit);
                    document.getElementById("SpoonkeyBloc").innerHTML = '<input type="hidden" id="SpoonKey" name="SpoonKey" value="'+valSplit+'" />';
                    webServ2()
                  }
                  else
                  {
                    document.getElementById('affiche_erreur').style.display = "block";
                    document.getElementById('affiche_erreur').innerHTML = 'Votre Pass Connect est invalide.';
                  }


        } else {
      			// waiting for the call to complete
        }
    };
    // Make the actual request
    xmlhttp.send(null);
    

}


function webServ2()
{
    var url = 'http://www.saveur-biere.com/AccesServiceSpoonkey.php?type=access_passconnect&Email=' + this.document.FormPassConnect.email.value + '&Passwd=' + this.document.FormPassConnect.password.value+ '&Nom=' + this.document.FormPassConnect.Nom.value+ '&Spoonkey=' + this.document.FormPassConnect.SpoonKey.value;

	// Create xmlhttprequest object
	var xmlhttp = null;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		//make sure that Browser supports overrideMimeType
		if ( typeof xmlhttp.overrideMimeType != 'undefined') { xmlhttp.overrideMimeType('text/xml'); }
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}  else {
		alert('Perhaps your browser does not support xmlhttprequests?');
	}
	// Create an HTTP GET request
	xmlhttp.open('GET', url, true);


	// Set the callback function
	xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {

                  var valSplit = xmlhttp.responseText;
                  
                  if ( valSplit == '-1#Paramètres non valides#0#0#' )
                  {
                    document.getElementById('affiche_erreur').style.display = "block";
                    document.getElementById('affiche_erreur').innerHTML = 'Vérifiez votre email ou mot de passe';
                  }
                  if ( valSplit == 'MAJ' )
                  {
                    document.getElementById('FormSpoonkey').style.display = "none";
                    document.getElementById('affiche_erreur').style.display = "none";
                    document.getElementById('affiche_success').style.display = "block";
                    document.getElementById('affiche_success').innerHTML = 'Vous allez être connecté d\'ici quelques instants.';
                    self.setTimeout("window.location='http://www.saveur-biere.com/account.php'",1000); // delai en millisecondes
                  }
                  if ( valSplit == 'MAJP' )
                  {
                    document.getElementById('FormSpoonkey').style.display = "none";
                    document.getElementById('affiche_erreur').style.display = "none";
                    document.getElementById('affiche_success').style.display = "block";
                    document.getElementById('affiche_success').innerHTML = 'Vous allez être connecté d\'ici quelques instants. Vous pouvez poursuivre votre commande';
                    self.setTimeout("window.location='http://www.saveur-biere.com/shopping_cart.php'",1000); // delai en millisecondes
                  }
                  if ( valSplit == 'CRT' )
                  {
                    document.getElementById('FormSpoonkey').style.display = "none";
                    document.getElementById('affiche_erreur').style.display = "none";
                    document.getElementById('affiche_success').style.display = "block";
                    document.getElementById('affiche_success').innerHTML = 'Votre compte a été créé correctement. Vous allez recevoir un email de confirmation. Vous pouvez désormais passer votre commande';
                    self.setTimeout("window.location='http://www.saveur-biere.com/create_account_success.php'",1000); // delai en millisecondes
                  }
                  if ( valSplit == 'CRTP' )
                  {
                    document.getElementById('FormSpoonkey').style.display = "none";
                    document.getElementById('affiche_erreur').style.display = "none";
                    document.getElementById('affiche_success').style.display = "block";
                    document.getElementById('affiche_success').innerHTML = 'Votre compte a été créé correctement. Vous allez recevoir un email de confirmation. Vous pouvez poursuivre votre commande';
                    self.setTimeout("window.location='http://www.saveur-biere.com/shopping_cart.php'",1000); // delai en millisecondes
                  }
                  if ( valSplit == '' )
                  {
                    document.getElementById('affiche_erreur').style.display = "block";
                    document.getElementById('affiche_erreur').innerHTML = 'Une erreur est survenue. Merci de recommencer votre identification';
                  }

        } else {
      			// waiting for the call to complete
        }
    };
    // Make the actual request
    xmlhttp.send(null);
}

function verif_email()
{
	// The full path to the proxy
	var url = 'http://www.saveur-biere.com/AccesServiceSpoonkey.php?type=verif_email&Email=' + this.document.FormPassConnect.email.value;

	// Create xmlhttprequest object
	var xmlhttp = null;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
		//make sure that Browser supports overrideMimeType
		if ( typeof xmlhttp.overrideMimeType != 'undefined') { xmlhttp.overrideMimeType('text/xml'); }
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}  else {
		alert('Perhaps your browser does not support xmlhttprequests?');
	}
	// Create an HTTP GET request
	xmlhttp.open('GET', url, true);


	// Set the callback function
	xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {

                  var valSplit = xmlhttp.responseText;

                  if ( valSplit != '' )
                  {
                    document.getElementById("NomBloc").innerHTML = '<input type="hidden" name="Nom" id="Nom" value="'+valSplit+'" />';
                  }

        } else {
      			// waiting for the call to complete
        }
    };
    // Make the actual request
    xmlhttp.send(null);
}


function affiche_lightbox_spoonkey()
{
	document.getElementById("lightbox_spoonkey").style.display = "block";
	document.getElementById("overlay_spoonkey").style.display = "block";
}

function masque_lightbox_spoonkey()
{
	document.getElementById("lightbox_spoonkey").style.display = "none";
	document.getElementById("overlay_spoonkey").style.display = "none";
}