$(document).ready(function()
{	
	var validator = $("#contactform").validate();
	
	$("#submit_contactform").click(function()
	{
		if($("#contactform").valid())
			$("#contactform").submit();
	});
	
	$("#reset_contactform").click(function()
	{
		validator.resetForm();
//		$("form")[0].reset();
	});
	
	$("#submit_quickform").click(function()
	{
		$("#quickform").submit();
	});

	var div = $('#small_text');
	if(div.length > 0)
	{
		var fullHeight = div.height();
		var newHeight = 1.25 * parseInt($('#small_text span').css('font-size').substr(0,2),10);
		if($.browser.msie || $.browser.safari || $.browser.webkit) newHeight = newHeight *16;
		else newHeight = newHeight * 15;
		div.css('height', newHeight);
		div.css('overflow', 'hidden');
		$('a.toggle').click(function () {
			if (div.hasClass('open')) {
				div.animate({ height: newHeight }, { duration: 1000});
				$('a.toggle').html('<span>More</span>');
				div.removeClass('open');
			} else {
				div.animate({ height : fullHeight }, { duration: 1000 });
				$('a.toggle').html('<span>Less</span>');
				div.addClass('open');
			}
			
			return false;
		});
	}
});

function nextTestimonial(id)
{
	//new Ajax('/testimonials.php',{method:'get',data:'id='+id,update:'testimonial_content',evalScripts:true}).request();
	//new Request.HTML({url:'/testimonials.php',update:'testimonial_content',evalScripts:true}).get({'id': id});
	$("#testimonial_content").load('/testimonials.php',{id:id});
}

function nextStaff(id)
{
	//new Ajax('/staff.php',{method:'get',data:'id='+id,update:'staff_content',evalScripts:true}).request();
	//new Request.HTML({url:'/staff.php',update:'staff_content',evalScripts:true}).get({'id': id});
	$("#staff_content").load('/staff.php',{id:id});
}

function showStates()
{
	if($("#country").val() == 'United States of America')
		$("#states").show();
	else
		$("#states").hide();
}

function hideFAQ()
{
	if($('#bottom_content p').length > 4)
	{
		$('#bottom_content p').each(function(i)
		{
			if(i > 4)
				$(this).remove();
		});
		if($('#bottom_content p').children(":last").is("b"))
			$('#bottom_content p').children(":last").remove();
	}
}

