/******** FONCTIONS COMMUNES SCRIPTS MODX MARQUE *******/

	function exist(id){
		if($(id).length>0) return true
		return false;
	}

	function checktout(checkb,id,idtxt){
		$(id).find(':checkbox').attr('checked', $(checkb).checked);
		if($(checkb).checked==true) $(idtxt).text('Tout décocher');  else $(idtxt).text('Tout cocher');	
	}

	function count_checkbox(){
		var clength = $(":checkbox:checked").length;
		if(clength<2)
			alert('Merci de sélectionner au moins 2 offres à comparer !');
		else if(clength>4)
			alert("Vous pouvez comparer 4 offres au maximum !");
		else
			$("#compar").submit();	
	}

	function goto(uri,message){
		if(message=="") window.location.href=uri;
		else if(confirm(message)){
			window.location.href=uri;
		}
	}

	function affich_dom(){
		$(".disabled").slideToggle();	
	}
	
	function effet_hl(){
		setTimeout(function(){
			$("#effect").removeAttr('style').fadeOut();
		}, 1000);
	};	
	
	function confirmcgv(){
		if($("#confirm_cgv").length!=0) {
			if(document.getElementById('confirm_cgv').checked===false){
				if(confirm('Vous n\'avez pas coché les CGV.\nCliquez sur OK pour les accepter et poursuivre votre commande.')) { document.getElementById('confirm_cgv').checked=true; return true }
				var options = {};
				$("#confirm_cgv_box").effect("highlight",options,2000,effet_hl);
				return false;
			}
		}
	}
	
	function loading_box(id){
		$.fn.colorbox({inline:true, href:"#loading_box", open:true, width:'300px', height:'200px'});	
		$("#loading_box").show();
		$(id).show();
	}

