// Copyright (c) 2010 42 Answers Creative Internet Studio. All rights reserved.
// No reproduction or republication without exclusive written permission from owner.
// http://42answers.com/

$(document).ready(function(){

  $("a[href*='http://']:not([href*='"+location.hostname+"']),[href*='https://']:not([href*='"+location.hostname+"'])")
    .addClass("external")
    .attr("target","_blank");

  // jQuery SmoothScroll | Version 10-04-30
  $('a[href*=#top], a[href*=#about], a[href*=#diciplines], a[href*=#work], a[href*=#news], a[href*=#contact], a[href*=#quotes]').click(function() {

    var duration=1000;  // duration in ms
    var easing='swing'; // easing values: swing | linear

    // get / set parameters
    var newHash=this.hash;
    var target=$(this.hash).offset().top;
    var oldLocation=window.location.href.replace(window.location.hash, '');
    var newLocation=this;
    
    // make sure it's the same location   
    if(oldLocation+newHash==newLocation) {
      // set selector
      if($.browser.safari) var animationSelector='body:not(:animated)';
      else var animationSelector='html:not(:animated)';
      
      // animate to target and set the hash to the window.location after the animation
      $(animationSelector).animate({ scrollTop: target }, duration, easing, function() {
        window.location.href=newLocation; // add new hash to the browser location
      });
       
      // cancel default click action
      return false;
    }
  });

  $('.flexslider').flexslider({
    animation: "fade"
  });

});
