	// JavaScript Document
$(document).ready(function(){
	var ideas = {
		divid: '#nav1',
		state: 0,
		openTop: '-100px',
		closeTop: '-360px',
	};
	var exps = {
		divid: '#nav2',
		state: 0,
		openTop: '-100px',
		closeTop: '-360px'
	};
	var contact = {
		divid: '#nav3',
		state: 0,
		openTop: '-100px',
		closeTop: '-360px'
	};
	divs = [];
	divs.push(ideas, exps, contact);
	
	function moveNav(divTar, openTar)
	{
		$(divTar).animate({top:openTar},{queue:false,duration:300});
	}
	function bump(divTar, state)
	{
		if (state != 1){
			$(divTar).animate({left:'565px'},{queue:false,duration:160});
		}
	}
	function bumpBack(divTar, state)
	{
		if (state != 1){
			$(divTar).animate({left:'575px'},{queue:false,duration:160});
		}
	}
	
	/*jQuery.each(divs, function(i){
		var item = divs[i];
		$(item.divid).mouseover(function(){
			bump(item.divid, Number(item.state));
		}).mouseout(function() {
			bumpBack(item.divid, Number(item.state))
		});
	});*/
	
	$('.nav').mouseup(function(){
		var idNum = this.id.charAt(this.id.length-1)-1;
		var otherOne = -1;
		var otherTwo = -1;
		for (var m=0; m<divs.length; m++){
			if (m != idNum){
				otherOne = m;
				otherTwo = (m-1)%3;
			}
			if (otherTwo == idNum || otherTwo == otherOne){
				otherTwo--;
			}
		}
		var item2 = findDiv(this.id);
		if (item2.state == 0) {
			var string = item2.divid;
			if (string.charAt(string.length-1) == 1){
				moveNav(String(item2.divid), item2.openTop);
				moveNav('#textA', '35px');
				moveNav('#textB', '45px');
				moveNav('#textC', '85px');
				moveNav(String(divs[otherOne].divid), divs[otherOne].openTop);
				moveNav(String(divs[otherTwo].divid), divs[otherTwo].openTop);
			}
			if (string.charAt(string.length-1) == 2){
				moveNav(String(item2.divid), item2.openTop);
				moveNav('#textA', '-260px');
				moveNav('#textB', '45px');
				moveNav('#textC', '85px');
				moveNav(String(divs[otherOne].divid), divs[otherOne].openTop);
				moveNav(String(divs[otherTwo].divid), divs[otherTwo].closeTop);
			}
			if (string.charAt(string.length-1) == 3){
				moveNav(String(item2.divid), item2.openTop);
				moveNav(String(divs[otherOne].divid), divs[otherOne].closeTop);
				moveNav(String(divs[otherTwo].divid), divs[otherTwo].closeTop);
				moveNav('#textA', '-260px');
				moveNav('#textB', '-260px');
				moveNav('#textC', '85px');
			}
			item2.state = 1;
			divs[otherOne].state = 0;
			divs[otherTwo].state = 0;
		}
		else {
			moveNav(String(item2.divid), item2.closeTop);
			moveNav('#textA', '-260px');
			moveNav('#textB', '-260px');
			moveNav('#textC', '-260px');
			moveNav(String(divs[otherOne].divid), divs[otherOne].closeTop);
			moveNav(String(divs[otherTwo].divid), divs[otherTwo].closeTop);
			item2.state = 0;
			divs[otherOne].state = 0;
			divs[otherTwo].state = 0;
		}
	});
	
	function findDiv(tarID){
		var target = String(tarID);
		var tarNum = Number(target.charAt(target.length-1));
		
		for (var k=0, searchItem; searchItem = divs[k]; k++){
			var searchID = String(searchItem.divid);
			var searchNum = Number(searchID.charAt(searchID.length-1));
			if (searchNum == tarNum){
				return searchItem;
			}
		}
	}
});