//.....................................................
// Doc Ready
//.....................................................

$(document).ready(function(){

  // External Links in New Window
  $('a[rel*=external]').click(function(){
   window.open(this.href);
   return false;
  });

  // Home Slides
  $('#homeSlides').cycle({
    speed: 2000,
    easein: 'easeInCubic',
    easeout: 'easeOutCubic'
  });
  
  // Main Nav
  if($('#primaryNav ul li ul.toplevel').hasClass("open")){
    $('#primaryNav ul li a.nogo').click(function() {
  		$(this).next().slideToggle(200);
  		return false;
  	})    
  }
  else{
    $('#primaryNav ul li a.nogo').click(function() {
  		$(this).next().slideToggle(200);
  		return false;
  	}).next().hide();
  }
  
  //$('.toplevel').hide();
  
  // FB	
  if(jQuery.fn.fancybox) {
    $('#grid a').fancybox({
      centerOnScroll : true,
      overlayColor: '#fff',
      padding: 0,
      cyclic: true,
      changeSpeed : 200,
      autoScale : true,
      titlePosition : 'outside',      
      'onComplete'	:	function() {
        $("#fancybox-title").hide();
    		$("#fancybox-left, #fancybox-right").hover(function() {
    			$("#fancybox-title").fadeIn(400);
    		}, function() {
    			$("#fancybox-title").fadeOut(400);
    		});
    	}
    });
  }
  
  // Work Hovers
  $('#grid ul li img').hover(
    function(){
      $(this).animate({
        opacity : 1
      }, 200)
    },
    function(){
      $(this).animate({
        opacity : .75
      }, 400, 'easeOutCubic')
    }
  );
  
  // Load thumbs nice
  $('#grid img').bind('load', function(e) {
      $(this).animate({
        'opacity': .75
      });
  });
  
  // Contact
  $('#contact').click(function(){
    $('#secondaryNav').find('#contactInfo').animate({
      opacity : 'toggle'
    }, 400, 'easeInOutCubic');
  });
    
});


//.....................................................
// Win Load
//.....................................................

$(window).load(function() {
    $('#grid img').animate({
      'opacity': .75
    });
      
    $('#homeSlides .slide.first img').animate({
      'opacity': 1
    });        
});
