var myCounter		= 1;
var totalSlides		= new Array();
var setWidth		= 691; //668; //671
if(typeof jQuery != 'undefined') {
	jQuery(document).ready(function() {
		for(var i=1; i < myCounter; i++)
		{
			if(totalSlides[i] == "undefined") totalSlides[i] = 1;
			
			jQuery("#slideshow-holder-" + i).width( ((totalSlides[i] * setWidth ) + (totalSlides[i] - 1)));
		}
	});
}

function showMoreInsightsSlider(counter)
{
	var contentSlides = "";
	var scrollAmount = 0;
	contentSlides = jQuery("#slideshow-content-" + counter + " .slideshow-content-box");

	var currentSlideObj = $('#current-slider-' + counter);
	currentSlide = currentSlideObj.val();
	
	if(totalSlides[counter] == currentSlide) { 
		// reset the current slide value
		currentSlide = 1;
	} else {
		contentSlides.each(function(i){
			if( i % 3 == 0) {
				if(currentSlide > parseInt(i/3))
					scrollAmount += setWidth;
			}
		});
		currentSlide++;
	}
	currentSlideObj.val(currentSlide);
	
	jQuery("#slideshow-scroller-" + counter).animate({scrollLeft: scrollAmount}, 1000);
}

function loadInsightsWidget(id, ins_type)
{
	for(var i=1; i < totalSlides.length; i++ ) 
	{
		if(totalSlides[i] != 'undefined' && totalSlides[i] > 1)
			loadInsightsPerHolder(i, id, ins_type);
	}
}

function loadInsightsPerHolder(i, id, ins_type)
{
	$.ajax({
		url: '/cms/features/insights/load-insights-per-holder',
		data: {i:i, id:id, type:ins_type},
		dataType:'HTML',
		type:'POST',
		success: function(response)
		{
			$('#slideshow-content-' + i).append(response);
		}
	});
}
