// banners
var isTopBanner = false;
var isCenterBanner = false;

var topBanners = new Array();
var centerBanners = new Array();

function loadBanners() {
    if (isTopBanner) loadTopBanner();
    if (isCenterBanner) loadCenterBanner();
}

// album
function showImage(urlFile, popUrlFile) {
    var img = window.parent.document.getElementById("imgLarge");
    img.src = "getimage.aspx?filename=" + urlFile + "&maxWidth=" + maxWidth + "&maxHeight=" + maxHeight;
    img.lowsrc = urlFile;
    img.style.display = '';
    //img.style.cursor = "pointer";
    //img.onclick = function() { popImage(popUrlFile); };

    var lnkDelete = window.parent.document.getElementById("lnkDelete");
    if (lnkDelete) lnkDelete.onclick = function() { window.open("album_files_delete.aspx?file=" + urlFile, "album_files_delete", "width=300,height=150"); };

    var lnkDownload = window.parent.document.getElementById("lnkDownload");
    if (lnkDownload) lnkDownload.onclick = function() { location.href = "download.aspx?file=" + urlFile, "", ""; };
}

// scroll
var scrollId;
var scrollFrame;
var scrolling = false;

function startScrollLeft(frmId) {
    if (!scrolling) {
        scrollFrame = frmId;    
        scrolling = true;
        doScrollLeft();
    }
}

function startScrollRight(frmId) {
    if (!scrolling) {
        scrollFrame = frmId;
        scrolling = true;
        doScrollRight();
    }
}

function doScrollLeft() {
    var frames = (document.frames ? document.frames : window.frames)

    frames[scrollFrame].scrollBy(-7, 0);
    scrollId = setTimeout("doScrollLeft()", 30);
}

function doScrollRight() {
    var frames = (document.frames ? document.frames : window.frames)

    frames[scrollFrame].scrollBy(7, 0);
    scrollId = setTimeout("doScrollRight()", 30);
}

function stopScroll() {
    scrolling = false;
    clearTimeout(scrollId);
}

// print
var wndPrint;
var objPrint;

function printElement(id) {
    objPrint = document.getElementById(id);
    wndPrint = window.open('print.aspx', '', '');

    setTimeout("doPrintElement()", 500);
}

function doPrintElement() {
    var div = wndPrint.document.getElementById("divHtml");

    if (div) {
        div.innerHTML = objPrint.innerHTML;
        wndPrint.print();
    } else {
        setTimeout("doPrintElement()", 500);
    }
}

// processes
var processSummary_div;
var processTitle_table;

function processSummary_over(div) {
    div.oldClassName = div.className;
    div.className = 'ProcessSummaryOver';
}

function processSummary_out(div) {
    div.className = (div.oldClassName ? div.oldClassName : '');
}

function processSummary_showDiv(divId, tableId) {
    if (processSummary_div) {
        processSummary_div.style.display = 'none';
    }
    if (processTitle_table) {
        processTitle_table.className = '';
        processTitle_table.oldClassName = '';
    }

    var div = document.getElementById(divId);
    if (div != processSummary_div) {
        div.style.display = '';

        processSummary_div = div;
    } else {
        processSummary_div = null;
    }

    var table = document.getElementById(tableId);
    if (table != processTitle_table) {
        table.className = 'ProcessSummaryActive';
        table.oldClassName = 'ProcessSummaryActive';
    
        processTitle_table = table;
    } else {
        processTitle_table = null;
    }
}

// navigation
function iframeLoadToResize(id, href) {
    var iframe = document.getElementById(id);
    if (!iframe.loaded) {
        var iframeWnd = document.frames[id];

        iframe.loading = 1;
        iframeWnd.location.href = href;
    }
}

function iframeResizeContent(iframe) {
    if (iframe.loading == 1) {
        iframe.loaded = 1;
        iframe.height = document.frames[iframe.id].document.body.scrollHeight;
    }
}

function rowOver(objRow) {
    objRow.oldClassName = objRow.className;
    objRow.className = "MouseOver";
}

function rowOut(objRow) {
    objRow.className = objRow.oldClassName;
}
// div display
function toggleDiv(divId) {
    var div = document.getElementById(divId)
    
    div.style.display = (div.style.display == "" ? "none" : "");
}

function togglePlusMinus(imgId) {
    var img = document.getElementById(imgId)

    img.open = (img.open == 0 ? 1 : 0)
    img.src = (img.open == 1 ? "images/mais.jpg" : "images/menos.jpg");
}

//image
PositionX = 50;
PositionY = 50;

defaultWidth  = 800;
defaultHeight = 500;

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
    var isNN=(navigator.appName=="Netscape")?1:0;
    var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
    var isSF=(navigator.userAgent.indexOf("Safari")!=-1)?1:0;
}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=100,height=100';
var optSF='scrollbars=no,width=100,height=100';

function popImage(imageURL,imageTitle){
    if (isIE) {
        imgWin=window.open('about:blank','',optIE);
    } else if (isSF) {
        imgWin=window.open('about:blank','',optSF);
    } else if (isNN) {
        imgWin=window.open('about:blank','',optNN);
    }
    
    with (imgWin.document){
        writeln('<html><head><title>A carregar...</title><style>body{margin:0px;}</style>');
        writeln('<sc'+'ript>');
        writeln('var isNN,isSF,isIE;');
        writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
        writeln('isNN=(navigator.appName=="Netscape")?1:0;');
        writeln('isSF=(navigator.userAgent.indexOf("Safari")!=-1)?1:0;');
        writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
        writeln('function reSizeToImage(){');
        writeln('if (isIE){');
        writeln('window.resizeTo(300,300);');
        writeln('width=300-(document.body.clientWidth-document.images[0].width);');
        writeln('height=300-(document.body.clientHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);');
        writeln('} else if (isSF){');
        writeln('window.resizeTo(300,300);');
        writeln('opener.status = document.images[0].height;');
        writeln('width=300-(self.innerWidth-document.images[0].width);');
        writeln('height=300-(self.innerHeight-document.images[0].height);');
        writeln('window.resizeTo(width,height);');
        writeln('} else if (isNN){');       
        writeln('window.innerWidth=document.images["imgPopup"].width;');
        writeln('window.innerHeight=document.images["imgPopup"].height;}}');
        writeln('function doTitle(){document.title="'+imageTitle+'";}');
        writeln('</sc'+'ript>');
        if (!AutoClose)
            writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
        else
            writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
        writeln('<img name="imgPopup" src="'+imageURL+'" style="display:block"></body></html>');
        close();		
    }
}

