var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;

theInterval = function(cur){
	clearInterval(theInt);
	
	if( typeof cur != 'undefined' )
		curclicked = cur;
	
	$crosslink.removeClass("active-thumb");
	$navthumb.eq(curclicked).parent().addClass("active-thumb");
		$(".stripNav ul li a").eq(curclicked).trigger('click');
	
	theInt = setInterval(function(){
		$crosslink.removeClass("active-thumb");
		$navthumb.eq(curclicked).parent().addClass("active-thumb");
		$(".stripNav ul li a").eq(curclicked).trigger('click');
		curclicked++;
		if( 6 == curclicked )
			curclicked = 0;
		
	}, 3000);
};

$(function(){
	
	$("#main-photo-slider").codaSlider();
	
	$navthumb = $(".nav-thumb");
	$crosslink = $(".cross-link");
	
	$navthumb
	.click(function() {
		var $this = $(this);
		theInterval($this.parent().attr('href').slice(1) - 1);
		return false;
	});
	
	theInterval();
});

// Hover fade rollover for images and video
$(document).ready(function(){
$(".portfolio-item a.hover-zoom-video, .hover-zoom, .hover-zoom-video-home, #video a.hover-zoom-video-single, .gallery1 a.hover-zoom-video").append("<span></span>"); 
    $(".portfolio-item a.hover-zoom-video, .hover-zoom, .hover-zoom-video-home, #video a.hover-zoom-video-single, .gallery1 a.hover-zoom-video").hover(function(){
	 $(this).children("span").hide();										   
        $(this).children("span").stop().fadeTo(800, 0.45);
    },function(){
        $(this).children("span").stop().fadeTo(400, 0);
    });
});