/* ===============================================================================
	THE MIND ARTIST GLOBAL JAVASCRIPT:
	All these functions are needed globally
==================================================================================
	NOTES:
	- 
	- 
	- 
================================================================================*/

function toggleForm(){
	var fieldset = $('#contactform fieldset');
	if(!$('#contactform').hasClass('show')){
		// Hide contactform and show toggle
		fieldset.after('<p class="alignCenter"><a href="#submitknop" class="button toggle">Toon contactformulier</a></p>');
		fieldset.hide();
	}
	$('#contactform .toggle').click(function(evnt){
		evnt.preventDefault();
		fieldset.slideDown();
		$(this).parent().remove();
	});
}

// function ajaxifyForm(){
// 	// Hijack submission of contactform and handle with AJAX
// 	var form = $('#contactform');
// 	var action = window.location;
// 	
// 	form.submit(function(evnt){
// 		evnt.preventDefault();
// 		$.get("/contact/", {'ajax':true}, function(data){
// 			alert("Data Loaded: " + data);
// 		});
// 	});
// }

// Executing at document ready
function init(){
	// Automagically hide/show default input text onFocus
	$('#contactform').emptyonfocus();
	// Hide all labels: NOTE: the label text should be in inputs!
	$('#contactform label').hide();
	// Hide contactform and show toggle
	toggleForm();
	// Hijack contactform for AJAX
	// ajaxifyForm();
	// Activate Smooth Scrolling Anchors on .wrapper scope
	$('.wrapper').scrollanchors();
}
/* ===============================================================================
	On Document Ready: load init()
================================================================================*/
$(document).ready(init);
