// JavaScript Document

var currSection = "home";
var prevSection = "home";

$(document).ready(function() {
	
	initStates();
	navigation();
	
	$(function() {
            // create the image rotator
            setInterval("rotateImages()", 5000);
        })
	
});

function initStates(){
	
	$("#home_section").show();
	$("#work_section").hide();
	$("#resume_section").hide();
	$("#about_section").hide();
	
};

function navigation(){
	$("#nav_id_home").click(function(){
		openSection("home");
		});
	$("#nav_id_work").click(function(){
		openSection("work");
		});
	$("#nav_id_resume").click(function(){
		openSection("resume");
		});
	$("#nav_id_about").click(function(){
		openSection("about");
		});
}

function openSection(_sectionName){
	
	prevSection = currSection;
	$("#" + prevSection + "_section").slideUp(500);
	$("#" + "nav_id_" + prevSection).removeClass('nav_' + prevSection + '_o').addClass('nav_' + prevSection);
	
	currSection = _sectionName;
	
	setTimeout(function(){
		//$("#" + currSection + "Section").fadeIn(1000);
		$("#" + currSection + "_section").slideDown(1000);
	}, 1000);
	
	$("#" + "nav_id_" + currSection).removeClass('nav_' + currSection).addClass('nav_' + currSection + '_o');
	<!--resizing();
	
}


//----------homepage image rotation starts here
///////////////////////////////////////////////

function rotateImages() {
            var oCurPhoto = $('#rotator_section div.current');
            var oNxtPhoto = oCurPhoto.next();
            if (oNxtPhoto.length == 0)
                oNxtPhoto = $('#rotator_section div:first');

            oCurPhoto.removeClass('current').addClass('previous');
            oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1500,
                function() {
                    oCurPhoto.removeClass('previous');
                });
}

//----------homepage image rotation ends. here
///////////////////////////////////////////////




