$(document).ready(function() {  

$('.contactLink').click(function(){showMessageBox();});
$('#overlay_container').click(function(){cancel();});
$('.reset').click(function(){cancel();});
$('.custom').click(function(){dropdown('custom')});
$('#dropdown .close').click(function(){cancel(); return false;});
//$('.buttons a').click(function(){show_content($(this)); return false;});
//$('form[name="messageForm"]').submit(function(){submitForm(); return false;});
$('#messageForm').validate({
	submitHandler: function() {
   	submitForm();
   }
	});

});

function showMessageBox(){
	$('#messageBox').show('slow');
	$('#overlay_container').fadeIn();
	}
function hideMessageBox(){
	$('#messageBox').hide('slow');
	}
function cancel(){
	hideMessageBox();
	closeDropdown();
	$('#overlay_container').fadeOut('slow', function() {
	$('.form').show(); $('.thankyou').hide();});
	
	}
function dropdown(page){
	$('#dropdown').slideDown('slow');	
	$('#overlay_container').fadeIn();
	}
function closeDropdown(){
	$('#dropdown').slideUp('slow');	
	
	}

function show_content(link){
	a = link.attr('class');
	$('.content').html($('#'+a).html());
	}
function submitForm(){
	$.post("http://putonium.com/message", $('#messageForm').serialize(),
	function(data){
		if(data == 1){
			$('.form').fadeOut('slow', function(){$('.thankyou').fadeIn();});
			$('#messageForm').reset();
		}
		else alert('Sorry there was an error');
		}
	
	);
	}
