function convertHistory(){
	// Set the image location for the back and forward buttons:
	var left_on = '/img/misc/arrow-left.gif';
	var left = '/img/misc/arrow-left-off.gif';

	var right_on = '/img/misc/arrow-right.gif';
	var right = '/img/misc/arrow-right-off.gif';

	// Hide all but three products:
	$('#xsell .swatch_container:lt(3)').show();

	// Add the scroll buttons if there are more than three items:
	if($('#xsell .swatch_container').length > 3){
		$('#xsell .swatch_container:first').before('<td onclick="javascript:scrollHistory(\'previous\');" width="3%" class="swatch_navigation swatch_navigation_previous" align="left" valign="middle"><img src="' + left + '" alt="Previous" /></td>');
		$('#xsell .swatch_container:last').after('<td onclick="javascript:scrollHistory(\'next\');" width="3%" class="swatch_navigation swatch_navigation_next" align="right" valign="middle"><img src="' + right_on + '" alt="Previous" /></td>');
	}
}

function scrollHistory(direction){
	// Set the image location for the back and forward buttons:
	var left_on = '/img/misc/arrow-left.gif';
	var left = '/img/misc/arrow-left-off.gif';

	var right_on = '/img/misc/arrow-right.gif';
	var right = '/img/misc/arrow-right-off.gif';

	// If they're scrolling left and there are products to the left...
	if(direction == 'previous' && $('#xsell .swatch_container').index($('#xsell .swatch_container:visible:first')) != 0){
		// Hide the rightmost product and display the next left-side product:
		$('#xsell .swatch_container:visible:last').hide();
		$('#xsell .swatch_container:visible:first').prev().show();

		// Change the 'previous" button to its 'off' state, if necessary:
		if( $('.swatch_navigation_previous img').attr('src') == left_on && $('#xsell .swatch_container').index($('#xsell .swatch_container:visible:first')) === 0 ){
			$('.swatch_navigation_previous img').attr('src', left);
		}

		// Change the 'next' button to its 'on' state, if necessary:
		if( $('.swatch_navigation_next img').attr('src') == right ){
			$('.swatch_navigation_next img').attr('src', right_on);
		}
	}

	// If they're scrolling right and there are products to the right...
	if( direction == 'next' && $('#xsell .swatch_container').index($('#xsell .swatch_container:visible:last')) != $('#xsell .swatch_container').index($('#xsell .swatch_container:last')) ){
		// Hide the leftmost product and display the next right-side product:
		$('#xsell .swatch_container:visible:first').hide();
		$('#xsell .swatch_container:visible:last').next().show();

		// Change the 'next' button to its 'off' state, if necessary:
		if( $('.swatch_navigation_next img').attr('src') == right_on && $('#xsell .swatch_container').index($('#xsell .swatch_container:visible:last')) === $('#xsell .swatch_container').index($('#xsell .swatch_container:last')) ){
			$('.swatch_navigation_next img').attr('src', right);
		}

		// Change the 'previous' button to its 'on' state, if necessary:
		if( $('.swatch_navigation_previous img').attr('src') == left ){
			$('.swatch_navigation_previous img').attr('src', left_on);
		}
	}
}

function scrollHistoryAutomatic(){
	// Stub... could be made to automatically scroll through the previous history until user interaction.
}
