// Revealing Module Pattern
// This pattern progressively enhances a page by hooking onto events transparently,
// and also by managing public and private access to methods and properties.
// All public methods and properties are returned as an object from the main
// function, which is executed at run time automatically; initialization should
// be bound to an appropriate load or domready event. The template is compatible
// with any javascript framework, or by itself - but a framework is a huge
// help in simplifying event binding.

var Dynamo = function() {
	var bindObservers = function() {
		unbindObservers();
		if($('.nav_directory')) { // only do this if the directory is there as well as the menu
			$('.nav_main>li>a').each(function(item) {
				$(this).hover(function(event){Dynamo.navHover(event);}, function(event){Dynamo.navUnHover(event);});
			});
		}
		if($('.work-description')) { // only do this if the directory is there as well as the menu
			$('.work-folio>li').each(function(item) {
				$(this).hover(function(event){Dynamo.workHover(event);}, function(event){Dynamo.workUnHover(event);});
			});
		}
	}

	var unbindObservers = function() {
		
	}




	var navHover = function(event) {
		var title = $(event.target).attr('title');
		if(title) { // bug trap
			$('.nav_directory li').hide(0);
			$('#'+title).fadeIn('def');
		}
	}




	var navUnHover = function(event) {
	}




	var workHover = function(event) {
		event.preventDefault();
		var title = $(event.target).attr('title');
		if(title) { // bug trap
			$('.work-description li').css({display:'none'});
			$('#'+title).fadeIn('def');
		}
	}




	var workUnHover = function(event) {
	}



	var init = function() {
		bindObservers();
	}
	
	return {
		// Public methods and properties go here
		init: init,
		bindObservers: bindObservers, unbindObservers: unbindObservers,
		navHover:navHover, navUnHover:navUnHover, workHover:workHover, workUnHover:workUnHover
	}
}();

// Replace the following with an event binding appropriate to your framework
// or simply use:
// window.onload = ModuleName.init;
// For use without a framework.
$(document).ready(function(){Dynamo.init();});
