//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================


$(document).ready(function() {
	$('.cta-toggle').click( function(e)
	{
		e.preventDefault();

		var display = $(this).siblings('.cta-form').css('display');

		if (display == 'none') {
			$(this).siblings('.cta-form').slideDown();
		}
		else
		{
			$(this).siblings('.cta-form').slideUp();
		}
	});
	
	$('.close').click( function(e)
	{
		e.preventDefault();

		$(this).parents('.cta-form').slideUp();
	});

	//---------------------------------------------------------------------------------------------------------
	//		make sure mega dropdown menus are the same height 
	//---------------------------------------------------------------------------------------------------------
	$('ul.mega_dropdown').each(function(){
		currentTallest = 0;
		$(this).css({'display':'block','z-index':'-3'});
		$(this).find('li.i1').each(function(){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
			//alert($(this).height());
		});
		currentTallest = (currentTallest*1) + 6;

		//$(this).css({"height":currentTallest +'px !important;'});
		
		$(this).find('li.i1').each(function(){
		
				$(this).height(currentTallest);
		});

		$(this).css({'display':'none','z-index':''});
		
	});

	//---------------------------------------------------------------------------------------------------------
	//		remove text from the textboxes when one focuses on the textbox
	//---------------------------------------------------------------------------------------------------------
    $('.label_in_textbox').each(function(){
		$(this).attr('label',$(this).val());

		$(this).focus(function(){
			var label = $(this).attr('label');
			var value = $(this).val();
			
			//alert('l='+label +' v='+value);
			if( label == value )
			{
				$(this).val('');
			}
			
		});

		$(this).blur(function(){
			var label = $(this).attr('label');
			var value = $(this).val();

			if( !value )
			{
				$(this).val(label);
			}
			
		});

    });

	// remove search if someone clicks submit
	$('#global_area form').submit(function(){
		if( $('.label_in_textbox').val() == $('.label_in_textbox').attr('label')){
			$('.label_in_textbox').val('');
		}
	});


});
