/*
-----------------------------------------------
Application class

By Rodesigned 2008

Version         1.0
-----------------------------------------------
*/

function Page() {
	this.container = 'content';
	this.request = '';
}

/**
 * Cart objects
 */
function Cart() {}

Cart.prototype.show = function(type) {

	type = (type !== undefined) ? type : '';

	if ($('shoppingcart') !== undefined) {
        show($('shoppingcart'));
		var objCart = $('shoppingcart_contents');
		var message = 'Bezig met laden...';
		objCart.className = 'notice';
		objCart.firstChild ? objCart.firstChild.data = message : objCart.appendChild(document.createTextNode(message));
	}

	Ajax.Updater('shoppingcart_contents','ajax/cart.php','',{
		method: 'post',
		onSuccess: function(response) {}
	});

	objCart.className = '';

};

Cart.prototype.add = function(id) {

	id = (id !== undefined) ? id : '';
	if (id === '') {
		return false;
	}

	Ajax.Response('ajax/cart.php','cmd=add&id='+id,{
		method: 'post',
		onSuccess: function(response) {
			var data = eval('('+response.responseText+')');
			if (data.response === true) {
				Cart.show();
				alert('Het product is toegevoegd in uw winkelwagen');
			}
		}
	});

	return false;

};

Cart.prototype.remove = function() {

	if (confirm("Weet u zeker dat u dit product uit uw winkelwagentje wilt verwijderen?")) {
		return true;
	}
	
	return false;

}


function confirmDelete(page,id) {

	if (confirm('Weet u zeker dat u het geselecteerde item wilt verwijderen?')) {
		location.href = page+'?id='+id+'&action=delete';
		return true;
	}
	return false;

}


onerror = errorHandler;
Error = new Error();
Cart = new Cart();

/**
 * Constructor functies
 */
window.onload = function(e) {
	try {
		Cart.show();
		document.execCommand("BackgroundImageCache", false, true);
	}
	catch(exception) {}
};