var ajax = new sack();
var ProductoListObj;
var activeProducto = false;
var clickedProducto = false;
var contentObj;	// Reference to Producto content <div>



function showContent()	// Displaying content in the content <div>
{
	contentObj.innerHTML = ajax.response;	// ajax.response is a variable that contains the content of the external file	
	displayStaticMessage('El producto fue agregado a su carro de compras<br><br><a class="botonVentana" href="#" onclick="closeMessage();return false"><IMG SRC="images/btn_seguir.gif" WIDTH="121" HEIGHT="29" BORDER="0" ALT=""></a>&nbsp;&nbsp;&nbsp;<a class="botonVentana" href="?op=carro"><IMG SRC="images/btn_ir_carro.gif" WIDTH="121" HEIGHT="29" BORDER="0" ALT="ir a mi carro"></a><br><div style="float:right;padding-right:15px;padding-top:3px;"><a class="botonVentana" href="#" onclick="closeMessage();return false"><IMG SRC="images/close_x.gif" WIDTH="73" HEIGHT="20" BORDER="0" ALT="cerrar"></A></div>','');
}

function showWaitMessage()
{
	
	contentObj.innerHTML = '<table cellpadding=0 cellspacing=0 border=0><tr><td style=font-size:11px;color:white; valign=top><i>cargando carro</i></td><td><img src=js/images/tiny_red.gif align=right hspace=5></td></tr></table>';
}
function getAjaxFile(fileName)
{
	
	ajax.requestFile = fileName;	// Specifying which file to get
	ajax.onCompletion = showContent;	// Specify function that will be executed after file has been found
	ajax.onLoading = showWaitMessage;	// Action when AJAX is loading the file
	ajax.runAJAX();		// Execute AJAX function	
}

function selectProducto(id, qty)	// User have clicked on an Producto
{
	getAjaxFile('addproduct.php?id='+id+'&qty='+qty);	// Calling the getAjasFile function. argument to the function is id of this <li> + '.html', example "Producto1.html"
}


function addProduct(ProductoID, qty)
{
	contentObj = document.getElementById('contentContainer');
	displayStaticMessage('<img src="images/bar-loader.gif"><br><br>Agregando el producto a su carro de compras','');
	selectProducto(ProductoID, qty);
	
}
//window.onload = initAjaxDemo;


