$(document).ready(function() {

	// make all the boxes on the homepage the same height
	$(".float_box").equalHeights();
	
	// cycle slideshow images
	$(".lead_image").cycle({ 
    	fx:    'fade',
    	random: 1,
    	speed:  6000 
 	});
 	
 	// remove/insert 'search' text on searchbox
 	$("#searchbox").each(function()
	{
		document['def_'+$(this).attr('name')] = $(this).attr('value');
		$(this).focus(function()
		{
			if($(this).attr('value') == document['def_'+$(this).attr('name')]) $(this).attr('value','');
		});
		$(this).blur(function()
		{
			if($(this).attr('value') == '') $(this).attr('value',document['def_'+$(this).attr('name')]);
		});
	});
	
	// get the height of the float_box
	var theBoxHeight = $(".float_box").height() + 20;
	// set the shadow to the same height as the float_box
	$(".box_shadow").height(theBoxHeight);
	$(".box_shadow .mid").height(theBoxHeight-40);
	
	
	// menu show / hide
	$(".header .main_menu ul li").each(function (){
		// hide all menu at start
		$(this).find("ul").hide();
		
		// show menus when hovered over
		$(this).hover(
			function(){
				$(this).find("ul").show();
				// find sub menus
				$(this).find("ul li").each(function () {
					// hide all menu at start
					$(this).find("ul").hide();
					$(this).find("ul").parent().addClass("add_arrow");
					
					$(this).hover(
						function(){
							$(this).find("ul").show();
						},
						function(){
							$(this).find("ul").hide();
						}
					);
				});
				
			},
			function(){
				$(this).find("ul").hide();	
			}
		);
	});
	
	// color override
	$(".header .main_menu ul li ul li").each(function (){
		
		$(this).hover(function()
			{
				// new blue styles
				$(this).css({'background-color':'#0397d6'});
				$(this).find('a').css({'color':'#fff'});
				$(this).find('ul li').each(function(){
					$(this).find('a').css({'color':'#0d6cb6'});
				});
			},function()
			{
				// new blue styles
				$(this).css({'background-color':'#fff'});
				$(this).find('a').css({'color':'#0d6cb6'});	
			}
		);
	});
	
	
	
	
	// chart
	$('#chart').fadeIn('slow');
	
	var max = 0;
	$('.chart_col').each(function() {
		temp_height = $(this).height() * 3;
		if(temp_height > max) { max = temp_height; }
	});
	$('.chart_col').each(function() {
		temp_height = $(this).height() * 3;
		if(temp_height > max) { max = temp_height; }
		$(this).height(temp_height);
		$(this).css({'position': 'relative', 'top': max - temp_height});
	});

});

function set_session()
{
	$.post('/includes/close_dropdown/');
}
