$(function(){

    var initialIndex = 0;
    var isFrontPage = $(".slidetabs").hasClass("front_page");
    var current_slide_id = $(".current_page_slide").attr('id');




    //Navivigation vide
    //resize empty size in the nav bar
    var margin_left = 138;
    $("#navigation-vide").width($(".container").width()-($("#navigation-left").width()+$("#navigation-right").width()+margin_left));
    var nav_left_pos = $("#navigation-left").position();
    $("#navigation-vide").css({"left" : nav_left_pos.left+$("#navigation-left").width()+margin_left+"px"});
    //navigation click
    $( ".navigation li").click(function(e){ 
        if (!e.ctrlKey) {
                window.location=$("a",this).attr("href");
        } else {
                window.open($("a",this).attr("href"));
        } 
    });
   


    //scrollbar
    $(".news").tinyscrollbar();
    
    
    //colorbox img
    $('a::has(img)').colorbox();
    
    //accordion
    $("#accordion").accordion({ autoHeight: false });

    $(".accordion-more").click(function(e){ 
            if (!e.ctrlKey) {
                    window.location=$(this).attr("href");
            } else {
                    window.open($(this).attr("href"));

    } 
    });

			
                                
    //slideshow
    $(".slidetabs").tabs("#slideshow_content > #slideshow_wrapper >.slideshow_content", {

        // enable "cross-fading" effect
        effect: 'fade',
        fadeOutSpeed: "slow",
        // start from the beginning after the last tab
        rotate: true,

        clickable: false

    // use the slideshow plugin. It accepts its own configuration
    }).slideshow({
        clickable: false,
        autoplay: isFrontPage
    });


    $("#navbar").addClass("buttons-" + $("#navbar li").size());

    $("#footer ul#sitemap").addClass("pages-" + $("#footer ul#sitemap > li").size());


    $("ul#subpage_menu li a").click(function(){
        $("#the_content").load($(this).attr('href')+"?ajax=1");
        $(this).addClass("current_subpage");
        return false;
    });

    $("#content_right #news-widget li > a").click(function(){
        if($(this).attr('href').indexOf("?")>=0)
        {
            $("#the_content").load($(this).attr('href')+"&ajax=1");
        }
        else
        {
            $("#the_content").load($(this).attr('href')+"?ajax=1");

        }
        return false;
    });
    $("#content_right #news-widget li h3.widget-title> a").click(function(){
        return false;
    });
    $(".slideshow_content").corner();

    $(".ajax_subpages").click(function(){
        if($(this).attr('href').indexOf("?")>=0)
        {
            $("#the_content").load($(this).attr('href')+"&ajax=1");
        }
        else
        {
            $("#the_content").load($(this).attr('href')+"?ajax=1");
        }
        $(this).addClass("current_subpage");
        return false;
    });
});
