﻿function ChangeImage(imagepath, name, description, id) {

    document.getElementById("imgMain").src = imagepath;
    document.getElementById("picTitle").innerHTML = name;
    document.getElementById("picDesc").innerHTML = description;
    document.getElementById("hdId").value = id;
}


function apresentacaoSWF(url, width, height) {
    var strHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"" + width + "\" height=\"" + height + "\">";
    strHTML += "<param name=\"movie\" value=\"" + url + "\" />";
    strHTML += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
    strHTML += "<param name=\"quality\" value=\"high\" />";
    strHTML += "<param name=\"allowFullScreen\" value=\"true\" />";
    strHTML += "<param name=\"bgcolor\" value=\"#000000\" />";
    strHTML += "<embed src=\"" + url + "\" quality=\"high\" allowScriptAccess=\"sameDomain\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\"></embed>";
    strHTML += "</object>";
    popupCreate(strHTML, width, height);
}

function apresentacaoImg(url, width, height) {
    var strHTML = "<img src=\"" + url + "\" />";
    popupCreate(strHTML, width, height);
}
function popupCreate(content, width, height) {

    if (width == 950) { width2 = "width:" + width + "px;"; } else { width2 = ""; }
    if (height == 500) { height2 = "height:" + height + "px;"; } else { height2 = ""; }

    var obj = document.getElementById('boxPOPUP');
    if (!obj) {

        target = document.getElementById("BASE");
        var newElement = document.createElement('div');
        newElement.setAttribute('id', 'boxPOPUP');
        newElement.setAttribute('name', 'boxPOPUP');
        document.body.appendChild(newElement);
        obj = newElement;
    }

    obj.innerHTML = "";
    obj.style.display = "block";

    var posTop = -((height + 18) / 2 - document.documentElement.scrollTop);
    var strHTML = "<div onclick=\"popupRemove('boxPOPUP')\" id=\"lightMASK\" style=\"position:absolute;top:0;left:0;width:100%;height:" + /*document.body.scrollHeight*/GetFullHeight() + "px;z-index:1500;background-color:#000000;opacity:0.8;filter:alpha(opacity=80);\" ></div>";
    strHTML += "<div id=\"popupPDF\"  style=\" " + width2 + height2 + "position:absolute; z-index:2000; top:50%; left:50%; margin:" + posTop + "px 0px 0px -" + width / 2 + "px; background:none; \">";
    strHTML += "<div class=\"popupTitle\" style=\"text-align:right;\"><a href=\"javascript:popupRemove('boxPOPUP');\" title=\"Fechar\">fechar</a></div>";
    strHTML += "<div style=\" border:1px solid #FFFFFF;\">";
    strHTML += content;
    strHTML += "</div>";
    strHTML += "</div>";
    strHTML += "";

    obj.innerHTML = strHTML;
}
function popupRemove(obj) {
    obj = document.getElementById(obj);
    if (obj) {
        obj.style.display = "none";
        obj.innerHTML = "";
    }
}
function GetFullHeight() {
    var yWithScroll = 0;
    if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        //xWithScroll = windo.winnerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
        //xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.documentElement.scrollHeight;  //document.body.parentNode.clientHeight; //document.body.offsetHeight;
        //xWithScroll = document.body.offsetWidth;
    }

    return yWithScroll;


}




