jQuery(function(){
   jQuery("div.svw").prepend("<img src='images/spinner.gif' class='ldrgif' alt='loading...'/ >"); 
});
var j = 0;
var quantofamo = 0;
jQuery.fn.slideView = function(settings) {
	  settings = jQuery.extend({
     easeFunc: "easeInOutExpo",
     easeTime: 750,
     toolTip: false
  }, settings);
	  
	  
	return this.each(function(){
		var container = jQuery(this);
		container.find("img.ldrgif").remove(); // removes the preloader gif
		container.removeClass("svw").addClass("stripViewer");		
		var pictWidth = container.find("img").width();
		var pictHeight = container.find("img").height();
		var pictEls = container.find("li").size();
		var stripViewerWidth = (pictWidth*pictEls)+35;
		container.find("ul").css("width" , stripViewerWidth);
		container.css("width" , pictWidth);
		container.css("height" , pictHeight);
		container.each(function(i) {
	
			
			//Alex Wesler 1/18/10
			// targets div#summary instead of "this" because want nav to show up after the summary div
			jQuery("div#summary").after("<div class='stripTransmitter' id='stripTransmitter" + (j) + "'><ul><\/ul><\/div>");
			
			
			jQuery(this).find("li").each(function(n) {
						jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("alt") + "' href='#'>"+(n+1)+"<\/a><\/li>");												
				});
			
			
			jQuery("div#stripTransmitter" + j + " a").each(function(z) {
				jQuery(this).bind("click", function(){

				jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
				
				
				
				//Alex Wesler 1/18/10
				// 7 added to compensate for 7px padding in this layout
				var cnt = -((7+pictWidth)*z); //distance to slide left
				
				
				//Alex Wesler 1/18/10
				//modified from direct slider to fade slider - now image fades out, slides invisibly, then fades in
				//probably more effifient to do with z index and non-sliding images, but this way, can be easily modified to use as a slider again
				container.find("ul").animate({opacity: 0}, 400)
				.animate( {left: cnt} ,  100 )
				.animate( {opacity: 1.0} , 400 );
				
				
				
				//Alex Wesler 1/18/10
				//detect NEW HEIGHT of current image
				var pictHeightnew = container.find("img#"+z).height();
				//Alex Wesler 1/18/10
				//change height of container to fit new height
				container.animate({height: pictHeightnew}, 400);
				
				
				return false;
				   });
				});
			

			// next image via image click	14/01/2009
			 
			 
	//Alex Wesler 1/18/10		 
	//the prev() and next() below traverse to the surrounding sibling elements. Since I altered the navigation to appear after the div#summary, need to go prev x 2
			
				jQuery("div#stripTransmitter" + j + " a").parent().parent().parent().prev().prev().find("img").each(function(z) {
																													  
				jQuery(this).bind("click", function(){
					var ui 	= 	jQuery(this).parent().parent().parent().next().next().find("a");
					if(z+1 < pictEls){
						
						ui.eq(z+1).trigger("click");
					}
					else ui.eq(0).trigger("click");
				   });
				
				});

		
		//Alex Wesler 1/8/20
		//not using the tool tips in this project, but leaving code in place
				
			jQuery("div#stripTransmitter" + j).css("width" , 300);
			jQuery("div#stripTransmitter" + j + " a:first").addClass("current");
			if(settings.toolTip){
			container.next(".stripTransmitter ul").find("a").Tooltip({
				track: true,
				delay: 0,
				showURL: false,
				showBody: false
				});
			}
			});
		j++;
  });	
};
