function csubmit() {
	var type = null;
	for (var i=0; i < document.paiement.form_type.length; i++) {
		if (document.paiement.form_type[i].checked) {
			type = document.paiement.form_type[i].value;
		}
	}
	
	if ((type == null) || ((type != 'paypal') && (type != 'datatrans'))) {
		alert("Merci de choisir PayPal / Datatrans pour le paiement.");
		return;
	}
	
	//nom
	var nom = document.getElementById('form_name').value;
	if ((nom == null) || (nom == '')) {
		alert("Merci d'indiquer votre nom.");
		return;
	}
	document.getElementById('nom_'+type).value = '(C) '+nom;
	
	//voyant
	var select = document.getElementById('form_voyant');
	var voyant = select.options[select.selectedIndex].value;
	if ((voyant == null) || (voyant == '')) {
		alert("Merci de choisir un voyant.");
		return;
	}
	document.getElementById('ref_'+type).value = 'V#'+voyant;
	
	//montant
	if (!is_number('form_somme')) {
		alert("Merci d'indiquer un montant.");
		return;
	}
	var amount = document.getElementById('form_somme').value;
	if (type == 'datatrans') {
		amount = amount * 100;
	}
	document.getElementById('amount_'+type).value = amount;
	
	//currency
	var curr = document.getElementById('form_currency');
	var curr_val = curr.options[curr.selectedIndex].value;
	if ((curr_val == null) || ((curr_val != 'CHF') && (curr_val != 'EUR'))) {
		alert('Merci de choisir la monnaie: euros ou francs suisses.');
		return;
	}
	document.getElementById('currency_'+type).value = curr_val;
	
	//all clear!
	document.getElementById(type).submit();
}

function is_number(id) {
	var obj = document.getElementById(id);
	
	if (obj == null) {
		return 0;
	}
	
	obj.value = obj.value.replace(/,/g , ".");
	if (!(obj.value.match(/^(\d*\.{0,1}\d+|)$/g))) {		
		obj.focus();
		return 0;
	} else {
		return 1;
	}
}

