function expandableMenus()
{
	// for the main practice page
	if( $('body#services').length )
	{
		condLink = $('<a href="#condensed" class="inactive">Condensed Listing</a>')
		.click(function(){
			$('#expandLinks a').toggleClass('inactive');
			
			$(document.body).removeClass('js-expanded');
			
			$('#practiceList > li.expanded')
			.removeClass('expanded');
		});
		
		expLink = $('<a href="#expanded">Expanded Listing</a>')
		.click(function(){
			$(document.body).addClass('js-expanded');
			$('#expandLinks a').toggleClass('inactive');
			
			$('#practiceList > li')
			.addClass('expanded');
			
			$(document.body).removeClass('js-expanded');
		});
		
		$('<p id="expandLinks">View: </p>')
		.css('position','absolute')
		.append(condLink)
		.append(' | ')
		.append(expLink)
		.insertBefore('#practiceList');
		
		if( $(document.body).hasClass('js-expanded') )
			expLink.click();
	}
	
	// expandable side menus on various pages

	$('#practiceList li:has(ul), #childrenList li.withChildren')
		.each(function(){
		thisItem = $(this);
		
		thisItem.addClass('withChildren');
		
		thisItem.click(function(event){
			// make sure we clicked on this list item, and not a child of it
			if(this == event.target)
			{
				var item = $(this);
				
				subItems = item.find('li');
				
				if( item.hasClass('expanded') )
				{
					item.toggleClass('expanded');
				}
				else
				{
					subItems.hide();
					item.toggleClass('expanded');
					subItems.slideToggle();				
				}
			}
		});
	});
}

function faqList()
{
	faqs = $('#faqList dt a')

	if(faqs.length < 1)
		return;
		
	
	faqs.each(function(){
		
		faqItem = $(this);
		
		faqItem		
		// add the click functionality to each faq question
		.click(function(){
			$(this)
			.blur()
			.parent()
			.next('dd')
			.slideToggle('fast')
		})
		
		faqItem.parent()
		// store the original ID and remove it
		// so jump links won't jump around
		.data('id', faqItem.parent().attr('id'))
		.removeAttr('id');
		
		if( '#'+faqItem.parent().data('id') == document.location.hash)
		{
			faqItem.parent().next('dd').show();
		}
	});
}

function siteSearchLabel()
{
	$('#searchField')
	.attr('value', 'Search')
	.focus(function(){
		if(this.value == 'Search')
			this.value = '';	
	})
	.blur(function(){
		if($.trim(this.value) == '')
			this.value = 'Search'
	});
}

function fixSelects()
{
	if( !document.all )
		return;
	
	$('#subNav select').hover(function(){
		$(this).css({
			width: 'auto',
			position: 'absolute'
		})
		},
		function(){
			$(this).css({
				width: '165px',
				position: 'absolute'
			})
		});
}

jQuery(function(){
	expandableMenus();
	faqList();
	siteSearchLabel();
	//fixSelects();
});