$(document).ready(function(){
	// style select box
	$("#state").selectbox();

	// when page loads...
	$(".tab_content").hide(); // hide all content
	$("ul.tabs li:first").addClass("active").show(); // activate first tab
	$(".tab_content:first").show(); // show first tab content

	// on Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); // remove any "active" class
		$(this).addClass("active"); // add "active" class to selected tab
		$(".tab_content").hide(); // hide all tab content

		var activeTab = $(this).find("a").attr("href"); // find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn("Slow"); // fade in the active ID content
		return false;
	});
 
 	// contact form
	$('#contactform').submit(function(){
		var action = $(this).attr('action');
		$('#submit')
			.after('<img src="images/ajax-loader.gif" class="loader" />')
			.attr('disabled','disabled');
 
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			suburb: $('#suburb').val(),
			state: $('#state').val()
		},
			function(data){
				$('#contactform #submit').attr('disabled','');
				$('.response').remove();
				$('#contactform').after('<span class="response">'+data+'</span>');
				$('.response').slideDown();
				$('#contactform img.loader').fadeOut(500,function(){$(this).remove()});
				if(data=='Thank you, your message has been sent!') $('#contactform').slideUp();
			}
		);
		return false;
	});
	
	$("#home form p:last").css("padding","0");
});
