$(document).ready(function() {
						   
	$('#products_solutions ul li ul').each(function() {
		
		// apply style to final ul
		$(this).find('> li ul:last').addClass('final');
		
		// apply arrows
		$(this).find('> li:has(ul) > a').css('background-image', 'url(images/arrow.png)');
	});
	
	
	
	// products & solutions navigation
	
	$('#products_solutions ul li ul li:has(ul) > a').click(function() {
														  
		var is_clicked = $(this).hasClass('open');
		
		// find open uls and close them
		$(this).parent().parent().find('li a.open').each(function() {
			$(this).parent().find('ul').slideUp();
			$(this).toggleClass('open');
			$(this).css('background-image', 'url(images/arrow.png)');
		});
		
		// make sure that the item you clicked to close stays closed
		if (is_clicked == false) {
		
			var is_open = $(this).hasClass('open');
		
			if (is_open == false) {
				$(this).parent().find('> ul').slideDown();
				$(this).toggleClass('open');
				$(this).css('background-image', 'url(images/down_arrow.png)');
			}
		}
	});
	
	
	
	// tabs navigation
	
	$('#site_navigator #tabs ul li a').click(function() {
		var is_selected = $(this).hasClass('selected');
		
		var tab = $(this).attr('id');
		
		// make sure you're not clicking an already selected tab
		if (is_selected == false) {
			$('#site_navigator #tabs ul li a').toggleClass('selected');
			
			if (tab == "products_tab") {
				$('#products_solutions').css('display', 'block');
				$('#cooper_divisions').css('display', 'none');
			} else {
				$('#products_solutions').css('display', 'none');
				$('#cooper_divisions').css('display', 'block');
			}
		}
	});	
	
	// and because we can't use a hash mark in cold fusion
	$('#site_navigator a').click(function() {
		if ($(this).attr('href') == "return_false") {
			return false;
		}
	});
});
