// JavaScript Document

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(getTraduction("spk_janv"), getTraduction("spk_fev"), getTraduction("spk_mars"),getTraduction("spk_avr"), getTraduction("spk_mai"), getTraduction("spk_juin"), getTraduction("spk_juill"),getTraduction("spk_aout"),getTraduction("spk_sept"),getTraduction("spk_oct"),getTraduction("spk_nov"),getTraduction("spk_dec"));
    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(getTraduction("spk_afg"), getTraduction("spk_bel"), getTraduction("spk_coree"),getTraduction("spk_dan"), getTraduction("spk_esp"), getTraduction("spk_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 webServ()
{
	
	
// The full path to the proxy
var url = 'http://www.t-a-o.com/spoonkey/accesService.asp?Nom=' + document.monForm.SpoonKey.value;
//var url = 'http://tao.legrandmagasin.fr/spoonkey/accesService.asp?Nom=' + document.monForm.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(getTraduction("spk_perhaps"));
}
// Create an HTTP GET request
if(xmlhttp.overrideMimeType){
	xmlhttp.overrideMimeType('html/javascript');
}
xmlhttp.open('GET', url, true);


// Set the callback function
xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
			
				//alert(xmlhttp.responseText);
			
				  var valSplit = xmlhttp.responseText.split('#')
				  
				  
				  //alert("err : " + valSplit[0]);
				  
				  if (valSplit[0] == "1")
				  {
				  

					  // La civilité : radio button
					  for(i=0; i<document.form_inscription.CLIENT_Civilite.length; i++)
						{
							if(document.form_inscription.CLIENT_Civilite[i].value == valSplit[2])
							{
								document.form_inscription.CLIENT_Civilite[i].checked=true;
							}
						}
					   //  Le nom : simple textbox
						document.form_inscription.CLIENT_Nom.value = valSplit[3];			
						//  Le prénom : simple textbox
						//alert(valSplit[4]);
						
						document.form_inscription.CLIENT_Prenom.value = valSplit[4];
						//email
						document.form_inscription.CLIENT_Email.value = valSplit[6];
						//numero
						document.form_inscription.CLIENT_NumeroRue.value = valSplit[10];
						// L'adresse
						document.form_inscription.CLIENT_Adresse.value = valSplit[11];
						// complement adresse
						document.form_inscription.CLIENT_AdresseComp.value = valSplit[13];
						// Le code postal
						document.form_inscription.CLIENT_Cp.value = valSplit[14];
						// La ville
						document.form_inscription.CLIENT_Localite.value = valSplit[15];
	
						// Le pays : listebox
						//for(i=0; i<document.form_inscription.Pays.length; i++)
	//					{
	//						if(document.form_inscription.Pays.options[i].value == valSplit[16])
	//						{
	//							document.form_inscription.Pays.options[i].selected=true;
	//						}
	//					}
						
						// Le telephone
						document.form_inscription.CLIENT_Tel.value = valSplit[17];
						
						document.getElementById("msg_spk").innerHTML = "";
					
				  }
				  else
				  {
					  	if (valSplit[0] == "-1"){document.getElementById("msg_spk").innerHTML = getTraduction("spk_zone")}
						if (valSplit[0] == "0"){document.getElementById("msg_spk").innerHTML = getTraduction("spk_rien")}	
				  }
					
				  
        } else {
      			// waiting for the call to complete
        }
    };
    // Make the actual request
    xmlhttp.send(null);
}
