var Minicart = Class.create();
Minicart.prototype = {
    initialize: function(minicartUrl){
        this.minicartUrl = minicartUrl;
        this.onUpdate = this.fillForm.bindAsEventListener(this);
        this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
    },

    update: function(){
		var request = new Ajax.Request(
			this.minicartUrl,
			{
				method: 'post',
				onComplete: this.onComplete,
				onSuccess: this.onUpdate,
				onFailure: this.onComplete
			}
		);
    },

    fillForm: function(transport){
        var elementValues = {};
        if (transport && transport.responseText){
            try{
                elementValues = eval('(' + transport.responseText + ')');
            }
            catch (e) {
                elementValues = {};
            }
        }
        else{
            // do nothing.
        }
		
		$('quick-access').innerHTML = transport.responseText;
		
    },
	
	startLoadWaiting: function(transport) {
		// If we want to show the Loading image set it here.
	},
	
	resetLoadWaiting: function(transport) {
		// If Loading image is set, unset it here.
	}
}
