function swapout(containerId, type, imageId, exhibitionId) {
  new Ajax.Updater('main_'+containerId, '/ajax/swapout/?type='+type+'&id='+imageId+'&exhibitionId='+exhibitionId);
  if(type == 'artwork')		new Ajax.Updater('artists_works_info_'+containerId, '/ajax/swapout/text.php?id='+imageId);
  if(type == 'exhibitions')	new Ajax.Updater('artists_works_info_'+containerId, '/ajax/swapout/text.php?id='+imageId+'&exhibitionId='+exhibitionId);
}

function swapoutRandom(id) {
  new Ajax.Updater('imgPreview', '/ajax/swapout/imgpreview.php?&id='+id);
}

function swapoutSlide(containerId, direction, max) {
  currentOffset = $('thumbnails_'+containerId).getStyle('margin-left');
  currentOffset = parseInt(currentOffset.replace(/px/, ''));

  if(direction == 'right')	newOffset = currentOffset-80;
  else				newOffset = currentOffset+80;

  if (max<=5)	min=0;
  else		min = ((max-5)*80)*-1;

  if(newOffset > 0)	newOffset = 0;
  if(newOffset < min)	newOffset = min;

  $('thumbnails_'+containerId).setStyle({marginLeft: newOffset+"px"});
}

function swapoutSlideVertical(direction, max) {
  currentOffset = $('artistNames').getStyle('margin-top');
  currentOffset = parseInt(currentOffset.replace(/px/, ''));

  if(direction == 'down')	newOffset = currentOffset-30;
  else				newOffset = currentOffset+30;

  min = ((max-8)*30)*-1;

  if(newOffset > 0)	newOffset = 0;
  if(newOffset < min)	newOffset = min;

  $('artistNames').setStyle({marginTop: newOffset+"px"});
}
