$(document).ready(function(){

	// binds form submission and fields to the validation engine
	$("#contact-form").validationEngine();
	$("#contact-form").bind("jqv.form.validating", function(event){
		$("#hookError").html("")
	})
	$("#contact-form").bind("jqv.form.result", function(event , errorFound){
		if(errorFound) $("#hookError").append("Please enter all information correctly.");
	})

	// comment box scrolls with page scroll
	$(function () {
		var msie6 = $.browser == 'msie' && $.browser.version < 7;
  
			if (!msie6) {
			var top = $('#comment').offset().top - parseFloat($('#comment').css('margin-top').replace(/auto/, 0));
		
			$(window).scroll(function (event) {
				// what the y position of the scroll is
			  	var y = $(this).scrollTop();
			  	// whether that's below the form
			  	if (y >= top) {
				// if so, ad the fixed class
				$('#comment').addClass('fixed');
			  	} else {
				// otherwise remove it
				$('#comment').removeClass('fixed');
			  	}
			});
		}  
	});
	
	// countdown
	$(function () {
		var austDay = new Date("December 31, 2012 23:59:59");
			$('#defaultCountdown').countdown({until: austDay, layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'});
			$('#year').text(austDay.getFullYear());
	});
	
});
