function replace_all(_haystack,_needle,_replace){
	_haystack = (_haystack||'');
	while(_haystack.indexOf(_needle)>-1){
		_haystack = _haystack.replace(_needle,_replace);
	}
	return _haystack;
}

function rhp_clientlist_filter(industry){
    $('#rhp_client_list').hide();
    if(industry){
        // HIDE ALL
        $('#rhp_client_list span:not(.ind_'+industry+')').addClass('hidden');

        // SHOW SELECT CLIENTS
        $('#rhp_client_list span.ind_'+industry).removeClass('hidden');
    }else{
        // SHOW ALL
        $('#rhp_client_list span').removeClass('hidden');
    }
    $('#rhp_client_list').fadeIn();
}

$(document).ready(function(){

	// RHP CLIENT LIST
	var rhp_clientlist_dropdown = $('#rhp_clientlist_dropdown').eq(0);
	if(rhp_clientlist_dropdown) rhp_clientlist_filter(rhp_clientlist_dropdown.val());


	// SWAP-OUT WIDGETS
	$('.swap_out_widget').each(function(index,widget){
		if(!$(widget).attr('current_tab')) $(widget).attr('current_tab',$(widget).find('.swap_out:first').attr('tab'));
		$(widget).find('.swap_out:not(:first-child)').hide();
	});

	$('.swap_out_widget .swap_out_tabs a[tab]').mouseover(function(){
		var widget = $(this).closest('.swap_out_widget');
		var current_tab = widget.attr('current_tab');
		var tab = $(this).attr('tab');
		widget.attr('current_tab',tab);
		widget.find('.swap_out[tab="'+current_tab+'"]').eq(0).hide().siblings('.swap_out[tab="'+tab+'"]').eq(0).fadeIn();
		widget.find('.swap_out_tabs a.selected').removeClass('selected');
		widget.find('.swap_out_tabs a[tab="'+tab+'"]').addClass('selected');
	});
	// END SWAP-OUT WIDGETS

});