function show_add_neighborhood() {
	Element.hide('add_neighborhood_link');
	Element.hide('add_neighborhood_busy');
	Element.show('add_neighborhood_form');
} // end show_add_neighborhood()
function hide_add_neighborhood() {
	Element.hide('add_neighborhood_form');
	Element.hide('add_neighborhood_busy');
	Element.show('add_neighborhood_link');
} // end hide_add_neighborhood()
function busy_add_neighborhood() {
	Element.hide('add_neighborhood_form');
	Element.hide('add_neighborhood_link');
	Element.show('add_neighborhood_busy');
} // end busy_add_neighborhood()
function busy_edit_neighborhood() {
	Element.hide('edit_neighborhood');
	Element.show('edit_neighborhood_busy');
} // end busy_edit_neighborhood()
function hide_edit_neighborhood() {
	Element.hide('edit_neighborhood_busy');
	$('edit_neighborhood').innerHTML = '';
} // end hide_edit_neighborhood()

function show_mls_import_busy() {
	Element.hide('mls_import_form');
	Element.show('mls_import_busy');
} // end show_mls_import_busy()

function show_email_to_friend_form() {
	Element.hide('email_to_friend_link');
	Element.show('email_to_friend_form');
	Element.hide('email_to_friend_busy');
	Element.hide('email_to_friend_response');
} // end show_email_to_Friend_form()
function show_email_to_friend_busy() {
	Element.hide('email_to_friend_link');
	Element.hide('email_to_friend_form');
	Element.show('email_to_friend_busy');
	Element.hide('email_to_friend_response');
} // end show_email_to_friend_busy()
function hide_email_to_friend_form() {
	Element.show('email_to_friend_link');
	Element.hide('email_to_friend_form');
	Element.hide('email_to_friend_busy');
	Element.hide('email_to_friend_response');
} // end hide_email_to_friend_form() 

// neighborhood functions for the listings form in manage...
function show_add_neighborhood_form() {
	Element.show('neighborhood_select');
	Element.hide('neighborhood_add_link');
	Element.show('neighborhood_add_form');
	Element.hide('neighborhood_add_busy');
} // end show_add_neighborhood_form()
function hide_add_neighborhood_form() {
	Element.show('neighborhood_select');
	Element.show('neighborhood_add_link');
	Element.hide('neighborhood_add_form');
	Element.hide('neighborhood_add_busy');
	$('neighborhood_name').value = '';
} // end hide_add_neighborhood_form()
function show_add_neighborhood_busy() {
	Element.hide('neighborhood_select');
	Element.hide('neighborhood_add_link');
	Element.hide('neighborhood_add_form');
	Element.show('neighborhood_add_busy');
} // end show_add_neighborhood_busy()
function submit_add_neighborhood_form() {
	var n_name = $F('neighborhood_name');
	show_add_neighborhood_busy();
	new Ajax.Updater('neighborhood_select', 
									 '/manage/listings/add_neighborhood?name=' + n_name, 
									 {asynchronous:true, 
										evalScripts:true, 
										onComplete:function(request){hide_add_neighborhood_form()}
									 	}); 
	return false;
} // end submit_add_neighborhood_form()

// methods for adding attachments in the management section
function show_add_attachment_form() {
	Element.hide( 'add_attachment_link' );
	Element.show( 'add_attachment_form' );
	Element.hide( 'add_attachment_busy' );
} // end show_add_attachment_form()
function hide_add_attachment_form() {
	Element.show( 'add_attachment_link' );
	Element.hide( 'add_attachment_form' );
	Element.hide( 'add_attachment_busy' );
} // end hide_add_attachment_form()
function show_add_attachment_busy() {
	Element.hide( 'add_attachment_link' );
	Element.hide( 'add_attachment_form' );
	Element.show( 'add_attachment_busy' );
} // end show_add_attachment_busy()

function show_change_password_busy() {
	Element.hide('change_password_form');
	Element.show('change_password_busy');
} // end show_change_password_busy()

function swap_small_banner(banner,status) {
	// because IE can't handle PNGs...
	gif_path = '/images/banner_'+status+'.gif';
	if(/MSIE/.test(navigator.userAgent) && banner.src.indexOf('gif')==-1) {
		banner.src = gif_path;
	}
} // end swap_small_banner()
function swap_large_banner(banner,status) {
	// because IE can't handle PNGs...
	gif_path = '/images/banner_'+status+'_large.gif';
	if(/MSIE/.test(navigator.userAgent) && banner.src.indexOf('gif')==-1) {
		banner.src = gif_path;
	}
} // end swap_large_banner()

// -------------------------------------------------------
function show_redcloth_help(url) {
	var features = 'width=600,height=500,resizable=yes,scrollbars=yes';
	window.open(url,'redcloth',features);
}


// validation methods
function validate_date(element,which_date) {
	var date_str = $F(element);
	if(date_str.length==0) { return true; }
	var pieces = date_str.split('/');
	var mon = -1;
	var day = -1;
	var year = -1;
	if(pieces.length == 3) {
		mon = Number(pieces[0]);
		day = Number(pieces[1]);
		year = Number(pieces[2]);
	} else {
		pieces = date_str.split('-');
		if(pieces.length == 3) {
			if(pieces[0]>'1900') {
				mon = Number(pieces[1]);
				day = Number(pieces[2]);
				year = Number(pieces[0]);
			} else {
				mon = Number(pieces[0]);
				day = Number(pieces[1]);
				year = Number(pieces[2]);
			}
		}
	}
	if((mon>=1&&mon<=12)&&(day>=1&&day<=31)&&(year>=1900)) {
		return true;
	}
	alert(which_date+' is invalid. Please enter date in MM/DD/YYYY format.');
	return false;
}


function show_busy_div(name) {
	if($(name+'_form')) { Element.hide(name+'_form'); };
	if($(name+'_link')) { Element.hide(name+'_link'); };
	if($(name+'_busy')) { Element.show(name+'_busy'); };
}
function show_form_div(name) {
	if($(name+'_link')) { Element.hide(name+'_link'); };
	if($(name+'_busy')) { Element.hide(name+'_busy'); };
	if($(name+'_form')) { Element.show(name+'_form'); };
}
function show_link_div(name) {
	if($(name+'_busy')) { Element.hide(name+'_busy'); };
	if($(name+'_form')) { Element.hide(name+'_form'); };
	if($(name+'_link')) { Element.show(name+'_link'); };
}
function clear_form_div(name) {
	if($(name+'_form')) { $(name+'_form').innerHTML = ''; }
	if($(name+'_form')) { Element.hide(name+'_form'); };
	if($(name+'_busy')) { Element.hide(name+'_busy'); };
	if($(name+'_link')) { Element.show(name+'_link'); };
}
// methods to show/hide "AJAX" form spans in table rows.
function show_busy_row(name,id) {
	if($('tr_'+name+'_link_'+id)) { Element.hide('tr_'+name+'_link_'+id); };
	if($('tr_'+name+'_busy_'+id)) { Element.show('tr_'+name+'_busy_'+id); };
}
function show_link_row(name,id) {
	if($('tr_'+name+'_busy_'+id)) { Element.hide('tr_'+name+'_busy_'+id); };
	if($('tr_'+name+'_link_'+id)) { Element.show('tr_'+name+'_link_'+id); };
}
// methods to show/hide busy widgets
function show_busy_widget(name) {
	if($(name)) { Element.show(name); };
} 
function hide_busy_widget(name) {
	if($(name)) { Element.hide(name); };
}

