function sendMessage() {
	var name = document.getElementById('name');
	var email = document.getElementById('email');
	var message = document.getElementById('message');
	var budget = document.getElementById('budget');

	if (name.value == '') {
		alert('Please fill in your name.'); 
		return false;
	} else if (email.value == '' || email.value == 'you@example.com' || !validateEmailAddress(email.value)) {
		alert('Please fill in a valid email address.'); 
		return false;
	} else if (message.value == '') {
		alert('Please tell me what you want to say.'); 
		return false;
	}

	var xhr = new XMLHttpRequest(); 
	
	xhr.open('POST', '?xml=sendMessage', true); 
	query = 'name=' + encodeURI(name.value) + '&email=' + encodeURI(email.value) + '&message=' + encodeURI(message.value) + '&budget=' + encodeURI(budget.value);

	xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xhr.setRequestHeader('Content-Length', query.length);

	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && xhr.status == 200) {  
			var xmlDocument = xhr.responseXML;  
			var messages = xhr.responseXML.getElementsByTagName('message');
			document.getElementById('contactResponse').innerHTML = '<p style="color:#660000; height: 260px;"><b>' + messages[0].firstChild.data + '</b></p>';
		}
	}  

	xhr.send(query);
}

function checkEmailAddress(boolean) {
	var elm = document.getElementById('email');
	var defaultEmail = 'you@example.com';
							
	if (!boolean && elm.value == defaultEmail) {
		elm.value = '';  
	} else if (boolean && elm.value == '') {
		elm.value = defaultEmail;
	}
}

function goToByScroll(height){
	$('html,body').animate({scrollTop: height + 'px'}, 'slow');
}

$(document).ready(function(){
	
	// Portfolio
	$('.box').hover(function(){
		$('.cover', this).stop().animate({left:'0px', top: '-240px'},{queue:false,duration:500});
	}, function() {
		$('.cover', this).stop().animate({left:'0px', top: '0px'},{queue:false,duration:500});
	});
	
	// Identity
	$('a[rel="IdentityCombinationLogo"]').colorbox();
	$('a[rel="IdentitySymbolicLogo"]').colorbox();
	$('a[rel="IdentityWordMarkLogo"]').colorbox();
	$('a[rel="IdentityNamecard"]').colorbox();
	$('a[rel="IdentityStationary"]').colorbox();
			  
	// Webdesign
	$('a[rel="WebBlog"]').colorbox();
	$('a[rel="WebPortfolio"]').colorbox();
	$('a[rel="WebInformational"]').colorbox();
	$('a[rel="WebShop"]').colorbox();
	$('a[rel="WebCompany"]').colorbox();
		  
	// Print
	$('a[rel="PrintMagazine"]').colorbox();
	$('a[rel="PrintPoster"]').colorbox();
	$('a[rel="PrintProduct"]').colorbox();
	$('a[rel="PrintRetouching"]').colorbox();
	$('a[rel="PrintOther"]').colorbox();
		
	// Illustration
	$('a[rel="IllustrationStory"]').colorbox();
	$('a[rel="IllustrationBackground"]').colorbox();
	$('a[rel="IllustrationComics"]').colorbox();
	$('a[rel="IllustrationCharacter"]').colorbox();
	$('a[rel="IllustrationHanddrawn"]').colorbox();
});



