$(function() {

$('#content,#main-navigation,#phone-numbers').hide().fadeIn(300);

Cufon.replace('h1,.seriaSmallCaps', { fontFamily: 'Seria-RegularCaps' , hover: true });
Cufon.replace('h3,h6,.seriaItalic', { fontFamily: 'Seria-Italic' , hover: true });
Cufon.replace('h1.news-title,.seriaSans', { fontFamily: 'SeriaSansLf-Regular' , hover: true });
	
$('a.area').click(function(){
	
	$('div#grid-navigation').hide();
	
	var thisRel = $(this).attr('rel');
	var thisHref = $(this).attr('href');
	
	$('div.practice-area').attr('id',thisRel + '-grid').show(0,function(){
		
		$('div.grid-list ul li').show();
		$('div.grid-list ul li#' + thisRel + '-bullet').hide();
		
		$('div.grid-text span').hide();
		$('div.grid-text span#' + thisRel + '-text').show();
	
	});
	
	$('div.practice-area div.learn-more a').attr('href',thisHref);
	
	var v = $('div.practice-area > div').css('visibility', 'hidden'), cur = 0;
	for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
	function fadeInNextItem() {
  		v.eq(cur++).css('visibility','visible').hide().fadeIn();
  		if(cur != v.length) setTimeout(fadeInNextItem, 60);
	};
	fadeInNextItem();
	
	return false;
	
});

$('a.area').hover(
	function () {
		$(this).prev('div.description').show();
	}, 
	function () {
		$(this).prev('div.description').hide();
	}
);


$('li.menu').hover(
	function () {
		$(this).addClass('active').children('ul:eq(0)').show();
		$(this).css('position','relative');
	}, 
	function () {
		$(this).removeClass('active').children('ul:eq(0)').hide();
		//unfortunately we have to update cufon on menu mouseout
		Cufon.replace('div#main-navigation ul li.menu a.seriaSans', { fontFamily: 'SeriaSansLf-Regular' , hover: true });
		$(this).css('position','');
	}
);

$('a.noLink').click(function(){ return false; });


// attorneys filter
$('div#attorneys-filter').fadeIn();

$('ul#attorneys-photo-list').css('height',$('ul#attorneys-photo-list').outerHeight());

$('div#attorneys-filter select').change(function(){
	
	var thisVal = $(this).val();
	
	$('ul#attorneys-photo-list li').hide();
	
	//might need to change this to a function so I can test for it on refresh. is it worth it?
	$('ul#attorneys-photo-list li').each(function(){
		
		if ($(this).hasClass(thisVal)) {
			$(this).fadeIn();
		} else if (thisVal == 'all') {
			$('ul#attorneys-photo-list li').fadeIn();
		} else {
			$(this).hide();
		};
	
	});
	
	return false;

});

});
