// JavaScript Document

function SlideShow(updateDiv, jsonPath, interval) {
							var updateIt = $("#"+updateDiv);
							
							var jsonx = jsonPath;
							 
							var images = null;
							 
							var counter = 0;
							 
							var largePath = '';
							 
							var thumbPath = '';
							 
							var speed = 3000;
							 
							var duration = 1.0;
							var self = this;
							 
							
							var initialize = function() {
								 if (interval) {
								 	this.speed = interval;
								 }
								 
								var self = this;
								$.getJSON(jsonx, function (response) {
												largePath += response["lgPath"];
												images = response["images"]; 
												success: addImage();
										});
													
							 };
							 
							var i = initialize();
							
							var addImage= function() {
								 //this.updateIt.update();
								 zI = updateIt.css("zIndex");
								 for (var i = 0; i < images.length; i++) {
								 	var imageEl = $('<img src="'+largePath+images[i]+'" id="slideImage'+i+'"/>');
									zI = zI+i;
									imageEl.css({zIndex:zI, position:'absolute', border:'1px solid #999'});
									imageEl.hide();
									updateIt.append(imageEl);
								 }								
								 start();
								 updateIt.append("&nbsp;");
							 };
							 
							var start= function() {
								 showImage();
							 };
							var showImage= function() {				 
								 fadeImage();
								 if (counter >= images.length) counter = 0;
								 
								 if ($('#slideImage'+counter)) {
								 	$('#slideImage'+counter).fadeIn(500);
									counter++;
								 	var self = this;
								 	setTimeout(function() {
													showImage();
													 }, speed);
								 }
								 
							 };
							var fadeImage= function() {
								 var oneLess = counter - 1;
								if ($('#slideImage'+oneLess)) {
								 	$('#slideImage'+oneLess).fadeOut(1500);
								 }
							 };
							 
							 
			}

