﻿
function RemoveProductFromCart(productName)
{
    alertDrawer('You have removed ' + productName + ' from the cart.');
	return true;
}

function AddProductToCart(productName)
{
    alertDrawer('You have added ' + productName + ' to your cart.');
	return true;
}

function AddProductToMyFavoritesFromCart(productName)
{
    alertDrawer('You have added ' + productName + ' to Favorites.');
	return true;
}


function AddAllProductsToMyFavoritesFromCart()
{
    alertDrawer('You have added all your cart items to Favorites.');
	return true;
}

function RemoveAllProductsFromCart()
{
    alertDrawer('You have emptied your cart.');
	return true;
}

function getElementLeft(elem) {
	var xPos = elem.offsetLeft;
	
	var tempEl = elem.offsetParent;
	
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
	}
	
	return xPos;
}

function getElementTop(elem) {
	var yPos = elem.offsetTop;
	var tempEl = elem.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
	}
	
	return yPos;
}



function showLoadingDiv(divLoading, divCart, divCartContainer){

    // get the bounds of both the gridview and the progress div
    //var gridViewBounds = Sys.UI.DomElement.getBounds(divCart);
    //var updateProgressDivBounds = Sys.UI.DomElement.getBounds(divLoading);
               
    //  center of gridview
    //var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
    //var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);        

    divLoading.style.position = "absolute";
    divLoading.style.top = getElementTop(divCartContainer) - 40;
    divLoading.style.left = getElementLeft(divCartContainer) + 200;
 
    // make it visible
    divLoading.style.display = '';    

}

function hideLoadingDiv(divLoading, divCart) 
{
    // make it invisible
    divLoading.style.display = 'none';
    divCart.className = 'cart';
}