// NORMAL RULES

$(window).bind("resize", resizeWindow);
function resizeWindow() {
	if(typeof document.body.style.maxHeight != "undefined") {
	var window_height = $(window).height()
	var body_height = $("body").height()
	if (window_height <= body_height){
		main_body_min_height = (window_height - 420) + "px";
		$("div#main_body").css({'min-height':main_body_min_height});
	}
	}
}	 
$(window).load(function() {
	if($("#container_5").hasClass("home")){
		$('#eye_candy').nivoSlider({
			 effect:'fold', //Specify sets like: 'fold,fade,'
			slices: 50,
			animSpeed: 500, //Slide transition speed
			pauseTime: 4000,
			startSlide:0 //Set starting Slide (0 index)
		});
	}
	if($("#container_5").hasClass("focus")){
		$('#eye_candy').nivoSlider({
			 effect:'fold', //Specify sets like: 'fold,fade,'
			slices: 50,
			animSpeed: 300, //Slide transition speed
			pauseTime: 4000,
			startSlide:0 //Set starting Slide (0 index)
		});
	}
});


$(document).ready(function() {
	if(typeof document.body.style.maxHeight != "undefined") {
		resizeWindow();
	}
	
	if($("#container_5").hasClass("home")){
		$("a#about_link, a#focus_link, a#candidates_link, a#employers_link, a#careers_link, a#contact_link, #header h1, #body_text").fadeOut(0);
		$("#header h1").fadeIn(900, function (){
			$("a#about_link").fadeIn(900);
			$("a#focus_link").fadeIn(900);
			$("a#candidates_link").fadeIn(900);
			$("a#employers_link").fadeIn(900);
			$("a#careers_link").fadeIn(900);
			$("a#contact_link").fadeIn(900, function (){
				$("#body_text").fadeIn(900);
			});
		});	
	}
	$("#navigation li a").hover(
		function () {
			$("#navigation li a").css("background-position","0px 0px");
			$(this).css("background-position","0px -70px");
			dd_name = $(this).attr("id");
			dd_name = dd_name.replace("_link","_dd");
			dd_selector = "#"+dd_name;
			$('.dropdown').not(dd_selector).hide();
			$(dd_selector).show();
		}, 
		function () {}
	);

	$("#navigation_container").hover(
		function (){
		}, function (){
			$("#navigation li a").css("background-position","0px 0px");
			$('.dropdown').hide();
		}
	);

	$("#twitter_btn").hover(
		function(){
			if(!$("#twitter_slideup_container").hasClass("hover")){
			$("#twitter_slideup_container").addClass("hover");
			$("#twitter_slideup_container").animate({"height":"315px"},300);
			}
		},
		function(){
		}
	);
	
	$("#twitter_slideup_container").hover(
		function(){
		}, 
		function(){
			if($("#twitter_slideup_container").hasClass("hover")){	
			$("#twitter_slideup_container").animate({"height":"0px"},300);
			$("#twitter_slideup_container").removeClass("hover");
			}
			
	});
	
	
	// 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();
		});
	}
});
