﻿function highlight(img) {

    var urlPath = img.src.substring(0, img.src.lastIndexOf('/'));
    var oldImageName = img.src.substring(img.src.lastIndexOf('/') + 1);

    var fileName = oldImageName.substring(0, oldImageName.lastIndexOf('.'));
    
    if (fileName.match('_hl') != null) return;
    
    var extension = oldImageName.substring(oldImageName.lastIndexOf('.')+1);
    var highlightedImage = urlPath + "/" + fileName + "_hl." + extension;

    img.src = highlightedImage;

}

function restore(img) {

    var urlPath = img.src.substring(0, img.src.lastIndexOf('/'));
    var oldImageName = img.src.substring(img.src.lastIndexOf('/') + 1);

    var fileName = oldImageName.substring(0, oldImageName.lastIndexOf('.')-3);
    var extension = oldImageName.substring(oldImageName.lastIndexOf('.') + 1);
    var restoredImage = urlPath + "/" + fileName +"."+ extension;

    img.src = restoredImage;


}

function isSelected(img) {

    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    alert(sPage);
}