jQuery.noConflict();

//autofocus inputs
window.onload = function () {
    focusInput("Achternaam");
    focusInput("Name");
};

function focusInput(inputName) {
    // focus on the input field for easy access...
    var input = document.getElementById(inputName);
    if (input !== null) {
        input.focus();
        // ...but if someone wishes to go back in their history, let them!
        document.onkeydown = function (e) {
            if (!e) {
                var e = window.event;
            }
            if (e.keyCode === 8 && !input.value) {
                history.back();
            }
        };
    }

}
//end autofocus inputs

jQuery(document).ready(function () {
    
    setTimeout(function () {        
        jQuery(".view-featured .logo").css("visibility", "visible");
        jQuery(".view-featured .logo").addClass("animated fadeInLeft");
        
        
        jQuery(".hero-default h1").css("visibility", "visible");
        jQuery(".hero-default h1").addClass("animated fadeInRight");
    }, 1000);
    
    setTimeout(function () {        
        jQuery(".view-featured .gold").css("visibility", "visible");
        jQuery(".view-featured .gold").addClass("animated fadeIn");
    }, 2000);
    
    setTimeout(function () {        
        jQuery(".view-featured #mainmenu").css("visibility", "visible");
        jQuery(".view-featured #mainmenu").addClass("animated fadeInDown");
        jQuery(".view-featured #language").css("visibility", "visible");
        jQuery(".view-featured #language").addClass("animated fadeInRight");
        jQuery(".view-featured .search-trigger").css("visibility", "visible");
        jQuery(".view-featured .search-trigger").addClass("animated fadeInRight");
        
        jQuery(".view-featured #navigation_mobile").css("visibility", "visible");
        jQuery(".view-featured #navigation_mobile").addClass("animated fadeInRight");
        
        jQuery(".hero").css("visibility", "visible");
        jQuery(".hero").addClass("animated fadeIn");
        
        jQuery(".view-featured #main").css("visibility", "visible");
        jQuery(".view-featured #main").addClass("animated fadeIn");
    }, 2500);
    
    
    var header_default1 = jQuery(".contentpage h1").text();
    jQuery(".hero-default").append("<h1>"+header_default1+"</h1>");
    
    var header_rsform = jQuery(".view-rsform h2").text();
    jQuery(".hero-default").append("<h1>"+header_rsform+"</h1>");

    //open search form
    jQuery('.cd-search-trigger').on('click', function (event) {
        event.preventDefault();
        toggleSearch();
    });
    
    jQuery(".products-list li a").each(function(){
        jQuery(this).click(function(){

            event.preventDefault();
            var idProduct = jQuery(this).attr("href");
            jQuery(idProduct).animatescroll({scrollSpeed:2000,easing:'easeInOutBack'});
        });
    });
    
    jQuery(".services-list li a").each(function(){
        jQuery(this).click(function(){

            event.preventDefault();
            var idService = jQuery(this).attr("href");
            jQuery(idService).animatescroll({scrollSpeed:2000,easing:'easeInOutBack'});
        });
    });

    function toggleSearch(type) {
        if (type == "close") {
            //close search 
            jQuery('.cd-search').removeClass('is-visible');
            jQuery('.cd-search-trigger').removeClass('search-is-visible');
            jQuery('.cd-overlay').removeClass('search-is-visible');
        } else {
            //toggle search visibility
            jQuery('.cd-search').toggleClass('is-visible');
            jQuery('.cd-search-trigger').toggleClass('search-is-visible');
            jQuery('.cd-overlay').toggleClass('search-is-visible');
            focusInput("mod-search-searchword");
        }
    }

    // product categories select box
    jQuery('#category').on('change', function () {
        jQuery('#brand').val('');
        jQuery('#searchFormCatFilter').submit();
    });
    // end product categories

    // product categories radio buttons
    jQuery('#cat_list input:radio').click(
            function () {
                jQuery('#brand_list input').each(function () {
                    jQuery(this).removeAttr("checked");
                });

                jQuery('#searchFormCatFilter1').submit();
            }
    );
    // end product categories

    jQuery('ul li:first-child').addClass('first_item');
    jQuery('ul li:last-child').addClass('last_item');

    

});

jQuery(document).ready(function($){
	// browser window scroll (in pixels) after which the "back to top" link is shown
	var offset = 300,
		//browser window scroll (in pixels) after which the "back to top" link opacity is reduced
		offset_opacity = 1200,
		//duration of the top scrolling animation (in ms)
		scroll_top_duration = 700,
		//grab the "back to top" link
		$back_to_top = $('.cd-top');

	//hide or show the "back to top" link
	$(window).scroll(function(){
		( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
		if( $(this).scrollTop() > offset_opacity ) { 
			$back_to_top.addClass('cd-fade-out');
		}
	});

	//smooth scroll to top
	$back_to_top.on('click', function(event){
		event.preventDefault();
		$('body,html').animate({
			scrollTop: 0 ,
		 	}, scroll_top_duration
		);
	});

});





