function findMaxValue(element){
	var maxValue = undefined;
	$(element).each(function(){
		var val = parseInt($(this).height());
		if (maxValue === undefined || maxValue < val) {
			maxValue = val;
		}
	});
	return maxValue;
}

$(document).ready(function() {
	//populate slides
	var source = $("#slide-template").html();
	var template = Handlebars.compile(source);
	$(".slides_container").html(template(dataList));

	//populate video thumbnails
	var source = $("#thumbnail-template").html();
	var template = Handlebars.compile(source);
	$("#videos_container").html(template(dataList));
	
	//init slideshow
    $('#slides').slides({
        preload: true,
        preloadImage: 'http://sses.s3.amazonaws.com/events/img/loading.gif',
        play: 5000,
        pause: 5000,
		crossfade: true,
		effect: 'fade',
        pagination: false,
        generatePagination: false,
        hoverPause: false,
    });

    $('.hover-div').hover(
      function () {
        $('.play', this).addClass("hover");
	  },
	  function () {
        $('.play', this).removeClass("hover");
	  }
	);
	
	listItems = $('#videos_container li');
	var rows = Math.ceil(listItems.length / 3);

	for (var i = 1; i <= rows; i++) {
		aRow = listItems.splice(0,3);
		maxValue = findMaxValue(aRow);
		$(aRow).css("height",maxValue);
	}

});
