/* JavaScript File Area Digital CMS	(Base 4.2)						*/
/* functions.js 													*/
/* Modified january 05th 2010								 		*/
/* http://www.carboncreditedfarming.com/ 							*/

$(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 - controls the first child and last child for IE browsers ---------------------------------------------------

	$('.topmenu ul li:first-child').css({'background': 'none', 'padding-left': '0px'});
	$('.footmenu ul li:first-child').css({'background': 'none', 'padding-left': '0px'});
	$('.socialmenu ul li:first-child').css({'background': 'none', 'padding-left': '0px'});
	$('.pagemenu li').hover( function () { $(this).addClass('hover'); }, function () { $(this).removeClass('hover'); });
	$('.pagemenu li .dropdown li').hover( function () { $(this).css({'background-color': '#b7b7b7'}); }, function () { $(this).css({'background-color': '#ebeaf0'}); });

// ---------------------------------------- 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});
		});
	});

// -----------------------------------------------------------------------------------------------------------------------------------------------------------

});