function menu(pageLoader){

	this.pageLoader = pageLoader;

	this.currentLink = null;

	this.currentSection = null;

	this.init();

}



menu.prototype = {

	init: function(){

		var instance = this;

		

		$('div.contentSection h3 a').mouseover(function(){

			instance.swapText(this);

		})

		.mouseout(function(){

			instance.swapText(this);

		});

		

		$('div.contentSection h3 a').click(function(e){

			e.preventDefault();

			var contentArea = $(this).parents('div.contentSection').find('div.contentArea');

			if (contentArea.hasClass('shown') == true){

				instance.hideSection(this, contentArea);

			}

			else{

				instance.showSection(this, contentArea);

			}

		});

		

		//close section if header or tagline clicked

		$('div#header a').click(function(){

			instance.hideSection(instance.currentLink, instance.currentSection);

		});

	},

	

	swapText: function(el){

		var altText = $(el).attr('title');

		var currentText = $(el).html();

		

		$(el).attr('title', currentText);

		$(el).html(altText);

	},

	

	showSection: function(linkEl, section, pageToShow){

		if (this.currentSection != null){ 

			this.hideSection(this.currentLink, this.currentSection);

		}

		$(linkEl).addClass('on');

		

		var pageToShowInfo = (pageToShow) ? pageToShow : $(linkEl).attr('href');

		var sectionToShow = $(linkEl).attr('rel')

		

		this.pageLoader.loadPage(pageToShowInfo, sectionToShow);

		section.slideDown().addClass('shown');

		

		this.currentSection = section;

		this.currentLink = linkEl;

	},

	

	hideSection: function(linkEl, section){

		$(linkEl).removeClass('on');

		section.slideUp().removeClass('shown');

	}

}



var menuObj = new menu(pageLoaderObj);
