// Global Namespace
var NH = {

  FONT_LOAD_TIMEOUT: 3000,
  isFontLoaded: false,
	fontLoadStartTime: 0,

	// ------------------------------------------------------------------
  // @initialize
  // ------------------------------------------------------------------
  init: function($) {
    
    // check TypeKit font load
		debug.log("initialize :: isFontLoaded: "+NH.isFontLoaded);
		if (NH.isFontLoaded) {
    	$('html').NHInitialize();
		}	else {
			this.fontLoadStartTime = new Date().getTime();
 			setTimeout(NH.checkFontLoad, 250, [$]);
		}
				
  },

	fontLoaded: function() {
		debug.log("NH :: TypeKit font loaded");
		NH.isFontLoaded = true;
	},
	
	checkFontLoad: function() {
		//debug.log("checkFontLoad :: ");
		if (NH.isFontLoaded) {
			$('html').NHInitialize();
		} else
		{
			var fontLoadTime = new Date().getTime() - NH.fontLoadStartTime;
			//debug.log("fontLoadTime :: "+fontLoadTime);
			if (fontLoadTime > NH.FONT_LOAD_TIMEOUT) { // check for timeout
				// font load timed out - go ahead and initialize the site
				$('html').NHInitialize();
			} else {
				setTimeout(NH.checkFontLoad, 100);
			}
		}
	}
};

(function($){
    
  $.fn.NHInitialize = function() {
    var $this = this;

		function _init() {
			
			$('#content').css('display','block').animate({opacity: 1}, 250);
			
			$('.glowline').glowline();
		
		};

  	_init();
    
    return this;
    
  };
  
  // ==================================================================
  
  $.fn.glowline = function() {
    var $this = this;

		function _init() {
			var glowlineHtml = '<div class="left"></div>'+
      									 '<div class="mid"></div>'+
										     '<div class="right"></div>';
			
			$this.append(glowlineHtml);
		};

  	_init();
    
    return this;
  };

})(jQuery);


jQuery(function($){
  
  // Initialize the page on DOM ready.
  NH.init($);
  
});
