// 
//  refill.js
//  Pages recharge.
//  

/*function validate_amount_and_move_to_step3(ev) {
	if (ev) { Event.stop(ev); }
	
	// Validation du montant.
	var montant = parseInt($('montant').getValue());
	if (isNaN(montant) || montant < 5 || montant > 100) {
		$('montant').addClassName('error');
		$('notice-amount').innerHTML = "Le montant doit être un nombre en 5 et 100.";
		$('notice-amount').show();
	} else {
		$('montant').removeClassName('error');
			$('notice-amount').hide();
		$('montant').setValue(montant);
		if (! $('step3').visible()) {
			new Effect.SlideDown('step3', {duration: 0.5});
			getListOptTarif();
		}
			
	}
	
	return false;
}*/

document.observe('dom:loaded', function(){
	['step2', 'step3','step3-2', 'row-valider', 'notice-amount'].each(Element.hide);
	
	$('switch-prepaye-radio').observe('click', function(ev){
		$('row-valider').hide();
		new Effect.SlideDown('step2', {duration: 0.5});
		/* $('step2').show(); */
	});
	
	$('switch-blocked-radio').observe('click', function(ev){
		['step2', 'step3','step3-2'].each(Element.hide);
		new Effect.SlideDown('row-valider', {duration: 0.5});
	});

	//$('amount-ok').observe('click', validate_amount_and_move_to_step3);

	$$('#step3 input').each(function(el){
		$(el).observe('click', function(){
			$('row-valider').show();
		})
	})
	
	// Prevent submission of the form by return key, in the middle
	// of the 3 step process.
	$('left-col').observe('submit', function(ev){
		if ($('switch-prepaye-radio').checked && ! $('step3').visible()) {
			Event.stop(ev);
			//validate_amount_and_move_to_step3();
		}
	})
});