// Background Postion Fix
/* 
$(document).ready(resizeWindow);
$(window).bind("resize", resizeWindow);
function resizeWindow( e ) {
	var body_width = $('body').width()
	if (body_width <= 1000){
		$("div#total_entire_whole_site_container, div#whole_site_container, div#footer_container").css({'background-position':'500px 0px', 'width' : '1000px' });
	}
	else {
		$("div#total_entire_whole_site_container, div#whole_site_container, div#footer_container").css({'background-position':'center top', 'width' : '100%'});
	}
}	 
*/

// NORMAL RULES

$(document).ready(function() {
	
	// NAVIGATION FUNCTIONS
	function nav_hover (right_pos) {
		$("h2.important_links").hide().css({'right' : right_pos }).show().animate({backgroundPosition : "0px -31px"}, 600);
	}
	
	function nav_rolloff () {
		$("h2.important_links").stop().hide().css({'background-position' : "0px 0px"});
	}
	
	function nav_append (this_id) {
		$(".important_links").remove();
		$(this_id).append('<h2 class="important_links"><span>Important Links</span></h2>');
	}

	function dd_show (dd_id) {
		$(".drop_down").hide();
		$(dd_id).show();
	}
	
	// NAVIGATION RULES
	$("a#about_link").hover( 
		function(){ 
			$("#navigation li a").css({'background-position' : '0px 0px' });				
			$(this).css({'background-position' : '0px -120px' });
			nav_append ("a#about_link");
			nav_hover("33px"); 
			dd_show("div#about_dd");
		},function(){
			nav_rolloff();
		}
	);						   
							 
	$("a#solutions_link").hover( 
		function(){
			$("#navigation li a").css({'background-position' : '0px 0px' });				
			$(this).css({'background-position' : '0px -120px' });
			nav_append ("a#solutions_link");
			nav_hover("52px"); 
			dd_show("div#solutions_dd");
		},function(){
			nav_rolloff();
		}
	);						   
							 
	$("a#candidates_link").hover( 
		function(){ 
			$("#navigation li a").css({'background-position' : '0px 0px' });	
			$(this).css({'background-position' : '0px -120px' });
			nav_append ("a#candidates_link");
			nav_hover("58px"); 
			dd_show("div#candidates_dd");
		},function(){
			nav_rolloff(); 
		}
	);						   
							 
	$("a#clients_link").hover( 
		function(){
			$("#navigation li a").css({'background-position' : '0px 0px' });				
			$(this).css({'background-position' : '0px -120px' });
			nav_append ("a#clients_link");
			nav_hover("34px"); 
			dd_show("div#clients_dd");
		},function(){
			nav_rolloff(); 
		}
	);						   
							 
	$("a#careers_link").hover( 
		function(){
			$("#navigation li a").css({'background-position' : '0px 0px' });	
			$(this).css({'background-position' : '0px -120px' });
			nav_append ("a#careers_link");
			nav_hover("36px"); 
			$(".drop_down").hide();					
		},function(){ 
			nav_rolloff(); 
		}
	);						   
	
	$("a#contact_link").hover( 
		function(){
			$("#navigation li a").css({'background-position' : '0px 0px' });	
			$(this).css({'background-position' : '0px -120px' });
			nav_append ("a#contact_link");
			nav_hover("42px"); 
			$(".drop_down").hide();		
		},function(){ 
			nav_rolloff(); 
		}
	);						   
	
	
	$("#navigation_container").hover(
		function (){},
		function (){
			$(".drop_down").hide();		
			$("#navigation li a").css({'background-position' : '0px 0px' });		
		}
	);
				
				
	// 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();
			$("#sumbmit_container").html('<input class="submit_button" type="image" src="/images/misc_elements/submit_btn.gif" name="submit" />');
			$(".submit_button").fadeIn('slow');
		}
		count--;
		}, 1000);
	}
	
	// UL TRICK
/*	if ($("ul").hasClass("body_ul")){
		var li = $(".body_ul li");
		var position = li.position();
		if(position.top < 420) {
			$(".body_ul li").addClass("small_list");
			$(".body_ul li").append(" XXX");
		}
	}
*/
//	$("ul.body_ul").append( "<li>left: " + position.left + ", top: " + position.top  + "</li>" );


// CAROUSEL START

	var auto_slide = 1;
	var hover_pause = 0;
	var key_slide = 1;
	var auto_slide_time = 6000;
	$('#eye_candy li:first').before($('#eye_candy li:last'));

	if(auto_slide == 1){
		var timer = setInterval('slide("top")', auto_slide_time);
	}

	if(hover_pause == 1){
		$('#eye_candy li div').hover(function(){
			clearInterval(timer)
		},function(){
			timer = setInterval('slide("top")', auto_slide_time);
		});
	}

});


// CAROUSEL FUNCTIONS 
	function slide(where){
	
		var item_height = $('#eye_candy li').outerHeight();
		if(where == 'down'){
			var top_indent = parseInt($('#eye_candy').css('top')) + item_height;
		}
		else{
			var top_indent = parseInt($('#eye_candy').css('top')) - item_height;
		}
		$('#eye_candy:not(:animated)').animate({'top' : top_indent}, 700, 'easeOutSine', function(){
		
			// INFINITY FIX
			if(where == 'down'){
				$('#eye_candy li:first').before($('#eye_candy li:last'));
			}else{
				$('#eye_candy li:last').after($('#eye_candy li:first'));
			}
			//...and then just get back the default top indent
			$('#eye_candy').css({'top' : '-589px'});
		});
	
	}
	


