$(document).ready(function() {
  
  /* menu mouse over handlers */

  $('#navindex').mouseenter(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#ffffff');
  });
  $('#navindex').mouseleave(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#A6A5C4');
  });
  $('#navindex').click(function() {
    window.location = "index.htm";
  });

  $('#navabout').mouseenter(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#ffffff');
  });
  $('#navabout').mouseleave(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#A6A5C4');
  });
  $('#navabout').click(function() {
    window.location = "about.htm";
  });

  $('#navportfolio').mouseenter(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#ffffff');
  });
  $('#navportfolio').mouseleave(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#A6A5C4');
  });
  $('#navportfolio').click(function() {
    window.location = "portfolio.htm";
  });

  $('#navcontact').mouseenter(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#ffffff');
  });
  $('#navcontact').mouseleave(function() {
    if($(this).attr('selected') == undefined)
      $(this).css('color', '#A6A5C4');
  });
  $('#navcontact').click(function() {
    window.location = "contact.php";
  });
  
});

/* Scroller */

function ShowHideControls() {
  prevVisible = nextVisible = 'visible';
  
  if(photoCurrent == 1)
    prevVisible = 'hidden';
  if(photoCurrent == kNumPhotos - kPhotosPerPage +1)
    nextVisible = 'hidden';
    
  document.getElementById('prev').style.visibility = prevVisible;
  document.getElementById('next').style.visibility = nextVisible;
}

function PhotoNext() {
  if(photoCurrent+1 <= kNumPhotos - kPhotosPerPage +1) {
    photoCurrent++;
    PhotoScroll(photoCurrent);
  }
  ShowHideControls();
}

function PhotoPrev() {
  if(photoCurrent-1 > 0) {
    photoCurrent--;
    PhotoScroll(photoCurrent);
  }
  ShowHideControls();  
}

function PhotoFirst() {
  photoCurrent = 1;
  PhotoScroll(photoCurrent);
}

function PhotoLast() {
  photoCurrent = kNumPhotos;
  PhotoScroll(photoCurrent);
}

function PhotoScroll(num) {
  var x = -(num - 1) * kPhotoWidth;
  
  var attributes = {
    'margin-left': { to: x }
  };
  
  var anim = new YAHOO.util.Anim('photos', attributes, 1.0, YAHOO.util.Easing.easeBoth);
  anim.animate();
}

function PhotoClick(photo) {
  $('#portcaption').fadeOut('slow');
  $('#photo').fadeOut('slow', function() {
    $('#photo').attr('src', 'assets/portfolio/'+photo+'.jpg');
    $('#portcaption').html(captions[photo]);
    $('#portcaption').fadeIn('slow');
    $('#photo').fadeIn('slow');
  });
  
}


