var photos = Array();
var delay = 4000;
var imageFade = 600;
var counter = 2; // we are hard coding first image on the page
var currentImage = 1; //we are hard coding first image on the page
var timer;
var loading = true;
var curLink = 1;
var firstImage = true;
var imgSrcb =0;


function getSlide(imageID){
	if(!loading){
		clearTimeout(timer);
		currentImage = (imageID-1);
		showImage();
	};
};

function nextPhoto(){
	if(!loading){
		clearTimeout(timer);
		currentImage++;
		currentImage = currentImage >= photos.length ? 0 : currentImage;
		
		showImage();
	};
};

function prevPhoto(){
	if(!loading){
		clearTimeout(timer);
		currentImage--;
		currentImage = currentImage < 0 ? photos.length-1 : currentImage;
		showImage();
	}
};

function showImage(){
	loading = true;
	var imgSrc = photos[currentImage];
	
	
	if(counter > 3){
		counter = 2; $('#jsSlideShow img:first-child').css('z-index','1');  
	};
	
	
	var imgStyle = 'z-index:'+ counter +'; display:none; cursor:pointer';
	
	
	
	/*modify by neto*/
	$('<img />').attr('src', imgSrc).attr('style', imgStyle).load(function(){
		$('#homeLink_'+curLink).removeClass('slideNav_selected');
		$('#homeLink_'+(currentImage+1)).addClass('slideNav_selected');
		curLink = currentImage+1;
		
		$('#jsSlideShow').prepend($(this));
		
		
		$(this).click(function(){ window.location.href = imgLinks[currentImage]; });
		$('#jsSlideShow img:first').fadeIn(imageFade,function(){
			
			$('#jsSlideShow img:not(:first-child)').remove();
			counter++;
			loading = false;
			timer = setTimeout(nextPhoto, delay);
		});
	});	/**/
	
		/*$('<img />').attr('src', imgSrc).attr('style', imgStyle).load(function(){
		$('#homeLink_'+curLink).removeClass('slideNav_selected');
		$('#homeLink_'+(currentImage+1)).addClass('slideNav_selected');
		curLink = currentImage+1;
		
		$('#jsSlideShow').prepend($(this));
		
		
		$(this).click(function(){ window.location.href = imgLinks[currentImage]; });
		$('#jsSlideShow img:first').fadeIn(imageFade,function(){
			
			$('#jsSlideShow img:not(:first-child)').remove();
			counter++;
			loading = false;
			timer = setTimeout(nextPhoto, delay);
		});
	})*/
	
	
}
