function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function registrarImatge(datos,id){



	ajax=objetoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {

    document.getElementById(id).innerHTML = "<img src=\"images/ajax-loader.gif\">";

		if (ajax.readyState==4) {
				
      if(ajax.responseText == "1"){

        window.location.reload();
        
      }else{
      
        document.getElementById(id).innerHTML = "<img src=\"images/ajax-loader.gif\">" + ajax.responseText;
        window.location.reload();       
      
      }
      	
		}
	}
	ajax.send(null);

}

function wrongImage(datos,div){


	ajax=objetoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {


    document.getElementById(div).innerHTML = "<img src=\"images/ajax-loader.gif\">";

		if (ajax.readyState==4) {
				


			document.getElementById(div).innerHTML = ajax.responseText;

    }

	}
	ajax.send(null);

}
