﻿function switchImage(href, newImage, numImgs, mainImageId, thumbWidth, mainImgWidth, maxUploadedImageWidth) {
    var oldImg = document.getElementById(mainImageId);
    var newImg = document.getElementById(newImage);
    //alert("oldImg = " + oldImg);
    //alert("thumb to parse and switch out = " + newImg.src);
    var oldStr = "w=" + thumbWidth;
    var newStr = "w=" + mainImgWidth;
    oldImg.src = newImg.src.replace(oldStr,newStr);

    var oldStrFullSize = "w=" + thumbWidth;
    var newStrFullSize = "w=" + maxUploadedImageWidth;

    var fullSizeLink = newImg.src.replace(oldStrFullSize,newStrFullSize);
    oldImg.parentNode.href = fullSizeLink;
    resetThumbStyles(numImgs);
    newImg.parentNode.className = "thumbnailSelected";
}
              
function resetThumbStyles(totalImgs) {
     for (i = 1; i <= totalImgs; i++) {
         var thisImg = document.getElementById("img" + i);
         thisImg.parentNode.className = "thumbnailNormal";
         //alert("new class name assigned");
     }
}
