

$(document).ready(function(){

	
	$('#dynabanner').swap(5000, 1000);
	
	
	$('.closebox').closer();
	
	partners();
	
});


function partners() {
	if (location.href.search('partners')) {
		$('#right .feed .item .title a, #right .feed .item .image a').attr('target', '_blank');
		
	}
}

$.fn.swap = function(loopTime, fadeTime) {
	if ($('body#index').length == 0) {
		return false;
	}
	
	var box = this;
	var items = $('.item', box);

	var length = items.length;
	var current = 0; 
	
	function loop() {
		var next = current < length-1 ? next = current + 1 : 0;
		$(items[current]).fadeOut(fadeTime);
		$(items[next]).fadeIn(fadeTime);
		current = next
		setTimeout(loop, loopTime)
	}	
	
	setTimeout(loop, loopTime)
	
}


$.fn.closer = function() {
	//var box = this;
	var button = $('.btop .button', this);
	
	button.click(move);
	
	function move() {
		var box = $(this).closest('.block');
		box.toggleClass('isclosed');
	}
	
	
	
}