var compt = 1;

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}

function cherche(page,element,div)
{
	sel = document.getElementById(element);	
	id = sel.options[sel.selectedIndex].value;
    if(texte = file(page + '?id=' + id))
    {
    	writediv(texte,div);
    }    					
}
function cherche2(page,id,div)
{
	
    if(texte = file(page + '?id=' + id))
    {
		
    	writediv(texte,div);
    }    					
}


function writediv(texte,div)
{
    document.getElementById(div).innerHTML = texte;
	
}
    					
function file(fichier)
{
var xhr_object = null; 

    if(window.XMLHttpRequest)
    	xhr_object = new XMLHttpRequest()
    else 
		if(window.ActiveXObject)
			xhr_object = new ActiveXObject('Microsoft.XMLHTTP');
    	else
			return(false);
    xhr_object.open('GET', fichier, false);
    xhr_object.send(null);
    if(xhr_object.readyState == 4  && xhr_object.status == 200) return(xhr_object.responseText);
    else return(false);
}

function popup(url, titre, largeur, hauteur, scroll) 
  {
  window.open(url, titre, 'width=' + largeur + ', height=' + hauteur + ', scrollbars=' + scroll);
  }
  
 function tableau_ajoute_ligne(tableau)
 {
	  
	  var tableau = document.createElement("TABLE");
var derniere_ligne = document.createElement("TR");
for (i=0;i<2;i++) {
   var cell = document.createElement("TD");
        var texte = document.createTextNode('test');
   cell.appendChild(texte);
   derniere_ligne.appendChild(cell);
}
tableau.appendChild(derniere_ligne);
document.getElementById("test").appendChild(tableau);

 }


function createTable(){
  var tab = ["soldat_id","soldat_nom","soldat_prenoms","armee_id","grade_id","soldat_grade_autre","soldat_grade_rens_sup_fr","soldat_grade_rens_sup_all","soldat_grade_rens_sup_ang","regiment_id","regiment_autre","soldat_division_fr","soldat_division_all","soldat_division_ang","soldat_matricule","soldat_matricule_recrutement","soldat_mort_france","soldat_departement_recrutement","soldat_lieu_recrutement","soldat_infos_militaires_fr","soldat_infos_militaires_all","soldat_infos_militaires_ang","soldat_decorations_Id","soldat_autres_decorations","soldat_citations","soldat_cause_mort_id","soldat_cause_mort_autre","soldat_date_deces","soldat_departement_deces","soldat_ville_deces","soldat_deces_infos_fr","soldat_deces_infos_all","soldat_deces_infos_ang","soldat_deces_date_transcription","soldat_deces_lieu_transcription","soldat_date_naissance","soldat_pays_naissance_id","soldat_autre_pays_naissance","soldat_ville_naissance","soldat_departement_naissance","soldat_province_naissance","soldat_nom_pere","soldat_prenom_pere","soldat_nom_mere","soldat_prenom_mere","soldat_autres_infos_famille_fr","soldat_autres_infos_famille_all","soldat_autres_infos_famille_ang","soldat_profession_fr","soldat_profession_all","soldat_profession_ang","soldat_rens_sup_fr","soldat_rens_sup_all","soldat_rens_sup_ang","cimetiere_id","type_sepulture_id","soldat_num_sepulture","soldat_pays_inhumation_id","soldat_pays_inhumation_autre","soldat_departement_inhumation","soldat_region_inhumation","soldat_commune_inhumation","soldat_inhumation_infos_supp_fr","soldat_inhumation_infos_supp_all","soldat_inhumation_infos_supp_ang","soldat_inhumation_precedente_infos_fr","soldat_inhumation_precedente_infos_all","soldat_inhumation_precedente_infos_ang","soldat_inhumation_carre","soldat_inhumation_rang","monument_id","soldat_photo_identite","soldat_photo_identite_legende_fr","soldat_photo_identite_legende_all","soldat_photo_identite_legende_ang","soldat_photo_sup1","soldat_legende_photo_sup1_fr","soldat_legende_photo_sup1_all","soldat_legende_photo_sup1_ang","soldat_photo_sup2","soldat_legende_photo_sup2_fr","soldat_legende_photo_sup2_all","soldat_legende_photo_sup2_ang","soldat_photo_sup3","soldat_legende_photo_sup3_fr","soldat_legende_photo_sup3_all","soldat_legende_photo_sup3_ang","soldat_photo_tombe","soldat_photo_tombe_fr","soldat_photo_tombe_all","soldat_photo_tombe_ang","bataille_1_id","bataille_2_id","bataille_3_id","soldat_verif_mdh","soldat_incoherences","soldat_incoherences_detail_fr","soldat_incoherences_detail_all","soldat_incoherences_detail_ang","soldat_date_creation_fiche","contributeur_id","cercle_id","cercle_recrutement_id","pays_afrique_id","commentaires"] 
  
  //creation d'un select
  var inp = document.createElement("SELECT");
  inp.setAttribute('nom', 'select' + compt);
  compt++;
  //creation option (on boucle pour toutes les options)
  for(i=0; i < tab.length; i++)
  {
  	var opt = document.createElement("OPTION"); // on cree l'element option
  	opt.setAttribute('value',tab[i]); // on place l'attribut value pour l'option
  	var texte = document.createTextNode(tab[i]);//on cree un texte pour l'option
  	opt.appendChild(texte);	//on attache le texte de l'option
	inp.appendChild(opt); //on attache loption au select
  }
  	var inp2 = document.createElement("INPUT");



//on attache

  var br = document.createElement("BR");//retour a la ligne avc un BR
  
  document.getElementById("test").appendChild(inp); //on attache au div le SELECT
  document.getElementById("test").appendChild(inp2); //on attache au div le SELECT
  document.getElementById("test").appendChild(br); // on attache au div le BR
}

function lireForm ()
{
	var liste = document.getElementsByTagName("INPUT");
	for(i=0;i<liste.length;i++)
		{
			alert(liste[i].value);
		}
}