$(document).ready(function(){ 
var speed = 6000;
var sc_control = setInterval('pic_scrolls(0)', speed);	
$('#info li').css('height','auto');
$('#video_slide li:first, #info li:first').addClass('scroll_active');



	$('#cols').hover(
	function() {
			clearInterval(sc_control); // pause
			// show buttons
			$('#control_hold').removeClass('hide');
		}, 
		function() {
			sc_control = setInterval('pic_scrolls(0)', speed);	
			//hide buttons
			$('#control_hold').addClass('hide');
		}
	); 	

	$('#next').click(function () {
		pic_scrolls(0);	
		return false;
	});	

	
	$('#prev').click(function () {
		pic_scrolls(1);	
		return false;
	});	
		
});


function pic_scrolls(x) {
	var big_height = 369;
	var current_image = $('#video_slide li.scroll_active').length ? $('#video_slide li.scroll_active') : $('#video_slide li:first');
	var current_excerpt = $('#info li.scroll_active').length ? $('#info li.scroll_active') : $('#info li:first');
	if (x) {
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#video_slide li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#info li:last');
	} else {
		
		var next_image = (current_image.next().length) ? current_image.next() : $('#video_slide li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#info li:first');
	}
	$('#info li, #video_slide li').removeClass('scroll_active');
	next_image.addClass('scroll_active');
	next_excerpt.addClass('scroll_active');
	// ugly hack to fix margin on next/prev image caption
	var t_height = next_excerpt.height();
	var x =  ((big_height / t_height) * 100) - 100;
	next_excerpt.css('margin-top',x+'%');
	$('.pict_slide').scrollTo(next_image, 900);		
	$('.slide_info').scrollTo(next_excerpt, 900,{margin:true}); // height of DIV = 340; 
	
}
