$(document).ready(function(){

    //Augmenter/diminuer la taille du texte                          accueil
    var fontsize = 100;

    $("#TextTransform #BigText").click(function(){
        fontsize = fontsize+15;
        $('.container_content').css("font-size", fontsize+"%", "!important");
        $('.container_content p').css("font-size", fontsize+"%", "!important");
        $('.container_content a').css("font-size", fontsize+"%", "!important");
        $('.container_content h1').css("font-size", fontsize+"%", "!important");
        $('.container_content h2').css("font-size", fontsize+"%", "!important");
        $('.container_content h3').css("font-size", fontsize+"%", "!important");
        $('.container_content h4').css("font-size", fontsize+"%", "!important");
        $('.container_content h5').css("font-size", fontsize+"%", "!important");
        $('.container_content h6').css("font-size", fontsize+"%", "!important");

        $('#accueil').css("font-size", fontsize+"%", "!important");
        $('#accueil p').css("font-size", fontsize+"%", "!important");
        $('#accueil a').css("font-size", fontsize+"%", "!important");
        $('#accueil h1').css("font-size", fontsize+"%", "!important");
        $('#accueil h2').css("font-size", fontsize+"%", "!important");
        $('#accueil h3').css("font-size", fontsize+"%", "!important");
        $('#accueil h4').css("font-size", fontsize+"%", "!important");
        $('#accueil h5').css("font-size", fontsize+"%", "!important");
        $('#accueil h6').css("font-size", fontsize+"%", "!important");
    });
     
    $("#TextTransform #SmallText").click(function(){
        fontsize = fontsize-15;
        $('.container_content').css("font-size", fontsize+"%", "!important");
        $('.container_content p').css("font-size", fontsize+"%", "!important");
        $('.container_content a').css("font-size", fontsize+"%", "!important");
        $('.container_content h1').css("font-size", fontsize+"%", "!important");
        $('.container_content h2').css("font-size", fontsize+"%", "!important");
        $('.container_content h3').css("font-size", fontsize+"%", "!important");
        $('.container_content h4').css("font-size", fontsize+"%", "!important");
        $('.container_content h5').css("font-size", fontsize+"%", "!important");
        $('.container_content h6').css("font-size", fontsize+"%", "!important");

        $('#accueil').css("font-size", fontsize+"%", "!important");
        $('#accueil p').css("font-size", fontsize+"%", "!important");
        $('#accueil a').css("font-size", fontsize+"%", "!important");
        $('#accueil h1').css("font-size", fontsize+"%", "!important");
        $('#accueil h2').css("font-size", fontsize+"%", "!important");
        $('#accueil h3').css("font-size", fontsize+"%", "!important");
        $('#accueil h4').css("font-size", fontsize+"%", "!important");
        $('#accueil h5').css("font-size", fontsize+"%", "!important");
        $('#accueil h6').css("font-size", fontsize+"%", "!important");
    });

    // Formulaire de contact flottant
    $("#contactUs-tab").click(function() {
        $("#request-contactUs").toggleClass("visible");
    });

    $(".contactUs-close").click(function() {
        $("#request-contactUs").removeClass("visible");
    });

	//validate required checkbox
	$('#jq_validate_checkbox').click(function() {
	      checked = $("input.required_checkbox:checkbox:checked").length;

	      if(!checked) {
	        alert("Cochez les cases obligatoire.");
	        return false;
	      }
	});

    /*
    $("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'normal',
        opacity: 0.80,
        deeplinking: false,
        allow_resize: true, /* Resize the photos bigger than viewport. true/false */
       /* default_width: 500,
        default_height: 344,
        showTitle: true,
        social_tools: ''
   });
    */
        /*------------------PAGINATION----------------*/
    var show_per_page = 10;
    var number_of_items = $('#wrapper_list_cab').children('.list_cab').size();
    var number_of_pages = Math.ceil(number_of_items / show_per_page);

    $('#current_page').val(0);
    $('#show_per_page').val(show_per_page);

    var navigation_html = '<a class="prev" onclick="previous()">Précedent</a>';
    var current_link = 0;
    while (number_of_pages > current_link) {
        navigation_html += '<a class="page" onclick="go_to_page(' + current_link + ')" longdesc="' + current_link + '">' + (current_link + 1) + '</a>';
        current_link++;
    }
    navigation_html += '<a class="next" onclick="next()">Suivant</a>';

    $('.controls_pagination').html(navigation_html);
    $('.controls_pagination .page:first').addClass('active');

    $('#wrapper_list_cab').children().css('display', 'none');
    $('#wrapper_list_cab').children().slice(0, show_per_page).css('display', 'block');    
    

    
        
    $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) {
		event.preventDefault(); 
		event.stopPropagation(); 
		$(this).parent().siblings().removeClass('open');
		$(this).parent().toggleClass('open');
	});    
    $("#mobile_spc_menu_btn").click(function(e){
        $(this).toggleClass("Active");
        $("#menu_spc").slideToggle("fast");
        e.preventDefault();
    });   

    /*
    $("#main_slider").owlCarousel({
        autoPlay : 6000,
        stopOnHover : true,
        navigation:true,
        pagination:false,
        paginationSpeed : 1000,
        goToFirstSpeed : 2000,
        singleItem : true,
        autoHeight : true,
        navigationText: [
           "<i class='fa fa-chevron-left'></i>",
           "<i class='fa fa-chevron-right'></i>"
        ],
        transitionStyle:"fade"
    });


    $("#partenaire_slider").owlCarousel({
        autoPlay: 6000,
        stopOnHover : true,
        navigation: true,
        pagination: false,
        paginationSpeed: 2000,
        goToFirstSpeed: 3000,
        singleItem : false,
        autoHeight : false,
        items: 5,
        itemsDesktop : [1200, 5],
        itemsTablet: [1000, 3],
        navigationText: [
           "<i class='fa fa-chevron-left'></i>",
           "<i class='fa fa-chevron-right'></i>"
        ],
        transitionStyle:"fade"
    });
    */
    $("#partenaire_slider2").owlCarousel({
        autoPlay: 6000,
        stopOnHover: true,
        navigation: true,
        pagination: false,
        paginationSpeed : 1000,
        goToFirstSpeed : 2000,
        singleItem : false,
        autoHeight : true,
        items:4,
        navigationText: [
           "<i class='fa fa-chevron-left'></i>",
           "<i class='fa fa-chevron-right'></i>"
        ],
        transitionStyle:"fade"
    });

    $("#videos_slider").owlCarousel({
        autoPlay : 6000,
        stopOnHover : true,
        navigation:true,
        pagination:false,
        paginationSpeed : 1000,
        goToFirstSpeed : 2000,
        singleItem : false,
        items: 5,
        autoHeight : true,
        navigationText: [
           "<i class='fa fa-chevron-left'></i>",
           "<i class='fa fa-chevron-right'></i>"
        ],
        transitionStyle:"fade"
    });

	/* ================ Show Login box. ================ */
	$('.login-btn').prepend('<b class="tri hidden"></b>');
	$('.login-btn').click(function(e){	    
		e.preventDefault();
        $(this).toggleClass('active_hd');
		$('.login-box').slideToggle();
		$('.login-btn').find('.tri').toggleClass('visible');
		$('.close-login').click(function(e){
			e.preventDefault();
            $('.login-btn').toggleClass('active_hd');
			$('.login-box').slideUp();
			$('.login-btn').find('.tri').removeClass('visible');
		});
	}); 
    
     
	/* ================ Back to top button. ================ */
	var winScroll = $(window).scrollTop();
	if (winScroll > 1) {
		$('#to-top').css({bottom:"10px"});
	} else {
		$('#to-top').css({bottom:"-100px"});
	}
	$(window).on("scroll",function(){
		winScroll = $(window).scrollTop();
		
		// PARALLAX background Animation.
		var y = parseInt($('.parallax').css('background-position-y'));
		var newY = -(winScroll * 0.05) + 'px';
		$('.parallax').css("background-position-y",newY);

		
		//  Show Hide back to top button.
		if (winScroll > 1) {
			$('#to-top').css({opacity:1,bottom:"10px"});
		} else {
			$('#to-top').css({opacity:0,bottom:"-100px"});
		}
	});
    
    
	$('#to-top').click(function(){
		$('html, body').animate({scrollTop: '0px'}, 800);
		return false;
	});
    
    
    
    
    	/* ================ Show Hide Search box. ================ */
        /*
        	$('.top-search a').click(function(){
        		if($(this).parent().find('.search-box').is(':visible')){
        			$('.search-box').fadeOut(300);
        			$(this).parent().removeClass('selected');
        			return false;
        		}else{
        			$('.search-box').fadeIn(300);
        			$(this).parent().addClass('selected');
        			return false;
        		}
        	});
        	$(document).mouseup(function(e){
        		if($('.search-box').is(':visible')){
        			var targ = $(".search-box");
        			if (!targ.is(e.target) && targ.has(e.target).length === 0){
        			$('.search-box').fadeOut(300);
        			$('.top-search').removeClass('selected');
        			}
        		}
        	});
        */
    /*
    $( function() {
        $( ".accordion" ).accordion({
          heightStyle: "content",
          collapsible: true,
          active: false
        });
      } );
    */

    
    	/* ================ Album Photos ================ */
    $(".filter-button").click(function(){
        var value = $(this).attr('data-filter');
        
        if(value == "all")
        {
            //$('.filter').removeClass('hidden');
            $('.filter').show('1000');
        }
        else
        {
        //  $('.filter[filter-item="'+value+'"]').removeClass('hidden');
        //  $(".filter").not('.filter[filter-item="'+value+'"]').addClass('hidden');
            $(".filter").not('.'+value).hide('3000');
            $('.filter').filter('.'+value).show('3000');
            
        }
    });
    
    if ($(".filter-button").removeClass("active")) {
        $(this).removeClass("active");
    }
    $(this).addClass("active");

    /*animation load*/
    new WOW().init(); 
    

    //Sticky Nav
    // When the user scrolls the page, execute stickyNav


    // Get the navbar
    var navbar = document.getElementById("menu_principal");
    if(navbar) {
        window.onscroll = function() {stickyNav()};
        var logo = document.getElementById("logo_sticky_nav");
        var change_lang = document.getElementById("changeLang_sticky_nav");
        // Get the offset position of the navbar
        var sticky = navbar.offsetTop;
    }

    // Add the sticky class to the navbar when you reach its scroll position.
    // Remove "sticky" when you leave the scroll position
    function stickyNav() {
        if (window.pageYOffset >= sticky) {
            navbar.classList.add("sticky");
            logo.classList.add("sticky_nav_logo");

            if (logo.style.display === "none"){
                logo.style.display = "table-cell";
            }

            /*if (change_lang.style.display === "none"){
                change_lang.style.display = "table-cell";
            }*/
        } else {
            navbar.classList.remove("sticky");
            logo.classList.remove("sticky_nav_logo");

            if (logo.style.display === "table-cell"){
                logo.style.display = "none";
            }

            if (change_lang.style.display === "table-cell"){
                change_lang.style.display = "none";
            }
        }
    }
        
});



function go_to_page(page_num) {
    var show_per_page = parseInt($('#show_per_page').val(), 0);
    start_from = page_num * show_per_page;
    end_on = start_from + show_per_page;
    $('#wrapper_list_cab').children().css('display', 'none').slice(start_from, end_on).css('display', 'block');
    $('.page[longdesc=' + page_num + ']').addClass('active').siblings('.active').removeClass('active');
    $('#current_page').val(page_num);
}
function previous() {
    new_page = parseInt($('#current_page').val(), 0) - 1;
    //if there is an item before the current active link run the function
    if ($('.active').prev('.page').length == true) {
        go_to_page(new_page);
    }
}
function next() {
    new_page = parseInt($('#current_page').val(), 0) + 1;
    //if there is an item after the current active link run the function
    if ($('.active').next('.page').length == true) {
        go_to_page(new_page);
    }
}

function toggle_tuile(tuile_id){
	$('.fix_tuile_height').removeClass('tuile_active');
	$('#tuile_'+tuile_id).addClass('tuile_active');
	$('.tuile_detail').hide("fade");
	$('#tuile_detail_'+tuile_id).show("fade");
}

jQuery(function($){
    //$("#date").mask("99/99/9999");
    $(".mask_phone_full").inputmask("(999) 999-9999 #9999");
    $(".mask_phone").inputmask("(999) 999-9999");
    $(".mask_postcode").inputmask("a9a 9a9");
    //$(".mask_courriel").mask("999-99-9999");
});