	var CP = {
		elems		:0,
		width		:0,
		left 		:0,
		fullWidth	:0,
		interval	:5000,
		pause		:15000,
		id			:0,
		timeOutID	:0,
		
		init		:function() {
			CP.elems = $("#main-panels > div ").length;
			CP.width = $("#main-panels > :last-child").width();
			CP.fullWidth = CP.elems*CP.width;
			$("#main-panels").width(CP.fullWidth);
			$(".blogpost > ul > li > img ").each(function(i) {
				$(this).click(function() {
					clearInterval(CP.id);
					CP.moveSlide(i*CP.width);
					CP.resetTimer();
					return false;
				})
				.mouseover(function() {
					$(this).addClass("active");
				})
				.mouseout(function() {
					$(this).removeClass("active");
				})
			});
			CP.startTimer();
		},

		next		:function() {
			CP.left += CP.width;
			CP.moveSlide(CP.left);
  		},
  		
		prev		:function() {
			CP.left -= CP.width;
			CP.moveSlide(CP.left);
		},
		
		moveSlide	:function(left) {
			CP.removeActive();
			if(left>(CP.fullWidth-CP.width)) left -=CP.fullWidth;
			if(left<=-CP.width) left +=CP.fullWidth;
			$("#main-panels").animate({opacity:0},650,'easeboth').animate({left:"-"+left+"px"},10,"easeboth").animate({opacity:1},650,'easeboth');
			CP.left = left;
			CP.setActive();
			return false;
		},
		
		removeActive:function() {
			$(".blogpost > ul > li > img").each(function() {$(this).removeClass("activeone")});
		},
		
		setActive	:function() {
			i = Math.ceil(CP.left/CP.width);
			$($(".blogpost > ul > li > img")[i]).addClass("activeone");
		},
		
		startTimer	:function() {
			CP.id = setInterval(CP.next, CP.interval);
		},
		
		resetTimer	:function() {
			clearInterval(CP.id);
			clearTimeout(CP.timeOutID);
			CP.timeOutID = setTimeout(CP.startTimer,CP.pause);
		}
	};
	
	$(document).ready(function() {
		CP.init();
	});
