﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/


$().ready(function(){
	//global vars
	var menuSections = $("#menu li");
	var projects = $("#projects");
	var projectsSection = $("#projects > div");
	
	//current section
	var currentSection = $("#sectionLatest");
	var currentMenu = "sectionLatest";
	
	//current project areas
	var areaLatest = $("#projects div.latest");
	var areaWeb = $("#projects div.web");
	var areaPhoto = $("#projects div.photo");
	var areaOthers = $("#projects div.others");
	
	//manage sections activation
	menuSections.click(function(){
		//change section if it's different than current
		if(currentMenu != this.id){
			//menu style
			$(this).addClass("active");
			currentSection.removeClass("active");
			currentSection = $(this);
			currentMenu = this.id;
			
			//activate the new selected section
			switch(this.id){
				case "sectionLatest":
					projects.fadeTo("slow", 0.0,function(){projectsSection.css({display:"none"});
					areaLatest.css({display:"block"});});
					projects.fadeTo("slow", 1.0);
					break;
				case "sectionWeb":
					projects.fadeTo("slow", 0.0,function(){projectsSection.css({display:"none"});
					areaWeb.css({display:"block"});});
					projects.fadeTo("slow", 1.0);
					break;
				case "sectionPhoto":
					projects.fadeTo("slow", 0.0,function(){projectsSection.css({display:"none"});
					areaPhoto.css({display:"block"});});
					projects.fadeTo("slow", 1.0);
					break;
				case "sectionOthers":
					projects.fadeTo("slow", 0.0,function(){projectsSection.css({display:"none"});
					areaOthers.css({display:"block"});});
					projects.fadeTo("slow", 1.0);
					break;
			}
		}
	});
});