$.preloadImages([
	'assets/images/spacer.gif'
]);
$(document).ready(function(){
	// Clickable Logo
	$('.logo').click(function() {document.location.href='/';});
	
	// Rollover Images
	$('img').hover(
		function() {src = $(this).attr('src'); $(this).attr('src',src.replace(/off\./,'on.'));},
		function() {src = $(this).attr('src'); $(this).attr('src',src.replace(/on\./,'off.'));}
	);
	
	// Contact Form Validation
	$("#contactForm").validate({
		rules: {
			zip: {
				digits: true,
				rangelength: [5, 5]
			}
		},
		messages: {
			zip: {
				rangelength: "Zip must be 5 digits"
			}
		}
	});
	
	$(".hidden").hide();
	$(".show").click(function () {
		$(".hidden").slideToggle("slow");
	});
});

// characters remaining code
function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
		return true;
	}
}

$(function(){
 	$('#comments').keyup(function(){
 		limitChars('comments', 250, 'charlimitinfo');
 	})
});
