var indexHref = 'http://172.16.8.65/index.aspx';
var innerFrames = new Array("ifesqcim", "ifdircim", "navigation", "ifesqbax", "ifdirbax");
var err = false;

for (i = 0; i < innerFrames.length; i++) {
    if (window.location.href.toLowerCase().indexOf(innerFrames[i]) != -1) {
        if (top.frames[0] != window.parent) {
            top.location.href = indexHref;
            err = true;
        }
    }
}

if (!err) {
    if (window.location.href.toLowerCase().indexOf("index") != -1) {
        if (top != window)
            top.location.href = indexHref;
    }
    else if (window.location.href.toLowerCase().indexOf("intro") != -1 || window.location.href.toLowerCase().indexOf("iframes") != -1 || window.location.href.indexOf("contactos") != -1 || window.location.href.indexOf("sitemap") != -1 ) {
        if (top.frames[0] != window)
            top.location.href = indexHref;
    }
    else if (window.location.href.toLowerCase().indexOf("artigo") != -1) {
        if (top.frames[0].window.frames[4] != window.parent && top.frames[0].window.frames[4] != window)
            top.location.href = indexHref;
    }
    else if (window.location.href.toLowerCase().indexOf("logoperation") != -1) {
        if (!(top.frames[0] == window || top.frames[0] == window.parent))
            top.location.href = indexHref;
    }
}
