﻿ //<!--
var MAX_ITENS = 6;
var posicaoAtual = -1;
var paginaAtual = -1;
var arrayFoto;

var queryString = new Array();
var variaveis = location.search.replace(/\x3F/, "").replace(/\x2B/g, " ").split("&");
if (variaveis != "") {
    for (i = 0; i < variaveis.length; i++) {
        nvar = variaveis[i].split("=");
        queryString[nvar[0]] = unescape(nvar[1]);
    }
}

function inserirTexto(campo, texto) {
    if (campo.value == "")
        campo.value = texto;
}

function limparTexto(campo, texto) {
    if (campo.value == texto)
        campo.value = "";
}

function agendarVisita(campo) {
    var txt = document.getElementById(campo);
    if (txt != null) {
        txt.focus();
        txt.style.backgroundColor = "#F7FEDA";
    }
}

function exibirFoto(index) {

    var pag = Math.floor(index / MAX_ITENS);
    if (pag != paginaAtual)
        carregarNavegador(pag);
    posicaoAtual = index;

    var vFotoLegendaDiv = document.getElementById('FotoLegendaDiv');
    if (arrayFoto.length > 0) {
        var i;
        var aFoto;
        for (i = 0; i < arrayFoto.length; i++) {
            aFoto = document.getElementById('foto' + (i + 1));
            //alert('foto' + (i+1) + "=" + aFoto);
            if (aFoto != null) {
                if (index == i) {
                    aFoto.style.display = 'block';
                    var aGaleria = document.getElementById('imgGaleria' + (i + 1));
                    if (aGaleria != null)
                        aGaleria.src = arrayFoto[i][0].replace("/58x58/", "/376x282/");
                }
                else
                    aFoto.style.display = 'none';
            }
        }
        vFotoLegendaDiv.removeChild(vFotoLegendaDiv.firstChild);
        vFotoLegendaDiv.appendChild(document.createTextNode(arrayFoto[index][1]));
    }
    else {
        var vDivFoto = document.getElementById('foto0');
        if (vDivFoto != null)
            vDivFoto.style.display = 'block';
        vFotoLegendaDiv.removeChild(vFotoLegendaDiv.firstChild);
        vFotoLegendaDiv.appendChild(document.createTextNode(" "));
    }

    /*
    var vFotoPrincipalDiv = document.getElementById('FotoPrincipalDiv');
    if (vFotoPrincipalDiv != null) {

        var pag = Math.floor(index / MAX_ITENS);
        if (pag != paginaAtual)
            carregarNavegador(pag);
        posicaoAtual = index;
    
        vFotoPrincipalDiv.removeChild(vFotoPrincipalDiv.firstChild);
        var aFoto = document.createElement('a');
        aFoto.setAttribute('href', arrayFoto[index][1]);
        aFoto.setAttribute('rel', 'foto');
        var imgFoto = document.createElement('img');
        imgFoto.setAttribute('src', arrayFoto[index][1].replace('/58x58/', '/'));
        imgFoto.setAttribute('border', '0');
        aFoto.appendChild(imgFoto);
        vFotoPrincipalDiv.appendChild(aFoto);
    }
    */

    /*    
    var vFotoPrincipalImg = document.getElementById('FotoPrincipalImg');
    var vFotoLegendaDiv = document.getElementById('FotoLegendaDiv');
    if (arrayFoto.length == 0) {
        vFotoPrincipalImg.setAttribute('src', '/images/semfoto_dados.jpg');
        vFotoLegendaDiv.removeChild(vFotoLegendaDiv.firstChild);
        vFotoLegendaDiv.appendChild(document.createTextNode(" "));
    }
    else {

        var pag = Math.floor(index / MAX_ITENS);
        if (pag != paginaAtual)
            carregarNavegador(pag);
        posicaoAtual = index;

        vFotoPrincipalImg.setAttribute('src', arrayFoto[index][1]);
        vFotoLegendaDiv = document.getElementById('FotoLegendaDiv');
        vFotoLegendaDiv.removeChild(vFotoLegendaDiv.firstChild);
        vFotoLegendaDiv.appendChild(document.createTextNode(arrayFoto[index][2]));
    }
    */
    carregarBanners();
}

function moverAnterior() {
    if (arrayFoto != null && arrayFoto.length > 0 && (posicaoAtual - 1) >= 0)
        exibirFoto(posicaoAtual - 1);
}

function moverProximo() {
    if (arrayFoto != null && arrayFoto.length > 0 && (posicaoAtual + 1) < arrayFoto.length)
        exibirFoto(posicaoAtual + 1);
}

function carregarFotos(pag) {
    if (arrayFoto.length == 0)
        return;

    var vFotoListaUl = document.getElementById('FotoListaUl');
    if (vFotoListaUl.hasChildNodes()) {
        while (vFotoListaUl.childNodes.length >= 1)
            vFotoListaUl.removeChild(vFotoListaUl.firstChild);
    }

    var pagIni = MAX_ITENS * pag;
    var pagFim = (MAX_ITENS * pag) + MAX_ITENS;
    if (pagFim > arrayFoto.length)
        pagFim = arrayFoto.length;
    var i, liFoto, aFoto, imgFoto;
    for (i = pagIni; i < pagFim; i++) {
        var texto = arrayFoto[i][1];
        if (texto.length > 55)
            texto = texto.substring(0, 52) + '...';
            
        liFoto = document.createElement('li');
        aFoto = document.createElement('a');
        //aFoto.setAttribute('href', '#');
        if (navigator.appName == 'Microsoft Internet Explorer')
            aFoto.onclick = new Function('exibirFoto(' + i + ');');
        else
            aFoto.setAttribute('onclick', 'exibirFoto(' + i + ');');
        imgFoto = document.createElement('img');
        if (posicaoAtual == i)
            //imgFoto.setAttribute('class', 'selecionado');
            imgFoto.setAttribute('style', 'border: solid blue 1px');
        imgFoto.setAttribute('src', arrayFoto[i][0]);
        imgFoto.setAttribute('alt', texto);
        imgFoto.setAttribute('border', '0');
        aFoto.appendChild(imgFoto);
        liFoto.appendChild(aFoto);
        //conteudo = conteudo + '><a href="javascript:;" onclick="exibirFoto(' + arrayFoto[i][0] + ');"><img src="images/camera.gif" />' + texto + '</a></li>\n';
        vFotoListaUl.appendChild(liFoto);
    }
}

function carregarNavegador(pag) {
    
    if (pag != paginaAtual) {
        paginaAtual = pag;
        exibirFoto(MAX_ITENS * pag);
        carregarFotos(pag);
    }

    var i;
    var titulo;
    var maxPaginas2 = arrayFoto.length / MAX_ITENS;
    var maxPaginas1 = Math.round(maxPaginas2);
    if (maxPaginas2 > maxPaginas1)
        maxPaginas1 = maxPaginas1 + 1;

    var vPaginacaoDiv = document.getElementById('PaginacaoDiv');
    if (vPaginacaoDiv.hasChildNodes()) {
        while (vPaginacaoDiv.childNodes.length >= 1)
            vPaginacaoDiv.removeChild(vPaginacaoDiv.firstChild);
    }

    for (i = 0; i < maxPaginas1; i++) {
        titulo = (i < 10) ? "0" + (i + 1) : (i + 1);
        if (i == paginaAtual) {
            var link = document.createElement('b');
            link.appendChild(document.createTextNode(titulo));
        }
        else {
            var link = document.createElement('a');
            //link.setAttribute('href', '#');
            if (navigator.appName == 'Microsoft Internet Explorer')
                link.onclick = new Function('carregarNavegador(' + i + ');');
            else
                link.setAttribute('onclick', 'carregarNavegador(' + i + ');');
            link.appendChild(document.createTextNode(titulo));
        }
        vPaginacaoDiv.appendChild(link);
        if (i != maxPaginas1 - 1)
            vPaginacaoDiv.appendChild(document.createTextNode(' - '));
    }

    if (linkMap != null)
        abrirFrame(linkMap, 800, 600, 60);
}

function carregarBanners() {
    var frameFotoBanner = window.parent.frames[1];
    if (frameFotoBanner != null)
        frameFotoBanner.location.href = "banner_foto.aspx?guid=" + queryString["guid"];

    var frameSuperBanner = window.parent.frames[0];
    if (frameSuperBanner != null)
        frameSuperBanner.location.href = "banner_super.aspx?guid=" + queryString["guid"];
}

/* --------- */

function abrirFrame(url,largura,altura,top) {
    var pageSize = getPageSize();

    var divSombra = document.createElement('div');
    divSombra.id = 'div_contato_sombra';
    divSombra.style.background = '#000 none repeat scroll 0';
    divSombra.style.left = '0pt';
    divSombra.style.filter = 'alpha(opacity=30)';
    divSombra.style.opacity = '0.3';
    divSombra.style.position = 'absolute';
    divSombra.style.top = '0pt';
    divSombra.style.zIndex = '900000';
    divSombra.style.width = (pageSize.pageWidth + 'px');
    divSombra.style.height = (pageSize.pageHeight + 'px');
    document.body.appendChild(divSombra);

    var objLeft = (document.body.clientWidth - largura) / 2;
    objLeft = objLeft + document.body.scrollLeft;
    //objTop = objTop + document.body.scrollTop;

    var divConteudo = document.createElement('div');
    divConteudo.id = 'div_contato_frame';
	divConteudo.style.margin = 'auto';
	divConteudo.style.color = '#069';
	divConteudo.style.font = '10px Verdana';
	divConteudo.style.font.weight = 'Normal';
	divConteudo.style.textAlign = 'justify';
	divConteudo.style.padding.left = '10px';
	divConteudo.style.padding = '10px';
	divConteudo.style.border = 'solid 1px #CCC';
	divConteudo.style.backgroundColor = '#FFF';
	divConteudo.style.zIndex = '900001';
	divConteudo.style.position = 'absolute';
	divConteudo.style.width = largura + 'px';
	divConteudo.style.height = altura + 'px';
	divConteudo.style.top = top + "px";
	divConteudo.style.left = objLeft + "px";
    //divConteudo.className = 'borda_contato_' + css;
    //divConteudo.className = 'fotoZoom';

    var frameContato = document.createElement('iframe');
    frameContato.id = 'frameContato';
    frameContato.style.width = (largura - 20) + 'px';
    frameContato.style.height = (altura - 20) + 'px';
    //frameContato.className = 'borda_contato_frame_' + css;
    frameContato.src = url;
    frameContato.frameBorder = 0;
    frameContato.scrolling = "no";

    var divFechar = document.createElement('div');
    divFechar.className = 'fechar';
    divFechar.align = "right";
    var aFechar = document.createElement('a');
    aFechar.title = 'fechar';
    aFechar.innerHTML = '<img src="images/telefone_fechar.jpg\" border=\"0\" />';
    aFechar.href = '#';
    aFechar.onclick = function() {
        closeZoom(this);
        return false;
    }
    divFechar.appendChild(aFechar);
    divConteudo.appendChild(divFechar);
    divConteudo.appendChild(frameContato);
    document.body.appendChild(divConteudo);
}

function zoom() {
    var pageSize = getPageSize();

    var divSombra = document.createElement('div');
    divSombra.id = 'div_contato_sombra';
    divSombra.style.background = '#000 none repeat scroll 0';
    divSombra.style.left = '0pt';
    divSombra.style.filter = 'alpha(opacity=30)';
    divSombra.style.opacity = '0.3';
    divSombra.style.position = 'absolute';
    divSombra.style.top = '0pt';
    divSombra.style.zIndex = '900000';
    divSombra.style.width = (pageSize.pageWidth + 'px');
    divSombra.style.height = (pageSize.pageHeight + 'px');
    document.body.appendChild(divSombra);

    var objLeft = (document.body.clientWidth - 650) / 2;
    objLeft = objLeft + document.body.scrollLeft;

    var divConteudo = document.createElement('div');
    divConteudo.id = 'div_contato_frame';
    divConteudo.style.margin = 'auto';
    divConteudo.style.color = '#069';
    divConteudo.style.font = '10px Verdana';
    divConteudo.style.font.weight = 'Normal';
    divConteudo.style.textAlign = 'justify';
    divConteudo.style.padding.left = '10px';
    divConteudo.style.padding = '10px';
    divConteudo.style.border = 'solid 1px #CCC';
    divConteudo.style.backgroundColor = '#FFF';
    divConteudo.style.zIndex = '900001';
    divConteudo.style.position = 'absolute';
    divConteudo.style.width = '650px';
    divConteudo.style.height = '500px';
    divConteudo.style.top = '50px';
    divConteudo.style.left = objLeft + "px";
    divConteudo.style.textAlign = 'center';
    //divConteudo.className = 'borda_contato_' + css;
    //divConteudo.className = 'fotoZoom';

    var imgFotoZoom = document.createElement('img');
    imgFotoZoom.id = 'FotoZoomImg';
    imgFotoZoom.style.width = 640 + 'px';
    imgFotoZoom.style.height = 480 + 'px';
    imgFotoZoom.src = arrayFoto[posicaoAtual][0].replace('/58x58/','/');

    var divFechar = document.createElement('div');
    divFechar.className = 'fechar';
    divFechar.align = "right";
    var aFechar = document.createElement('a');
    aFechar.title = 'fechar';
    aFechar.innerHTML = '<img src=\"/images/telefone_fechar.jpg\" border=\"0\" />';
    aFechar.href = '#';
    aFechar.onclick = function() {
        closeZoom(this);
        return false;
    }
    divFechar.appendChild(aFechar);
    divConteudo.appendChild(divFechar);
    divConteudo.appendChild(imgFotoZoom);
    document.body.appendChild(divConteudo);
}

function getPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) pageHeight = windowHeight;
    else pageHeight = yScroll;
    if (xScroll < windowWidth) pageWidth = windowWidth;
    else pageWidth = xScroll;
    arrayPageSize = { pageWidth: pageWidth, pageHeight: pageHeight, windowWidth: windowWidth, windowHeight: windowHeight }
    return arrayPageSize;
}

function getPageScroll() {
    var yScroll;
    if (self.pageYOffset) yScroll = self.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop;
    else if (document.body) yScroll = document.body.scrollTop;
    arrayPageScroll = { yScroll: yScroll };
    return arrayPageScroll;
}

function initZoom(div) {
    var container = document.getElementById(div);
    var lnks = container.getElementsByTagName('a');
    for (var i = 0, len = lnks.length; i < len; i++) {
        if (lnks[i].className.indexOf('linkZoom') > -1) {
            lnks[i].onclick = function() {
                openZoom(this);
                return false;
            }
        }
    }
}

function closeZoom(obj) {
    document.body.removeChild(document.getElementById('div_contato_sombra'));
    document.body.removeChild(document.getElementById('div_contato_frame'));
}

function resizeZoom(obj) {
    var largura = obj.width;
    var altura = obj.height;
    var box = obj.parentNode.parentNode;
    var pageSize = getPageSize();
    var pageScroll = getPageScroll();
    var boxTop = pageScroll.yScroll + ((pageSize.windowHeight - altura - 26) / 2);
    var boxLeft = ((pageSize.pageWidth - largura - 40) / 2);
    box.style.top = (boxTop < 0) ? "0px" : boxTop + "px";
    box.style.left = (boxLeft < 0) ? "0px" : boxLeft + "px";
    box.style.visibility = 'visible';
    try {
        var divZoom = document.getElementById('zoom_' + obj.className);
        var divDescricao = document.getElementById('desc_' + obj.className);
        if (divZoom) divZoom.style.width = largura;
        if (divDescricao) divDescricao.style.width = largura;
    } catch (erro) { }
}

function desabilitarMouse(e) {
    var evento = e ? e : window.event;
    var botao = evento ? evento.which : evento.button;
    if (botao == 1)
        return true;
    else {
        botao = false;
        evento.returnValue = false;
        return false;
    }
}

function desabilitarTeclado(e) {
    var evento = e ? e : window.event;
    if (evento.ctrlKey) {
        evento.returnValue = false;
        return false;
    }
    else
        return true;
}

function retornarFalso(e) {
    return false;
}

function ocultarEmbed() {
    document.getElementById('tabs').style.display = 'none';
}

function buildEmbed(response) {

    var Embed = document.createElement('Embed');
    var src = 'http://www.youtube.com/v/' + response + '?fs=1&amp;hl=pt_BR&amp;rel=0&amp;border=1';

    Embed.setAttribute('src', src);
    Embed.setAttribute('type', 'application/x-shockwave-flash');
    Embed.setAttribute('allowscriptaccess', 'always');
    Embed.setAttribute('allowfullscreen', 'true');
    Embed.setAttribute('width', '410');
    Embed.setAttribute('height', '340');
    Embed.setAttribute('id', 'embed2');
    var tdYoutube = document.getElementById('tdYoutube');

    tdYoutube.appendChild(Embed);
    document.getElementById('aba2').style.display = 'none';
}

function opentab(num) {
    $("#content > div").hide();
    $("#content > div:eq(" + (num - 1) + ")").fadeIn();
    $("#tabs > a").css("background", "url(tab.jpg) top left no-repeat");
    $("#tabs > a:eq(" + (num - 1) + ")").css("background", "url(tab-selected.jpg) top left no-repeat");

    if (num == 1) {
        document.getElementById('aba1').style.display = 'block';
        document.getElementById('aba2').style.display = 'none';
    }
    else {
        document.getElementById('aba2').style.display = 'block';
        document.getElementById('aba1').style.display = 'none';
    }
}

document.onkeydown = desabilitarTeclado;
document.onkeyup = desabilitarTeclado;
document.oncontextmenu = retornarFalso;
document.ondragstart = retornarFalso;
document.onmousedown = desabilitarMouse;
document.onmouseup = desabilitarMouse;
document.onselectstart = retornarFalso;

//-->
