// INTERFACE RULES

// TESTIMONIAL FADE FUNCTION
function testimonial_fade() {
	if ($('ul#location_showcase li:last').hasClass('active_location')) {
		$('.active_location').fadeOut("slow", function() {
			$(this).removeClass('active_location');
			$('ul#location_showcase li:first').addClass('active_location');
			$('ul#location_showcase li:first').fadeIn("slow");
	});
}
else {
	$('.active_location').fadeOut("slow", function() {
		$(this).removeClass('active_location');
		$(this).next('ul#location_showcase li').addClass('active_location');
		$(this).next('ul#location_showcase li').fadeIn("slow");
	});
	}
};

$(document).ready(function() {


	// DROP DOWN
	
	drop_down = $("#navigation_container div");
	
	$('#navigation li a').mouseenter(
	function() {
		$('#navigation li a').css({backgroundPosition: '0px 0px'});
		$("#navigation li a strong").stop().animate({'width': '0'},300);			
		drop_down.stop(true, true).slideUp(200);
		dd_name = $(this).attr("id");
		this_width = $(this).width();		
		dd_name = dd_name.replace("_link","_dd");
		dd_selector = "div#"+dd_name;
		$(this).find("strong").animate({'width': this_width},300);
		$(dd_selector).stop().slideDown(400);
	});	
	
	$("#navigation_container").mouseleave(
		function (){
			$("#navigation li a strong").stop().animate({'width': '0'},150);			
			drop_down.stop(true, true).slideUp(200);
			$('#navigation li a').css({backgroundPosition: '0px 0px'});			
		}
	);


	// LOCATION FADING CALL
	
	$('ul#location_showcase li:first').css('display', 'block').addClass('active_location');
	setInterval(testimonial_fade, 4000);


	// GENERAL FORM RULES							 	
	
	if ($("form").hasClass("body_form")){
		$.getScript('/scripts/validate_rules.js');
		$.getScript('/scripts/jquery_placify.js');
		var count = 10;
		countdown = setInterval(function(){
		$("#timer").html("Please wait " + count + " seconds before you submit!");
		
		if (count == 0) {
			$('#timer').remove();
			$("#submit_container").html('<a href="#" class="submit_button "><span>Submit</span></a>');
			$(".submit_button").fadeIn('slow');
		}
		count--;
		}, 1000);
	
		$("a.submit_button").live('click', function() {
			$(this).parents("form").submit();
			return false;
		});
	}
});


