function sendEmail() {
	document.getElementById('sendEmail').value = 'Sending...';
	document.getElementById('sendEmail').disabled = true;
	$.post("process.php?type=sendEmail", $("#emailForm").serialize(),
	function(data){
		if(data == '<span style="color: #000;">Email Sent!</span>') {
	        document.getElementById('emailError').innerHTML = data;
	        document.getElementById('emailName').value = 'Your Name';
	        document.getElementById('emailEmail').value = 'Your Email';
	        document.getElementById('emailContent').value = 'Message';
			document.getElementById('sendEmail').value = 'Send Email';
			document.getElementById('sendEmail').disabled = false;
		} else {
	        document.getElementById('emailError').innerHTML = data;
			document.getElementById('sendEmail').value = 'Send Email';
			document.getElementById('sendEmail').disabled = false;
		}
	});
}

$(document).ready(function() {
	$('.boxgrid').hover(function(){
		$(".cover", this).stop().animate({top:'125px'},{queue:false,duration:200});
		$(this).addClass("boxgridHover");
	}, function() {
		$(".cover", this).stop().animate({top:'185px'},{queue:false,duration:200});
		$(this).removeClass("boxgridHover");
	});
	
	$('#sendEmail').click(function() {
		sendEmail();
	});
	
	$('#whereElse a').tipsy({fade: true, gravity: 'w'});
	
	$('#expandPortfolio').click(function () {
		$('#morePortfolio').slideDown(function callback() {
			$('.scroll').css('height', $('#profile').height());														
			$('#showMore').remove();
			$.scrollTo('#footer', 500);
		});
		return false;
	});
	
	$("a.portfolioImg").fancybox();
	
	$('#contactForm input[type="text"], #contactForm textarea').addClass("idleField");
	$('#contactForm input[type="text"], #contactForm textarea').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('#contactForm input[type="text"], #contactForm textarea').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
});