var CCaddy = new Class({
	isModified : false,
	experience : null,
	caddySlide : null,
	
	/**
	 * POURSUIVRE LA COMMANDE
	**/
	order : function()	{
		location.href = "/checkout/identification.php" ;
	},	

	/**
	 * ADD EXPERIENCE TO CART
	**/
	hideSmallCaddy : function()	{
		this.caddySlide.hide() ;
	},	
	toggleSmallCaddy : function () {
		if (this.caddySlide)	{
			this.caddySlide.toggle() ;
		}	
	},
	
    addToCart : function(experience, refresh)   {
        var qstr = Object.toQueryString({
            'command': 'add_experience', 
            'experience': experience,
            'insurance': ($('insurance') && $('insurance').checked ? 1 : 0),
            'present': ($('present') && $('present').checked ? 1 : 0),
            'localization': ($('localization') ? $('localization').value : 0),
            'quantity': ($('quantity') ? $('quantity').value : 1)
        }) ;
        var rq = new Ajax('/checkout/caddy/smallcaddy.php', {method: 'post', data: qstr, onComplete: refresh}) ;
        rq.request() ;
        
        return false ;
    },

    addBoxToCart : function(experience, refresh)   {
        var qstr = Object.toQueryString({
            'command': 'add_box', 
            'experience': experience,
            'insurance': ($('insurance') && $('insurance').checked ? 1 : 0),
            'present': ($('present') && $('present').checked ? 1 : 0),
            'localization': ($('localization') ? $('localization').value : 0),
            'quantity': ($('quantity') ? $('quantity').value : 1)
        }) ;
        var rq = new Ajax('/checkout/caddy/smallcaddy.php', {method: 'post', data: qstr, onComplete: refresh}) ;
        rq.request() ;
        
        return false ;
    },

	removeFromCart : function(key)	{
		var qstr = Object.toQueryString({
			'command': 'remove_experience', 
			'key': key
		}) ;
		var rq = new Ajax('/checkout/caddy/smallcaddy.php', {method: 'post', data: qstr, onComplete: Caddy.refreshCaddyOnly}) ;
		rq.request() ;
		
		return false ;
	},
	
	refreshCaddy : function(response)	{
		$('smallcaddy').setHTML(response) ;
		
		Caddy.caddySlide = new Fx.Slide('smallcaddy_content') ;
		if ($('small_caddy_nbarticle').getText() > 0)	{
			Caddy.caddySlide.show() ;
		} else {
			Caddy.caddySlide.hide() ;
		}	
	},	
	
	refreshCaddyOnly : function(response)	{
		$('smallcaddy').setHTML(response) ;
		Caddy.caddySlide = new Fx.Slide('smallcaddy_content') ;
		Caddy.caddySlide.show() ;
		
		if ($('small_caddy_nbarticle').getText() > 0)	{
			Caddy.caddySlide.show() ;
		} else {
			Caddy.caddySlide.hide() ;
		}	
	},	
	
	hideAddCartIndicator : function(experience)	{
		$('add_cart_indicator_' + experience).setStyle('visibility', 'hidden') ;
		$('add_cart_indicator_' + experience).setStyle('display', 'none') ;
	},
	
	showAddCartIndicator : function(experience)	{
		$('add_cart_indicator_' + experience).setStyle('visibility', 'visible') ;
		$('add_cart_indicator_' + experience).setStyle('display', 'block') ;
	},	

	hideAddCartButton : function(experience)	{
		$('add_cart_button_' + experience).setStyle('visibility', 'hidden') ;
		$('add_cart_button_' + experience).setStyle('display', 'none') ;
	},
	
	showAddCartButton : function(experience)	{
		$('add_cart_button_' + experience).setStyle('visibility', 'visible') ;
		$('add_cart_button_' + experience).setStyle('display', 'block') ;
	},	

    /* ajout d'une experience dans le caddy depuis la fiche d'une experience */
    addToCartFromExperience : function (experience) {
        this.experience = experience ;
        this.hideAddCartButton(experience) ;
        this.showAddCartIndicator(experience) ;

        this.addToCart(experience, Caddy.refreshCaddyFromExperience) ;

        return false ;
    },

    /* ajout d'un coffret dans le caddy depuis la fiche d'une experience */
    addBoxToCartFromExperience : function (experience) {
        this.experience = experience ;
        this.hideAddCartButton(experience) ;
        this.showAddCartIndicator(experience) ;

        this.addBoxToCart(experience, Caddy.refreshCaddyFromExperience) ;

        return false ;
    },

	/* rafraichis le caddy depuis la fiche d'une expérience */
	refreshCaddyFromExperience : function (response)	{
		Caddy.refreshCaddy(response) ;

		Caddy.setAddCartExperienceIndicatorDone.delay(1000, Caddy, Caddy.experience) ;
		Caddy.hideAddCartIndicator.delay(2500, Caddy, Caddy.experience) ;
		Caddy.showAddCartButton.delay(2500, Caddy, Caddy.experience) ;
		Caddy.setAddCartExperienceIndicatorProcess.delay(2500, Caddy, Caddy.experience) ;
	},

	/* ajout d'une experience dans le caddy depuis la liste des experiences */
	addToCartFromExperiencesList : function (experience)	{
		this.experience = experience ;
		this.hideAddCartButton(experience) ;
		this.showAddCartIndicator(experience) ;
		
		this.addToCart(experience, Caddy.refreshCaddyFromExperiencesList) ;
		
		return false ;
	},
	
	/* set experience indicator done */
	setAddCartExperienceIndicatorDone : function(experience)	{
		$('add_cart_indicator_' + experience).className = 'add_cart_experience_indicator_done' ;
	},	

	setAddCartExperienceIndicatorProcess : function(experience)	{
		$('add_cart_indicator_' + experience).className = 'add_cart_experience_indicator' ;
	},	
	
	/* rafraichis le caddy depuis la liste des expériences */
	refreshCaddyFromExperiencesList : function (response)	{
		Caddy.refreshCaddy(response) ;

		Caddy.setAddCartListIndicatorDone(Caddy.experience) ;
		Caddy.hideAddCartIndicator.delay(1500, Caddy, Caddy.experience) ;
		Caddy.showAddCartButton.delay(1500, Caddy, Caddy.experience) ;
		Caddy.setAddCartListIndicatorProcess.delay(1500, Caddy, Caddy.experience) ;
	},
	
	/* set list indicator done */
	setAddCartListIndicatorDone : function(experience)	{
		$('add_cart_indicator_' + experience).className = 'add_cart_indicator_done' ;
	},	

	setAddCartListIndicatorProcess : function(experience)	{
		$('add_cart_indicator_' + experience).className = 'add_cart_indicator' ;
	},	

	/**
	 * REMOVE EXPERIENCE FROM CART
	**/
	removeExperience : function(key)	{
		this.hideRemoveButton(key) ;
		this.hidePromotionTotal() ;
		this.hideTotal() ;
		this.showRemoveIndicator(key) ;
		this.showTotalIndicator() ;
		this.showPromotionIndicator() ;
		
		var qstr = Object.toQueryString({
			'command': 'remove_experience', 
			'key': key
		}) ;
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshTotalsAfterRemove}) ;
		rq.request() ;
		
		return false ;
	},
	
	refreshTotalsAfterRemove : function(response)	{
		checkout = Json.evaluate(response) ;
		
		$('experience_' + checkout.key).remove() ;
    /*
    $('experience_' + checkout.key).style.display = 'none' ;
		$('experience_insurance_' + checkout.key).remove() ;
		$('experience_present_' + checkout.key).remove() ;
		$('experience_present_infos_' + checkout.key).remove() ;
    */
		$('total').setHTML(checkout.total) ;
		$('promotion_total').setHTML(checkout.promotion_total) ;

		Caddy.hideTotalIndicator() ;
		Caddy.hidePromotionIndicator() ;
		Caddy.showTotal() ;
		Caddy.showPromotionTotal() ;
	},	

	hideRemoveButton : function(key)	{
		$('remove_button_' + key).setStyle('visibility', 'hidden') ;
		$('remove_button_' + key).setStyle('display', 'none') ;
	},
	
	showRemoveButton : function(key)	{
		$('remove_button_' + key).setStyle('visibility', 'visible') ;
		$('remove_button_' + key).setStyle('display', 'block') ;
	},	

	hideRemoveIndicator : function(key)	{
		$('remove_indicator_' + key).setStyle('visibility', 'hidden') ;
		$('remove_indicator_' + key).setStyle('display', 'none') ;
	},
	
	showRemoveIndicator : function(key)	{
		$('remove_indicator_' + key).setStyle('visibility', 'visible') ;
		$('remove_indicator_' + key).setStyle('display', 'block') ;
	},	
	
	/**
	 * ADD / REMOVE PRESENT AND INSURANCE
	**/
	addRemovePresent : function(key, checked)	{
		this.hideProductTotal(key) ;
		this.hideTotal() ;
		this.hidePromotionTotal() ;
		this.showHidePresentInfos(key, checked) ;
		this.showProductTotalIndicator(key) ;
		this.showTotalIndicator() ;
		this.showPromotionIndicator() ;
		
		if (checked)	{
			var command = 'add_present' ;
		} else {
			var command = 'remove_present' ;
		}	

		var qstr = Object.toQueryString({'command': command, 'key': key}) ;
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshTotals}) ;
		rq.request() ;
	},

  updateQuantity : function(key, quantity)  {
    this.hideProductTotal(key) ;
    this.hideTotal() ;
    this.hidePromotionTotal() ;
    this.showProductTotalIndicator(key) ;
    this.showTotalIndicator() ;
    this.showPromotionIndicator() ;
    
    var qstr = Object.toQueryString({'command': 'set_quantity', 'key': key, 'quantity': quantity}) ;
    var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshTotals}) ;
    rq.request() ;
  },

  updateLocalization : function(key, localization)  {
    this.hideProductTotal(key) ;
    this.hideTotal() ;
    this.hidePromotionTotal() ;
    this.showProductTotalIndicator(key) ;
    this.showTotalIndicator() ;
    this.showPromotionIndicator() ;
    
    var qstr = Object.toQueryString({'command': 'set_localization', 'key': key, 'localization': localization}) ;
    var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshTotals}) ;
    rq.request() ;
  },

	addRemoveInsurance : function(key, checked)	{
		this.hideProductTotal(key) ;
		this.hideTotal() ;
		this.hidePromotionTotal() ;
		this.showProductTotalIndicator(key) ;
		this.showTotalIndicator() ;
		this.showPromotionIndicator() ;
		
		if (checked)	{
			var command = 'add_insurance' ;
		} else {
			var command = 'remove_insurance' ;
		}
		
		var qstr = Object.toQueryString({'command': command, 'key': key}) ;
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshTotals}) ;
		rq.request() ;
	},
	
	showProductTotal : function(key)	{
		$('total_' + key).setStyle('visibility', 'visible') ;
		$('total_' + key).setStyle('display', 'block') ;
	},	
	
	showProductTotalIndicator : function(key)	{
		$('experience_indicator_' + key).setStyle('visibility', 'visible') ;
		$('experience_indicator_' + key).setStyle('display', 'block') ;
	},
	
	showTotal : function()	{
		$('total').setStyle('visibility', 'visible') ;
		$('total').setStyle('display', 'block') ;
	},	
	
	showTotalIndicator : function()	{
		$('total_indicator').setStyle('visibility', 'visible') ;
		$('total_indicator').setStyle('display', 'block') ;
	},

  hideProductTotal : function(key)	{
		$('total_' + key).setStyle('visibility', 'hidden') ;
		$('total_' + key).setStyle('display', 'none') ;
	},

	hideProductTotalIndicator : function(key)	{
		$('experience_indicator_' + key).setStyle('visibility', 'hidden') ;
		$('experience_indicator_' + key).setStyle('display', 'none') ;
	},
	
	hideTotal : function()	{
		$('total').setStyle('visibility', 'hidden') ;
		$('total').setStyle('display', 'none') ;
	},
		
	hideTotalIndicator : function()	{
		$('total_indicator').setStyle('visibility', 'hidden') ;
		$('total_indicator').setStyle('display', 'none') ;
	},
	
	refreshTotals : function(response)	{
		var caddy = Json.evaluate(response) ;
		
		$('total').setHTML(caddy.total) ;
		$('promotion_total').setHTML(caddy.promotion_total) ;
		$('total_' + caddy.key).setHTML(caddy.experience_total) ;

		Caddy.hideTotalIndicator() ;
		Caddy.hidePromotionIndicator() ;
		Caddy.hideProductTotalIndicator(caddy.key) ;
		Caddy.showTotal() ;
		Caddy.showPromotionTotal() ;
		Caddy.showProductTotal(caddy.key) ;
	},

	/**
	 * IS EXCHANGED
	**/
	isExchanged : function (exchanged)	{
		if (exchanged)	{
			//this.removePromotion() ;
			//this.removePresents() ;
			//this.hidePromotion() ;
		} else {
			//this.enablePresents() ;
			//this.showPromotion() ;
		}	

		this.hideTotal() ;
		this.showTotalIndicator() ;

		var qstr = Object.toQueryString({
			'command': 'set_exchanged',
			'exchanged': exchanged ? 1 : 0
		}) ;
		
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', onComplete: Caddy.refreshExchanged, data: qstr}) ;
		rq.request() ;
	},
	
	refreshExchanged : function(response)	{
		checkout = Json.evaluate(response) ;
		
		$('total').setHTML(checkout.total) ;
		
		Caddy.hideTotalIndicator() ;
		Caddy.showTotal() ;
	},

	enablePresents : function()	{
		$$('.experience_id').each(function(e) {
			var id = e.getAttribute('id') ;
			pos = id.lastIndexOf('_') ;
			key = id.substr(pos+1) ;
			$('present_' + key).disabled = false ;
		}) ;
	},	

	/* retire tous les emballages cadeaux sélectionnés */
  removePresents : function()	{
		$$('.experience_id').each(function(e) {
			var id = e.getAttribute('id') ;
			pos = id.lastIndexOf('_') ;
			key = id.substr(pos+1) ;
			
			if ($('present_' + key).checked)	{
				$('present_' + key).checked = false ;
				
				Caddy.hideProductTotal(key) ;
				Caddy.showHidePresentInfos(key, false) ;
				Caddy.showProductTotalIndicator(key) ;
				
				var command = 'remove_present' ;
				
				var qstr = Object.toQueryString({'command': command, 'key': key}) ;
				var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshTotals}) ;
				rq.request() ;
			}
			
			$('present_' + key).disabled = true ;
		}) ;
	},

  removePromotion : function()	{
		this.hideTotal() ;
		this.hidePromotionTotal() ;
		this.showTotalIndicator() ;
		this.showPromotionIndicator() ;
		this.hidePromotionError() ;
		
		var qstr = Object.toQueryString({
			'command': 'del_promotion_code'
		}) ;
		
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshPromotion}) ;
		rq.request() ;
		
		return false ;
	},	
	
	hidePromotion : function()	{
		$('promotion').setStyle('visibility', 'hidden') ;
		$('promotion').setStyle('display', 'none') ;
	},
	
	showPromotion : function()	{
		$('promotion').setStyle('visibility', 'visible') ;
		$('promotion').setStyle('display', 'block') ;
	},

	/**
	 * PROMOTION ADD / REMOVE
	**/
  addRemovePromotion : function (has_promotion)	{
		this.hideTotal() ;
		this.hidePromotionTotal() ;
		this.showTotalIndicator() ;
		this.showPromotionIndicator() ;
		this.hidePromotionError() ;
		
		var qstr = Object.toQueryString({
			'command': 'add_remove_promotion',
			'code': $('code').value
		}) ;
		
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshPromotion}) ;
		rq.request() ;
		
		return false ;
	},

	refreshPromotion : function(response)	{
	    //location.href = '/checkout/caddy.php' ;
		var checkout = Json.evaluate(response) ;
		
		if (!checkout.error)	{
            if (checkout.has_promotion) {
                if (checkout.promotion_type == 'club') {
                    location.href = '/checkout/caddy.php' ;
                }
                
                Caddy.hidePromotionAdd() ;
                Caddy.showPromotionRemove() ;
            } else {
                Caddy.hidePromotionRemove() ;
                Caddy.showPromotionAdd() ;
            }

            $('promotion_total').setHTML(checkout.promotion_total) ;
            $('total').setHTML(checkout.total) ;
		} else {
			$('promotion_error').setText(checkout.message) ;
			Caddy.showPromotionError() ;
		}	

		Caddy.hideTotalIndicator() ;
		Caddy.hidePromotionIndicator() ;
		Caddy.showTotal() ;
		Caddy.showPromotionTotal() ;
	},
	
	hidePromotionError : function()	{
		$('promotion_error').setStyle('visibility', 'hidden') ;
		$('promotion_error').setStyle('display', 'none') ;
	},	

	showPromotionError : function()	{
		$('promotion_error').setStyle('visibility', 'visible') ;
		$('promotion_error').setStyle('display', 'block') ;
	},	
	
	hidePromotionIndicator : function()	{
		$('promotion_indicator').setStyle('visibility', 'hidden') ;
		$('promotion_indicator').setStyle('display', 'none') ;
	},

	showPromotionIndicator : function()	{
		$('promotion_indicator').setStyle('visibility', 'visible') ;
		$('promotion_indicator').setStyle('display', 'block') ;
	},

	hidePromotionTotal : function()	{
		$('promotion_total').setStyle('visibility', 'hidden') ;
		$('promotion_total').setStyle('display', 'none') ;
	},

	showPromotionTotal : function()	{
		$('promotion_total').setStyle('visibility', 'visible') ;
		$('promotion_total').setStyle('display', 'block') ;
	},
	
	hidePromotionAdd : function()	{
		$('promotion_add').setStyle('visibility', 'hidden') ;
		$('promotion_add').setStyle('display', 'none') ;
	},

	showPromotionAdd : function()	{
		$('promotion_add').setStyle('visibility', 'visible') ;
		$('promotion_add').setStyle('display', 'block') ;
	},

	hidePromotionRemove : function()	{
		$('promotion_remove').setStyle('visibility', 'hidden') ;
		$('promotion_remove').setStyle('display', 'none') ;
	},

	showPromotionRemove : function()	{
		$('promotion_remove').setStyle('visibility', 'visible') ;
		$('promotion_remove').setStyle('display', 'block') ;
	},
	
	/**
	 * PRESENTS MESSAGE / ADDRESS MODIFICATION
	**/
	showHidePresentInfos : function(key, checked)	{
		if (checked)	{
			$('present_infos_' + key).setStyle('display', 'block') ;
			$('present_infos_' + key).setStyle('visibility', 'visible') ;
		} else {
			$('present_infos_' + key).setStyle('display', 'none') ;
			$('present_infos_' + key).setStyle('visibility', 'hidden') ;
		}	
	},
	
	savePresentInfos : function(key)	{
		this.showPresentSaveIndicator(key) ;
		this.hidePresentSaveButton(key) ;
		
		var qstr = Object.toQueryString({
			'command': 'save_present_infos', 
			'key': key, 
			'message': $('present_message_' + key).value, 
			'contact': $('select_address_' + key) ? $('select_address_' + key).value : 0,
			'firstname': $('present_firstname_' + key).value,
			'lastname': $('present_lastname_' + key).value,
			'address': $('present_address_' + key).value,
			'postcode': $('present_postcode_' + key).value,
			'city': $('present_city_' + key).value/*,
			'email': $('present_email_' + key).value*/
		}) ;
		
		var rq = new Ajax('/checkout/caddy/process.php', {method: 'post', data: qstr, onComplete: Caddy.refreshPresent}) ;
		rq.request() ;
		
		return false ;
	},
	
	showPresentSaveIndicator : function(key)	{
		$('present_indicator_' + key).setStyle('visibility', 'visible') ;
		$('present_indicator_' + key).setStyle('display', 'block') ;
	},

	hidePresentSaveIndicator : function(key)	{
		$('present_indicator_' + key).setStyle('visibility', 'hidden') ;
		$('present_indicator_' + key).setStyle('display', 'none') ;
	},

	showPresentSaveButton : function(key)	{
		$('present_save_' + key).setStyle('visibility', 'visible') ;
		$('present_save_' + key).setStyle('display', 'block') ;
	},

	hidePresentSaveButton : function(key)	{
		$('present_save_' + key).setStyle('visibility', 'hidden') ;
		$('present_save_' + key).setStyle('display', 'none') ;
	},
	
	showPresentMessageModified : function (key)	{
		$('message_modified_' + key).setStyle('visibility', 'visible') ;
		$('message_modified_' + key).setStyle('display', 'inline') ;
	},
	
	hidePresentMessageModified : function (key)	{
		$('message_modified_' + key).setStyle('visibility', 'hidden') ;
		$('message_modified_' + key).setStyle('display', 'none') ;
	},
	
	showPresentAddressModified : function (key)	{
		$('address_modified_' + key).setStyle('visibility', 'visible') ;
		$('address_modified_' + key).setStyle('display', 'inline') ;
	},
	
	hidePresentAddressModified : function (key)	{
		$('address_modified_' + key).setStyle('visibility', 'hidden') ;
		$('address_modified_' + key).setStyle('display', 'none') ;
	},
	
	refreshPresent : function(response)	{
		var present = Json.evaluate(response) ;
		
		Caddy.refreshSelectAddress() ;
		
		Caddy.hidePresentSaveIndicator(present.key) ;
		Caddy.showPresentSaveButton(present.key) ;
		Caddy.hidePresentMessageModified(present.key) ;
		Caddy.hidePresentAddressModified(present.key) ;

		Caddy.isModified = false ;
	},	

	refreshSelectAddress : function() {
		var rq = new Ajax('/checkout/caddy/get_contacts.php', {method: 'post', onComplete: Caddy.refreshSelectAddressComplete}) ;
		rq.request() ;
	},
	
	refreshSelectAddressComplete : function(response)	{
		contacts = Json.evaluate(response) ;
		
		// refreshing all select box
		$$('.select_address').each(function(e)	{
			// backup of the current selected option
			value = e.value ;
			custom = e.options[0].getText() ;
			
			// removing all options
			length = e.length ;
			for (i = 0 ; i < length + 1 ; i++)	{
				e.remove(0) ;
			} ;

            // creating the custom option
			option = new Element('option', {
				'value' : 0
			}) ;
			option.setText(custom) ;
			option.injectInside(e) ;
			
			// appending each contact
			contacts.each(function(c)	{
				option = new Element('option', {
					'firstname' : c.firstname,
					'lastname' : c.lastname,
					'address' : c.address,
					'postcode' : c.postcode,
					'city' : c.city,
//					'email' : c.email,
					'value' : c.contact
				}) ;
				option.setText(c.firstname + ' ' + c.lastname) ;
				option.injectInside(e) ;
				
				if (c.contact == value)	{
					e.options[e.length-1].selected = true ;
				}	
			}) ;
		}) ;	
	},	
	
	onChangePresentMessage : function(key)	{
		this.showPresentMessageModified(key) ;
		this.isModified = true ;
	},
	
	onChangePresentAddress : function(key)	{
		this.showPresentAddressModified(key) ;
		this.isModified = true ;
		if ($('select_address_' + key)) {
      $('select_address_' + key).options[0].selected = true ;
    }
	},
	
	onChangeSelectAddress : function(key)	{
		this.showPresentAddressModified(key) ;
		this.isModified = true ;
		
		if ($('select_address_' + key).selectedIndex > 0)	{
			obj = $('select_address_' + key).options[$('select_address_' + key).selectedIndex] ;
			$('present_firstname_' + key).value = obj.getAttribute('firstname') ;
			$('present_lastname_' + key).value = obj.getAttribute('lastname') ;
			$('present_address_' + key).value = obj.getAttribute('address') ;
			$('present_postcode_' + key).value = obj.getAttribute('postcode') ;
			$('present_city_' + key).value = obj.getAttribute('city') ;
//			$('present_email_' + key).value = obj.getAttribute('email') ;
		} else {
			$('present_firstname_' + key).value = $('present_firstname_' + key).getAttribute('default') ;
			$('present_lastname_' + key).value = $('present_lastname_' + key).getAttribute('default') ;
			$('present_address_' + key).value = $('present_address_' + key).getAttribute('default') ;
			$('present_postcode_' + key).value = $('present_postcode_' + key).getAttribute('default') ;
			$('present_city_' + key).value = $('present_city_' + key).getAttribute('default') ;
//			$('present_email_' + key).value = $('present_email_' + key).getAttribute('default') ;
		}	
	},	
	
	/**
	 * Résumé de la commande
	**/
	
	validateSummary : function()	{
		if ($('accept').checked != true)	{
			alert($('accept').getAttribute('emsg')) ;
			return false ;
		}
		
		return true ;
	}
}) ;

var Caddy = new CCaddy() ;