function centraliza(largura, altura) {
    window.moveTo((window.screen.width - largura) / 2, (window.screen.height - altura) / 2);
}

function abreJanela(arquivo, nome, barra, largura, altura) {
    window.open(arquivo, nome, "resizable=no,toolbar=no,status=no,menubar=no,scrollbars=" + barra + ",width=" + largura + ",height=" + altura);
}

function redimenciona() {
    var i = 0;
    function resize() {
        if (navigator.appName == 'Netscape') i = 40;
        if (document.images[0]) window.resizeTo(document.images[0].width + 50, document.images[0].height + 80 - i);
        if (window.moveTo((window.screen.width - document.images[0].width) / 2, (window.screen.height - document.images[0].height) / 2));
    }
}

function montaSWF(arquivo, largura, altura, action) {

    var now = new Date();
    var dia = now.getDay();
    var mes = now.getMonth();
    var ano = now.getFullYear();
    var hora = now.getHours();
    var mintuto = now.getMinutes();
    var segundo = now.getSeconds();
    var data = ano + "" + mes + "" + dia + "" + hora;

    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
    document.write('<param name="movie" value="swf/' + arquivo + '.swf?ieSux=' + data + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="menu" value="false" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="FlashVars" value="' + action + '&clearCache=' + data + '" />');
    document.write('<embed FlashVars="' + action + '&clearCache=' + data + '" wmode="transparent" menu="false" src="swf/' + arquivo + '.swf?ieSux=' + data + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
    document.write('</object>');
}

function montaSWF2(arquivo, largura, altura, action) {
    var now = new Date();
    var dia = now.getDay();
    var mes = now.getMonth();
    var ano = now.getFullYear();
    var hora = now.getHours();
    var mintuto = now.getMinutes();
    var segundo = now.getSeconds();
    var data = ano + "" + mes + "" + dia + "" + hora;

    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
    document.write('<param name="movie" value="/simulador/' + arquivo + '.swf?ieSux=' + data + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="menu" value="false" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="FlashVars" value="' + action + '&clearCache=' + data + '" />');
    document.write('<embed FlashVars="' + action + '&clearCache=' + data + '" wmode="transparent" menu="false" src="/simulador/' + arquivo + '.swf?ieSux=' + data + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
    document.write('</object>');
}

//if (top.location != location) {top.location.href = "http://www.scorro.com.br/";}

function menudrop(n) {
    var div = document.getElementById("menudrop" + n);
    if (div.style.display == "none")
        div.style.display = '';
    else
        div.style.display = 'none';
}

window.onload = init;

function init() {
    var link = window.location.toString();
    link = link.substring(link.lastIndexOf('/') + 1, link.length - 1);
    link = link.substring(0, link.indexOf('.'));

    switch (link) {
        // Eletricidade   
        case "servicos-centro":
        case "servicos-quadro":
        case "servicos-comando":
        case "servicos-iluminacao":
        case "servicos-geradores":
        case "servicos-nobreak":
            document.getElementById("menudrop").style.display = '';
            break;
        // Proteção contra incêndio   
        case "deteccao":
        case "extincao":
        case "central-controle":
            document.getElementById("menudrop1").style.display = '';
            break;
        // Cabeamento estruturado   
        case "cabeamento-metalico":
        case "cabeamento-optico":
        case "certificacoes":
        case "documentacao":
            document.getElementById("menudrop2").style.display = '';
            break;

    }
}

function trocaimagem() {

    var img = document.getElementById(arguments[0]);
    img.src = arguments[1];

}

function escondeddl() {

    var select = document.getElementById(arguments[0]);
    select.style.display = "none";
    var txt = document.getElementById(arguments[2]);
    txt.value = arguments[1];
}

function aparece(dive, talvez) {
    var div = document.getElementById(dive);

    if (talvez == true)
        div.style.display = "none";
    else
        div.style.display = "block";
}

function aparece1() {
    var select = document.getElementById('sel1');

    switch (select.style.display) {
        case "":
        case "none":
            select.style.display = "block";
            break;
        default:
            select.style.display = "none";
            break;
    }
}

function aparece2() {
    var select = document.getElementById('sel2');
    switch (select.style.display) {
        case "":
        case "none":
            select.style.display = "block";
            break;
        default:
            select.style.display = "none";
            break;
    }
}

function aparece3() {
    var select = document.getElementById('sel3');
    switch (select.style.display) {
        case "":
        case "none":
            select.style.display = "block";
            break;
        default:
            select.style.display = "none";
            break;
    }
}

function aparece4() {
    var select = document.getElementById('sel4');
    switch (select.style.display) {
        case "":
        case "none":
            select.style.display = "block";
            break;
        default:
            select.style.display = "none";
            break;
    }
}

function sh(div, aparece, url) {
    if (aparece == "nao") {
        document.getElementById(div).style.display = "none";
    }
    else {
        var video = document.getElementById('frmVideo');
        video.src = url;
        document.getElementById(div).style.display = "block";
    }
}

function TrocaFoto(img, src) {
    document.getElementById(img).src = src;
}

function sh1() {
    var select = document.getElementById('sel1');
    switch (select.style.display) {
        case "":
        case "none":
            select.style.display = "block";
            break;
        default:
            select.style.display = "none";
            break;
    }
}

function sh2() {
    var select = document.getElementById('sel2');
    switch (select.style.display) {
        case "":
        case "none":
            select.style.display = "block";
            break;
        default:
            select.style.display = "none";
            break;
    }
}

function ver_elemento(id) {
    var d = document.getElementById(id);
    if (d.style.display == 'none')
        d.style.display = '';
    else
        d.style.display = 'none';
}

function galeria(i, wid, n) {
     $("._principal").attr("src", "_admin/arquivos/produtos/" + i + "/galeria/" + wid + "/" + n);
}
function galeriaPort(i, wid, n,legenda) {
    $("._principal").attr("src", "_admin/arquivos/imagens/ambientes/" + i + "/fotos/" + wid + "/" + n);
    document.getElementById('legendafoto').innerHTML = legenda;
}

// START CARROSSEL
$(document).ready(function () {
    if ($(".Xgaleria").length > 0) {
        $(".Xgaleria").jcarousel({
            visible: 5,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallback,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }
    

    if ($(".linha").length > 0) {
        $(".linha").jcarousel({
            visible: 3,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallback2,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }
    if ($(".portifolio").length > 0) {
        $(".portifolio").jcarousel({
            visible: 8,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallback,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }
    if ($(".quemUsa").length > 0) {
        $(".quemUsa").jcarousel({
            visible: 3,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallback,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }

    if ($(".produto").length > 0) {
        $(".produto").jcarousel({
            visible: 3,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallback1,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }

    if ($("._Sugest").length > 0) {
        $("._Sugest").jcarousel({
            visible: 3,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallback2,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }
});

function mycarousel_initCallback(carousel) {
    jQuery('._next').bind('click', function () {
        carousel.next();
        return false;
    });

    jQuery('._back').bind('click', function () {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallback1(carousel) {
    jQuery('._next1').bind('click', function () {
        carousel.next();
        return false;
    });

    jQuery('._back1').bind('click', function () {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallback2(carousel) {
    jQuery('._next2').bind('click', function () {
        carousel.next();
        return false;
    });

    jQuery('._back2').bind('click', function () {
        carousel.prev();
        return false;
    });
};
// END CARROSSEL



