$(document).ready(function() {
    // $('#prev, #next').hide();
   // $('#prev, #next').hover(function() {
      // if ($(this).attr('id') == 'prev') {
      //    $(this).text('-');
      // }else{
      //    $(this).text('+');
      // };
      // $(this).addClass('fade');
   // }, function() {
      // $(this).text('');
      // $(this).removeClass('fade');
   // });
   
   
   $('#photos').cycle({ 
        speed:  300, 
        next:   '#next',
        prev:   '#prev',
        timeout: 0,
        before: onBefore
    });
    function onBefore() { 
        $('#caption').html($('img', this).attr('alt')); 
        // alert($('img', this).attr('alt'));
        // alert($('.img0').attr('alt'));
    };
    
    /* disable the right click context menu */
    $(document).bind("contextmenu",function(e){
             return false;
      });
    
    /* what to do on right/left mouse clicks */
    $('#photos').mousedown(function(event) {
        switch (event.which) {
            /* left */
            case 1:
            case 2:
                $('#next').click();
            case 3:
                /* right */
                $('#prev').click();
                break;
            default:
                $('#next').click();
        }
    });
    
    /* change background color on load */
    /* make sure to have a matching text color for each bg */
    var bgcolors   = ['#fff']; /* colors used for the background */
    var linkcolors = ['#000'];   /* matching color for the text/links */
    var inactivecolors = ['#bbb', '#bbb', '#bbb', '#bbb', '#bbb'];   /* matching color for the text/links */
    var activecolors = ['#bbb', '#bbb', '#bbb', '#bbb', '#bbb'];   /* matching color for the text/links */
    var rand = Math.floor(Math.random() * bgcolors.length);
    var bgcolor = bgcolors[rand];
    var linkcolor = linkcolors[rand];
    var inactivecolor = inactivecolors[rand];
    var activecolor = activecolors[rand];
    
    $('#nav a').css('color', linkcolor);
    $('#nav a.active').css('background-color', activecolor);
    $('#nav span.inactive').css('color', inactivecolor);
    $('#nav').css('background-color', bgcolor);
});

$(window).keydown(function(e){
  if(e.which == 37){ 
      $('#prev').click();
  }else if(e.which == 39){ 
      $('#next').click();
  }
});
