var video = {
	slideshow : function() {
		$('.fade_cycle').cycle();
	},
	
	initPopup : function () {
		$('li.video_link a').colorbox({
			width:'890',  //jens: Changed dimensions to fit new video
			height:"615", //jens: Changed dimensions to fit new video
			iframe:true, 
			opacity: 0.5,
			onOpen:function() {
				$('html').css('overflow', 'hidden');
				$('body').css('overflow', 'hidden');
				//$('#colorbox').css({position: 'fixed',left: '0', top: '0'})
				$('#cboxOverlay').attr('title', 'Click to close the video player');
				$('#cboxClose').attr('title', 'Click to close the video player');
				$('#cboxWrapper').addClass('video_wrapper');
			},
			onCleanup:function() {
				$('html').css('overflow', 'auto');
				$('body').css('overflow', 'auto');
				$('#cboxOverlay').attr('title', '');
				$('#cboxClose').attr('title', '');
				$('#cboxWrapper').removeClass('video_wrapper');
			}
		});
		
		
	}
}

var roicalculator = {
	init : function() {
		jQuery(document).ready(function() {
			$('.size a').click(function(e){
				e.preventDefault();
				var $thisLink  = $(this);
				
				//Remove default class and all other active classes from roiCalculator
				$('#roiCalculator').removeClass('roi_default_active');
				$('#roiCalculator').removeClass('roi_small_active');
				$('#roiCalculator').removeClass('roi_medium_active');
				$('#roiCalculator').removeClass('roi_large_active');
				
				//Determine class to apply to roiCalculator
				var newClass = $thisLink.attr('rel');
				
				//Apply class
				$('#roiCalculator').addClass(newClass);
			});
		});
	}
}



var partners = {
	init : function() {
		jQuery(document).ready(function() {
			$('.size a').click(function(e){
				e.preventDefault();
				var $thisLink  = $(this);
				
				//Remove default class and all other active classes from roiCalculator
				$('#partnersBox').removeClass('partners_agency_active');
				$('#partnersBox').removeClass('partners_client_active');
				$('#partnersBox').removeClass('partners_how_it_works_active');
				
				//Determine class to apply to roiCalculator
				var newClass = $thisLink.attr('rel');
				
				//Apply class
				$('#partnersBox').addClass(newClass);
			});
		});
	}
}



var content = {
	toggleContent : function() {
		jQuery(document).ready(function() {
			$('a.toggle_next').click(function(e){
				e.preventDefault();
				var $thisLink = $(this);
				var $nextElem = $thisLink.next();
				if($thisLink.hasClass('show')) {
					$nextElem.show();
					$thisLink.removeClass('show');
					$thisLink.html('Hide');
				} else {
					$nextElem.hide();
					$thisLink.addClass('show');
					$thisLink.html('Read more');
				}	
			});
		});	
	}
}


var casestudies = {
	init:function() {
		$(".case_studies li.thumb a").hover(function() {
			$("img",this).animate({top:-$(this).height()},{duration:200,queue:false});
		},function() {
			$("img",this).animate({top:0},{duration:200,queue:false});	
		});		
	}
};


jQuery(document).ready(function() {
	//video.slideshow();
	video.initPopup();
	//Init toggle function
	content.toggleContent();
	// case studies grid
	casestudies.init();
	// partners tabs
	partners.init();
});
		
