var cat_requester = new Requester();
var iframecalificacion = false;
function openFrameCalificacion(a,left) {
/*var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
if (!isIE || ( isIE && (document.readyState == 'complete'))) {*/
if (!document.readyState || (document.readyState && (document.readyState == 'complete'))) {
if (!iframecalificacion) {
iframecalificacion = document.createElement('IFRAME');
iframecalificacion.className = 'calificarproducto';
iframecalificacion.src = a.href;
if (left) {
iframecalificacion.style.top = (offsetTop(a.parentNode)-165)+'px';
iframecalificacion.style.left = (offsetLeft(a.parentNode)-295)+'px';
} else {
iframecalificacion.style.top = (offsetTop(a)-217)+'px';
iframecalificacion.style.left = (offsetLeft(a)+widthObj(a)+2)+'px';
}
document.body.appendChild(iframecalificacion);
} else {
var reload = false;
if (iframecalificacion.src != a.href) {
var reload = true;
}
document.body.removeChild(iframecalificacion);
iframecalificacion = false;
if (reload) {
openFrameCalificacion(a,left);
}
}
}
return false;
}
function openImagenProducto(link) {
var imagenproductowindow = window.open((link.href?link.href:link),'imagenproducto','width=640,height=620,resizable=yes,toolbars=no,scrollbars=no,statusbar=no,top='+parseInt((screen.height-620)/2)+',left='+parseInt((screen.width-640)/2));
if (imagenproductowindow && window.focus) {imagenproductowindow.focus()}
return false;
}
function openTrailerProducto(link) {
var trailerproductowindow = window.open((link.href?link.href:link),'trailerproducto','width=734,height=400,resizable=yes,toolbars=no,scrollbars=no,statusbar=no,top='+parseInt((screen.height-400)/2)+',left='+parseInt((screen.width-734)/2));
if (trailerproductowindow && window.focus) {trailerproductowindow.focus()}
return false;
}
var imagen_del_producto = false;
var last_imagenproducto_link = false;
function switchImagenProducto(link) {
imagen_del_producto = (imagen_del_producto)?imagen_del_producto:document.getElementById('imagen_del_producto');
if (link && imagen_del_producto && link.href && imagen_del_producto.href
&& (imagen_del_producto.href != link.href)
&& link.firstChild && imagen_del_producto.firstChild) {
imagen_del_producto.href = link.href;
imagen_del_producto.firstChild.src = link.firstChild.src.replace(/40/g,'200');
last_imagenproducto_link = (last_imagenproducto_link)?last_imagenproducto_link:document.getElementById('imagen_producto_default');
delCSSClass(last_imagenproducto_link,'selected');
addCSSClass(link,'selected');
last_imagenproducto_link = link;
}
return false;
}
/*function mouseOverSmiley(obj) {
obj.src2 = obj.src;
obj.src = '/images/catalogo/smile_bien.gif';
}
function mouseOutSmiley(obj) {
obj.src = obj.src2;
}
function updateVotosProducto(reference, idproductoweb) {
var r = new Request('http://catalogo.walmart.com.ar/ajax/catalogo.php', 'GET', 'action=updatevotosproducto&idproductoweb='+idproductoweb+'&calificacion='+reference.getAttribute('value'), cat_requester, reference.parentNode).run();
}
function hr_updatevotosproducto(result, request) {
if (!request.error)
request.reference.innerHTML = getXMLTagValue(result, 'calificador').replace(/>/g, '<');
else
alert(request.error_msg);
}
*/
function addToShoplist(reference) {
new Request('http://catalogo.walmart.com.ar/ajax/catalogo.php', 'GET', 'action=addtoshoplist&request=add&codigo='+reference.getAttribute('codigo'), cat_requester, reference).run();
return false;
}
function updateShoplist(reference, value) {
var cant = parseInt(value);
if (cant>0)
new Request('http://catalogo.walmart.com.ar/ajax/catalogo.php', 'GET', 'action=addtoshoplist&request=update&codigo='+reference.getAttribute('codigo')+'&cant='+cant, cat_requester, reference).run();
else
removeFromShoplist(reference, 'shoplist');
}
function hr_addtoshoplist(result, request) {
if (!request.error) {
switch (result.getAttribute('request')) {
case 'add':
request.reference.innerHTML = "
En mi lista"; //"Item en lista de compras
";
break;
case 'update':
// request.reference tiene el TR donde se origino el request
request.reference.setAttribute('cant', getXMLTagValue(result.firstChild, 'cant'));
updateTotalShoplist(request.reference.parentNode);
break;
}
} else
alert(request.error_msg);
}
function removeFromShoplist(reference, caller) {
var request = caller || 'catalogo';
new Request('http://catalogo.walmart.com.ar/ajax/catalogo.php', 'GET', 'action=removefromshoplist&codigo='+reference.getAttribute('codigo')+'&request='+request, cat_requester, reference).run();
return false;
}
function hr_removefromshoplist(result, request) {
if (!request.error) {
switch (result.getAttribute('request')) {
case 'catalogo':
request.reference.innerHTML = "
Agregar a mi lista";
break;
case 'shoplist':
// En request.reference tenemos el TR del IMG que genero el request
var tabla = request.reference.parentNode; // Ojo, en tabla tenemos el TBODY
tabla.removeChild(request.reference); // Quitamos el TR de la tabla
//Actualizamos el total de la lista
updateTotalShoplist(tabla);
break;
}
} else
alert(request.error_msg);
}
function updateTotalShoplist(tabla) {
// tabla tiene el TBODY
var trs = tabla.getElementsByTagName('TR');
var total = 0, cant, precio;
for (var i=0; i