
function tx_netvshopbase() {
	var shopbase_version = '1.0';
	var cartContainerId = '';
	var cartSubsessionId = '';
	var remoteUrl = '';
	
	
	
	this.createCartContainer=function(cartContainerId) {
		this.cartContainerId = cartContainerId;
		document.write('<div id="' + this.cartContainerId + '"><!-- DBG_CART_IS_EMPTY_INFO --></div>');
	}
	
	
	this.setRefreshUrl=function(url) {
		this.refreshUrl = url;
	}
	
	this.setRemoteUrl=function(url) {
		this.remoteUrl = url;
	}
	
	this.setCartSubsessionId=function(cartSubsessionId) {
		this.cartSubsessionId = cartSubsessionId;
	}
	
	this.loadConsolidCartContent=function() {
		new Ajax.Updater(this.cartContainerId, this.remoteUrl, {
			method: 'post',
			//insertion: Insertion.Top,
			parameters: { 
				handler: 'loadConsolidCartContent',
				cartSubsessionId: this.cartSubsessionId,
				cartContainerId: this.cartContainerId
			},
			onComplete: function(transport){
				if(transport.responseText == 'hide'){
					$(this.cartContainerId).hide();
				}
				else{
					$(this.cartContainerId).show();
				}
			}
		});
	}
	
	this.loadDetailCartContent=function() {
		new Ajax.Updater(this.cartContainerId, this.remoteUrl, {
			method: 'post',
			//insertion: Insertion.Top,
			parameters: { 
				handler: 'loadDetailCartContent',
				cartSubsessionId: this.cartSubsessionId,
				cartContainerId: this.cartContainerId
			}  
			
		});
	}
	
	this.addToCart=function(product_uid, variant_id,refreshurl){
		var pobj = this;
		new Ajax.Request(this.remoteUrl, {
			method: 'post',
			parameters: {
				handler: 'addToCart',
				cartSubsessionId: this.cartSubsessionId,  
				product_uid: product_uid,
				variant_id: variant_id
			},
			onSuccess: function(){
				if(refreshurl!=undefined && pobj.refreshUrl!=undefined){
					window.location.href = pobj.refreshUrl;
				}
				else{
					pobj.loadConsolidCartContent();
					window.scrollTo(0, 0);
				}
			},
			onFailure: function(){ 
				alert('ADD_TO_CHART_FAILED_ERR');
			}
		});
	}
	
	this.setToCart=function(product_uid, variant_id, quantity){
		var pobj = this;
		new Ajax.Request(this.remoteUrl, {
			method: 'post',
			parameters: {
				handler: 'setToCart',
				cartSubsessionId: this.cartSubsessionId,  
				product_uid: product_uid,
				variant_id: variant_id,
				quantity: quantity
			},
			onSuccess: function(){
				pobj.loadDetailCartContent();
			},
			onFailure: function(){ 
				alert('ADD_TO_CHART_FAILED_ERR');
			}
		});
	}
	
	this.cleanCart=function(){
		var pobj = this;
		new Ajax.Request(this.remoteUrl, {
			method: 'post',
			parameters: {
				handler: 'cleanCart' ,
				cartSubsessionId: this.cartSubsessionId
			},
			onSuccess: function(){
				pobj.loadConsolidCartContent();
			},
			onFailure: function(){ 
				alert('CLEAN_CHART_FAILED_ERR');
			}
		});
	}
}

