	$(document).ready(function(){ 
		
		$(".box, li, input[type=text], textarea").corner("5px");
		
		$("div#nav li, .section").corner("10px");
			
		$("#main-content ul > li:even").addClass("even");
		
		$('#nav li')
		
		.mousedown(function(){
		
			var openThis = $(this).children('a').attr('href');
	
			//$("#nav ul li").not(this).removeClass("active").css({"background-position": "0px 0px"});			
	
			$(this).addClass("active");
	
		});
	
		$("div.portfolio-piece")
		
			.mouseenter(function(){
								 
			
				$(this).stop().delay(300).animate({height: ['480px']}, 300, function(){
			
					//$("div.portfolio-piece").not(this).animate({height: ['40px']}, 100);
			
					$(".portfolio-caption", this).fadeIn(300);
					
					return false;
				
				});
				
			
			})
			
			.mouseleave(function(){
	
				$(".portfolio-caption", this).fadeOut();
	
				$(this).stop().animate({height: ['100px']}, 300);
				
	
		});
		
		
		$("#nav a").click(function(){
		
			$.address.value($(this).attr("href"));
			
			return false;
		
		});
		
		$.address.change(function(event) {  
	
			 $(".section").hide();
			 
			 $("#nav li").css({"background-position": "0 0"}).removeClass("active");			 
	
			 thisSection = event.value.replace("%23", "#");
			 
			 if(thisSection == "") { thisSection = "#home"; $("#home").fadeIn(); }
			 
			 thisNavClass = thisSection.replace("#", '');
			 
			 $("#nav li."+thisNavClass).css({"background-position": "-250px 0px"}).addClass("active");
			 
			 $(thisSection).fadeIn(300);
			 
			 $('html, body').animate({scrollTop:0}, 'slow');
	
			 return false;
			 
		 }); 
		 
		 $("ul.abbr-info li").mouseenter(function(){
		 
		 	var li_msg = $(this).attr("title");
			
			$(this).attr("title", "");

			if(li_msg != "") {
			
				$("<div class='tooltip'>"+li_msg+"</div>").fadeIn(350).appendTo(this);
			
			}
			 
		 })
		 
		 .mouseleave(function(){
	
			original = $(this).children(".tooltip").text();
			
			$(this).attr("title", original);
			
		 	$(".tooltip").fadeOut(250).remove();
		 
		 });
		 
		 $("ul.showcase li").mouseenter(function(){
	
			$("ul.showcase li").stop();
	
			var msg = $(this).attr("title");
			
			$("img", this).animate({opacity: 0.05}, 350);
			
			$("<div class='showcase-tooltip'>"+msg+"</div>").appendTo(this).fadeIn(250);
	
		 })
		 
		 .mouseleave(function(){
	
				$("ul.showcase li").stop();
				$(".showcase-tooltip").fadeOut(250);
				$(".showcase-tooltip").remove();
				$("img", this).animate({opacity: 1});				
	
		  })
		 
		 var options = { target: "#form-output", success:showResponse }
		 
		 $('#contactform').ajaxForm(options); 
		 
	});


function showResponse(responseText, statusText, xhr, $form)  { 
    
		$("#form-output").fadeIn(350);
		
		if(responseText == "Thanks!  Your eMessage has been iMagically E-delivered to me.") {
		
			$("#contactform").fadeOut(350)
		
		}
		
} 