var CProduct = new Class({
	showTotalIndicator : function()	{
		$('product_total_indicator').setStyle('visibility', 'visible') ;
		$('product_total_indicator').setStyle('display', 'block') ;
	},
	
	hideTotalIndicator : function()	{
		$('product_total_indicator').setStyle('visibility', 'hidden') ;
		$('product_total_indicator').setStyle('display', 'none') ;
	},
	
	showTotal : function()	{
		$('product_total').setStyle('visibility', 'visible') ;
		$('product_total').setStyle('display', 'block') ;
	},
	
	hideTotal : function()	{
		$('product_total').setStyle('visibility', 'hidden') ;
		$('product_total').setStyle('display', 'none') ;
	},	
	
  updateQuantity : function(experience, select) {
    this.updateTotal(experience) ;
  },

  updateLocalization : function(experience, select) {
    this.updateTotal(experience) ;
  },
    
	updateTotal : function(experience)	{
		this.hideTotal() ;
		this.showTotalIndicator() ;
		
		var qstr = Object.toQueryString({
			'command': 'get_total', 
			'experience': experience,
      'quantity': ($('quantity') ? $('quantity').value : 1),
      'localization': ($('localization') ? $('localization').value : 0),
			'insurance': ($('insurance') && $('insurance').checked ? 1 : 0),
			'present': ($('present') && $('present').checked ? 1 : 0)
		}) ;
		var rq = new Ajax('/experiences/process.php', {method: 'post', data: qstr, onComplete: Product.refreshTotal}) ;
		rq.request() ;
		
		return false ;
	},
	
	refreshTotal : function(response)	{
		product = Json.evaluate(response) ;
		
		$('product_total').setHTML($('product_total').getAttribute('prefix') + ' ' + product.total) ;
		
		Product.hideTotalIndicator.delay(1000) ;
		Product.showTotal.delay(1000) ;
	}	
}) ;

var Product = new CProduct() ;
