/** Funciones para el carrito de compras
	* Aplica al portal 8 - NO MODIFICAR!
	*/
function reloadCarrito(){
	window._post('../_post/aperturanew/carrito.php?accion=reload');
}
	
function addCarrito(idProducto){
	window._post('../_post/aperturanew/carrito.php?accion=add&idProducto='+idProducto);
}

function delCarrito(idProducto){
	window._post('../_post/aperturanew/carrito.php?accion=delete&idProducto='+idProducto);	
}

function addRow(idProducto, descripcion, precio_pesos)
{
	var objCarrito 				= document.getElementById("Carrito") ? document.getElementById("Carrito") : '';
	if( objCarrito )
	{
		var objCarritoMensaje	= document.getElementById("CarritoMensaje") ? document.getElementById("CarritoMensaje") : '';
		if(objCarritoMensaje){
			objCarritoMensaje.style.display = 'none';
		}

		var row 			 				= objCarrito.insertRow(0);
    		row.setAttribute('Carrito:Row', idProducto);
    		
		var cell			 				= row.insertCell(0);	
    cell.colSpan					= "2";
    cell.valign           = "middle";
     cell.innerHTML       = '<img src="../_modulos/notas/_imgs/aperturanew/spacer.gif" border="0" alt="" width="1" height="1"/>'
    cell.height				    =	"10";
    cell.style.padding    = "0px";
    
		var row 			 				= objCarrito.insertRow(0);
    		row.setAttribute('Carrito:Row', idProducto);

		var cell			 				= row.insertCell(0);	
    cell.colSpan					= "2";
    cell.valign           = "middle";
    cell.innerHTML        = '<img src="../_modulos/notas/_imgs/aperturanew/spacer.gif" border="0" alt="" width="1" height="1"/>'
    cell.height				    =	"10";
    cell.style.padding    = "0px";
    cell.style.borderBottom    = "1px solid #E1E1E1";


		var row 			 				= objCarrito.insertRow(0);
				row.setAttribute('Carrito:Row', idProducto);

		var cell			 				= row.insertCell(0);	
		
		contenidohtml 				= '';
		contenidohtml 			 += '<div class="t4 c4B73B0"><b>'+descripcion+'.-</b></div>';
		contenidohtml 			 += '<div class="t6 c656565"><b>Precio: $'+precio_pesos+'.-</b></div>';
		                          
		cell.innerHTML        = contenidohtml;                          
		                          
    cell.style.padding    = "4px";
    cell.style.backgroundColor  = "#FFFFFF";
    cell.height				    =	"50";
    
		var cell			 				= row.insertCell(0);	
		cell.innerHTML 				= "<a href=\"javascript:delCarrito("+idProducto+")\" ><img src=\"../_modulos/productos/_imgs/aperturanew/eliminar.gif\" border=\"0\" align=\"middle\"></a>";
    cell.align						= "left";
    cell.style.padding    = "8px";
    cell.style.backgroundColor  = "#FFFFFF";
    cell.style.verticalAlign   = "top";
    cell.width				    =	"10";
		
    
    
    
	}
}

function deleteRow(idProducto)
{
	var objCarrito	= document.getElementById("Carrito") ? document.getElementById("Carrito") : '';
	if( objCarrito )
	{
		var arrNodos 		= getElementsByAttribute(objCarrito,'TR','Carrito:Row',idProducto);
		for( var i = 0; i < arrNodos.length; i++){
			objCarrito.deleteRow( arrNodos[i].rowIndex );
		}
	}
}

function setTotal(total)
{
	var total      	= '$'+total+".-";
	var objCarrito	= document.getElementById("ObjCarrito") ? document.getElementById("ObjCarrito") : '';
	if( objCarrito )
	{
		var arrNodo 		= getElementsByAttribute(ObjCarrito,'DIV','Carrito:Total','total');
		if( arrNodo )
		{
			for( var i = 0; i < arrNodo.length; i++ )
			{
				arrNodo[i].innerHTML = 'Total: '+total;
			}
		}
	}
}

function setCantidadItems(total)
{
	var msj = 'Productos: tiene '+total+" item" + (total == 1 ? '' : 's');
	document.getElementById("cantidadItems") ? document.getElementById("cantidadItems").innerHTML = msj : null;
}

function bloqueoSelect(totalProd)
{
  try
  { 
      
    if (document.forms['frmProductos'] != 'undefined')
    {
      if (totalProd > 0)
      {        
        document.getElementById('region').disabled    = true;
        document.getElementById('provincia').disabled = true;
        document.getElementById('ciudad').disabled    = true;
        document.getElementById('divContinuar').style.display = 'block';
      }
      else
      {
        document.getElementById('region').disabled    = false;
        document.getElementById('provincia').disabled = false;
        document.getElementById('ciudad').disabled    = false;
        if (document.getElementById('provincia').length < 2) document.getElementById('provincia').disabled=true;
        if (document.getElementById('ciudad').length < 2) document.getElementById('ciudad').disabled=true;
        document.getElementById('divContinuar').style.display = 'none';
      }               
    }
  }
  catch(e)
  {}

}  