$(document).ready(function() {
	
	$('#send-a-message').click(function() {
		$(window).scrollTop($(document).height(), 0);
	});
	
	$('#view-current-site').click(function() {
		window.location.href = 'http://www.lucidfusion.com/';
	});
	
	$('.select-label').click(function () {
		if($(this).parent().children('.select-dropdown').css('display') == 'block') {
			$(this).parent().children('.select-dropdown').hide();
		} else {
			$(this).parent().children('.select-dropdown').show();
		}
		$('.select-box .select-option').click(function() {
			var val = $(this).attr('rel')
			$(this).parent().siblings('.select-label').html(val);
			var sel = $(this).parent().siblings('select');
			sel.val(val);
			sel.children('option').attr('selected', false);
			sel.children('option[value=' + val + ']').attr('selected', true);
			$(this).parent().hide();
		});
	});
	
	$('#submit').click(function() {
		console.log("asdf");
		$('input, textarea').removeClass('input-error');
		var errors = false;
		if($('input[name=name]').val() == '') {
			errors = true;
			$('input[name=name]').addClass('input-error');
		}
		if($('input[name=email]').val() == '') {
			errors = true;
			$('input[name=email]').addClass('input-error');
		}
		
		if(errors == false) {
			$.post('/contact-submit.php', $('form[name=contact-form]').serialize(), function(data) {
					$('#contact-feedback').css('display', 'block');
					$('input, textarea').removeClass('input-error').val('');
					setTimeout(function() {
							$('#contact-feedback').fadeOut(500);
						}, 2000);
				}
			);
		}
		return false;
	});
});
