﻿function abreJanelaMaximizada(url) {
    var params = 'width=' + screen.width + ', height=' + screen.height;
    params += ', top=0, left=0';
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=yes';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(url, 'windowname5', params);
    if (window.focus) { newwin.focus() }
    return false;
}

function abreJanelaCentro(url, height, width) {
    if (navigator.appName != 'Microsoft Internet Explorer') {
        /* Para Internet Explorer, é preciso remover 17 pixels fornecidos como
         * padrão para alojar as barras de rolagem.
         */
        var left = (screen.width - width - 17) / 2;
        var top = (screen.height - height - 17) / 2;
    } else {
        /* Como se pode notar, para os outros navegadores não há o mesmo problema.
         */
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 2;    
    }
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=yes';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(url, 'windowname5', params);
    if (window.focus) { newwin.focus() }
    return false;
}

function abreJanela(url, nome, width, height, extras) {
    tope = (screen.height - height) / 2;
    lefte = (screen.width - width) / 2;
    window.open(url, nome, "width=" + width + ", height=" + height + ",top=" + tope + ",left=" + lefte + extras);
}

function EscreveFlash(caminho, width, height, fundo) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
    document.write('<param name="movie" value="' + caminho + '">');
    document.write('<param name="quality" value="high">');
    if(fundo != "N")
        document.write('<param name="wmode" value="transparent">');
    document.write('<embed src="' + caminho + '" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"');
    if(fundo != "N")
        document.write(' wmode="transparent"');
    document.write('></embed>');
    document.write('</object>');
}

function EscreveFlashYouTube(caminho, width, height) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
    document.write('<param name="movie" value="http://www.youtube.com/v/' + caminho + '&hl=en">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<embed src="http://www.youtube.com/v/' + caminho + '&hl=en" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
    document.write('</object>');
}

function EscreveFlashFlv(pasta, caminho, width, height) {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" align="middle">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="allowFullScreen" value="false" />');
    document.write('<param name="wmode" value="transparent">');
    document.write('<param name="movie" value="/Images/abreFlv.swf?video=/' + pasta + '/' + caminho + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<embed src="/Images/abreFlv.swf?video=/' + pasta + '/' + caminho + '" quality="high" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function EscreveFlashFlvAdmin(pasta, caminho, width, height) {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" align="middle">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="allowFullScreen" value="false" />');
    document.write('<param name="movie" value="../Images/abreFlv.swf?video=/' + pasta + '/' + caminho + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="wmode" value="transparent">');
    document.write('<embed src="../Images/abreFlv.swf?video=/' + pasta + '/' + caminho + '" quality="high" width="' + width + '" height="' + height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function abreGaleria(id) {
    if (id == 'geral') {
        id = "todos";
    }
    abreJanela('popGaleria.aspx?galeria=' + id, 'galeria' + id, '751', '580', '');
}

function abreVideos() {
    abreJanela('Videos.aspx', 'videos', '718', '464', '');
}

function AbreIframe() {
    if (navigator.appName.toLowerCase().indexOf("microsoft internet explorer") > -1) {
        parent.document.getElementById("conteudo").style.height = document.getElementById("content").offsetHeight;
    }
    else if (navigator.appName.toLowerCase().indexOf("netscape") > -1) {
        parent.document.getElementById("conteudo").style.height = parent.document.getElementById("conteudo").contentDocument.body.scrollHeight;
    }
}

function getFlashMovieObject(movieName)
{
    if (window.document[movieName]) 
    {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1)
    {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName]; 
    }
    else
    {
        return document.getElementById(movieName);
    }
}

function SelecionaPlaylist(idPlaylist, nomePlaylist)
{
    /*
    document.getElementById("nomePlaylistTocando").innerHTML = nomePlaylist;
    
    var objFlash = getFlashMovieObject("myytplayer");
    
    objFlash.LoadXML('http://www.saraivaconteudo.com.br/RestService.aspx?cmd=obtem_playlist&id=' + idPlaylist);
    */
    playerSC = window.open('Player.aspx?id=' + idPlaylist + '&nome=' + nomePlaylist,'playerSC','toolbar=no,location=no,titlebar=no,chrome=true,directories=no,status=no,menubar=no,scrollbars=no,scroll=no,resizable=no,copyhistory=no,screenX=50,screenY=80,left=50,top=80,width=284,height=176');
    playerSC.focus();
}

function TocaPlayer(idPlaylist)
{
    var objFlash = getFlashMovieObject("myytplayer");
    objFlash.LoadXML('http://www.saraivaconteudo.com.br/RestService.aspx?cmd=obtem_playlist&id=' + idPlaylist);
    //objFlash.LoadXML('http://mirabola/Saraiva/RestService.aspx?cmd=obtem_playlist&id=' + idPlaylist);
    //objFlash.LoadXML('http://localhost:2237/Website/RestService.aspx?cmd=obtem_playlist&id=' + idPlaylist);
}

function alteraAltura(altura)
{
    var objFlash = getFlashMovieObject("myytplayer");
    objFlash.style.height = altura + "px";
    var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    var is_ie = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
    if(is_chrome)
    {
        window.resizeTo(294, altura + 75);
    }
    else if(is_ie)
    {
        window.resizeTo(294, altura + 90);
    }
    else
    {
        window.resizeTo(294, altura + 45);
        window.innerHeight = altura + 10;
    }
}

function getWidth()  
 {  
      // Thiago Marotta Couto  
      // thiago@isbyte.com  
      // http://thiagocouto.wordpress.com/  
      // December, 06 - 2008  
      return window.innerWidth ? window.innerWidth : /* For non-IE */  
             document.documentElement ? document.documentElement.clientWidth : /* IE 6+ (Standards Compilant Mode) */  
             document.body ? document.body.clientWidth : /* IE 4 Compatible */  
             window.screen.width; /* Others (It is not browser window size, but screen size) */  
 }  
  
 function getHeight()  
 {  
      // Thiago Marotta Couto  
      // thiago@isbyte.com  
      // http://thiagocouto.wordpress.com/  
      // December, 06 - 2008  
      return window.innerHeight ? window.innerHeight : /* For non-IE */  
             document.documentElement ? document.documentElement.clientHeight : /* IE 6+ (Standards Compilant Mode) */  
             document.body ? document.body.clientHeight : /* IE 4 Compatible */  
             window.screen.height; /* Others (It is not browser window size, but screen size) */  
 }  

function SelecionaTop10(secao, caminho, link1, link2)
{
    if(arrTop10 != null)
    {
        if(arrTop10.length == 6)
        {
            document.getElementById(arrTop10[0]).style.display = secao == 0 ? "" : "none";
            document.getElementById(arrTop10[1]).style.display = secao == 1 ? "" : "none";
            document.getElementById(arrTop10[2]).style.display = secao == 2 ? "" : "none";
            document.getElementById(arrTop10[3]).style.display = secao == 3 ? "" : "none";
            document.getElementById(arrTop10[4]).style.display = secao == 4 ? "" : "none";
            document.getElementById(arrTop10[5]).style.display = secao == 5 ? "" : "none";
            
            document.getElementById("imgBtLivros").src = (secao == 0 || secao == 1) ? caminho + "top/top_livros-on.jpg" : caminho + "top/top_livros.jpg";
            document.getElementById("imgBtMusica").src = (secao == 2 || secao == 3) ? caminho + "top/top_musica-on.jpg" : caminho + "top/top_musica.jpg";
            document.getElementById("imgBtCinema").src = (secao == 4 || secao == 5) ? caminho + "top/top_dvd-on.jpg" : caminho + "top/top_dvd.jpg";
            
            document.getElementById("divOutros").style.textAlign = secao % 2 == 0 ? "left" : "right";
            
            //document.getElementById("legenda").innerHTML = secao == 5 ? 'Mais Vendidos' : 'Mais Vendidos';
            document.getElementById("legenda").innerHTML = 'Mais Vendidos';
            
            switch(secao)
            {
                case 0: //letras fic
                    document.getElementById("imagemLeft").src = caminho + "top10_cat_blu-01-on.jpg";
                    document.getElementById("imagemRight").src = caminho + "top10_cat_blu-02-off.jpg";
                    
                    document.getElementById(link1).href = "javascript:SelecionaTop10(0, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    document.getElementById(link2).href = "javascript:SelecionaTop10(1, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    break;
                case 1: //letras nao
                    document.getElementById("imagemLeft").src = caminho + "top10_cat_blu-01-off.jpg";
                    document.getElementById("imagemRight").src = caminho + "top10_cat_blu-02-on.jpg";
                    document.getElementById(link1).href = "javascript:SelecionaTop10(0, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    document.getElementById(link2).href = "javascript:SelecionaTop10(1, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    break;
                case 2: //musica cd
                    document.getElementById("imagemLeft").src = caminho + "top10_cat_pnk-01-on.jpg";
                    document.getElementById("imagemRight").src = caminho + "top10_cat_pnk-02-off.jpg";
                    document.getElementById(link1).href = "javascript:SelecionaTop10(2, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    document.getElementById(link2).href = "javascript:SelecionaTop10(3, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    break;
                case 3: //musica dvd
                    document.getElementById("imagemLeft").src = caminho + "top10_cat_pnk-01-off.jpg";
                    document.getElementById("imagemRight").src = caminho + "top10_cat_pnk-02-on.jpg";
                    document.getElementById(link1).href = "javascript:SelecionaTop10(2, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    document.getElementById(link2).href = "javascript:SelecionaTop10(3, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    break;
                case 4: //cinema dvd
                    document.getElementById("imagemLeft").src = caminho + "top10_cat_grn-01-on.jpg";
                    document.getElementById("imagemRight").src = caminho + "top10_cat_grn-02-off.jpg";
                    document.getElementById(link1).href = "javascript:SelecionaTop10(4, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    document.getElementById(link2).href = "javascript:SelecionaTop10(5, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    break;
                case 5: //cinema
                    document.getElementById("imagemLeft").src = caminho + "top10_cat_grn-01-off.jpg";
                    document.getElementById("imagemRight").src = caminho + "top10_cat_grn-02-on.jpg";
                    document.getElementById(link1).href = "javascript:SelecionaTop10(4, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    document.getElementById(link2).href = "javascript:SelecionaTop10(5, '" + caminho + "', '" + link1 + "', '" + link2 + "');void(0);";
                    break;
            }
        }
    }
}

function LegendaCampo(objeto)
{
    if(objeto.value == 'Faça aqui sua busca...')
    {
        objeto.value = '';
    }
}

function ToggleDisplay(id)
{
    if(document.getElementById(id).style.display == 'none')
        document.getElementById(id).style.display = 'block';
    else
        document.getElementById(id).style.display = 'none';
}