
/*
function load_content(page_id) {
	
	if (isNaN(page_id)) {
		page = 'Sorry, can\'t load  content';
		$('#attorneys-content').html(page);
		return false;
	}
	
	$.get("/api/get_page/", { id: page_id }, function(data){
		var page_content = data['page']['content'];
		var page_title = data['page']['title_plain'];
		var email = 
		
		'<h1>'+page_title+email+
		'</h1>'+
		
		'<div class="attorney-picture">
			<?php the_post_thumbnail(\'attorney-headshot]\'); ?>
		</div>'+page_content;
		
		
		$('#attorneys-content').html(page);
	});
}
*/

function open_attorney(link) {
	
	
	//var page_id = link.parent().attr('class').replace('page_item page-item-','');
	
	
	if ($('#attorneys-list').find('li.current_page_item').eq(0).html() != null) {
		$('#attorneys-list').find('li.current_page_item').removeClass('current_page_item');
		link.parent().addClass('current_page_item');
	} else {
		link.parent().addClass('current_page_item');
		
		$('#attorneys-block').stop().animate({
			width: 940
		}, 600, function() {
			$('#attorneys-content').stop().fadeIn(100, function() {
				//load_content(page_id);
				$('#attorneys-content').html('<div class="ajax-loader"></div>');
				return false;
			});
		});
	}
	
}

function close_attorney() {
	$('#attorneys-list').find('li.current_page_item').removeClass('current_page_item');
	
	$('#attorneys-content').stop().fadeOut('fast', function() {
		$('#attorneys-block').stop().animate({
			width: 325
		}, 'slow');
	});
}

$(function() {
	
	//placeholder for all browsers
	$("[placeholder]").textPlaceholder();
	
	if (typeof attorney_page != 'undefined') {
	
		$('#attorneys-list a').click(function(e) {
			var active_status = $(this).parent().hasClass('current_page_item');
		
			var anchor = $(this), h;
			h = anchor.attr('href');
			e.preventDefault();
		
			if (active_status) {
				close_attorney();
			} else {	
				open_attorney($(this));
			}
		
			setTimeout(function() {
				window.location = h;
			}, 550);
		
		})
	}
});

$(window).load(function() {
	$('#attorneys-content').height($('#attorneys-block').height());
	$('#attorneys-content').scrollbarPaper();
})

