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;
		
	}, 4000);
};
$(document).ready(function(){
	// $("a[href^=http]").each(
	//    function(){
	// 	  if(this.href.indexOf(location.hostname) == -1) { 
	//       $(this).attr('target', '_blank');
	//     }
	// });
	
	$('#start_slider') 
	.before('<div id="slidernav">') 
	.cycle({ 
	    fx:     'fade', 
	    speed:  '1000', 
	    timeout: 10000, 
	    pager:  '#slidernav' 
	});
	
	$(".tv_thumb").hover(
		function () {
			$(this).addClass("over");
		}, 
		function () {
			$(this).removeClass("over");
		}
	 );
	
	$('#sr_prev').removeClass("h");
	$('#sr_next').removeClass("h");
	
	$('#showroom_slider') 
	.cycle({ 
	    fx:     'scrollHorz', 
	    speed:  '1000', 
	    timeout: 0,
	    prev:    '#sr_prev',
        next:    '#sr_next'
	});
	
	$(function() {
	    $(".mcarousel").jCarouselLite({
	        btnNext: ".next",
	        btnPrev: ".prev",
			visible: 5
	    });
	});
	

	
	$(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();
	});
	
});
