////////////////////////////////////////////////////////////////////////////////
// Class			: ImageViewer
// Description		: This class definition allows users to create an instance of
//					: of an ImageViewer in javascript.  The image viewer object 
//					: manages all of the data and interface updates.
// Methods			: 
//					: 
// Revision History : 
// Date			Initials	Changes
// 08/13/2007	CJH			Created.
////////////////////////////////////////////////////////////////////////////////

function ImageViewer()
{
	// Declare and Initailize Private Member Attributes
	var m_this = this;							// Refers to the Image Viewer object
	
	var m_strImageLocation_Thumbnail = "";		// Location of thumbnail image files
	var m_strImageLocation_Large = "";			// Location of large image files
	
	var m_iNumThumbnailViews = 0;				// The number of thumbnail views the user can see
	var m_iPrevSelectedView = 1;				// The view which was previously selected by the user
	var m_iSelectedView = 1;					// Which view is selected (1 to iNumThumbnailViews)
	
	var m_iSelectedImage = 0;					// Which image is selected (0 to Upper Bound of arrThumbnailImages)
	var m_iSelectedImage_Min = 0;				// Minimum thumbnail image viewed
	var m_iSelectedImage_Max = 0;				// Maximum thumbnail image viewed
	
	var m_arrImageID = new Array();				// Contains list of Image IDs
	var m_arrThumbnailImages = new Array();		// Contains list of Thumbnail Images
	var m_arrDetailImages = new Array();		// Contains list of Detial Images
	var m_arrImageTitles = new Array();			// Contains list of Image Titles
	var m_arrImageCaptions = new Array();		// Contains list of Image Captions
	var m_arrThumbnailImages_ID = new Array();	// Contains list of all thumbnail element ids
	
	var m_strImageTitle_ID = "";				// Name of the element ID for the Image Title
	var m_strImageCaption_ID = "";				// Name of the element ID for the Image Caption
	var m_strImageDetail_ID = "";				// Name of the element ID for the lager detail image
	
	var m_strPrevButton_ID = "";				// Name of the element ID for the Prev button
	var m_strPrevButtonA_Class = "";			// Name of the class for the Prev button when available
	var m_strPrevButtonNA_Class = "";			// Name of the class for the Prev button when not available
	
	var m_strNextButton_ID = "";				// Name of the element ID for the Next button
	var m_strNextButtonA_Class = "";			// Name of the class for the Next button when available
	var m_strNextButtonNA_Class = "";			// Name of the class for the Next button when not available
	
	var m_strThumbnailA_Class = "";				// Name of the class for the Thumbnail when available
	var m_strThumbnailAS_Class = "";			// Name of the class for the Thumbnail when available and selected
	var m_strThumbnailNA_Class = ""				// Name of the class for the Thumbnail when not available
	
	var m_bLoaded = false;						// Indicates whether any Images have been loaded
	var m_bChange = false;						// Detirmines if any changes were made


	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : SetImageLocations
	// Parm Values  : strThumbnailImageLocation - Indicates the location of the 
	//				:    thumbnail images
	//				: strLargeImageLocation - Indicates the location of the large
	//				:    images
	// Return Value : N/A
	// Pre-Cond     : N/A
	// Post-Cond	: N/A
	// Description  : Sets the location where the thumbnail and large images are located
	////////////////////////////////////////////////////////////////////////////////
	this.SetImageLocations = function(strThumbnailImageLocation, strLargeImageLocation)
	{
		m_strImageLocation_Thumbnail = strThumbnailImageLocation;
		m_strImageLocation_Large = strLargeImageLocation;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.AddThumbnailView = function(strThumbnailImagesID)
	{
		m_arrThumbnailImages_ID[m_iNumThumbnailViews] = strThumbnailImagesID;
		m_iNumThumbnailViews++;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.SetThumbnailViewStyles = function(strThumbnailA_Class, strThumbnailAS_Class, strThumbnailNA_Class)
	{
		m_strThumbnailA_Class = strThumbnailA_Class;
		m_strThumbnailAS_Class = strThumbnailAS_Class;
		m_strThumbnailNA_Class = strThumbnailNA_Class;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.SetImageTitle = function(strImageTitleID)
	{
		m_strImageTitle_ID = strImageTitleID;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.SetImageCaption = function(strImageCaptionID)
	{
		m_strImageCaption_ID = strImageCaptionID;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.SetImageDetail = function(strImageDetailID)
	{
		m_strImageDetail_ID = strImageDetailID;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.SetPrevButton = function(strPrevButtonID, strPrevButtonA_Class, strPrevButtonNA_Class)
	{
		m_strPrevButton_ID = strPrevButtonID;
		m_strPrevButtonA_Class = strPrevButtonA_Class;
		m_strPrevButtonNA_Class = strPrevButtonNA_Class;

	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	this.SetNextButton = function(strNextButtonID, strNextButtonA_Class, strNextButtonNA_Class)
	{
		m_strNextButton_ID = strNextButtonID;
		m_strNextButtonA_Class = strNextButtonA_Class;
		m_strNextButtonNA_Class = strNextButtonNA_Class;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : Load
	// Parm Values  : strThumbnailImage - Path and name of thumbnail image
	//				: strDetailImage - Path and name of large detial image
	//				: strImageTitle - Image title to display
	//				: strCaption - Text caption to display for the image
	// Return Value : Returns true if the image and text was successfully loaded
	// Pre-Cond     : Init() must be called first
	// Post-Cond	: Sets load flag to true to indicate at least one item has been 
	//				: loaded into the ImageViewer object
	// Description  : Loads the images into the ImageViewer object.
	////////////////////////////////////////////////////////////////////////////////
	this.Load = function(iImageID, strThumbnailImage, strDetailImage, strImageTitle, strCaption)
	{		
		// Declare Local Variables
		var iLength;
		
		// Get length of thumbnails array
		iLength = m_arrThumbnailImages.length
		
		// Store Image details
		m_arrImageID[iLength] = iImageID;
		m_arrThumbnailImages[iLength] = strThumbnailImage;
		m_arrDetailImages[iLength] = strDetailImage;
		m_arrImageTitles[iLength] = strImageTitle;
		m_arrImageCaptions[iLength] = strCaption;
		
		// Min and Max viewable range in image arrays
		if(((iLength - m_iSelectedImage_Min) + 1) <= m_iNumThumbnailViews)
		{
			m_iSelectedImage_Max = iLength;
		}
		
		// At least one item has been loaded
		m_bLoaded = true;
		
		// Items have changed
		m_bChange = true;
		
		// Info successfully loaded
		return true;
	};
	

	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : Start
	// Parm Values  : strStartAt - The image to start at in the collection
	// Return Value : N/A
	// Pre-Cond     : Init() and Load() must be called first
	// Post-Cond	: N/A
	// Description  : Starts the image viewer and sets it to a specific thumbnail
	//				: if requested.  If the image that it is trying to start at does
	//				: does not exist then it will start at the first image in the 
	//				: thumbnail collection.
	////////////////////////////////////////////////////////////////////////////////
	this.Start = function()
	{
		if(arguments)
		{
			MoveToAndUpdate(arguments[0]);
		}
		else
		{
			MoveToAndUpdate(0);
		}
		/*
		jQuery('.ThumbnailBar_Item img').each(function() {
            var par = jQuery(this).parent();
            jQuery(this).remove();
            jQuery.get('ImageTag.axd?img=' + jQuery(this).attr('src') + '&type=small', function(data) {
                var i = jQuery(data);  
                jQuery(par).append(i);
                try
                {
                    jQuery(i).resizer({ width: 85, height: 85 });
                } catch(inner) { };
            });
        }); */
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : Search
	// Parm Values  : iImageID - The image id to search for
	// Return Value : Returns an integer value of the image location.  Returns a -1
	//				: if no valid match was found.
	// Pre-Cond     : Init() and Load() must be called first before performing a search
	// Post-Cond	: N/A
	// Description  : Searches the image arrays for a match and returns the index 
	//				: value of the images array.  You can then use the MoveTo() function
	//				: move to that new location.
	////////////////////////////////////////////////////////////////////////////////
	function Search(iImageID)
	{
		//alert("DEBUG: Search() Called")
		
		// Declare Local Variables
		var iLength;
		
		// Object must be init and loaded data
		if(m_bLoaded == true)
		{
			// Get length of the thumbnails array
			iLength = m_arrThumbnailImages.length
			
			// Loop through each element in the image arrays
			for(var iCounter = 0; iCounter < iLength; iCounter++)
			{
				// Check if a match was found
				if(m_arrImageID[iCounter] == iImageID)
				{
					// Return the index
					return iCounter;
				}
			}
		}
		
		// No match
		return -1;
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MovePrev
	// Parm Values  : N/A
	// Return Value : Returns true if we were able to successfully move to the 
	//				: previous position
	// Pre-Cond     : Init() and Load() must be called first
	// Post-Cond	: N/A
	// Description  : Moves the selector one position to the left.  If it is not
	//				: possible to move the selector on position to the right then 
	//				: the method will return false
	////////////////////////////////////////////////////////////////////////////////
	function MovePrev()
	{
		//alert("DEBUG: MovePrev() Called");
		
		// Object must be init and loaded data
		if(m_bLoaded == true)
		{
			// Check if selector is all the way to the left
			if(m_iSelectedView == 1 && m_iSelectedImage == 0)
			{
				// Unable to move selector
				return false;
			}
			else if(m_iSelectedView == 1 && m_iSelectedImage > 0)
			{
				// Record previous view index
				m_iPrevSelectedView = 1;
				
				// Set Image Selection
				m_iSelectedImage = m_iSelectedImage - 1;
				m_iSelectedImage_Min = m_iSelectedImage_Min - 1;
				m_iSelectedImage_Max = m_iSelectedImage_Max - 1;				
			}
			else if(m_iSelectedView > 1 && m_iSelectedView <= m_iNumThumbnailViews)
			{
				// Change view index
				m_iPrevSelectedView = m_iSelectedView;
				m_iSelectedView = m_iSelectedView - 1;
				
				// Set Image Selection
				m_iSelectedImage = m_iSelectedImage - 1;
			}
						
			// Selector Position Changed
			m_bChange = true;
			
			// Successfully moved to previous position
			return true;
		}
		
		// Unable to move to previous position
		return false;
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MoveNext
	// Parm Values  : N/A
	// Return Value : Returns true if we were able to successfully move to the 
	//				: next position
	// Pre-Cond     : Init() and Load() must be called first
	// Post-Cond	: N/A
	// Description  : Moves the selector one position to the right.  If it is not
	//				: possible to move the selector on position to the right then 
	//				: the method will return false
	////////////////////////////////////////////////////////////////////////////////
	function MoveNext()
	{		
		// Declare Local Variables
		var iImageUpperBound;
		
		// Object must be loaded
		if(m_bLoaded == true)
		{
			// Get the upper bound of the Images array
			iImageUpperBound = m_arrThumbnailImages.length - 1;
			
			// Check if selector is all the way to the right
			if(m_iSelectedView == m_iNumThumbnailViews && m_iSelectedImage == iImageUpperBound)
			{
				// Unable to move selector
				return false;
			}
			else if(m_iSelectedView == m_iNumThumbnailViews && m_iSelectedImage < iImageUpperBound)
			{
				// Record previous view index
				m_iPrevSelectedView = m_iNumThumbnailViews;
				
				// Set Image Selection
				m_iSelectedImage = m_iSelectedImage + 1;
				m_iSelectedImage_Min = m_iSelectedImage_Min + 1;
				m_iSelectedImage_Max = m_iSelectedImage_Max + 1;				
			}
			else if(m_iSelectedView >= 1 && m_iSelectedView < m_iNumThumbnailViews)
			{
				// Ensure selected image does not pass upper bound
				if(m_iSelectedImage == iImageUpperBound)
				{
					return false;
				}
				
				// Change view index
				m_iPrevSelectedView = m_iSelectedView;
				m_iSelectedView = m_iSelectedView + 1;
				
				// Set Image Selection
				m_iSelectedImage = m_iSelectedImage + 1;
			}
			
			// Selector Position Changed
			m_bChange = true;
		
			// Successfully moved to next position
			return true;
		}
		
		// Unable to move to next position
		return false;
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MoveFirst
	// Parm Values  : N/A
	// Return Value : N/A
	// Pre-Cond     : Init() and Load() must be called first
	// Post-Cond	: N/A
	// Description  : Moves the image selector to the first item in the collection
	//				: of available thumbnails
	////////////////////////////////////////////////////////////////////////////////
	function MoveFirst()
	{
		//alert("DEBUG: MoveFirst() Called")
		
		// Declare Local Variables
		var iSelectedImageIndex = 0;
		
		// Object must be init and loaded data
		if(m_bLoaded == true)
		{
			// Get image index to move to
			iSelectedImageIndex = Search(m_arrImageID[0]);
			
			// Move to the selected image index
			MoveTo(iSelectedImageIndex);
		}
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MoveLast
	// Parm Values  : N/A
	// Return Value : N/A
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	function MoveLast()
	{
		// Declare Local Variables
		var iSelectedImageIndex = 0;
		
		// Object must be init and loaded data
		if(m_bLoaded == true)
		{
			// Get Image Index to move to						
			iSelectedImageIndex = Search(m_arrImageID[m_arrImageID.length - 1]);
			
			// Move to the selected image index
			MoveTo(iSelectedImageIndex);
		}
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MoveTo
	// Parm Values  : iImageIndex - Moves to a specific image index
	// Return Value : Returns true if you are able to move to a specific Image Index
	// Pre-Cond     : Init() and Load() must be called first
	// Post-Cond	: N/A
	// Description  : Moves the selector to a specific image index
	////////////////////////////////////////////////////////////////////////////////
	function MoveTo(iImageIndex)
	{
		// Declare Local Variables
		var iImageUpperBound;
		var iCounter;
		var iSelectedImage;
		var iPrevSelectedView;
		
		// Object must be init and loaded data
		if(m_bLoaded == true)
		{
			// Get the upper bound of the Images array
			iImageUpperBound = m_arrThumbnailImages.length - 1;
			
			// Ensure Image Index Exists
			if(iImageIndex >= 0 && iImageIndex <= iImageUpperBound)
			{
				iSelectedImage = m_iSelectedImage
				
				// Detirmine which way to move
				if(m_iSelectedImage < iImageIndex)
				{
					// Record what previous view
					iPrevSelectedView = m_iSelectedView;
					
					// Move to the selected image
					for(iCounter = iSelectedImage; iCounter < iImageIndex; iCounter++)
					{
						MoveNext();
					}
					
					// Reset previous selected view after move
					m_iPrevSelectedView = iPrevSelectedView;
					
					// Selector Position Changed
					m_bChange = true;
					
					return true;
				}
				else if(m_iSelectedImage > iImageIndex)
				{
					// Record what previous view
					iPrevSelectedView = m_iSelectedView;
					
					// Move to the selected image
					for(iCounter = iSelectedImage; iCounter > iImageIndex; iCounter--)
					{
						MovePrev();
					}
					
					// Reset previous selected view after move
					m_iPrevSelectedView = iPrevSelectedView;
					
					// Selector Position Changed
					m_bChange = true;
					
					return true;
				}
				else if(m_iSelectedImage == iImageIndex)
				{
					return true;
				}
			}
		}
		
		// Unable to move to position
		return false;
	};
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MovePrevAndUpdate
	// Parm Values  : N/A
	// Return Value : N/A
	// Pre-Cond     : N/A
	// Post-Cond	: N/A
	// Description  : Moves the image selector one position to the left and updates
	//				: the interface
	////////////////////////////////////////////////////////////////////////////////
	function MovePrevAndUpdate()
	{		
		MovePrev();
		
		Update();
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MoveNextAndUpdate
	// Parm Values  : N/A
	// Return Value : N/A
	// Pre-Cond     : N/A
	// Post-Cond	: N/A
	// Description  : Moves the image selector one position to the right and updates
	//				: the interface
	////////////////////////////////////////////////////////////////////////////////
	function MoveNextAndUpdate()
	{
		MoveNext();
		
		Update();
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : MoveToAndUpdate
	// Parm Values  : iImageID - Image ID of the image to move to
	// Return Value : N/A
	// Pre-Cond     : N/A
	// Post-Cond	: N/A
	// Description  : Moves the image selector to a specific index and updates the
	//				: interface.  If the ImageID does not exist then the first
	//				: thumbnail will be selected.
	////////////////////////////////////////////////////////////////////////////////
	function MoveToAndUpdate(iImageID)
	{
		//  Declare Local Variables
		var iSelectedImageIndex;
	
		// Search for selected image
		iSelectedImageIndex = Search(iImageID);
		
		// Was an image index found
		if(iSelectedImageIndex != -1)
		{		
			// Move to the selected image
			MoveTo(iSelectedImageIndex);
		
			// Update the User Interface
			Update();
		}
		else
		{
			// Move to first item
			MoveFirst();
			
			// Update the User Interface
			Update();
		}	
	}
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : 
	// Parm Values  : 
	// Return Value : 
	// Pre-Cond     : 
	// Post-Cond	: 
	// Description  : 
	////////////////////////////////////////////////////////////////////////////////
	function Thumbnail_OnClick()
	{		
		// Loop through each thumbnail view
		for(var iCounter = 0; iCounter < m_iNumThumbnailViews; iCounter++)
		{
			// Check if element id matches thumbnail list
			if(m_arrThumbnailImages_ID[iCounter] == this.id)
			{
				// Move to the selected image
				MoveTo(m_iSelectedImage_Min + iCounter);
		
				// Update the User Interface
				Update();
			}
		}
	}

	
	////////////////////////////////////////////////////////////////////////////////
	// Method Name  : Update
	// Parm Values  : N/A
	// Return Value : Returns true if update was successful
	// Pre-Cond     : Init() and Load() must be called first
	// Post-Cond	: N/A
	// Description  : Updates the interface if changes were made to the selector or
	//				: new images were loaded into the Image Viewer object
	////////////////////////////////////////////////////////////////////////////////
	function Update()
	{
		// Declare Local Variables
		var iImgCounter;
		var iSelCounter;
		
		// Image Viewer should be initialized and loaded and a change should be made
		if(m_bLoaded == true && m_bChange == true)
		{	
			/////////////////////////
			// Update the Image Title
			/////////////////////////
			document.getElementById(m_strImageTitle_ID).innerHTML = m_arrImageTitles[m_iSelectedImage];
			
			/////////////////////
			// Update the Caption
			/////////////////////
			document.getElementById(m_strImageCaption_ID).innerHTML = m_arrImageCaptions[m_iSelectedImage];
			
			//////////////////////////
			// Update the Image Detail
			//////////////////////////
			document.getElementById(m_strImageDetail_ID).innerHTML = "<img src='" + m_strImageLocation_Large + m_arrDetailImages[m_iSelectedImage] + "' " + "alt='" +  m_arrImageTitles[m_iSelectedImage] + "' border='0' />";
			
			// RTR
			jQuery(m_strImageDetail_ID).resizer({ width: 450, height: 445 });
			
			////////////////////
			// Check left button
			////////////////////
			if(m_iSelectedImage == 0)
			{
				// Left button NOT available
				document.getElementById(m_strPrevButton_ID).className = m_strPrevButtonNA_Class;
				document.getElementById(m_strPrevButton_ID).onclick = null;
			}
			else
			{
				// Left button available
				document.getElementById(m_strPrevButton_ID).className = m_strPrevButtonA_Class;
				document.getElementById(m_strPrevButton_ID).onclick = MovePrevAndUpdate;
			}
			
			/////////////////////
			// Check right button
			/////////////////////
			if(m_iSelectedImage == (m_arrImageID.length - 1))
			{
				// Right button NOT available
				document.getElementById(m_strNextButton_ID).className = m_strNextButtonNA_Class;
				document.getElementById(m_strNextButton_ID).onclick = null;
			}
			else
			{
				// Right button available
				document.getElementById(m_strNextButton_ID).className = m_strNextButtonA_Class;
				document.getElementById(m_strNextButton_ID).onclick = MoveNextAndUpdate;
			}
			
			///////////////////////////
			// Display thumbnail images
			///////////////////////////  m_iSelectedImage_Max
			for(iImgCounter = m_iSelectedImage_Min, iSelCounter = 0; iImgCounter <= m_iSelectedImage_Max ; iImgCounter++, iSelCounter++)
			{
				// List all thumbnails
				var imgRef = "";
				if(iImgCounter <= (m_arrImageID.length - 1))
				{
					document.getElementById(m_arrThumbnailImages_ID[iSelCounter]).className = m_strThumbnailA_Class;
					imgRef = '#' + m_arrThumbnailImages_ID[iSelCounter] + ' img:first';
					jQuery(imgRef).attr('src', m_strImageLocation_Thumbnail + m_arrThumbnailImages[iImgCounter]);
					jQuery(imgRef).attr('alt', m_arrImageTitles[iImgCounter]);
					document.getElementById(m_arrThumbnailImages_ID[iSelCounter]).onclick = Thumbnail_OnClick;
				}
				else
				{
					document.getElementById(m_arrThumbnailImages_ID[iImgCounter]).className = m_strThumbnailNA_Class;
					document.getElementById(m_arrThumbnailImages_ID[iImgCounter]).onclick = null;
				}
			}
			
			////////////////////////////
			// Enable Selected Thumbnail
			////////////////////////////
			if(m_iSelectedView >= 1 && m_iSelectedView <= m_iNumThumbnailViews)
			{
				// Select the thumbnail
				document.getElementById(m_arrThumbnailImages_ID[m_iSelectedView - 1]).className = m_strThumbnailAS_Class;
			}
			
			// Changes have been implimented
			m_bChange = false;
			
			// Resize the images
			jQuery('#ImageDetail img').each(function() {
			    var par = jQuery(this).parent();
                jQuery('#ImageDetail img').remove();
                jQuery.get('ImageTag.axd?img=' + jQuery(this).attr('src') + '&type=small', function(data) {
                    var i = jQuery(data);  
                    jQuery(par).append(i);
                    jQuery(i).resizer({ width: 450, height: 445 });
                });
            });
            
            jQuery('.ThumbnailBar_Item img').each(function() {
                var par = jQuery(this).parent();
                jQuery(this).remove();
                jQuery.get('ImageTag.axd?img=' + jQuery(this).attr('src') + '&type=small', function(data) {
                    var i = jQuery(data);  
                    jQuery(par).append(i);
                    try
                    {
                        jQuery(i).resizer({ width: 85, height: 85 });
                    } catch(inner) { };
                });
            });
            
		}
	}
}