 /***********************************************************************
 * COMMANDE
 ***********************************************************************/
 
function openFormule(domaineId, typeFormuleId){

	var element = domaineId+'_'+typeFormuleId;
	
	// Afficher l'élément lors du clic
	$(element).style.display = '';
	
	// Premier élément coché dans la liste des formules du type choisi
	var tab_input = $(element).getElementsByTagName('input');
	tab_input[0].checked = 'checked';
	
	// Déplie les formules du type utilisé
	// Replie les autres formules ouvertes diférentes du type coché
	var tab_table = $('domaine_'+domaineId).getElementsByTagName('table');
	for(var i=0; i<tab_table.length; i++){
	
		var table_id = tab_table[i].id;
		
		if( table_id != 'formules_'+domaineId+'_'+typeFormuleId ){
			tab_table[i].style.display = 'none';
		}else{
		
			// La formule choisie est du type 2 (Domaine) : ne pas déplier
			if(typeFormuleId == 2){
				tab_table[i].style.display = 'none';
			}else{
			// La formule choisie n'est pas de type 2 (Domaine) : déplier
				tab_table[i].style.display = '';
			}
			
			

			if(typeFormuleId == 6){
				$('transfert_'+domaineId).checked = '';
				$('transfert_'+domaineId).disabled = 'true';
			}else{
				$('transfert_'+domaineId).checked = 'checked';
				$('transfert_'+domaineId).disabled = '';
			}
			
			
		}
		
	}	

}//openFormule
 
 
function setTransfert(domaine_id, value){

	var myAjax = new Ajax.Request('/commande/index/setTransfertDomaine/id/'+domaine_id+'/value/'+value,
	{
	method: 'get',
	parameters: {format: 'html'},
	onComplete: function(transport) { $('commande').innerHTML = transport.responseText; }
	});
}
	
/*
 * effet toggle sur les contacts d'un domaine.
 */
function toggleContacts(divId) {

	var time = 0.5;
	
	switch(divId) {
		case 'public':
			Effect.toggle('admin','blind', { duration: time });
			Effect.BlindUp('billing', { duration: time });
			Effect.BlindUp('tech', { duration: time });
			Effect.BlindUp('registrant', { duration: time });
			break;
		case 'billing':
			Effect.BlindUp('admin', { duration: time });
			Effect.toggle('billing','blind', { duration: time });
			Effect.BlindUp('tech', { duration: time });
			Effect.BlindUp('registrant', { duration: time });
			break;
		case 'tech':
			Effect.BlindUp('admin', { duration: time });
			Effect.BlindUp('billing', { duration: time });
			Effect.toggle('tech','blind', { duration: time });
			Effect.BlindUp('registrant', { duration: time });
			break;
		case 'registrant':
			Effect.BlindUp('admin', { duration: time });
			Effect.BlindUp('billing', { duration: time });
			Effect.BlindUp('tech', { duration: time });
			Effect.toggle('registrant','blind', { duration: time });
			break;
	}
	
}


function showCart(id){
	Effect.toggle('dom_'+id,'blind', { duration: 0 });
}

function setCGV(){

	// Récup des valeurs
	var checked = document.getElementById('conditions').checked;

	if(checked==true){
		var flag = "true";
	}else{
		var flag = "false";
	}

	// MAJ en session
	var url = '/commande/index/appliquercgv/conditions/'+flag;
	var myAjax = new Ajax.Request(url,
	{
	method: 'get',
	parameters: {format: 'html'},
	onLoading: function() {  },
	onComplete: function(transport) {  }
	});
}