/* JavaScript File Area Digital CMS	(Area Digital 4.2)				*/
/* functions.js 													*/
/* Modified january 05th 2010								 		*/
/* http://www.areadigital.org/ 									    */

$(document).ready(function() { 

// ---------------------------------- target blank - checks for anchor tags that should be open in new window -------------------------------------------------

	$('a[rel=external]').attr({'target': '_blank'});
	$('a[rel=nofollow external]').attr({'target': '_blank'});


// ------------------------------------------ css - adds the even and odd classes to all tables  -------------------------------------------------------

	$('table tr:nth-child(even)').addClass('even');
	$('table tr:nth-child(odd)').addClass('odd');
	
// ---------------------------------------- teaser slider - slides the text panel element up and down ---------------------------------------------------------
	
	$('.teaser.slider:visible').each(function (i) {
		
		var startSize =  $('.caption', this).css('height');
		startSize = parseInt(new String(startSize).replace('px', ''));
		
		var height =  $('.teaser.slider img').height();
		$('.teaser.slider').css({'height' : height});
			
		$('.teaser.slider').hover(function () {
			
			var endSize = ($('.caption > p', this).height() + startSize + 12);
			
			if ($('.caption > p', this).height() != null)
				$('.caption', this).stop().animate({bottom: '0px', height: endSize + 'px'},{queue:false, duration:160});
		}, function () {
			if ($('.caption > p', this).height() != null)
				$('.caption', this).stop().animate({bottom: '0px', height: startSize + 'px'},{queue:false, duration:160});
		});
	});

// ------------------------------------- clean up margin - grabs the last element and add margin zero ---------------------------------------------------------

	//$('.widget .data *:last-child').css({'margin-bottom': '0px'});
	//$('.widget .data p:last-child').css({'margin-bottom': '0'});

// ------------------------------------------------------------------------------------------------------------------------------------------------------------

});

