$().ready(function() {	

	$("body").removeClass("noJquery");
	
	$("#about #skills .bar div").each(function(i) {
		$(this).css({'width':'0%'});
		$(this).animate({'width':$(this).html()}, 1200,'easeOutBounce');
		$(this).text("");
	});
	
	$('#footer .list li a').hover(function() {
		$(this).stop(true,false).animate({paddingLeft: '15px', width: '205px'}, 300,'easeOutQuart');
	}, function() {
		$(this).stop(true,false).animate({paddingLeft: '5px', width: '215px' }, 300,'easeOutQuart');
	}); 	
	
	$('#sidebar .list a').hover(function() {
		$(this).stop(true,false).animate({paddingLeft: '15px'}, 300,'easeOutQuart');
		return false;
	}, function() {
		$(this).stop(true,false).animate({paddingLeft: '5px'}, 300,'easeOutQuart');
	}); 
	
	$('#portfolioItems .image img').hover(function() {
		$(this).stop(true,false).animate({opacity: 0.5}, 0);
	}, function() {
		$(this).stop(true,false).animate({opacity: 1}, 500);
	}); 
	
	$('#recent-work .image img').hover(function() {
		$(this).stop(true,false).animate({opacity: 0.5}, 0);
	}, function() {
		$(this).stop(true,false).animate({opacity: 1}, 500);
	}); 
			
						
	var autoSlide = true;
	var curSlide = 1;
	var numSlides = $('#slides li.slide').size(); ;
	
	function slide(var1,var2){
	
		if(var1 == false){
			if(var2 == 1){
				if(curSlide == 1){
					nextSlide = numSlides;
				} else {
					nextSlide = curSlide-1;
				}
			} else {
				if(curSlide == numSlides){
					nextSlide = 1;
				} else {
					nextSlide = curSlide;
					nextSlide++;
				}
			}			
		} else {
			if(var1 <= numSlides || var1 >= 1){
				nextSlide = var1;
			} 
			
		}
		curSlide = nextSlide;
		
		$("#indicators a").each(function(i) {
			if((nextSlide-1) == i){
				$("#indicators a").removeClass("active");
				$(this).addClass("active");
			}
		});
		
		$("#slides").stop(true,false).animate({'left':''+(nextSlide-1)*1020+'px'}, 1000, 'easeOutQuart');
	
	}
		
	var timer = setInterval(slide, 5000, false, 2);
	
	$("#home #slider .leftButton").click(function(){
		clearInterval(timer);
		autoSlide = false;
		slide(false,1);
		return false;
	});

	$("#home #slider .rightButton").click(function(){	
		clearInterval(timer);
		autoSlide = false;
		slide(false,0);
		return false;
	});
	
	$("#home #indicators li a").click(function(){	
		clearInterval(timer);	
		autoSlide = false;
		href = $(this).attr("href");
		id = href.replace(/#slide/, '');
		slide(id,false);
		return false;
	});
	
});
