// 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, .fader div").css({'background-position':'-400px 0px', 'width' : '1000px' });
	}
	else {
		$("div#total_entire_whole_site_container, div#whole_site_container, div#footer_container, .fader div").css({'background-position':'center top', 'width' : '100%'});
	}
}	 
	

// NORMAL RULES

$(document).ready(function() {

	$("#navigation li a").hover(
		function () {
			$("#expertise_dd").hide();
		}, function () {}							 
	);
	$("#expertise_link").hover( 
		function (){
			$("#expertise_dd").show();
		},function (){}
	);
	
	$("#navigation_container").hover(
		function (){},function (){
			$("#expertise_dd").hide();
		}
	);
							 
	// 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('<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();
		});	
	}



	// CAROUSEL START

	var auto_slide = 1;
	var hover_pause = 0;
	var key_slide = 1;
	var auto_slide_time = 8000;
	$('#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' : '-750px'});
		});
	
	}
	


