// JavaScript Document

function init() {
    //settingColors();
    //abrirProd();
}

function MostrarMensaje(mensaje) {
    alert(mensaje);

}

/* El maravillo insertaContenidos */
function unInner(lugar, loqueva) {
    var receptor = document.getElementById(lugar);
    var unhtml = loqueva;
    receptor.innerHTML = unhtml;
}

/* El maravillo rastreador de Clases */
function identClases(laClase, etiqueta, contenedor, accion) {
    var contenedorVar = document.getElementById(contenedor);
    var tipoEtiqueta = contenedorVar.getElementsByTagName(etiqueta);
    if (tipoEtiqueta.length > 0) {
        for (i = 0; i < tipoEtiqueta.length; i++) {
            if (tipoEtiqueta[i].className == laClase) {
                switch (accion) {
                    case "quitarClase":
                        tipoEtiqueta[i].className = "";
                        break;

                    case "bgTop":
                        tipoEtiqueta[i].style.backgroundPosition = "top";
                        break;

                    case "hide":
                        tipoEtiqueta[i].style.display = "none";
                        break;
                }
            }
        }
    }
}


function abrirVentana(unContenedor, unAncho, unAlto) {
    var envioUnContenedor = document.getElementById(unContenedor).value;
    unInner('insertarCont', envioUnContenedor);
    var tamanyoContainer = document.getElementById('container').offsetHeight;
    document.getElementById('base').style.height = tamanyoContainer + "px";
    document.getElementById('base').style.opacity = ".01";
    document.getElementById('base').style.display = "block";
    document.getElementById('emergente').style.display = "block";
    document.getElementById('emergente').style.width = (unAncho + 36) + "px";
    document.getElementById('insertarCont').style.width = unAncho + "px";
    document.getElementById('emergente').style.height = unAlto + "px";
    document.getElementById('emergente').style.visibility = "hidden";
    //centrarModal(unAncho,unAlto);
    unAlto = $("#emergente").children().height();
    setTimeout("centrarModal(" + unAncho + "," + unAlto + ");", 500);
    $('.alphaValidation').alpha();
    $('.emailValidation').alphanumeric({ allow: ".@_-", nocaps: true });
    $("#aspnetForm").validationEngine('attach');
}

function abrirVentanaContenido(contenido, unAncho, unAlto) {
    var envioUnContenedor = contenido;
    unInner('insertarCont', envioUnContenedor);
    var tamanyoContainer = document.getElementById('container').offsetHeight;
    document.getElementById('base').style.height = tamanyoContainer + "px";
    document.getElementById('base').style.opacity = ".01";
    document.getElementById('base').style.display = "block";
    document.getElementById('emergente').style.display = "block";
    document.getElementById('emergente').style.width = (unAncho + 36) + "px";
    document.getElementById('insertarCont').style.width = unAncho + "px";
    document.getElementById('emergente').style.height = unAlto + "px";
    document.getElementById('emergente').style.visibility = "hidden";
    //centrarModal(unAncho,unAlto);
    setTimeout("centrarModal(" + unAncho + "," + unAlto + ");", 5);
}

function cerrarVentana(cerrarVent) {
    document.getElementById(cerrarVent).style.display = "none";
    document.getElementById('base').style.display = "none";
    $("#aspnetForm").validationEngine('hideAll');
    $("#aspnetForm").validationEngine('detach');
}



//setTimeout("centrarModal("+unAncho+","+unAlto+");", 500);

function centrarModal(centralAncho, centralAlto) {
    document.getElementById('emergente').style.marginLeft = "-" + Math.round(centralAncho / 2) + "px";
    document.getElementById('emergente').style.marginTop = "-" + Math.round(centralAlto / 2) + "px";
    document.getElementById('emergente').style.visibility = "visible";
}

function comentar() {
    location.href = location.href + '#comentarios';
    document.getElementById('botonComentar').style.display = "none";
    document.getElementById('cajaComentar').style.display = "block";
}

function globoIn(cualGlobo) {
    document.getElementById(cualGlobo).style.display = "block";
    var alturaGlobo = document.getElementById(cualGlobo).offsetHeight;
    document.getElementById(cualGlobo).style.marginTop = "-" + (alturaGlobo + 18) + "px";
}

function globoOut() { identClases('globo', 'span', 'receta', 'hide'); }

function login() { document.getElementById('login').style.display = "block"; }
function cerrarLogin() { document.getElementById('login').style.display = "none"; }

function ayuda() { document.getElementById('ayuda').style.display = "block"; }
function cerrarAyuda() { document.getElementById('ayuda').style.display = "none"; }

function mostrarComments(cualesComments) {
    if (document.getElementById(cualesComments).style.display == "block") {
        document.getElementById(cualesComments).style.display = "";
    }
    else {
        document.getElementById(cualesComments).style.display = "block";
    }
}

function vintage(cualVintage) {
    identClases("vintDiv", "div", "vintage", "hide");
    document.getElementById(cualVintage).style.display = "block";
}


function carruselProd(carAbroDiv, iluminoLi) {
    identClases("plsHide", "div", "recetaDia", "hide");
    document.getElementById(carAbroDiv).style.display = "block";
}


function showErrorGrowl(message) {
    $.growlUI('', message);
    $(".growlUI").css("background", "url('/Images/error48.png') no-repeat 5px 5px");
}

function showOKGrowl(message) {
    $.growlUI('', message);
    $(".growlUI").css("background", "url('/Images/error48.png') no-repeat 5px 5px");
}
