// homepage featured rotating box
$(document).ready(function(){
  $('#featured').cycle({
    fx: 'fade',
//    fx: 'scrollLeft',
//    easing: 'easeInOutBack',
    pause: 1,
    timeout: 10000,
    next: '#next',
    prev: '#prev'
  });
});

// show/hide rfp items on contact form
$(document).ready(function(){
  $('#contact_reason').change(function(){
    if(($(this).val() != '') && ($(this).val() != 'question')) {
      $('.non_rfp_item').hide();
      $('.rfp_item').show();
    }
    else {
      $('.non_rfp_item').show();
      $('.rfp_item').hide();
    }
  });
});


// lightbox for portfolio screenshots
$(document).ready(function(){
  $(".lightbox").lightbox({
    fitToScreen: true,
    disableNavbarLinks: true
  });
});


// fade in for error messages
$(document).ready(function(){
   $(".form_notice").fadeIn(600);
 });


// animated scrolling - from http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links
$(document).ready(function() {
  function filterPath(string) {
  return string
    .replace(/^\//,'')
    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
    .replace(/\/$/,'');
  }
  var locationPath = filterPath(location.pathname);
  $('a[href*=#]').each(function() {
    var thisPath = filterPath(this.pathname) || locationPath;
    if (  locationPath == thisPath
    && (location.hostname == this.hostname || !this.hostname)
    && this.hash.replace(/#/,'') ) {
      var $target = $(this.hash), target = this.hash;
      if (target) {
        var targetOffset = $target.offset().top;
        $(this).click(function(event) {
          event.preventDefault();
          $('html, body').animate({scrollTop: targetOffset}, 400, function() {
            location.hash = target;
          });
        });
      }
    }
  });
});
