$(document).ready(function(){
	
	setup();
	
});
var campaignTeaserExpanded = false;

function setup(){
	$('#campaign-teaser').click(function(){

		if ($(this).hasClass('hidden') == false){

		var targetHeight = 650;
		if( campaignTeaserExpanded){
			targetHeight = 37;
			campaignTeaserExpanded = false;
		}else{
			campaignTeaserExpanded = true;
		}
		$('#campaign-teaser').animate({height: targetHeight})
		
		}
	});
	// Expand teaser by default
	$('#campaign-teaser').trigger('click');
	
	
	$('.ce_gallery td a').fancybox();
	setupHideableBlocks();
	
	// Add hover class to td for older browsers
	$('td').mouseover(function(){$(this).addClass('hover')})
	//$('td').mouseout(function(){$(this).removeClass('hover')})

	$("td.hover div.cell-data").mouseover(function () {
    	$(this).addClass('hover');
  	});
	$("td.hover div.cell-data").mouseout(function () {
    $(this).removeClass('hover');
  });
  
  
	
}


function setupHideableBlocks(){
	
	$('.hideable h2').addClass('closed').next().hide();
	
	
	$('.hideable.closed h2').next().hide();
	$('.hideable.open h2').next().show();
	
	$('.hideable h2').click(function(){
		var $this = $(this);
		
		if( $this.hasClass('closed') ){
			$this.next().show();
			$this.addClass('open').removeClass('closed'); 	
		}else{
			$this.next().hide();
			$this.addClass('closed').removeClass('open'); 
		}
		
		
	});
}

