jQuery(document).ready(function(){

	// handle rollover states for form buttons
	var btn_images = new Object;
	jQuery('input.btn_rollover').hover(
		function(){
			var this_id = jQuery(this).attr('id');
			btn_images[ this_id ] = jQuery(this).attr('src');
			jQuery(this).attr('src', jQuery('#'+this_id+'_over').attr('src'));
		},
		function(){
			var this_id = jQuery(this).attr('id');
			jQuery(this).attr('src', btn_images[ this_id ]);
		}
	);
	
	jQuery('#outbound_details_link').click(function(){
			jQuery('#outbound_stops').toggle();	
			return false;	
	});
	
	jQuery('#inbound_details_link').click(function(){
			jQuery('#inbound_stops').toggle();
			return false;		
	});
	
	
	// Disabled for JTA request for now. There is also display: none !important; for span.before_markup
	/*
	jQuery('.results_accomm_rooms_price_pp, .results_accomm_rooms_price_total, .results_accomm_rooms_price_dp_pp, .results_accomm_rooms_price_dp_total,.results_accomm_rooms_price_dp_total, .price_breakdown_price'
			).live('click', function(){
			jQuery('.before_markup').toggle();	
			return false;		
	});*/
	jQuery('#agent_price_toggle').live('click', function(){
		jQuery('.before_markup').toggle();	
		return false;		
	});
	
	jQuery('.agent_click').bind(
		'click',
		function() { 
			jQuery(this).closest('tr').find('.results_full_price_breakdown').toggle();
		}
	);
	
	jQuery('.results_flights_price').bind(
		'mouseleave',
		function() { jQuery(this).closest('tr').find('.results_full_price_breakdown').hide()	}
	);
	
	jQuery('.results_accomm_heading').bind(
		'mouseleave',
		function() { jQuery(this).closest('tr').find('.results_full_price_breakdown').hide()	}
	);
	
	jQuery('.agent_click').bind(
		'mouseenter',
		function() { 
			jQuery(this).closest('tr').find('.agent_click_box').show();
			// I had to add display:inline as block attr for this element will break the layout
			jQuery(this).closest('tr').find('.agent_click_box').css("display","inline");
		}
	);
	jQuery('.agent_click').bind(
		'mouseleave',
		function() { jQuery(this).closest('tr').find('.agent_click_box').hide() }
	);
	
	// Agent Info box
	jQuery('.agent_info').click(function(){
		var link_handler = jQuery(this);
		jQuery('#agent_info_wrapper').slideToggle('slow', function(){
			if(jQuery('#agent_info_wrapper').css('display') == 'none')
			{
				jQuery(link_handler).removeClass('agent_info_expanded');
				jQuery(link_handler).addClass('agent_info');
			}
			else
			{
				jQuery(link_handler).removeClass('agent_info');
				jQuery(link_handler).addClass('agent_info_expanded');
			}
		});
		
		return false;
	});
	
	// Generic helpful hints (see e.g. IT Fares message on flight results)
	jQuery('.help_hint_trigger').bind('click', function()
	{
		jQuery(this).parent().find('.help_hint_content').toggle();
	}
	);
	
});
