(function(){
var scrollTest;
$(document).ready(function(){
	var slides = $(document).find('div.slide');//document.getElementsByClassName('slide');
	var sl = slides.length;
	
	function slideChange(x){
		$(slides[x]).addClass('none');
	}
	function removeNone(y){
		$(slides[y]).removeClass('none');
	}
	function change1(){
		slideChange(0);
		removeNone(1);
	}
	function change2(){
		slideChange(1);
		removeNone(2);
	}
	function change3(){
		slideChange(2);
		removeNone(0);
	}
	function rotaterHome(){
		setTimeout(change1,5000);
		setTimeout(change2,10000);
		setTimeout(change3,15000);
	}
	
	
	rotaterHome();
	setInterval( rotaterHome, 15000);

	
	
	//$('.ca-more[class="last"]').click(function() {
	/*	var thisMore = $(this).parents('.ca-item').find('.ca-content-wrapper');
		var thisLi = $(this).parents('li');
		thisLi.find('a.ca-more').css('display','none');
		thisLi.css({
			'width':'420px'
		});
		thisMore.css({
			'width': '210px',
			'display': 'block'
		});
		//console.log(thisMore);
		*/
//		alert('hi');
//		$('.jcarousel-next').click();
//		return false;
//	});
	/*$('.last ').click(function() {
		$('.jcarousel-next').click();
		var thisMore = $(this).parents('.ca-item').find('.ca-content-wrapper');
		var thisLi = $(this).parents('li');
		thisLi.find('a.ca-more').css('display','none');
		thisLi.css({
			'width':'420px'
		});
		thisMore.css({
			'width': '208px',
			'display': 'block'
		});
		return false;
	});*/
	$('.jcarousel-next').click(function(){
		$('.ca-close').click();
	})
	$('.jcarousel-prev').click(function(){
		$('.ca-close').click();
	})
	
	
	$('a.ca-more').click(function() {
		$(this).parents('ul').find('.ca-close').click();
		var isLast = this.name;
		
		if (isLast == 'last'){
			$('.jcarousel-next').click();
			this.name = '';
		}
		var thisMore = $(this).parents('.ca-item').find('.ca-content-wrapper');
		var thisLi = $(this).parents('li');
		thisLi.find('a.ca-more').css('display','none');
		thisLi.css({
			'width':'420px'
		});
		thisMore.css({
			'width': '208px',
			//'float': 'none',
			'display': 'block'
		});
		return false;
	});
	
	//function closeMoreSection () {
		$('.ca-close').click(function() {
		//$('a.ca-more').css('display','block');
		var closeLi = $(this).parents('li');
		var closeMore = $(this).parents('.ca-content-wrapper');
		closeLi.css({
			'width':'208px'
		});
		closeMore.css({
			'display': 'none'
		});
		closeLi.find('a.ca-more').css('display','block');
		return false;
	//}
	//closeMoreSection();
	});
	
	
	
	//$('.jcarousel-list li').css("display","none").css("display","block");
});

})();
		
