var shapes = ["SmartShape_4","SmartShape_10","SmartShape_14"];
var images = ["Image_2","Image_7","Image_9"];
var infoFileRelativePath = "/wor/wo_5822/index.html";

function postProcess() {
    var myNodeList = document.querySelectorAll("#div_Slide");
    var children = myNodeList[0].childNodes;
    for (child in children) {
        var element = children[child];
        if (contains(shapes,element.id)) {
            if (element.classList.contains('cp-frameset'))
                element.classList -= 'cp-frameset';
        }
        if (images.includes(element.id)) {
            if (element.removeEventListener) { // For all major browsers, except IE 8 and earlier
                element.removeEventListener("click", displayInfo);
            } else if (element.detachEvent) { // For IE 8 and earlier versions
                element.detachEvent("click", displayInfo);
            }
            element.style.cursor = "pointer";
            element.addEventListener("click", displayInfo);
        }
    }
}

$(document).ready(function () {
    window.currentSlide = undefined;
    setInterval(checkScreen, 500);
});

function checkScreen() {
    if (document.querySelectorAll("#div_Slide").length < 1 || document.querySelectorAll("#div_Slide")[0].firstChild === undefined) {
        return;
    }
    if(document.querySelectorAll("#div_Slide")[0].firstChild === null || document.querySelectorAll("#div_Slide")[0].firstChild === undefined){
        return;
    }
    if(window.currentSlide!==undefined && window.currentSlide === document.querySelectorAll("#div_Slide")[0].firstChild.id){
        return;
    }
    window.currentSlide = document.querySelectorAll("#div_Slide")[0].firstChild.id;
    postProcess();
}

function displayInfo() {
    var win = window.open(window.location.href.substring(0, window.location.href.lastIndexOf('/')) + infoFileRelativePath, '_blank');
    win.focus();
}

function contains(a, obj) {
    for (var i = 0; i < a.length; i++) {
        if (a[i] === obj) {
            return true;
        }
    }
    return false;
}