






// Permet l'ouverture d'une popup
function popup(url,width,height)
{
	window.open(url,'','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width='+width+',height='+height+',left='+(screen.width - width)/2+',top='+(screen.height - height)/2+'');
}





/* Routine d'affichage/cache de div : http://www.webmasterworld.com/forum91/441.htm */
function voircacher(id)
{
	if (document.getElementById)
	{
		obj = document.getElementById(id);
		if (obj.style.display == "none")
		{
			obj.style.display = "";
		}
		else
		{
			obj.style.display = "none";
		}
	}
} // Fin fonction


function AjaxEnterPressed(evenement, url, dest, formId, loadType){
    var touche = window.event ? evenement.keyCode : evenement.which;
    
    // Enter
    if( touche == 13 ){
    	AjaxPostRequest(url, dest, formId, loadType);
    }
    
}



var checkAll_checked = false;
function checkAll(form_name){
	
	// Coche ou dé-coche
	checkAll_checked = !checkAll_checked;
	
	var tab_input = $(form_name).getElementsByTagName('input');
    for(var i=0; i<tab_input.length; i++){
   		tab_input[i].checked = checkAll_checked;
    }

}//checkAll



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) {  }
	});
}







function AjaxRequest(url, dest, loadType){
	
	switch(loadType) {
		case 'load':
			load = $(dest).innerHTML = "<div style='height: 280px; text-align: center;'>Chargement en cours ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		case 'contacts':
			load = $(dest).innerHTML = "<div style='height: 280px; text-align: center;'>Chargement en cours ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		case 'commande':
			load = $(dest).innerHTML = "<div style='height: 280px; text-align: center;'>Traitement de votre commande en cours ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		case 'exec':
			load = $(dest).innerHTML = "<div style='padding-top: 22px; text-align: center; font-size: 15px;'>Execution en cours, merci de patienter ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		default :
			load = $(dest).innerHTML = $(dest).innerHTML;
			break;
	}
	
	
	
	var myAjax = new Ajax.Request(url,
	{
	method: 'get',
	parameters: {format: 'html'},
	onLoading: function() { load; },
	onComplete: function(transport) { $(dest).innerHTML = transport.responseText; }
	});
}






function AjaxDelRequest(url, dest){
	var myAjax = new Ajax.Request(url,
	{
	method: 'get',
	parameters: {format: 'html'},
	onComplete: function(transport) { $(dest).innerHTML = '' }
	});
}






function AjaxPostRequest(url, dest, formId, loadType){

	// Serialization des champs du formulaire
	parametres = Form.serialize(formId);

	switch(loadType) {
		case 'off':
			load = $(dest).innerHTML;
			break;
		case 'load':
			load = $(dest).innerHTML = "<div>Chargement ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		case 'whois':
			load = $(dest).innerHTML = "<p style='margin-top: 100px; text-align:center; font-size:1.4em;'>VÃ©rification de la disponibilitÃ© des domaines en cours ...<br><img src='/images/public/ajax-loader2.gif' /></p>";
			break;
		case 'exec':
			load = $(dest).innerHTML = "<div style='padding-top: 22px; text-align: center; font-size: 15px;'>Execution en cours, merci de patienter ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		case 'commande':
			load = $(dest).innerHTML = "<div style='height: 280px; text-align: center; font-size: 15px;'>Traitement de votre commande en cours ...<br><img src='/images/public/ajax-loader2.gif' /></div>";
			break;
		default :
			load = $(dest).innerHTML;
			break;
	}

	
	var myAjax = new Ajax.Request(url,
	{
	method: 'POST',
	parameters: parametres,
	onLoading: function() { load ; },
	onComplete: function(transport) { 
			$(dest).innerHTML = transport.responseText;
		}
	});
}//AjaxPostRequest



function ongletsStatic(eltId, arrLinkId) {
	intNbLinkElt = new Number(arrLinkId.length);
	arrClassLink = new Array('current','ghost');
	strContent = new String()
	for (i=0; i<intNbLinkElt; i++) {
		strContent = "menu"+arrLinkId[i];
		if ( arrLinkId[i] == eltId ) {
			document.getElementById(arrLinkId[i]).className = arrClassLink[0];
			document.getElementById(strContent).className = 'on content';
		} else {
			document.getElementById(arrLinkId[i]).className = arrClassLink[1];
			document.getElementById(strContent).className = 'off content';
		}
	}	
}




 /***********************************************************************
 * public
 ***********************************************************************/


  
    
 /***********************************************************************
 * 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 = '';
			}else{
				$('transfert_'+domaineId).checked = 'checked';
			}
			
			
		}
		
	}	

}//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 });
}
   
    
 /***********************************************************************
 * Public
 ***********************************************************************/
	function vip() {
		window.open('./popvip','test','width=400, height=350, toolbar=0, status=0, scrollbars=0, resizable=0');
	}
	function monitoring() {
		window.open('./popmonitoring','test','width=400, height=250, toolbar=0, status=0, scrollbars=0, resizable=0');
	}
    