function nav_resize(){	
	body_width = $("body").width();
	extra_container_width = body_width - 1000;
	new_nav_width = 245 + (extra_container_width / 2); 
	if (new_nav_width < 245) {
		new_nav_width = 245;
	}
	if (new_nav_width > 945) {
		new_nav_width = 945;
	}
	$("#navigation").width(new_nav_width);

	new_sub_nav_width = 256 + (extra_container_width / 2); 
	if (new_sub_nav_width < 258) {
		new_sub_nav_width = 258;
	}
	
	$("#navigation").width(new_nav_width);
	$("#sub_navigation ul li a").width(new_sub_nav_width);
	subnav_repeater_height = $("#sub_navigation ul").height();
	
	if (subnav_repeater_height < 100 ) {
		subnav_repeater_height = 100;
	}
	$("#subnav_repeater").height(subnav_repeater_height);

}

$(window).bind("resize", nav_resize);

// NORMAL RULES

$(document).ready(function() {
	if (!$("body").hasClass("home")){
		$("#container_4").prepend('<div id="subnav_repeater">&nbsp;</div>');
	}
	else {

		cycle_counter = 0;
		tagline_counter = 0;
		
		$("#tagline_container h2").each(function(){
			tagline_counter_class = 'tagline_' + tagline_counter;
			$(this).addClass(tagline_counter_class);										
			tagline_counter = tagline_counter + 1; 										
		});
	
		function cycle_callback(){
			$("#tagline_container h2").fadeOut(100);
			if (cycle_counter == $('#tagline_container h2').size()) {cycle_counter = 0}
			fadeInObj = '#tagline_container h2.tagline_'+(cycle_counter);
			$(fadeInObj).fadeIn(600)
			cycle_counter = cycle_counter + 1;			
		}
		
		$("#eye_candy").cycle({
			before: cycle_callback
			}
		);
		
	}
	
	// INITIAL NAV RESIZE CALL
	
	nav_resize();

	// GENERAL FORM RULES							 	
	if ($("form").hasClass("body_form")){
		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;
		});
	}
});
