﻿// JScript File
function abrePopup() {
    $(document).ready(function() {
        $('a[href=#messages]').click();
    });
}

function openPopup(url, titulo, largura, altura) {
    window.open(url, titulo , 'scrollbars=1, resizable=1, width=' + largura + ', height=' + altura + ', top=10%, left=10%'); 
}

function confirmaExcluir() {
    return confirm('Deseja realmente excluir os itens selecionados?');
}

function confirmaZerarVotosEnquete() {
    return confirm('Deseja realmente zerar os votos da enquete?');
}

function confirmaExcluirAlbum() {
    return confirm('Deseja realmente excluir o álbum? \n\n Obs. Todas as fotos contidas no álbum serão excluídas.');
}

function confirmaExcluirprofissional() {
    return confirm('Deseja realmente excluir os itens selecionadso? \n\n');
}


function confirmaExcluirAvaliacao() {
    return confirm('Deseja realmente excluir a avaliação? \n\n Obs. Todas as questões contidas na avaliação serão excluídas.');
}

function confirmaAtivarDesativarEnquete(ativo) {
    if (ativo == 1) {
        return confirm('Deseja realmente desativar a enquete?');
    } else {
        return confirm('Deseja realmente ativar a enquete?');
    }
}

function confirmaAtivarDesativarConteudo(ativo) {
    if (ativo == 1) {
        return confirm('Deseja realmente desativar o conteúdo?');
    } else {
        return confirm('Deseja realmente ativar o conteúdo?');
    }
}

function confirmaAtivarDesativarItem(ativo) {
    if (ativo == 1) {
        return confirm('Deseja realmente desativar o item?');
    } else {
        return confirm('Deseja realmente desativar o item?');
    }
}


function confirmaAtivarDesativarProfissional(ativo) {
    if (ativo == 1) {
        return confirm('Deseja realmente desativar o profissional?');
    } else {
        return confirm('Deseja realmente ativar o profissional?');
    }
}


function expandeRetrai(elementoID, imgID) {
    var elemento = document.getElementById(elementoID);
    var img = document.getElementById(imgID);
    if (elemento.style.display == 'none') {
        elemento.style.display = 'block';
        img.src = '../images/misc/retrair.jpg'
    } else {
        elemento.style.display = 'none';
        img.src = '../images/misc/expandir.jpg'
    }
}

function mostraOculta(elementoID) {
    var elemento = document.getElementById(elementoID);    
    if (elemento.style.display == 'none') {
        elemento.style.display = 'block';    
    } else {
        elemento.style.display = 'none';      
    }
}

function mostraOcultaRecurso(img, elementoID) {
    var elemento = document.getElementById(elementoID);    
    if (elemento.style.display == 'none') {
        elemento.style.display = 'block';
        img.src = "../css/website/medplus/images/ico_menos.png"   
    } else {
        elemento.style.display = 'none';
        img.src = "../css/website/medplus/images/ico_mais.png"    
    }
}

function alternaElemento(show, hide) {
    var elementoShow = document.getElementById(show);    
    var elementoHide = document.getElementById(hide);  
    var BtnElementoShow = document.getElementById('btn_' + show);
    var BtnElementoHide = document.getElementById('btn_' + hide);          
    
    BtnElementoShow.className = 'BtnLaranja'; 
    BtnElementoHide.className = 'BtnAzul';        
    
    elementoShow.style.display = 'block'; 
    elementoHide.style.display = 'none';         
}


function selecionaMenu(id) {
    for (i in menus) {   
       var menu = document.getElementById(menus[i])    
       var conteudo = document.getElementById('Conteudo_' + menus[i])       
       if (menus[i] == id) {
            menu.className = 'Fonte_Item_Clicado'
            conteudo.style.display = 'block';
       } else {
            menu.className = 'Fonte_Item_Normal'
            conteudo.style.display = 'none';
       }
    }
}

function limpaCampos() {
    for (i in campos) {   
       var campo = document.getElementById(campos[i])       
       campo.value = valores[i];
    }
    document.getElementById(campos[0]).focus;
}

function validaForm() {
    var retorno = true;
    for (i in campos) {   
       var campo = document.getElementById(campos[i]) 
                     
       if (campo.value == valores[i]) {
            campo.style.backgroundColor = 'red';
            scroll(0,0);
            retorno = false;     
       } else {
            //campo.style.backgroundColor = 'White';
       }
       
    }
    
    if (!retorno) {
        alert("Os campos marcados são de preenchimento obrigatório.");
    }
    
    return retorno;
}

function mostraEstado(estado) {
    alert(estado);
}