function galleryChange(newImage,imagePos) 
{
  var captionLength = 36;
  
  var reg = /[a-z]/i;

  var file = newImage.substring(newImage.lastIndexOf('/')+1);
  var fileName = file.substring(0,newImage.lastIndexOf('.')+1);
  
  var imgPath = newImage.substring(0,newImage.lastIndexOf('/'));
  var category = imgPath.substring(imgPath.lastIndexOf('/'));
  var thumbPath = 'gallery_thumbs' + category;
  
  var captionText = (fileName.substring(newImage.search(reg))).substring(0,captionLength);
 
  var thumbBox = document.getElementById("galleryThumbs");
  
  var mainImage = thumbPath + '_main_' + fileName;
  var FullImage = imgPath + '/' + fileName;
  
  // gallerySize supplied by php
  var captionNum = imagePos + "/" + gallerySize;

  document.getElementById("galleryMain").src = mainImage;
  document.getElementById("galleryMainLink").href = FullImage;
  document.getElementById("galleryCaptionLeft").firstChild.nodeValue = captionText;
  document.getElementById("galleryCaptionRight").firstChild.nodeValue = captionNum;
  
}


function changePage(myForm){
  category = myForm.options[myForm.selectedIndex].value;
  window.location.href="./products.php?c=" + category;
}
