var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;
var panes = 5;

jQuery(document).ready(function() {
	/* let's hide what we don't need and reveal later in our load fn below */
	jQuery(".yslider-panelwrapper").hide();
	
	/* for clean loading this is pre-hidden, let's expose */
	jQuery("#featured_media .content .tab-box ").fadeIn('slow');
});

// for hp slider
if (typeof adj_panes != "undefined"){
	panes = adj_panes;
}

theInterval = function(cur){
	
	clearInterval(theInt);

	if( typeof cur != 'undefined' )
		curclicked = cur;
	
	if (curclicked > panes-1){
		curclicked = panes-1;}
	else if (curclicked < 0){
		curclicked = 0;}

	jQuery("#yslider").ycodaslider("go", curclicked);

	theInt = setInterval(function(){

		jQuery("#yslider").ycodaslider("go", curclicked);

		curclicked++;
		if( panes == curclicked )
			curclicked = 0;

	}, 8000);
};


(function($){
	jQuery(window).bind("load", function() {	
		// setup our slider							
		jQuery("div#yslider").ycodaslider({
			navigator: true,
			arrows: false,
			shortcut: false
		});
		// add custom arrows
		//jQuery(".nav_right").click(function() { theInterval(curclicked+1); return false; });
		//jQuery(".nav_left").click(function() { theInterval(curclicked-1); return false; });
		// reveal any hidden pre-loading
		jQuery(".yslider-panelwrapper").show();
		
		theInterval();
	});
})(jQuery);
