jQuery.fn.vertSlider = function(options) {

	//this allows the content to be seen with javascript turned off
	$('#main-container-background a[name]').removeAttr("name");
	//$('#main-container').css('overflow', 'hidden');
	$('#side-nav').css('visibility', 'visible');
	
	var count	=	options.title.length;
	//current tab
	var index	=	0;
	//rotator timer
	var time_slot	=	7;
	var timer=setTimeout(rotateSlide, time_slot*1000);
	
	function rotateSlide(){
		if(!$("div").is(':animated')){
			//set all to bottom
			$(".slide").css({"z-index": 1});
			//get current to back
			$(".slide:nth-child("+(index+1)+")").css({"z-index": 2});
			
			index++;
			if(index >count-1)
				index=0;
			$(".side-nav-item:nth-child("+(index+1)+")").removeClass('remove-bg');
			$(".side-nav-item:nth-child("+(index+1)+")").siblings().addClass('remove-bg');
			//set new to top
			$(".slide:nth-child("+(index+1)+")").css({"z-index": 3}).hide().fadeIn("slow");
			$(".overlay_bg").animate({opacity:.10}, 400);
			$(".overlay").animate({bottom: -65}, 500, function(){
						//$(".overlay").
						$(".overlay_content").html("<div><span>"+options.title[index]+" :</span>"+options.text[index]+"</div>");
						$(".overlay_bg").animate({opacity:.65}, 400);
						$(".overlay").delay(100).animate({bottom: 0}, 'slow');
																	});
		}
		timer=setTimeout(rotateSlide, time_slot*1000);
  	}
	
	//here we assign the click handler to each #side-nav a element to jump 
	//to a position in 	the #main-container-background
   // return this.each(function() {
	for(i=0; i<count; i++){						  
		$('.s'+(i+1)).html('<a href="' + options.link[i] + '" ><img src="' + options.path+options.image[i] + '" /></a>');
	}
	/**************************************************/
	$(".overlay_content").html("<div><span>"+options.title[0]+" :</span>"+options.text[0]+"</div>");
	$("#side-nav a").attr("href", "javascript://");
	$(".overlay_bg").fadeTo(0,0.65);
	/**************************************************/
	
		$(this).click(function() {
			//reset timer
			clearTimeout(timer);
			timer=setTimeout(rotateSlide, time_slot*1000);
			
			if(index != $('#side-nav a').index(this) && !$("div").is(':animated')){
			//set all to bottom
			$(".slide").css({"z-index": 1});
			//get current to back
			$(".slide:nth-child("+(index+1)+")").css({"z-index": 2});
			
			index = $('#side-nav a').index(this);
			
			$(".side-nav-item:nth-child("+(index+1)+")").removeClass('remove-bg');
			$(".side-nav-item:nth-child("+(index+1)+")").siblings().addClass('remove-bg');
			//set new to top
			$(".slide:nth-child("+(index+1)+")").css({"z-index": 3}).hide().fadeIn(1200);
			$(".overlay_bg").animate({opacity:.10}, 400);
			$(".overlay").animate({ bottom: -65}, 500, function(){
						//$(".overlay").
						$(".overlay_content").html("<div><span>"+options.title[index]+" :</span>"+options.text[index]+"</div>");
						$(".overlay_bg").animate({opacity:.65}, 400);
						$(".overlay").delay(100).animate({bottom: 0}, 'slow');
																	});
			
		   }
		});
	
	//});
};	
