jQuery(document).ready(function ($) {
    // start navigation
    var langwidth = 960 - $('nav ul').width();
    $('.language').css('width', langwidth + 'px');
    $('.language > a').click(function () {
        $(this).toggleClass('active');
        $('.language .subnav').toggle();
        return false;
    });
    $('body').click(function() { $('.language .subnav').hide();});

    $('.dropdown span').click(function () {
        $(this).parent().toggleClass('show');
        $(this).siblings('.fold').slideToggle();
    });
    $('.dropdown').not('.show').children('.fold').hide();
    // end navigation

    // start tabbed content

    //When page loads...

	$('.tabbed > .tab').hide(); //Hide all content
    if (location.hash) {
        realHash = location.hash.replace('#!', '#');
        $('.tabbed > ul li a[href=' + realHash + ']').closest('li').addClass('active').show(); //Activate first tab
        $(realHash).show();
    } else {
        $('.tabbed > ul li:first').addClass('active').show(); //Activate first tab
        $('.tab:first').show(); //Show first tab content
    }
    $('.tabbed > ul li').append('<span class="shadow">');
    $('.tabbed .shadow').each(function(){
        var liwidth = $(this).parent().width()+20;
        $(this).css({'width': liwidth});
    });


	//On Click Event
	$('.tabbed > ul li').click(function (e) {
        if($(this).hasClass('active')) {
            return false;
        }
		$('.tabbed > ul li').removeClass('active'); //Remove any 'active' class
		$(this).addClass('active'); //Add 'active' class to selected tab
        $('.tabbed > .tab').hide(); //Hide all tab content
        
		var activeTab = $(this).find('a').attr('href'); //Find the href attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active ID content
        location.hash = activeTab.replace('#', '#!');
        return false;
	});



    // Start Sticky footer

        var footerHeight = $("footer").height();
        $("#main").css("padding-bottom", footerHeight);
        $("footer").css("margin-top", -footerHeight);

    // End Sticky footer



        $('.dataexplorer').hover(
            function () {$('.dataexplorer .tooltip').fadeIn();},
            function () {$('.dataexplorer .tooltip').fadeOut();}
        );


// Start nth child fix

    $('table tr:nth-child(odd)').css({'background-color': '#F6F5F8'});
    $('table tr:nth-child(odd) .wider td').css({'background-color': '#F8FBF5'});
    $('table tr:nth-last-child(1) td').css({'border-bottom': '1px solid #ccc'});

// End nth child fix



// Home page slider

$('.slider').jCarouselLite({
    btnNext: ".next",
    btnPrev: ".prev"
});
    
var sliderWidth = $('.slider').width()-1;
$('.slider').css({'width': sliderWidth});


    // End Home page slider


});

