﻿






function mostraesconde(idDiv, e) {

    var divME = document.getElementById(idDiv);

    if (divME) {
    
    
        if (divME.style.display == ""){
        
            divME.style.display = "none";
            e.className = "botao_mais";

        } else {

            var content = $("#fotos_" + idDiv);
            if(content) {
                if(!content.is(":has(a)"))
    			    content.load(idDiv + ".htm", carregou("#fotos_" + idDiv));
            }
            divME.style.display = "";
            e.className = "botao_menos";
        }

        if (window.parent && window.parent.autoIframe) { autoIframeWindow(window.parent); }

    } else {
        alert("div nao encontrada.");
    }
}

function carregou(nomediv) {
    setTimeout(function(){timeoutLigtbox(nomediv)}, 500);
}

function timeoutLigtbox(nomediv) {
    $(nomediv + " a").lightBox();
}

function autoIframeWindow(janela) {
    var frames = janela.document.getElementsByTagName("iframe");
    for (var i = 0; i< frames.length; i++) {
        autoIframeObject(frames[i]);
    }
}

function autoIframeObject(frameObj) {

    innerDoc = (frameObj.contentDocument) ? frameObj.contentDocument : frameObj.contentWindow.document;

    objToResize = (frameObj.style) ? frameObj.style : frameObj;
    objToResize.height = "auto";
    
    objToResize.height = innerDoc.body.scrollHeight + "px";

}

function autoIframe(frameId) {
    
    try {
    
        frame = document.getElementById(frameId);
        autoIframeObject(frame);

    }
    catch(err){
        window.status = err.message;
        alert(err.message);
    }
}

