////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Peachtree Hills Place Javascript Functions
// This file includes a collection of functions for use on the Peachtree Hills Place site
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$(function()
{
	// member contacts widget
	if($('#member_contacts').length > 0) {
		$('#mc_thumbs .thumb').click(show_profile);
		$('#mc_profiles div .close').click(hide_profile);
	}

	// event slideshow
   if($('#event_slideshow').length > 0) {
      $('.thumbnail').click(switch_images);
   }

   if($('#yf_slideshow').length > 0) {
		setInterval('yf_slideshow()',5500);
	}

	if($('#continuum_collapser').length > 0) {
		$('#continuum_collapser strong').click(show_care);
		$('#continuum_collapser p span').click(hide_care);
	}

	if($('.healthcare_collapser').length > 0) {
		$('.healthcare_collapser strong').click(show_care);
		$('.healthcare_collapser span').click(hide_care);
	}

	if($('#services').length > 0) {
		$('#services li h3 span').click(show_service);
		$('#services li p span').click(hide_service);
	}

	// clear email updates input
	$('#email_updates input[name="email_update"]').click(clear_field);

});

function show_profile()
{
	var title = $(this).attr('title');

	$('#mc_profiles div').hide();
	$('#mc_profiles div[title="'+title+'"]').show();
}

function hide_profile()
{
	$(this).parent().hide();
}

function switch_images()
{
   $('.main_image').attr('src',$(this).attr('src'));
}

function yf_slideshow()
{
   var current_image = $('#yf_slideshow img:visible');
   var next_image = current_image.next().attr('tagName') != 'IMG' ? current_image.siblings('img:first') : current_image.next();

   current_image.fadeOut(3000);
   next_image.fadeIn(3000);
}

function show_care()
{
	$(this).siblings().slideDown();
}

function hide_care()
{
	$(this).siblings('p').slideUp();
	$(this).parent('p').slideUp();
	$(this).parent('p').siblings('ul').slideUp();
	$(this).parent('p').siblings('p').slideUp();
}

function show_service()
{
	$(this).parent().siblings('p').slideDown();
}

function hide_service()
{
	$(this).parent('p').slideUp();
}

function clear_field()
{
	$(this).attr('value','');
}