/*
Script: cartops.js
*/
var $url="http://bestworldcoins.com/cartops.php";
function addToCart (id, quantity) {
	var myAjax = new Ajax ($url, {
                      postBody: "action=add&id="+id+"&quantity="+quantity, 
		      update: $('cartsnapshot'), 
		      onComplete: flashCartSnapshot
	    });
	myAjax.request();
	alert (myAjax.response.text);
	
    new Ajax ($url, {
	              postBody: "action=refreshcart",
		      update: $('leftmenucart') 
		      }).request();
    popup_show('add_popup', 'add_popup_drag', 'add_popup_exit', 'mouse-corner', -10, -10);
}

function myPopUpExit(element) {
   element.style.visibility = 'hidden';
   element.style.display    = 'none';
}

function removeFromCartNE (id, quantity) {

    new Ajax ($url, {
	postBody: "action=remove&id="+id+"&quantity="+quantity 
                    }).request();
}

function removeFromCart (id, quantity) {

    new Ajax ($url, {
	postBody: "action=remove&id="+id+"&quantity="+quantity, 
		      update: $('cartsnapshot'), 
		      onComplete: flashCartSnapshot
		      }).request();
    new Ajax ($url, {
	postBody: "action=refreshcart",
		      update: $('leftmenucart') 
		      }).request();
    popup_show('remove_popup', 'remove_popup_drag', 'remove_popup_exit', 'mouse-corner', '-10', '-10');
}

//this will be called on request completion. 
//The request object will be passed by moo.ajax as default.
function flashCartSnapshot(request){
    var effect = $('cartsnapshot').effect('background-color', {duration: 500});
    effect.start('#6684a0').chain(function() {
	effect.start('#ffffe4');
    });
}
