$(document).ready(function(){
//offre 1
	// cocher la case 
	$("#offre_80").click( function() { 
		$("#event_80").attr("checked","true");
		// montrer la liste des packs
		$("#pack_location_offre_80").show();
		
		// cacher les offres
		$("#offres_liste").hide();
		$("#pack_location_offre_80_200").hide();
		$("#pack_location_offre_200_1500").hide();
		$("#pack_location_offre_regie").hide();

		mCustomScrollbars();
		return false;
	});
	
//offre 2	
	$("#offre_80_200").click( function() { 
		$("#event_80_200").attr("checked","true");

		// montrer la liste des packs
		$("#pack_location_offre_80_200").show();
		
		// cacher les offres 
		$("#offres_liste").hide();
		$("#pack_location_offre_80").hide();
		$("#pack_location_offre_200_1500").hide();
		$("#pack_location_offre_regie").hide();

		mCustomScrollbars();
		return false;
	});


//offre 3	
	$("#offre_200_1500").click( function() { 
		$("#event_200_1500").attr("checked","true");

		// montrer la liste des packs
		$("#pack_location_offre_200_1500").show();
		
		// cacher les offres
		$("#offres_liste").hide();
		$("#pack_location_offre_80_200").hide();
		$("#pack_location_offre_80").hide();
		$("#pack_location_offre_regie").hide();
		
		mCustomScrollbars();
		return false;
	});

//offre 4
	$("#offre_regie").click( function() { 
		$("#event_regie").attr("checked","true");

		//montrer la liste des packs
		$("#pack_location_offre_regie").show();
		
		// cacher les offres
		$("#offres_liste").hide();
		$("#pack_location_offre_80_200").hide();
		$("#pack_location_offre_80").hide();
		$("#pack_location_offre_200_1500").hide();
		
		mCustomScrollbars();
		return false;
	});

/************************************************/	
	// selectionner/deselectionner les packs 
		// OFFRE 1 pack1
	$("#location_offre_1_pack_1").click( function() { 	
		if( $('#pack_1_1').attr('checked'))
		{			 
			$('#pack_1_1').removeAttr('checked');
			$(".select_pack_1").css({ display: "none"});				
		}
		else
		{
			$('#pack_1_1').attr('checked', 'true');		
			$(".select_pack_1").css({ display: "block"});	
	
		}	
		return false;
	});
		// OFFRE 1 pack2
	$("#location_offre_1_pack_2").click( function() { 
	
		if( $('#pack_1_2').attr('checked') )
		{			 
			 $('#pack_1_2').removeAttr('checked');
			$(".select_pack_2").css({ display: "none"});	
		}
		else
		{
			$('#pack_1_2').attr('checked', 'true');		
			$(".select_pack_2").css({ display: "block"});		
		}	
		return false;
	});
		// OFFRE 1 pack3
	$("#location_offre_1_pack_3").click( function() { 
	
		if( $('#pack_1_3').attr('checked') )
		{			 
			 $('#pack_1_3').removeAttr('checked');
			$(".select_pack_3").css({ display: "none"});	
		}
		else
		{
			$('#pack_1_3').attr('checked', 'true');		
			$(".select_pack_3").css({ display: "block"});		
		}	
		return false;
	});
	
/************************************************/	
		// OFFRE 2 pack1
	$("#location_offre_2_pack_1").click( function() { 
	
		if( $('#pack_2_1').attr('checked') )
		{			 
			$('#pack_2_1').removeAttr('checked');
			$(".select_pack_1").css({ display: "none"});	
		}
		else
		{
			$('#pack_2_1').attr('checked', 'true');		
			$(".select_pack_1").css({ display: "block"});		
		}	
		return false;
	});
		// OFFRE 2 pack2
	$("#location_offre_2_pack_2").click( function() { 
	
		if( $('#pack_2_2').attr('checked') )
		{			 
			$('#pack_2_2').removeAttr('checked');
			$(".select_pack_2").css({ display: "none"});	
		}
		else
		{
			$('#pack_2_2').attr('checked', 'true');		
			$(".select_pack_2").css({ display: "block"});		
		}	
		return false;
	});	
		// OFFRE 2 pack3
	$("#location_offre_2_pack_3").click( function() { 
	
		if( $('#pack_2_3').attr('checked') )
		{			 
			$('#pack_2_3').removeAttr('checked');
			$(".select_pack_3").css({ display: "none"});	
		}
		else
		{
			$('#pack_2_3').attr('checked', 'true');		
			$(".select_pack_3").css({ display: "block"});		
		}	
		return false;
	});		
	
		// OFFRE 2 pack4
	$("#location_offre_2_pack_4").click( function() { 
	
		if( $('#pack_2_4').attr('checked') )
		{			 
			$('#pack_2_4').removeAttr('checked');
			$(".select_pack_4").css({ display: "none"});	
		}
		else
		{
			$('#pack_2_4').attr('checked', 'true');		
			$(".select_pack_4").css({ display: "block"});		
		}	
		return false;
	});		
		// OFFRE 2 pack5
	$("#location_offre_2_pack_5").click( function() { 
	
		if( $('#pack_2_5').attr('checked') )
		{			 
			$('#pack_2_5').removeAttr('checked');
			$(".select_pack_5").css({ display: "none"});	
		}
		else
		{
			$('#pack_2_5').attr('checked', 'true');		
			$(".select_pack_5").css({ display: "block"});		
		}	
		return false;
	});		
	
/************************************************/	

		// OFFRE 3 pack1
	$("#location_offre_3_pack_1").click( function() { 
	
		if( $('#pack_3_1').attr('checked') )
		{			 
			$('#pack_3_1').removeAttr('checked');
			$(".select_pack_1").css({ display: "none"});	
		}
		else
		{
			$('#pack_3_1').attr('checked', 'true');		
			$(".select_pack_1").css({ display: "block"});		
		}	
		return false;
	});	

		// OFFRE 3 pack2
	$("#location_offre_3_pack_2").click( function() { 
	
		if( $('#pack_3_2').attr('checked') )
		{			 
			$('#pack_3_2').removeAttr('checked');
			$(".select_pack_2").css({ display: "none"});	
		}
		else
		{
			$('#pack_3_2').attr('checked', 'true');		
			$(".select_pack_2").css({ display: "block"});		
		}	
		return false;
	});		

		// OFFRE 3 pack3
	$("#location_offre_3_pack_3").click( function() { 
	
		if( $('#pack_3_3').attr('checked') )
		{			 
			$('#pack_3_3').removeAttr('checked');
			$(".select_pack_3").css({ display: "none"});	
		}
		else
		{
			$('#pack_3_3').attr('checked', 'true');		
			$(".select_pack_3").css({ display: "block"});		
		}	
		return false;
	});	
		// OFFRE 3 pack4
	$("#location_offre_3_pack_4").click( function() { 
	
		if( $('#pack_3_4').attr('checked') )
		{			 
			$('#pack_3_4').removeAttr('checked');
			$(".select_pack_4").css({ display: "none"});	
		}
		else
		{
			$('#pack_3_4').attr('checked', 'true');		
			$(".select_pack_4").css({ display: "block"});		
		}	
		return false;
	});	
	
		// OFFRE 3 pack5
	$("#location_offre_3_pack_5").click( function() { 
	
		if( $('#pack_3_5').attr('checked') )
		{			 
			$('#pack_3_5').removeAttr('checked');
			$(".select_pack_5").css({ display: "none"});	
		}
		else
		{
			$('#pack_3_5').attr('checked', 'true');		
			$(".select_pack_5").css({ display: "block"});		
		}	
		return false;
	});	

/************************************************/	

		// OFFRE 4 pack1
	$("#location_offre_4_pack_1").click( function() { 
	
		if( $('#pack_4_1').attr('checked') )
		{			 
			$('#pack_4_1').removeAttr('checked');
			$(".select_pack_1").css({ display: "none"});	
		}
		else
		{
			$('#pack_4_1').attr('checked', 'true');		
			$(".select_pack_1").css({ display: "block"});		
		}	
		return false;
	});	

		// OFFRE 4 pack2
	$("#location_offre_4_pack_2").click( function() { 
	
		if( $('#pack_4_2').attr('checked') )
		{			 
			$('#pack_4_2').removeAttr('checked');
			$(".select_pack_2").css({ display: "none"});	
		}
		else
		{
			$('#pack_4_2').attr('checked', 'true');		
			$(".select_pack_2").css({ display: "block"});		
		}	
		return false;
	});	
		// OFFRE 4 pack2
	$("#location_offre_4_pack_3").click( function() { 
	
		if( $('#pack_4_3').attr('checked') )
		{			 
			$('#pack_4_3').removeAttr('checked');
			$(".select_pack_3").css({ display: "none"});	
		}
		else
		{
			$('#pack_4_3').attr('checked', 'true');		
			$(".select_pack_3").css({ display: "block"});		
		}	
		return false;
	});	
	
/************************************************/	
	// revenir aux offres depuis la page de contact 
	/*
	$(".location-annulation").click( function() {
		$("#offres_liste").show();	
		// cacher les offres 
		$(".locationdetails").hide();
		return false;
	});
	*/
	// réafficher les offres 
	$(".location-retour").click( function() { 
		$("#offres_liste").show();
		$('.pack').removeAttr('checked');
		$(".select_pack_1").css({ display: "none"});	
		$(".select_pack_2").css({ display: "none"});	
		$(".select_pack_3").css({ display: "none"});	
		$(".select_pack_4").css({ display: "none"});	
		$(".select_pack_5").css({ display: "none"});	

		// cacher les offres 
		$("#pack_location_offre_80").hide();	
		$("#pack_location_offre_80_200").hide();	
		$("#pack_location_offre_200_1500").hide();	
		$("#pack_location_offre_regie").hide();	
		$("#pack_location_offre_regie").hide();	
		return false;
	});		

	
	// fermer le bloc
	$(".close").click( function() { 
		$(".locationdetails").fadeOut();
		return false;
	});	
	// ouvrir la page contact
	$(".btnSuivant").click( function() {
		isPack = false;
	    $("input[name^=pack]").each(function(){
		  	if($(this).attr('checked') == true )
		  	{
		  		isPack = true;
			}
		});
	    
	    if(isPack)
	    {
			return true;
		}
		
		alert("Merci de sélectionner au moins un pack");
		return false;
	});	

 });
 
 
 
 function mCustomScrollbars(){
	/*
	malihu custom scrollbar function parameters:
	1) scroll type (values: "vertical" or "horizontal")
	2) scroll easing amount (0 for no easing)
	3) scroll easing type
	4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
	5) scrollbar height/width adjustment (values: "auto" or "fixed")
	6) mouse-wheel support (values: "yes" or "no")
	7) scrolling via buttons support (values: "yes" or "no")
	8) buttons scrolling speed (values: 1-20, 1 being the slowest)
	*/
	$("#mcs_container").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","no",15);
	$("#mcs_container2").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","no",15);
	$("#mcs_container3").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","no",15);
	$("#mcs_container4").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","no",15);
}

/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}

/* function to load new content dynamically */
function LoadNewContent(id,file){
	$("#"+id+" .customScrollBox .content").load(file,function(){
		mCustomScrollbars();
	});
}
