function GetXmlHttpObject() {
	var xmlHttp1=null;
	try {
  		xmlHttp1=new XMLHttpRequest();
  	}
	catch (e) {
		try {
			xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
    		}
  		catch (e) {
    			xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
    		}
  	}
	return xmlHttp1;
}

function nAjax() {
  this.xmlhttp = null;
  this.element="";
  this.page="";
  var self="";
 
  this.initnAjax=function() {
    try {
      this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) {
      try {
        this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
        this.xmlhttp = null;
      }
    }
 
    if (! this.xmlhttp) {
      if (typeof XMLHttpRequest != "undefined") {
        this.xmlhttp = new XMLHttpRequest();
      } else {
        this.failed = true;
      }
    }
  };
 
  this.run=function (page,element) {
    self = this;
    if (this.xmlhttp) {
      if (self.xmlhttp.readyState >= 1 && self.xmlhttp.readyState <= 3) { self.xmlhttp.abort();}
      this.now = new Date();
      this.xmlhttp.open("GET", page + "&t=" + this.now.getTime(), true);
      this.xmlhttp.onreadystatechange = function () {
        if(self.xmlhttp.readyState == 4){
            document.getElementById(element).innerHTML = self.xmlhttp.responseText;
        }
      }
      this.xmlhttp.send(null);
    }
  }
  this.initnAjax();
}


function media_edith(id) {
	var ajax1 = new nAjax();
	ajax1.run('_scripts/media/edith.php?id='+id+'&', 'media'+id);
}

function media_edith_save(id,n) {
	var ajax2 = new nAjax();
	
	var name = document.getElementById('form_media_name').value;
      if(document.getElementById('media_name'+id)) document.getElementById('media_name'+id).innerHTML= name;	
	var url = '_scripts/media/edith_save.php?id='+id+'&name='+name;

	if(n > 1) {
		var form1 = document.getElementById('form1').value;
		url = url+'&form1='+form1;
	}
	if(n > 2) {
		var form2 = document.getElementById('form2').value;
		url = url+'&form2='+form2;
	}	
	if(n > 3) {
		var form3 = document.getElementById('form3').value;
		url = url+'&form3='+form3;
	}	
	if(n > 4) {
		var form4 = document.getElementById('form4').value;
		url = url+'&form4='+form4;
	}
	ajax2.run(url+'&', 'media'+id);
}

function media_edith_close(id) {
	var ajax3 = new nAjax();
	ajax3.run('_scripts/media/edith_save.php?id='+id+'&', 'media'+id);
}

