jQuery.noConflict();

jQuery(function($){
	Cufon.replace('h2.itemCategory, span#menulink_1-subnav, span#menulink_2-subnav, div#subnav h3, div#news h2, p.pulltext, div.homeCal td.calendarCurrentMonth');
});

jQuery(function($){
	$('ul#menulist_root-subnav-inner').superfish({
		speed: 150,
		delay: 300
	});
});

jQuery(function($){
	$('div#hero').cycle();
});

// Contact form

// Validation

jQuery(function($){
	$('#contact_form_body').validate({ rules: {
		name: "required",
		email: {
       		required: true,
       		email: true
     		}
	}, messages:{
			name: "Please enter your name",
     		email: {
      			required: "Please enter your email address",
       			email: "Please enter a valid email address"
     		}
		}
	});
});

// Clears fields on focus
jQuery(function($){
	$('div#contact_form input').bind("focus", function(){
		var val = $(this).val();
	
		if(val == "Your name" || val == "Your email" || val == "Contact phone number")
			{
				$(this).val("");
			}
	});
});


// Form submission
jQuery(function($){
	$('input#submit').bind('click' , function(){
		var nameVal = $('input#name').val();
		var emailVal = $('input#email').val();
		var phoneVal = $('input#phone').val();
		var textVal = $('textarea#text').val();
		
		if( $('#contact_form_body').valid() )
		{
			$('div#contact_form form').slideUp(300 , function(){
				$('p.confirm').slideDown(100 , function(){
	
						$.post("http://www.helpful.com.au/carersupport/contact_submit.php" , {
						name: nameVal,
						email: emailVal,
						phone: phoneVal,
						text: textVal
	
					});
				});
			});
			return false;
		}
		else {
			return false;
		}
	});
});