if (typeof(NF) == 'undefined') NF = {};



NF.ShowContact = $.klass({
	initialize: function() {
		$('ul#projects li.add a').click(function(event) {
			var link = this;
			
			$.scrollTo('#contact', 100, {
				onAfter: function() {
					$('#contact').animate({ backgroundColor:'#ff0' }, 500)
					.animate({ backgroundColor:'#fff'}, 500)
				}
			});
		});
	}
});



NF.ProjectLinks = $.klass({
	initialize: function() {
		$this = this;

		$('ul#projects li.link a').each(function(i, link) {
			var li = $(link).parent('li');
			li.hover(function() {
				$this.toggleHover(li);
			}, function() {
				$this.toggleHover(li);
			});
			li.click(function() {
				window.location.href = $(link).attr('href');
			})
		});
	},
	
	toggleHover: function(li) {
		if (li.toggleClass('selected'));
	}
});



NF.Grid = $.klass({
	initialize: function() {
		// if the URL has "?edit" in it...
		var url = location.href;
		if ( url.search(/\?grid/) == -1 ) return false;
		
		// create + insert grid guide element
		$('<div id="gridguide"></div>').prependTo(document.body);
		
		// set height to the document's height
		var documentHeight = $(document.body).height();
		var documentHeight = documentHeight + 'px';
		$('#gridguide').css({ 'height':documentHeight });
		
	}
})



$(document).ready(function() { 

	new NF.ProjectLinks();

	new NF.ShowContact();

	// grid guide
	new NF.Grid();

}); // document.ready