$(document).ready(function(){
	$('p.more').slideUp(0);
	
	$('a.show-more').click(function(e){
		$(this).hide(0);
		$(this).parent().parent().find('p.more').slideDown(200);
		e.stopPropagation();
		e.preventDefault();
	});

	$('#email-button').bind('click', function(e){
		$('#email-text').slideUp();
		$('#email-form').animate({
			'height': '270px'
		});
		
		$(this).unbind();
		$(this).bind('click', function(){
			e.stopPropagation();
			e.preventDefault();
		});
		e.stopPropagation();
		e.preventDefault();
	});
	
	$('#email-form form').attr('target', 'formframe').bind('submit', function(e){
		var hasError = false;
	
		if ($('#ContactForm_email').val().length == 0) {
			$('#email-label').css({
				'color': 'red',
				'font-weight': 'bold'
			});
			hasError = true;
		}
		else {
			$('#email-label').css({
				'color': '#000',
				'font-weight': 'normal'
			});
		}
		
		if ($('#ContactForm_message').val().length == 0) {
			$('#message-label').css({
				'color': 'red',
				'font-weight': 'bold'
			});
			hasError = true;
			return false;
		}
		else {
			$('#message-label').css({
				'color': '#000',
				'font-weight': 'normal'
			});
		}
		
		if (hasError == true) {
			e.stopPropagation();
			e.preventDefault();
			return false;
		}
	
		$('#email-form').slideUp();
		$('#email-success').animate({
			'height': '150px'
		});
	});

	preloadImages = [
		'/assets/images/latest-news.png',
		'/assets/images/latest-news-hover.png',
		'/assets/images/our-creations.png',
		'/assets/images/our-creations-hover.png',
		'/assets/images/our-work.png',
		'/assets/images/our-work-hover.png',
		'/assets/images/connect.png',
		'/assets/images/connect-hover.png',
		'/assets/images/email.png',
		'/assets/images/email-hover.png',
		'/assets/images/facebook-bottom.png',
		'/assets/images/facebook-bottom-hover.png',
		'/assets/images/twitter.png',
		'/assets/images/twitter-hover.png',
		'/assets/images/subscribe.png',
		'/assets/images/subscribe-hover.png'
	];

	for (var i=0; i<preloadImages.length; i++) {
		$('<img>').attr('src', preloadImages[i]);
	}

});