$(window).load(function() {
	
	var tallest = 0;
	var $equalHeights = $('.left-content, .main-content');
	
	$equalHeights.each(function(i){
		if (tallest < $(this).height()) { tallest = $(this).height(); }
	});
	
	$equalHeights.css('height', tallest);
	
	var $slideShow = $('.P4SlidesContainer');
	
	if($slideShow.length > 0) {
		
		var $contentColumns = $('.main-content-left, .main-content-right');
		var $mainContent = $('.main-content');
		
		$contentColumns.each(function() {
			$(this).css('height', ($mainContent.height()-$slideShow.height()));
		});
	}

	// Slideshow configuration
	var slideShow; 
	// Slideshow ID's
	var slides = [1,2,3,4,5,6,7];
	
	// Check if there's slideshow object
	for (var i = 0; i < slides.length; i++) {
		
		var slideName = 'P4Slides_' + slides[i];
		
		if (typeof window[slideName] != undefined && window[slideName] != undefined) {
			slideShow = window[slideName];
		}
	}
	
	if(slideShow != undefined) {
		
		var slideImages = slideShow.getImages().length;
	
		if(slideImages == 1) {
			slideShow.pause();
		}
		
		slideShow.bind('p4SlidesChange', function() {
			// Hide text area if empty
			$('.p4SlidesTextArea:empty').css('display', 'none');
			$('.p4SlidesTextArea a:empty').parent().css('display', 'none');			
		});
		
		slideShow.bind('p4SlidesTransitionStop', function() {
			
			var $active = $('.active.imageSwapImage');
			var link = $active.find('.p4SlidesTextArea a').attr('href');
			
			if (typeof link != undefined && link != undefined) {

				var target = $active.find('img');
			
				$(target).hover(
					function() {
						$(target).css('cursor', 'pointer');
					},
					function() {
						$(target).css('cursor', 'auto');
					}
				);
			
				$(target).click(function(){
					window.location = link;
				});
			}
		});
	
	}

});

$(window).ready(function() {
	
	// Input text hint
	var $text = $('.newsletter-input');
	var hintClass = 'input-hint';
	
	$text.val($text.attr('title')).toggleClass(hintClass);
	
	$text.focus(function() {
		if($(this).hasClass(hintClass)) {
			$(this).val('');
			$(this).toggleClass(hintClass);
		}
	});
		
	$text.focusout(function() {
		if($(this).val() == '') {
			$(this).val($(this).attr('title')).toggleClass(hintClass);
		}
	});
	
});
