/*
	name : globalHeader
	file : jquery.globalheader.js
	author : Brandon Goode
	(c) Copyright 2009 AOL LLC
	///////////////////////////		
	dependencies : jQuery 1.3.2
	///////////////////////////
	description: 
	Attach functionality to expand/collapse contributor bio text.
*/

$(function(){

	$('#CE_writers').click(function(evt){

		if(evt.target.parentNode.className === 'CE_contrib_bio_more'){
			
			var $cBioNode=$(evt.target.parentNode.parentNode),
				$cBlurbNode=$cBioNode.parent(),
				$cRootNode=$cBioNode.parent().parent();

			if (!$cRootNode.data('defHeight')) {
				$cRootNode
					.data('defHeight',$cRootNode.height());
			}

			$cBioNode
				.find('em')
					.toggle()
					.end()
				.find('span')
					.toggle();

			if ($cRootNode.hasClass('is_exp')) {

				$(evt.target).text('More')
					.removeClass('CE_contrib_bio_close_A');

				var cssColHeight=$cRootNode.data('defHeight');
				$cBlurbNode
					.css('height',cssColHeight);
				$cRootNode
					.toggleClass('is_exp')
					.css('height',cssColHeight);
			} else {

				$(evt.target).text('Close')
					.addClass('CE_contrib_bio_close_A');

				var cssExpHeight=$cRootNode.height()+$cBioNode.find('span').height()-14;
				$cBlurbNode
					.css('height',cssExpHeight);
				$cRootNode
					.toggleClass('is_exp')
					.css('height',cssExpHeight);
			}

			evt.preventDefault();

		}

	});

});
