$(document).ready(function() {

	function toggle_slider(target) {
		slides_divs = target.find('.slides div.slide');
		width = slides_divs.width();

		if(slides_divs.size() > 4){
			target.loopedSlider({
				container: '.slide_container',
				containerClick: false
			});
		}
		if(slides_divs.size()<4){
			slides_divs.css({'float' : 'left', 'position' : 'relative'});
			target.find('.previous').css({'background-image' : 'none', 'cursor' : 'default'}).click(function() {return false});
			target.find('.next').css({'background-image' : 'none', 'cursor' : 'default'}).click(function() {return false});
		}
		if(slides_divs.size() == 4) {
			slides_divs.css({'float' : 'left', 'position' : 'relative'});
			target.find('.slides').width((width+10)*4);
			target.find('.previous').css({'background-image' : 'none', 'cursor' : 'default'}).click(function() {
				
				if(parseInt(target.find('.slides').css('left')) != 0){
					target.find('.slides').animate({left: "+="+width+"px"});
					target.find('.next').removeAttr('style');
					$(this).css({'background-image' : 'none', 'cursor' : 'default'});
				}
				return false;
			});
			target.find('.next').click(function () {
				if(target.find('.slides').css('left') != -width+"px"){
					target.find('.slides').animate({left: "-="+width+"px"});
					target.find('.previous').removeAttr('style');
					$(this).css({'background-image' : 'none', 'cursor' : 'default'});
				}
				return false;
			});
		}
	}
	
	toggle_slider($('#gallery_slider'));
	toggle_slider($('#events_slider'));
	toggle_slider($('#website_slider'));
	toggle_slider($('#videos_slider'));
	toggle_slider($('#others_slider'));
	
	
	$(".colorbox").colorbox({
		opacity: .7
	});
	
	$(".colorboxTxt").colorbox({
		maxwidth: 500,
		maxheight: 500,
		opacity: .7
	})
	
	function showdescription () {
		var id = $(this).find('a.describe').attr('rel');
		id = '#'+id;
		$(id).fadeIn('slow');
		$(id).css({"padding-top" : "7px"});
	}
	
	function hidedescription () {	
		var id = $(this).find('a.describe').attr('rel');
		id = '#'+id;
		$(id).fadeOut('slow');
	}
	
	$(".slide").hoverIntent(showdescription, hidedescription);
});