// JavaScript Document
// FUNCION PARA CARGAR HTML MEDIANTE AJAX
function creaAjax(){
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax = false;
          }
         }

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

function FAjax (url,capa,valores,metodo)
{
          var ajax=creaAjax();
          var capaContenedora = document.getElementById(capa);

/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
if(metodo.toUpperCase()=='POST'){
         ajax.open ('POST', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
         	capaContenedora.innerHTML='<img src="http://www.atajosargentina.com.ar/img/loading.gif">';
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {
                        document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no existe";
                                             }
                           else
                                             {
                            capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(valores);
         return;
}
/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
if (metodo.toUpperCase()=='GET'){

         ajax.open ('GET', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
         	capaContenedora.innerHTML='<img src="http://www.atajosargentina.com.ar/img/loading.gif">';
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200){
                                             document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no existe";
                                             }
                                             else
                                             {
                            capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(null);
         return
}

} 
// Funciones para Abrir y Cerrar una foto
function OpenPhoto(Url){
FAjax(Url,'Photo','','get');
document.getElementById('BackGround-Photo').style.visibility="visible";
document.getElementById('Photo').style.visibility="visible";
}
function ClosePhoto(){
document.getElementById('BackGround-Photo').style.visibility="hidden";
document.getElementById('Photo').style.visibility="hidden";
document.getElementById('Photo').innerHTML = "";
}
// USO (onclick="OpenPhoto('url en cuestion'))
// Funciones para Abrir y Cerrar Recomendacion
function OpenReco(Url){
FAjax(Url,'Reco','','get');
document.getElementById('BackGround-Photo').style.visibility="visible";
document.getElementById('Reco').style.visibility="visible";
}

function CloseReco(){
document.getElementById('BackGround-Photo').style.visibility="hidden";
document.getElementById('Reco').style.visibility="hidden";
document.getElementById('Reco').innerHTML = "";
}
// USO (onclick="OpenReco('url en cuestion')) 