function MDM_openWindow(theURL,winName,features){
	var _W=window.open(theURL,winName,features);
	_W.focus();
	_W.moveTo(250,150);
}

function getHTTPObject(id,table,action,type) {
  this.xmlhttp = null;
  this.xmlhttp_id = id;
  this.xmlhttp_table = table;
  this.xmlhttp_action = action;
  this.xmlhttp_type = type;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
      try {
        this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
        this.xmlhttp = false;
        }
      }
  @else
  this.xmlhttp = false;
  @end @*/
  if (!this.xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      this.xmlhttp = new XMLHttpRequest();
      } catch (e) {
      this.xmlhttp = false;
      }
    }
  return true;
  }

function requete(action,type,id,table) {
	var chose = null;
	var url = null;
	var alerte = null;
	var fait = null;
	var base = null;
	var identite = null;
	
	if (action == "supprimer") {
		if (type == "mini") {
			chose = "miniature";
			url = "maj/supprimer.php?type=mini&id="+id+"&table="+table;
		}
		else if (type == "photo") {
			chose = "photo";
			url = "maj/supprimer.php?type=photo&id="+id+"&table="+table;
		}
		else {
			alert("Type non défini");
		}
		alerte = "Vous allez supprimer la "+chose+" ";
		fait = "suppression";		
	}
	else if (action == "deplacer") {
		if (type == "mini") {
			chose = "miniature";
			url = "maj/deplacer.php?type=mini&id="+id+"&table="+table;
		}
		else if (type == "photo") {
			chose = "photo";
			base = prompt("Base de la photo :");
			identite = prompt("ID de la photo :");
			url = "maj/deplacer.php?type=photo&id="+id+"&table="+table+"&base="+base+"&identite="+identite+"";
		}
		else {
			alert("Type non défini");
		}
		alerte = "Vous allez déplacer la "+chose+" ";
		fait = "déplacement";
	}
	else {
		alert("Action non définie");
	}
	
	if (confirm(alerte+id+" de la table "+table)) {
    	getHTTPObject(id,table,action,type);
		this.xmlhttp.open('GET',url,true);
		this.xmlhttp.onreadystatechange = verifaction;
		this.xmlhttp.send(null);
  	}
  	else {
    	alert("Pas de "+fait+" de "+chose+"");
  	}
}

var obj=this;
function verifaction() {
	if (obj.xmlhttp_action == "supprimer") {
		var alerte2 = "Vous avez supprimé la miniature ou la photo ";
	}
	if (obj.xmlhttp_action == "deplacer") {
		var alerte2 = "Vous avez déplacé la miniature ou la photo ";
	}
	if (obj.xmlhttp.readyState == 4) {
		alert(alerte2+obj.xmlhttp_id+" de la table "+obj.xmlhttp_table);
		var bouton1 = "suppr"+obj.xmlhttp_id;
		var bouton2 = "modif"+obj.xmlhttp_id;
		var bouton3 = "deplace"+obj.xmlhttp_id;
		var bouton4 = "photo"+obj.xmlhttp_id;
		document.getElementById(bouton1).disabled = true;
		document.getElementById(bouton3).disabled = true;
		document.getElementById(bouton4).disabled = true;
		document.getElementById(bouton2).disabled = true;
	}
	else {
		return;
	}
}

function visibilite(thingId,txtAff,txtMasque) {
	var targetElement; var targetElementLink;
	targetElement = document.getElementById(thingId) ;
	targetElementLink = document.getElementById(thingId+'Link');
	if (targetElement.style.display == "none") {
		targetElement.style.display = "" ;
		targetElementLink.innerHTML = txtMasque ;
	}
	else {
	targetElement.style.display = "none" ;
	targetElementLink.innerHTML = txtAff ;
	}
}