// JavaScript Document

$(window).resize(function(){
	// get document dimensions
	width = $(document).width();
	height = $(document).height();

	// set link spacer properties
	contentHeight = height-138;
	linkSpacerHeight = contentHeight/4;
	$('.linkSpacer').css({height: linkSpacerHeight});
	linkSpacerLinkHeight = contentHeight-(linkSpacerHeight*3);
	$('.linkSpacerLink').css({height: linkSpacerLinkHeight});
	
	if ($('#homeMenu').css("left") != "-40px") {
		// move link to the right/left
		$('#homeMenu').css({left: width-120});
	}
	if ($('#homeContent').css("display") == "inline") {
		// update the width of the page
		$('#home').css({width: width-80});	
	}

	if ($('#servicesMenu').css("left") != "-40px") {
		// move link to the right/left
		$('#servicesMenu').css({left: width-120});
	}
	if ($('#servicesContent').css("display") == "inline") {
		// update the width of the page
		$('#services').css({width: width-120});	
	}

	if ($('#portfolioMenu').css("left") != "-40px") {
		// move link to the right/left
		$('#portfolioMenu').css({left: width-120});
	}
	if ($('#portfolioContent').css("display") == "inline") {
		// update the width of the page
		$('#portfolio').css({width: width-120});	
	}

	if ($('#contactMenu').css("left") != "-40px") {
		// move link to the right/left
		$('#contactMenu').css({left: width-120});
	}
	if ($('#contactContent').css("display") == "inline") {
		// update the width of the page
		$('#contact').css({width: width-120});	
	}
});
						   
$(document).ready(function(){
	// get document dimensions
	width = $(document).width();
	height = $(document).height();
	contentHeight = height-139;	

	// appropriately size the home box
	$('#home').css({width: width-80});	

	// set link spacer properties
	linkSpacerHeight = contentHeight/4;
	$('.linkSpacer').css({height: linkSpacerHeight});
	linkSpacerLinkHeight = contentHeight-(linkSpacerHeight*3);
	$('.linkSpacerLink').css({height: linkSpacerLinkHeight});
	$('#homeMenu').css({background: "#FFFFFF"});
	$('#servicesMenu').css({background: "#000000"});
	$('#portfolioMenu').css({background: "#000000"});
	$('#contactMenu').css({background: "#000000"});
	
	$("#home").click(function() {
		if ($('#homeMenu').css("left") != "-40px") {
			// hide contact info
			if ($('#contactContent').css("display") == "inline") {
				$('#contactContent').hide(); 
				$('#contactMenuImg').attr("src", "images/contact.jpg");
				$('#contactMenu').css({background: "#000000"});
				$('#contact').css({width: ""});	
			}
			
			// hide portfolio info
			if ($('#portfolioContent').css("display") == "inline") {
				$('#portfolioContent').hide(); 
				$('#portfolioMenuImg').attr("src", "images/portfolio.jpg");
				$('#portfolioMenu').css({background: "#000000"});
				$('#portfolio').css({width: ""});	
			} else if ($('#portfolioMenu').css("width") != "-40px") {
				$('#portfolioMenu').animate({"left": "-40px"}, 1000);
			}

			// hide services info
			if ($('#servicesContent').css("display") == "inline") {
				$('#servicesContent').hide(); 
				$('#servicesMenuImg').attr("src", "images/services.jpg");
				$('#servicesMenu').css({background: "#000000"});
				$('#services').css({width: ""});	
			} else {
				$('#servicesMenu').animate({"left": "-40px"}, 1000);
			}

			// show home
			$('#homeMenuImg').attr("src", "images/homeActive.jpg");
			$('#homeMenu').css({background: "#FFFFFF"});
			$('#homeMenu').animate({"left": "-40px"}, 1000, 
				function() {
					$('#home').css({width: width-80});						
					$('#homeContent').show(); 
				}); 
		}		
	});
	
	$("#services").click(function() {
		if ($('#homeMenu').css("left") == "-40px"){
			$('#homeContent').hide();
			$('#homeMenuImg').attr("src", "images/home.jpg");
			$('#homeMenu').css({background: "#000000"});
			$('#homeMenu').animate({"left": (width-120)}, 1000, 
					function() { 
						$('#servicesContent').show(); 
						$('#servicesMenuImg').attr("src", "images/servicesActive.jpg");
						$('#servicesMenu').css({background: "#FFFFFF"});
						$('#services').css({width: width-120});						
					});
		} else if ($('#servicesMenu').css("left") != "-40px") {
			// hide contact info
			if ($('#contactContent').css("display") == "inline") {
				$('#contactContent').hide(); 
				$('#contactMenuImg').attr("src", "images/contact.jpg");
				$('#contactMenu').css({background: "#000000"});
				$('#contact').css({width: ""});	
			}
			
			if ($('#portfolioContent').css("display") == "inline") {
				$('#portfolioContent').hide(); 
				$('#portfolioMenuImg').attr("src", "images/portfolio.jpg");
				$('#portfolioMenu').css({background: "#000000"});
				$('#portfolio').css({width: ""});	
			} else {
				$('#portfolioMenu').animate({"left": "-40px"}, 1000);
			}

			// show services
			$('#servicesMenuImg').attr("src", "images/servicesActive.jpg");
			$('#servicesMenu').css({background: "#FFFFFF"});
			$('#servicesMenu').animate({"left": "-40px"}, 1000, 
				function() {
					$('#services').css({width: width-120});						
					$('#servicesContent').show(); 
				}); 
		}
	});

	$("#portfolio").click(function() {
		if ($('#servicesMenu').css("left") == "-40px"){
			$('#servicesContent').hide();
			$('#servicesMenuImg').attr("src", "images/services.jpg");
			$('#servicesMenu').css({background: "#000000"});
			if ($('#homeMenu').css("left") == "-40px"){
				$('#homeContent').hide();
				$('#homeMenuImg').attr("src", "images/home.jpg");
				$('#homeMenu').animate({"left": (width-120)}, 1000);
				$('#homeMenu').css({background: "#000000"});
			}
			$('#servicesMenu').animate({"left": (width-120)}, 1000, 
					function() { 
						$('#portfolioContent').show(); 
						$('#portfolioMenuImg').attr("src", "images/portfolioActive.jpg");
						$('#portfolioMenu').css({background: "#FFFFFF"});
						$('#portfolio').css({width: width-120});						
					});
		} else if ($('#portfolioMenu').css("left") != "-40px") {
			// hide contact info
			$('#contactContent').hide(); 
			$('#contactMenuImg').attr("src", "images/contact.jpg");
			$('#contactMenu').css({background: "#000000"});
			$('#contact').css({width: ""});	
			
			// show portfolio
			$('#portfolioMenuImg').attr("src", "images/portfolioActive.jpg");
			$('#portfolioMenu').css({background: "#FFFFFF"});
			$('#portfolioMenu').animate({"left": "-40px"}, 1000, 
				function() {
					$('#portfolio').css({width: width-120});						
					$('#portfolioContent').show(); 
				}); 
		}
	});

	$("#contact").click(function() {
		if ($('#portfolioMenu').css("left") == "-40px"){
			$('#portfolioContent').hide();
			$('#portfolioMenuImg').attr("src", "images/portfolio.jpg");
			$('#portfolioMenu').css({background: "#000000"});
			if ($('#homeMenu').css("left") == "-40px"){
				$('#homeContent').hide();
				$('#homeMenuImg').attr("src", "images/home.jpg");
				$('#homeMenu').animate({"left": (width-120)}, 1000);
				$('#homeMenu').css({background: "#000000"});
			}

			
			if ($('#servicesMenu').css("left") == "-40px"){
				$('#servicesContent').hide();
				$('#servicesMenuImg').attr("src", "images/services.jpg");
				$('#servicesMenu').animate({"left": (width-120)}, 1000);
				$('#servicesMenu').css({background: "#000000"});
			}
			
			$('#portfolioMenu').animate({"left": (width-120)}, 1000, 
					function() { 
						$('#contactContent').show(); 
						$('#contactMenuImg').attr("src", "images/contactActive.jpg");
						$('#contactMenu').css({background: "#FFFFFF"});
						$('#contact').css({width: width-120});						
					});
		}		
	});
});
