// NORMAL RULES

$(document).ready(function() {
						   

//CONTAINER_3(ORANGE GRADIENT)  = WINDOW HEIGHT
	function normalize_height() {
		var wh = $(window).height();
		var ch = $('#container_3').height();
		if (wh > ch) {	
			$('#container_3').css("height", wh);
		}
	};

//	function subnav_height() {
//		var bth = $('#body_text').height();
//		var abth = (bth - 154);
//		var snh = $('#sub_navigation ul').height();
//		$('#sub_navigation ul').css("height", abth);
//	};

	normalize_height();
//	subnav_height();
	$(window).resize(function() {
		normalize_height();
//		subnav_height();
	});	

	
//SUB NAVIGATION
	
	$('#sub_navigation ul li a').hover(
	function() {
		$("#sub_navigation ul li a img").css("display", "none");
		$(this).find('img').stop(true, true).fadeIn('normal');
	},
	function() {
		$(this).find('img').stop(true, true).fadeOut('fast');
	});		
	
//JOB BOARD
	
	$('a.job_board_item').hover(
	function() {
		$("#job_board_item li a img").css("display", "none");
		$(this).find('img').stop(true, true).fadeIn('normal');
	},
	function() {
		$(this).find('img').stop(true, true).fadeOut('fast');
	});		
	
//CUSTOM LINK
	
	$('a.custom_link').hover(
	function() {
		$("a.custom_link img").css("display", "none");
		$(this).find('img').stop(true, true).fadeIn('normal');
	},
	function() {
		$(this).find('img').stop(true, true).fadeOut('fast');
	});				
	
	
//HOMEPAGE PANEL HOVERS

	//Shared Rules
	$(".homepage_panel").hover(
	function() {
		$(this).find('.homepage_panel_content').stop(true, false).animate({left: '0px'}, {duration: 200, queue: false});
		$(this).find('img').stop(true, false).animate({width: '270px'}, {duration: 200, queue: false});
		$(this).find('.home_panel_eye_candy_container').stop(true, false).animate({width: '259px', backgroundPosition: '-40px top'}, {duration: 200, queue: false});
		$('.homepage_panel').not(this).stop(true, false).fadeTo('fast', 0.2);
		}, function() {
		$(this).find('.homepage_panel_content').stop(true, false).animate({left: '15px'}, {duration: 200, queue: false});
		$(this).find('img').stop(true, false).animate({width: '240px'}, {duration: 200, queue: false});
		$(this).find('.home_panel_eye_candy_container').stop(true, false).animate({width: '230px', backgroundPosition: '-55px top'}, {duration: 200, queue: false});
		$('.homepage_panel').stop(true, false).fadeTo('fast', 1);
	});	


// DROPDOWN MENUS
    $("div.dropdown ul li:last-child").addClass('last');
	$('#navigation li a').hover(
	function() {
		$("#navigation li a img").css("display", "none");
		$(this).find('img').stop(true, true).fadeIn('normal');
		$('.dropdown').stop(true, true).fadeOut(200);
		dd_name = $(this).attr("id");
		dd_name = dd_name.replace("_link","_dd");
		dd_selector = "div#"+dd_name;
		$(dd_selector).stop().fadeIn(400);
	}, function() {
	})
	
	$("#navigation_container").hover(
		function (){},
		function (){
			$(this).find('img').stop(true, true).fadeOut('fast');
			$('.dropdown').stop(true, true).fadeOut(200);	
	});
	
	
// GENERAL FORM RULES							 	
	if ($("#request_info_form").hasClass("body_form") || $("#resume_submittal_form").hasClass("body_form")){
		$.getScript('/scripts/validate_rules.js');
		$.getScript('/scripts/jquery_placify.js');
		var count = 3;
		countdown = setInterval(function(){
		$("#timer").html("Please wait " + count + " seconds before you submit!");
		if (count == 0) {
			$('#timer').remove();
			$("#submit_button").css('display', 'block');
		}
		count--;
		}, 1000);
		$("a#submit_button").live('click', function() {
			$(this).parents("form").submit();
			return false;
		});
	}
});
