function loadimage(imagePath){
	var headerinfo = ('<html><head><title>American Textile History Museum in Lowell, Massachusetts</title></head><body bgcolor="#749dd3" style="margin: 0; padding: 0;"><center>');
	var image1 = ('<img src="'+imagePath+'" /><br /><br />');
	var closinginfo = ('<script type="text/javascript">window.focus();</script></center></body></html>');
	var pagecontent = (headerinfo + "" + image1 + "" + "" + closinginfo);
		
	imageWin = window.open(''+self.location,'largeImage','width=800, height=550, toolbar=0, resizable=0, scrollbars=1, status=0');

	imageWin.document.write(pagecontent);
	imageWin.document.close();
}
$(document).ready( function(){
	// Homepage Left Slideshow
	var slide_Prev = $('div.homepageCallouts div.featuredStory div.navArrows a.prevBtn');
	var slide_Next = $('div.homepageCallouts div.featuredStory div.navArrows a.nextBtn');
	var allSlides = $('div.story img');
	var slidingElement;
	var boxWidth;
	var elementWidth;
	var currentPosition;
	var currentlyShowing = 0;
	var pageLoaded = false;
	
	elementsLoaded = function(){
		pageLoaded = true;
		// Element to be slid inside of overflow box
		slidingElement = $('table.storyWrapper');
		
		// Width of the container (with css overflow applied)
		boxWidth = $('div.featuredStory').width();
		
		// width of element inside of 
		elementWidth = $(slidingElement).width() - boxWidth;

		// get the position of the sliding element
		currentPosition = $(slidingElement).css('left');
			
		currentPosition = currentPosition.split('px');
		currentPosition = currentPosition[0];
	}
	
	// on click of the previous button
	$(slide_Prev).click( function(){
		if(pageLoaded == false){
			elementsLoaded();
		}
		// create a positive number for comparison
		var absPositionValue = Math.abs(currentPosition);
		
		if(absPositionValue > 0){
			currentlyShowing--;
			$('div.navArrows p').html($(allSlides[currentlyShowing]).attr('alt'));
			// subtract the width of the visible area from the current position
			currentPosition = (eval(currentPosition) + boxWidth);
			
			if(currentPosition == 0){
				// if slider is back to starting position disable previous button
				$(slide_Prev).addClass('disabled');
			}
			
			var cssPosition = currentPosition+"px";
			
			$(slidingElement).each(function(){
				$(this).animate({left: cssPosition}, {duration: 500, easing: 'easeOutQuad'});
			});
			
			// if previous button clicked remove disabled class from the next button
			$(slide_Next).removeClass('disabled');
		}
		return false;
	});
	
	// on click of the next button
	$(slide_Next).click( function(){
		if(pageLoaded == false){
			elementsLoaded();
		}
		// create a positive number for comparison
		var absPositionValue = Math.abs(currentPosition);
		
		// if the current position is less the the width of the sliding element
		if(absPositionValue <= (elementWidth-boxWidth)){
			currentlyShowing++;
			$('div.navArrows p').html($(allSlides[currentlyShowing]).attr('alt'));
			// subtract the width of the visible area from the current position
			currentPosition = (currentPosition - boxWidth);
			
			if(Math.abs(currentPosition) >= (elementWidth-boxWidth)){
				// if slider is back to starting position disable previous button
				$(slide_Next).addClass('disabled');
			}
			
			var cssPosition = currentPosition+"px";
			
			$(slidingElement).each(function(){
				$(this).animate({left: cssPosition}, {duration: 500, easing: 'easeOutQuad'});
			});
			// if next button clicked remove disabled class from the previous button
			$(slide_Prev).removeClass('disabled');
		}
		return false;
	});
	
	
	// Homepage Featured Exhibits
	var FE_Previous = $('div.homepageCallouts div.right div.navigation a.previousBtn');
	var FE_Next = $('div.homepageCallouts div.right div.navigation a.nextBtn');
	var goSlidingElement;
	var goBoxHeight;
	var goElementHeight;
	var goCurrentPosition;
	var goPageLoaded = false;
	
	goElementsLoaded = function(){
		goPageLoaded = true;
		// Element to be slid inside of overflow box
		goSlidingElement = $('div.sectionSlider');
		
		// Width of the container (with css overflow applied)
		goBoxHeight = $('div.holder').height();
		
		// width of element inside of 
		goElementHeight = $(goSlidingElement).height() - goBoxHeight+4;

		// get the position of the sliding element
		goCurrentPosition = $(goSlidingElement).css('top');
			
		goCurrentPosition = goCurrentPosition.split('px');
		goCurrentPosition = goCurrentPosition[0];
	}
	
	// on click of the previous button
	$(FE_Previous).click( function(){
		if(goPageLoaded == false){
			goElementsLoaded();
		}
		// create a positive number for comparison
		var absPositionValue = Math.abs(goCurrentPosition);
		
		if(absPositionValue > 0){
			// subtract the width of the visible area from the current position
			goCurrentPosition = (eval(goCurrentPosition) + goBoxHeight);
			
			if(goCurrentPosition == 0){
				// if slider is back to starting position disable previous button
				$(FE_Previous).addClass('disabled');
			}
			
			var cssPosition = goCurrentPosition+"px";
			
			$(goSlidingElement).each(function(){
				$(this).animate({top: cssPosition}, {duration: 500, easing: 'easeOutQuad'});
			});
			
			// if previous button clicked remove disabled class from the next button
			$(FE_Next).removeClass('disabled');
		}
		return false;
	});
	
	// on click of the next button
	$(FE_Next).click( function(){
		if(goPageLoaded == false){
			goElementsLoaded();
		}
		// create a positive number for comparison
		var absPositionValue = Math.abs(goCurrentPosition);
		
		// if the current position is less the the width of the sliding element
		if(absPositionValue <= (goElementHeight-goBoxHeight)){
			// subtract the width of the visible area from the current position
			goCurrentPosition = (goCurrentPosition - goBoxHeight);
			
			if(Math.abs(goCurrentPosition) >= (goElementHeight-goBoxHeight)){
				// if slider is back to starting position disable previous button
				$(FE_Next).addClass('disabled');
			}
			
			var cssPosition = goCurrentPosition+"px";
			
			$(goSlidingElement).each(function(){
				$(this).animate({top: cssPosition}, {duration: 500, easing: 'easeOutQuad'});
			});
			// if next button clicked remove disabled class from the previous button
			$(FE_Previous).removeClass('disabled');
		}
		return false;
	});
	
	
	// Homepage Tabs
	var allLinks = $('div.tabs a');
	var allTabbedSections = $('div.tabbedSection');
	$(allLinks).click( function(){
		$(allLinks).removeClass('selected');
		$(this).addClass('selected');
		var currentTab = $(allLinks).index(this);
		$(allTabbedSections).addClass('hide');
		$(allTabbedSections[currentTab]).removeClass('hide');
		return false;
	});
	
	
	$('ul#topNav li').hover(
		function(){$(this).children('ul:first').show();}
		,
		function(){$(this).children('ul:first').hide();}
	);
	
	
});