//IMÁGENES DE LOS PRODUCTOS ****************************************************
var dimension=0;
var indice=0;
var vectorImagen=new Array();

function addImage(idProducto)
{
   vectorImagen[dimension]=idProducto;
   dimension++;
}

function cargarImagenes()
{
   //vectorImagen.reverse();
   window.setTimeout('imageLoad();',200);
}

function imageLoad()
{
   if(indice<dimension)
      peticionAjax(vectorImagen[indice]);

}

function peticionAjax(idProducto)
{
   //alert(idProducto);
   var currDate = new Date();
   parametros = 'uniqueRequest='+currDate.getTime();
   parametros+='&idProducto='+idProducto;
   makeRequest("ajax/producto.imagen.php",parametros,muestraImagen,"POST",true);
}

function muestraImagen()
{
   divImagen="dp_"+vectorImagen[indice];
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
      document.getElementById(divImagen).innerHTML = xmlHttp.responseText;
      indice++;
      window.setTimeout("imageLoad();",500);
   }
}

//IMÁGENES DE LAS OFERTAS ******************************************************
var dimOferta=0;
var indiceOfertas=0;
var vectorOfertas=new Array();

function addOfertas(idProducto)
{
   vectorOfertas[dimOferta]=idProducto;
   dimOferta++;
}

function cargarOfertas()
{
   //vectorImagen.reverse();
   window.setTimeout('ofertasLoad();',500);
}

function ofertasLoad()
{
   if(indiceOfertas<dimOferta)
      ajaxOfertas(vectorOfertas[indiceOfertas]);
   else
      cargarImagenes();

}

function ajaxOfertas(idProducto)
{
   //alert(idProducto);
   var currDate = new Date();
   parametros = 'uniqueRequest='+currDate.getTime();
   parametros+='&idProducto='+idProducto;
   makeRequest("ajax/producto.imagen.ofertas.php",parametros,muestraOferta,"POST",true);
}
function muestraOferta()
{
   divImagenOfertas="dpo_"+vectorOfertas[indiceOfertas];
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
      document.getElementById(divImagenOfertas).innerHTML = xmlHttp.responseText;
      indiceOfertas++;
      window.setTimeout("ofertasLoad();",500);
   }
}
