// NORMAL RULES

$(document).ready(function() {
	
	// INSERT CORNER CHUNKS
	
	$("body").prepend('<div id="top_right_corner" class="corners">&nbsp;</div>');						   
	$("body").append('<div id="bottom_left_corner" class="corners">&nbsp;</div>');						   

	// SUBNAV HEIGHT CALCULATIONS
	
	subnav_heading_height = $('#sub_navigation h2').outerHeight()
	subnav_list_height = $('#sub_navigation ul').outerHeight()
	subnav_height = subnav_heading_height + subnav_list_height;
	$('#sub_navigation').css({'height' : subnav_height});
	$("#sub_navigation ul li:last").find("a").addClass("last");
	
	
	/*
	
	// RESUME SUBMITAL FORM RULES							 
	if(typeof document.body.style.maxHeight === "undefined") {
		var is_ie6 = true;
		$.getScript('/scripts/validate_rules_ie6.js');
	}
	else {
		var is_ie6 = false;
		$.getScript('/scripts/validate_rules.js');
	}
	*/

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

	// NAVIGATION RULES

	$("#navigation li a").hoverIntent(
		function () {
			$("#navigation li a").css("background-position","0px 0px");
			$(this).css("background-position","0px -40px");
			dd_name = $(this).attr("id");
			dd_name = dd_name.replace("_link","_dd");
			dd_selector = "div#"+dd_name;
			$('.drop_down').not(dd_selector).hide(600);
			$(dd_selector).show(600);
		}, 
		function () {}
	);

	$("#navigation_container").hover(
		function (){
		}, function (){
			$("#navigation li a").css("background-position","0px 0px");
			$('.drop_down').hide(300);
		}
	);
	
	
	// TESTIMONIAL HOVER
	
	$('#tagline').click(function(){
		return false;
	});
	
	$('#testimonials').cycle({ 
		fx:    'fade', 
		speed:  800,
		timeout: 8000,
		next:   '#next_testimonial', 
		prev:   '#back_testimonial' 	
	});
	
	$("#testimonial_container").hoverIntent(
		function (){
			$(".testiomonail_items").show(600);
		}, 
		function(){
			$(".testiomonail_items").hide(200);																				
		}
	);

});


// INFINATE WIDTH DIV FIX

$(document).ready(resize_divs);
$(window).bind("resize", resize_divs);
function resize_divs() {
	function div_resize(item_min_width, item_id) {
		body_width = $('body').width()
		outside_body_width = body_width - 1000;
		oneside_outside_body_width = outside_body_width / 2;
		strectched_item_width = oneside_outside_body_width + item_min_width;
		if (body_width <= 1000){
			$(item_id).css({'width' : item_min_width });
		}
		else {
			$(item_id).css({'width' : strectched_item_width});
		}
	}

	// CALL THE ID AND SET THE ORIGINAL WIDTH (REPEAT TO ADD MORE);
	
	div_resize(565,"#eye_candy_container");
	div_resize(435,"#sub_navigation ul");
	
	body_width = $('body').width(); 
	if (body_width < 1576) {
		if (body_width < 1000) {
			$(".corners").css({'width' : 0});
		}
		else {
			body_excess = 1576 - body_width;
			body_excess = body_excess / 2;
			corner_width = 288 - body_excess;
			$(".corners").css({'width' : corner_width});
		}
	}
	
} 
