﻿var sUrl = "";

/*  
puedes hacer que salga <img alt="Error" src="imagenes/comun/popupError.gif" /> para errores
y <img alt="OK" src="imagenes/comun/popupOk.gif" /> para ok
*/

function writeFlash(url, w, h) {
    var peli;
    peli = '<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=' + w + ' height=' + h + '>';
    peli += '<param name="allowScriptAccess" value="sameDomain" />';
    peli += '<param name="movie" value=' + url + '>';
    if (document.all)
        peli += '<param name="quality" value="high">';
    peli += '<param name="wmode" value="transparent">';
    peli += '<embed src=' + url + ' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" wmode="transparent" width=' + w + ' height=' + h + '></embed>';
    peli += '</object>';
    document.write(peli);
}

function popup(idObra) {
    var w = window.open("/ObraAmpliada.aspx?id=" + idObra, "ImagenAmpliada", "location=0,toolbar=0,status=1,resizable=1,scrollbars=1,width=630,height=600");
    w.focus();
}

function mostrarPopup(url,ancho,alto) {
    var w = window.open(url, "ImagenAmpliada", "location=0,toolbar=0,status=1,resizable=1,scrollbars=1,width=" + ancho + ",height=" + alto);
    w.focus();
}	

function MostrarPopup(texto, url, esError) {
    var t = document.getElementById("txtMensaje");
    t.innerHTML = texto;
    if (url != "") {
        sUrl = url;
    }
    var txt = "";
    var img = document.getElementById("imgMensaje");
    if (esError) {
        img.setAttribute("alt", "Error");
        img.setAttribute("src", "imagenes/comun/popupError.gif");
    }
    else {
        img.setAttribute("alt", "OK");
        img.setAttribute("src", "imagenes/comun/popupOk.gif");
    }

    MostrarCapa();
}

function MostrarCapa() {

    window.onscroll = function() {
        position('alert');
    }
    opacity('velo', 50);
    resize('velo');
    show('velo');
    show('alert');
    position('alert');
}

function OcultarCapa() {

    hide('velo');
    hide('alert');

    var capa = document.getElementById("txtMensaje");
    capa.innerHTML = "";
    window.onscroll = function() {

    }

    if (sUrl != "") {
        window.location = sUrl;
        sUrl = "";
    }
}

function MostrarInfo() {

    window.onscroll = function() {
        position('info');
    }
    opacity('velo', 50);
    resize('velo');
    show('velo');
    show('info');
    position('info');
}

function OcultarInfo() {

    hide('velo');
    hide('info');

    var capa = document.getElementById("txtInfo");
    capa.innerHTML = "";
    window.onscroll = function() {

    }

    if (sUrl != "") {
        window.location = sUrl;
        sUrl = "";
    }
}

function OcultarFicha() {
    hide('FichaObraPop');
    hide('veloPop');
}

function opacity(div, opacity) {
    var capa = document.getElementById(div);
    if (capa) {
        // opacity to %
        capa.setAttribute("style", "opacity:0." + opacity + ";")
        if (capa.style.setAttribute) // IE
            capa.style.setAttribute("filter", "alpha(opacity=" + opacity + ");backgro")
    }
}


function resize(div) {
    var htmlheight = document.body.clientHeight;
    var windowheight = window.screen.height;
    var frame = document.getElementById(div);
    if (htmlheight > windowheight) {
        frame.style.height = htmlheight + "px";
    }

}

function position(div) {
    var thebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
    var top = document.all ? thebody.scrollTop : pageYOffset;
    var px = document.all ? "" : "px";
    var capa = document.getElementById(div);
    var windowheight = window.screen.height;
    if (capa) {

        var valTop = 0;
        valTop = 0;
        capa.style.top = (top) + px;
        //document.getElementById("velo").style.top = top + px;
    }
}

function show(div) {
    var capa = document.getElementById(div);
    if (capa && capa.style.display != "block") {
        capa.style.display = "block";
    }
}

function hide(div) {
    var capa = document.getElementById(div);
    if (capa) {
        capa.style.display = "none";
    }
}

function cambiaColor(boton, capa) {
    document.getElementById(capa).style.backgroundColor = "#E3E3E3";
}

function quitaColor(boton, capa) {
    document.getElementById(capa).style.backgroundColor = "#CCCCCC";
}

function SendVotacion(encID) 
{
    var frm = document.getElementById("mainForm");
    var enc = frm["Res_Encuesta_" + encID];
    var i;
    for (i = 0; i < enc.length; i++) {
        if (enc[i].checked)
            break;
    }

    if (enc[i]) {
        frm["AccionVotacion_" + encID].value = enc[i].value;
        frm.submit();
    }
}