function SlideShow(elementId, dataArray, autoPlay, isHighRes, onClickFunction) {
	
	this.mIsHighRes = isHighRes;
	this.mOnClickFunction = onClickFunction;
	this.mInitialStart = true;
	this.mDataArray = dataArray;
	this.mAutoPlay = autoPlay;
	
	// element id
	this.mElementId = elementId;
	this.mImgBoxId = elementId + 'ImgBox';
	this.mCaptionId = elementId + 'Caption';
	this.mImageNumId = elementId + 'ImageNum';
	this.mStartSlideshowId = elementId + 'StartSlideshow';

	// image properties
	this.mImageContainerWidth = 689;
	this.mImagePadding = 7;
	this.mImageWidth = 225 + this.mImagePadding;
	this.mImagePosition = -this.mImageWidth;
	this.mCurImgBox = 0;
	this.mClickable = true;
	this.mPlayDelay = 3500
	this.mCurViewingImg = 0;
	this.mCurViewingBox = 0;
	this.mTotalImgBox = 5;
	this.mGalleryHeight = (this.mIsHighRes) ? 325 : 169;

	// render html
	$('#' + this.mElementId).css('width', this.mImageContainerWidth + 'px');
	$('#' + this.mElementId).css('position', 'relative');
	$('#' + this.mElementId).html('<div style="width:' + this.mImageContainerWidth + 'px; overflow:hidden; margin-bottom:7px; height:' + this.mGalleryHeight + 'px; position:relative; top:0px; left:0px; z-index:9px;"><div id="' + this.mImgBoxId + '0" style="width:4000px; position:absolute; left:0px; z-index:15; background:white;"></div><div id="' + this.mImgBoxId + '1" style="width:4000px; position:absolute; left:0px; top:0px; background:white; z-index:15; display:none;"></div></div>');
	$('#' + this.mElementId).append('<div style="position:absolute; left:19px; top:' + (this.mGalleryHeight - 30) + 'px; z-index:20;"><a href="javascript: ss.StartScrollImage(1);"><img src="/images/shared/arrow_left_ss.gif" onMouseOver="this.src=\'/images/shared/arrow_left_ss_hover.gif\'" onMouseOut="this.src=\'/images/shared/arrow_left_ss.gif\'"></a></div><div style="position:absolute; left:658px; top:' + (this.mGalleryHeight - 30) + 'px; z-index:20;"><a href="javascript: ss.StartScrollImage(-1);"><img src="/images/shared/arrow_right_ss.gif" onMouseOver="this.src=\'/images/shared/arrow_right_ss_hover.gif\'" onMouseOut="this.src=\'/images/shared/arrow_right_ss.gif\'"></a></div>');
	$('#' + this.mElementId).append('<div class="ss_caption"><table cellspacing="0" width="100%" height="20"><tr><td style="width:160px;"></td><td id="' + this.mCaptionId + '" align="center" class="textSmall">&nbsp;</td><td class="textSmall" style="width:60px;" align="right" id="' + this.mImageNumId + '">1 of ' + this.mDataArray.length + '</td><td class="textSmall" align="right" style="width:100px; padding-right:7px;"><a id="' + this.mStartSlideshowId + '" href="javascript: ss.Play()">Start Slideshow</a></td></tr></table></div>');

	// set image boxes
	this.mImgBoxes = new Array();
	for (var i = 0; i < this.mTotalImgBox; i++) {
		$('#' + this.mImgBoxId + '0').append('<img id="' + this.mImgBoxId + '0' + i + '" style="margin-right:' + this.mImagePadding + 'px; height:' + this.mGalleryHeight + 'px;"/>');
		$('#' + this.mImgBoxId + '1').append('<img id="' + this.mImgBoxId + '1' + i + '" style="margin-right:' + this.mImagePadding + 'px; height:' + this.mGalleryHeight + 'px;"/>');
	}

	// render images
	this.RenderImages(this.mCurViewingImg);	
}

SlideShow.prototype.RenderImages=function(currentKey) {
	this.mCurViewingBox = Math.ceil(this.mTotalImgBox/2) - 1;
	var offset_to_start = -Math.floor(this.mTotalImgBox/2);
	var currentKey = this.GetImageKey(currentKey, this.mDataArray.length, offset_to_start);
	var this_obj = this;
	
	// get current mImgBoxId
	this.mCurImgBox = (this.mCurImgBox == 0) ? 1 : 0; 

	// update caption and image number display
	this.UpdateDescription();
	
	// set images and opacities
	var temp_image = new Image();
	for (var i = 0; i < this.mTotalImgBox; i++) {
		temp_image.src = this.mDataArray[currentKey]['large'];
		opacity = (i == this.mCurViewingBox) ? 1 : .10;
		$('#' + this.mImgBoxId + this.mCurImgBox + i).css('opacity', opacity);
		$('#' + this.mImgBoxId + this.mCurImgBox + i).attr('src', temp_image.src);
		currentKey = this.GetNext(currentKey, this.mDataArray.length);
	}

	// set image position after the first and second images have been loaded
	$('img').load(function(){this_obj.SetImagePosition();});
}

SlideShow.prototype.SetImagePosition=function() {
	if (this.mIsHighRes) {
		img_width1 = $('#' + this.mImgBoxId + this.mCurImgBox + '0').attr('width');
		img_width2 = $('#' + this.mImgBoxId + this.mCurImgBox + '1').attr('width');
		var pre_width = img_width1 + img_width2 + (this.mImagePadding * 2);
		this.mImagePosition = -(pre_width - ((this.mImageContainerWidth - $('#' + this.mImgBoxId + this.mCurImgBox + this.mCurViewingBox).attr('width')) / 2));
	} else {
		this.mImagePosition = -this.mImageWidth;
	}
	$('#' + this.mImgBoxId + this.mCurImgBox).css('marginLeft', this.mImagePosition + "px");
	
	// switch image box
	var this_obj = this;
	other_box = (this.mCurImgBox == 0) ? 1 : 0;
	$('#' + this.mImgBoxId + this.mCurImgBox).fadeIn('fast', function(){$('#' + this_obj.mImgBoxId + other_box).fadeOut('fast'); this_obj.mClickable = true;});
}

SlideShow.prototype.StartScrollImage=function(direction) {
	if (this.mClickable) {
		this.mClickable = false;
		this_obj = this;
		
		prev_img_width_pad = ((this.mImageContainerWidth - $('#' + this.mImgBoxId + this.mCurImgBox + this.mCurViewingBox).attr('width')) / 2) - this.mImagePadding;
		prev_img_box = this.mCurViewingBox; 
		
		this.mCurViewingBox = (direction > 0) ? this.GetPrev(this.mCurViewingBox, this.mTotalImgBox) : this.mCurViewingBox = this.GetNext(this.mCurViewingBox, this.mTotalImgBox);
		this.mCurViewingImg = (direction > 0) ? this.GetPrev(this.mCurViewingImg, this.mDataArray.length) : this.GetNext(this.mCurViewingImg, this.mDataArray.length);
		
		scroll_width = this.mImageContainerWidth - (((this.mImageContainerWidth - $('#' + this.mImgBoxId + this.mCurImgBox + this.mCurViewingBox).attr('width')) / 2) + prev_img_width_pad);
		this.mImagePosition += (scroll_width * direction);
		
		$('#' + this.mImgBoxId + this.mCurImgBox).animate({marginLeft:this.mImagePosition + "px"}, 'slow', 'swing');
		$('#' + this.mImgBoxId + this.mCurImgBox + prev_img_box).fadeTo(1000, .10);
		$('#' + this.mCaptionId).fadeTo('fast', 0);
		$('#' + this.mImgBoxId + this.mCurImgBox + this.mCurViewingBox).fadeTo(1100, 1, function(){this_obj.RenderImages(this_obj.mCurViewingImg);});
	}
}

SlideShow.prototype.UpdateDescription=function() {
	// handle callback function
    if (!this.mInitialStart && this.mOnClickFunction != false) {
		setTimeout(this.mOnClickFunction, 0);
    } else {
		this.mInitialStart = false;
    }
    
	if (this.mDataArray[this.mCurViewingImg]['caption'] != '') {
		link_target = (this.mDataArray[this.mCurViewingImg]['linkTarget']) ? this.mDataArray[this.mCurViewingImg]['linkTarget'] : '_top';
	    if (this.mDataArray[this.mCurViewingImg]['link']) {
	        $('#' + this.mCaptionId).html("<a href='"+this.mDataArray[this.mCurViewingImg]['link']+"' target='" + link_target + "'>"+this.mDataArray[this.mCurViewingImg]['caption']+"</a>");	
	    } else {
	        $('#' + this.mCaptionId).html(this.mDataArray[this.mCurViewingImg]['caption']);	
	    }
	} else {
		$('#' + this.mCaptionId).html('&nbsp;');
	}
	$('#' + this.mCaptionId).fadeTo('slow', 1);
	$('#' + this.mImageNumId).html((this.mCurViewingImg + 1) + ' of ' + this.mDataArray.length);
}

SlideShow.prototype.Play=function() {
	this.StartScrollImage(-1);
	var this_obj = this;
	this.PlayTimer = setTimeout(function(){this_obj.Play();}, this.mPlayDelay);
	$('#' + this.mStartSlideshowId).html('Stop Slideshow');
	$('#' + this.mStartSlideshowId).attr('href', 'javascript: ss.Stop();');
}

SlideShow.prototype.Stop=function() {
	clearTimeout(this.PlayTimer);
	$('#' + this.mStartSlideshowId).html('Start Slideshow');
	$('#' + this.mStartSlideshowId).attr('href', 'javascript: ss.Play();');
}

SlideShow.prototype.GetPrev=function(currentKey, total) {
	return (currentKey - 1 < 0) ? total - 1 : currentKey - 1;
}

SlideShow.prototype.GetNext=function(currentKey, total) {
	return (currentKey + 1 > total - 1) ? 0 : currentKey + 1;
}

SlideShow.prototype.GetImageKey=function(currentKey, totalKey, offsetKey) {
	offsetKey = (typeof(offsetKey) == 'undefined') ? 1 : offsetKey;
	if (offsetKey == 0) {
		return currentKey;
	}
	currentKey = (offsetKey > 0) ? this.GetNext(currentKey, totalKey) : this.GetPrev(currentKey, totalKey);
	offsetKey = (offsetKey > 0) ? offsetKey - 1 : offsetKey + 1;
	return this.GetImageKey(currentKey, totalKey, offsetKey);
}
