$(document).ready(function() {
	// $(".client a").hoverIntent(menuExpand, menuCollapse);
	// $(".client a").hoverIntent({
	// 	sensitivity: 3,
	// 	interval: 100,
	// 	over: menuExpand,
	// 	timeout: 500,
	// 	out: menuCollapse
	// });
	
	// function menuExpand() {
	// 	$(this).animate({height : "108px"}, "slow");
	// 	$(this).find("span").hide();
	// }
	// 
	// function menuCollapse() {
	// 	$(this).animate({height : "25px"}, "slow");
	// 	$(this).find("span").show();
	// }
	
	$(".colorbox").colorbox({
		opacity: .7
	});
	
	function toggle_slider(target) {
		
		var work_thumb = $(".work_thumb");
		var size_of_thumb = work_thumb.width();
		
		var slides_divs = target.find('.slides div.slide');
		var width = slides_divs.width();
		var num_of_slider_items = slides_divs.size();
	
		if(num_of_slider_items > 2) {
			$('#work_slider').loopedSlider({
				container: '.slide_container',
				containerClick: false
			});
		}
	
		if(num_of_slider_items < 2) {
			var second_slide = $(".slides").children(":eq(1)");
		
			work_thumb.removeAttr("style");
			second_slide.css({position : "absolute", left : size_of_thumb});
			$("a.previous").css({"display" : "none"});
			$("a.next").css({"display" : "none"});
		}
	
		if(num_of_slider_items == 2) {
			var first_slide = $(".slides").children(":eq(0)");
			var second_slide = $(".slides").children(":eq(1)");
			//var third_slide = $(".slides").children(":eq(2)");
			
			//first_slide.css({'margin-left' : '0'});
			second_slide.css({'position' : 'absolute', left : size_of_thumb});
			//third_slide.css({'position' : 'absolute', left : size_of_thumb*2});
			
			target.find('.slides').width((size_of_thumb+140)*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: "+="+size_of_thumb+"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') != -size_of_thumb+"px"){
					target.find('.slides').animate({left: "-="+size_of_thumb+"px"});
					target.find('.previous').removeAttr('style');
					$(this).css({'background-image' : 'none', 'cursor' : 'default'});
				}
				return false;
			});
		}
	}
	
	toggle_slider($('#work_slider'));
});