var APP = {
  site: {
    init: function() {
      
      // Font replacement
      // Make sure to identify element very specfically, to avoid extra space issues, e.g., '#main ul li a'
      var $cufon_elements = $('.home h1, .home h2, #header h1, #header a, #sidebar a, #photo a, #footer p, .home #footer p');         
      Cufon.replace('.home h1, .home h2, #header h1, #footer p, .home #footer p');
      Cufon.replace('#header a, #sidebar a, #photo a', { hover: true });
      Cufon.CSS.ready(function() {
        $cufon_elements.css('visibility', 'visible');
      });
      
      // Get IE to behave
      Cufon.now();
            
    }
  },
  
  home: {
    init: function() {
			var $jh = $('.home h2');
			var $l = $('.home h1');
			$jh.hide();
			$l.hide();
      $jh.customFadeIn(2000, function() {
        $l.customFadeIn('slow');
      });          
    }
  },
  
  about: {
    init: function() {
      // Cycle slideshow
			$('#slideshow').cycle({
				timeout: 4000
			});
    }
  },
  
  services: {
    init: function() {
      
    }
  },
  
  work: {
    init: function() {
      simpleSlide({ swipe: true });
      // Kludge to eliminate vertical jump when clicking simpleSlide nav link
      $('.left-button, .right-button').click(function() {
        var rel = $(this).attr('rel');
        simpleSlideAction(this, rel);
        return false;
      });
      
      // Advance slideshow when clicking image
      $(document).ready(function() {
        $('#photo img').live('click', function() {
          $('.right-button').trigger('click');
        });
        
        $('#photo img').hover(function() {
          $(this).css('cursor', 'pointer');
        }, function() {
          $(this).css('cursor', 'default');
        });
      });
    }
  },
  
  shared: {
   
  }
};

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

// Tips
// 
// - may need to call Cufon.refresh([element]) after DOM modifications
