$(document).ready(function () {   
    $('.timeline').click(function(event){
         $('#overlay').fadeIn("slow", function(){
             $('#tijdlijn').fadeIn("slow").css("display","block");
             $('#timeline').PikaChoose({
                 show_captions: true,
                 show_prev_next: false,
                 thumb_width: 100,
                 thumb_height: 84
             });
 			 $('#timeline').SliderJS({
 					window_width: 700,
 					window_height: 100,
 					list_width: 2520,
 					pikachoose: true
 			});
         }).css("display","block");
    });
    
    $('.close').click(function(event){
         child = $('#layer > div').attr("id");
         if(child == "tijdlijn"){
             stopTimeline();
         }
         $('#layer > div').fadeOut("slow", function(){
            $('#overlay').fadeOut("slow");    
         })
    });    
         
    $('#overlay').click(function(event){
         child = $('#layer > div').attr("id");
          if(child == "tijdlijn"){
              stopTimeline();
          }
         $('#layer > div').fadeOut("slow", function(){
            $('#overlay').fadeOut("slow");  
         })
    });  

    $('.left').hover(function(){
        $('#timeline').animate({"left": "-1820px"}, 16000); 
    }, function(){
        $('#timeline').stop();
    });
    
    $('.right').hover(function(){
        $('#timeline').animate({"left": "0px"}, 4000); 
    }, function(){
        $('#timeline').stop();
    });
    
    function stopTimeline(){
        $('#timeline').PikaChoose({
           slide_enabled: false,
           auto_play: false 
        });
    }
	/*
    $('#tijdlijn').mousedown(function (event) {
        $(this)
            .data('down', true)
            .data('x', event.clientX)
            .data('scrollLeft', this.scrollLeft);
            
        return false;
    }).mouseup(function (event) {
        $(this).data('down', false);
    }).mousemove(function (event) {
        if ($(this).data('down') == true) {
            this.scrollLeft = $(this).data('scrollLeft') + $(this).data('x') - event.clientX;
        }
    }).mousewheel(function (event, delta) {
        this.scrollLeft -= (delta * 30);
    }).css({
        'overflow' : 'hidden',
        'cursor' : '-moz-grab'
    });
    */
});
/*    
$(window).mouseout(function (event) {
    if ($('#tijdlijn').data('down')) {
        try {
            if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML') {
                $('#tijdlijn').data('down', false);
            }                
        } catch (e) {}
    }
});
*/
