function gotoProduct(id, catalog) {
	$('productDetailContainer').update('<center><br /><br /><img src="store/images/ajax-loader.gif" /><br /><br /></center>');
	
	if (catalog == undefined)
		catalog = 0;	
	
	new Ajax.Request('store/pages/productDetailPage.php', {
		method: 'post',
		parameters: { id: id, catalog: catalog },
		onSuccess: function(transport) {
			$('productDetailContainer').update(transport.responseText);
		}
	});
}

function addToCart(id, startingProduct, positionInList) {
	var productId = id;
	var productQuantity = $('addToCartQuantity').value;
	var productAttributes = $$('.attribute');
	queryString = 'productId=' + productId + '&startingProduct=' + startingProduct + '&quantity=' + productQuantity;
	
	if (positionInList != undefined)
		queryString += '&positionInList=' + String(positionInList);
	
	for (var i = 0; i < productAttributes.length; i++)
		queryString += '&' + productAttributes[i].name + '=' + escape(productAttributes[i].value);

	new Ajax.Request('store/pages/addToCartAction.php', {
		method: 'post',
		parameters: queryString,
		onSuccess: function(transport) {
			showAddResult(transport);
		}
	});	
}

function showAddResult(transport) {
	var startingSize 	= document.viewport.getDimensions();
	try { 
		if (window.scrollbars.visible)
			startingSize.width -= 15;
	} catch (caught) {}
	
	var screenFader;
	screenFader = document.createElement('div');
	screenFader.setAttribute('id', 'screenFader');
	screenFader.style.width = String(startingSize.width) + 'px';
	screenFader.style.height = String(startingSize.height) + 'px';
	screenFader.style.position = 'fixed';
	screenFader.style.left = '0px';
	screenFader.style.top = '0px';
	screenFader.style.display = 'none';
	screenFader.style.zIndex 	= '955';
	screenFader.style.background = '#000';
	document.body.appendChild(screenFader);
	
	new Event.observe(screenFader, 'click', function() {
		hideCartResult();
	});
	
	new Effect.Appear(screenFader, {
		from: 0.0,
		to: .5,
		duration: .4, 
		afterFinish: function() {
			var addCartResultBox;
			addCartResultBox = document.createElement('div');
			addCartResultBox.setAttribute('id', 'addCartResultBox');
			addCartResultBox.style.width = String(480) + 'px';
			addCartResultBox.style.height = String(120) + 'px';
			addCartResultBox.style.background = 'none';
			addCartResultBox.style.position = 'fixed';
			addCartResultBox.style.left = String(startingSize.width / 2 - 240 - 2) + 'px';
			addCartResultBox.style.top = String(startingSize.height / 2 - 60 - 2) + 'px';
			addCartResultBox.style.display = 'block';
			addCartResultBox.style.zIndex = '955';
			document.body.appendChild(addCartResultBox);
			
			var addCartResult;
			addCartResult = document.createElement('div');
			addCartResult.setAttribute('id', 'addCartResult');
			addCartResult.style.width = String(480) + 'px';
			addCartResult.style.height = String(120) + 'px';
			addCartResult.innerHTML = transport.responseText;
			addCartResultBox.appendChild(addCartResult);
		}
	});
}

function hideCartResult() {
	$('screenFader').remove();
	$('addCartResultBox').remove();
}