// NORMAL RULES

$(document).ready(function() {


	// GENERAL FORM RULES							 	
	if ($("form").hasClass("body_form")){
		// JS FORM VALIDAITON BELOW
		// $.getScript('/scripts/validate_rules.js');
		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;
		});
	}
	
	$("a#job_search_submit_btn").live('click', function() {
			$(this).parents("form").submit();
			return false;
		});
	
	$("#search_btn").click(function(){
		$(this).toggleClass("active");										
		$(".job_search_form").toggle();
		return false;
	});
	
	
	$('#navigation li a').mouseenter(
		function(){
			$('.hover_nav_img').animate({'top':'-200px'},400).remove();
			var nav_id = $(this).attr('id');
			var nav_id_hover_img = nav_id+'_hover';
			var nav_id_hover_img_selector = '#'+nav_id_hover_img;
			var nav_id_hover_str = '<img id="'+nav_id_hover_img+'" class="hover_nav_img" src="/images/navigation/'+link_info(nav_id)['name']+'" />';
			$('#navigation_container').prepend(nav_id_hover_str); 		
			$('.dropdown').hide();
			dd_name = $(this).attr("id").replace("_link","_dropdown");
			dd_selector = "div#"+dd_name;
			$(dd_selector).css('visibility','hidden').show();
			$(nav_id_hover_img_selector).css({'right':link_info(nav_id)['right']}).animate({'top':'0px'},300, function(){
				$(dd_selector).css('visibility','visible');
			});
		}
	);
	
	$('#navigation_container').mouseleave(
		function(){
			$('.dropdown').hide();			
			$('.hover_nav_img').animate({'top':'-200px'},400).remove();
			$('.dropdown ul li a').removeClass('active_dd_link');
		}									 
	);							
	
	
	$('.dropdown ul li a').not('.dropdown.secondary_drop_down ul li a').mouseenter(function(){
		$('.dropdown ul li a').removeClass('active_dd_link');
		$(this).addClass('active_dd_link');																							
		if($('.dropdown ul li a').hasClass('secondary_trigger')){
			$('.secondary_drop_down').hide();							
		}
		var dropdown_rel = $(this).attr('rel');
		var this_item_offset = $(this).offset();
		var this_top_offset = this_item_offset.top - 107;
		if (dropdown_rel != ""){
			trigger_selector = '#'+dropdown_rel+'_dropdown';
			$(trigger_selector).css('top',this_top_offset).show();
			$(this).addClass('secondary_trigger');
		}
	});
	
	$('.secondary_drop_down').mouseleave(function(){
		$('.dropdown ul li a').removeClass('secondary_trigger');
		$(this).hide();
	});
	
	$("h3.accordian_heading").next('ul, div').addClass('accordian_body');
	$("h3.accordian_heading").click(
		function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				$(this).next('.accordian_body').hide();
			}
			else {
				$(this).addClass('active');
				$(this).next('.accordian_body').show();
			}
		}
	);
	

	$('#job_search_options_form input').keydown(function(e){
		if (e.keyCode == 13) {
			$('a#job_search_submit_btn').trigger('click');
			return false;
		}
	});	
	
	function link_info(id) {
		var link_information = new Array; 
		if ( id == 'solutions_link' )
		{
			link_information['right'] = 450;
			link_information['name'] =  "solutions_glow.png";
		}
		if ( id == 'practices_link' )
		{
			link_information['right'] =  302;
			link_information['name'] = "practices_glow.png";
		}
		if ( id == 'careers_link' )
		{
			link_information['right'] = 158;
			link_information['name'] =  "careers_glow.png";
		}
		if ( id == 'who_link' )
		{
			link_information['right'] = 63;
			link_information['name'] =  "who_we_are_glow.png";
		}
		if ( id == 'contact_link' )
		{
			link_information['right'] =  -67;
			link_information['name'] =  "contact_glow.png";
		}	
		return link_information;
	}	
	
});



