$(document).ready(function(){
	jQuery.fn.exists = function(){return jQuery(this).length>0;}
	
	
	$('a.connect-button').toggle(
		function () {
			$('#header-connect-wrapper').slideDown("slow")
		}
		,
		function () {
			$('#header-connect-wrapper').slideUp("slow")
		}
	);
	
	if ($('#header-images').exists()) {
		$('#header-images').cycle({fx: 'scrollHorz',speed: 1000, cleartype:1,timeout:6000,prev: '#prev',next: '#next'});
	}
	
	$("#signup-form").validate({
					   					   
		rules: { 
			'cm-name': {
				required: true
			}, 
			'cm-kklra-kklra': {  
				required: true, 
				email: true 
			}, 
			'signup-checkbox': { 
				required: true
			}
		}, 
		errorElement: "div",
		errorContainer: $(""),
		errorPlacement: function(error, element) {
			error.appendTo();
		},
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				alert("Please enter all fields to sign up.");
			}
		},
		submitHandler: function(form) {
		   form.submit();
		}
	});
	
	$("#contact-form").validate({
					   					   
		rules: { 
			'contact-name': {
				required: true
			}, 
			'contact-email': {  
				required: true,
				email: true 
			}, 
			'contact-comment': { 
				required: true
			}
		}, 
		errorElement: "div",
		errorContainer: $(""),
		errorPlacement: function(error, element) {
			error.appendTo();
		},
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				alert("Please enter all comment fields.");
			}
		},
		submitHandler: function(form) {
		   form.submit();
		}
	}); 
	
}); 
