$(document).ready(function(){
	createSlideShow();
	setInterval(animate,5000);
});

/**
 * animations
 */ 
function animate(){
	autoSlide();
}

/**
 Slide show
 */
var slideCount = 0;
var slideLength = 4;
var slideElens = {};
function createSlideShow(){
	$(".short_image").each(function(){
		slideElens[slideCount] = $(this);
		slideIncrement();
	});
	$(".short_image").hover(function(){
		$(this).children(".h2").addClass("h2Hover");
		},function(){
			$(this).children(".h2").removeClass("h2Hover");
		}
	);
	$(".short_image").click(function(){
		var short = $(this);
		var url = short.children(".imgp").children().attr("src");
		var child =  short.children(".h2").children(".hidden");
		var h1 =child.children("h1").text();
		var h2 =child.children("h2").html();
		$(".big_image img").attr("src",url);
		$(".big_image h1").text(h1);
		$(".big_image h2").html(h2);
	});
}

function autoSlide(){
	for(var x=0; x<slideLength; x++){
		slideElens[x].children(".h2").removeClass("h2Hover");
	}
	slideElens[slideCount].trigger("click");
	slideElens[slideCount].children(".h2").addClass("h2Hover");
	slideIncrement();
}

function slideIncrement(){
	slideCount = slideCount+1;
	if(slideCount == slideLength){
		slideCount = 0;
	}
}


