﻿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 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;
        /*
        if (windowheight > 768) 
        {
        valTop = (top + 24 - (windowheight - capa.offsetHeight) / 2);
        }
        else 
        {
        valTop = -220;
        }*/
        valTop = 0;
        capa.style.top = 200 + px;
        capa.style.marginTop = valTop + px;
        veloFlashDemo.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 == "block") {
        capa.style.display = "none";
    }
}

function showVelo() {

    window.onscroll = function() {
        position('flashDemo');
    }
    opacity('veloFlashDemo', 50);
    resize('veloFlashDemo');
    show('veloFlashDemo');
    show('flashDemo');
    position('flashDemo');
}

function closeVelo() {
    hide('veloFlashDemo');
    hide('flashDemo');

    var capa = document.getElementById("flashDemo");
    capa.innerHTML = "";
    window.onscroll = function() {

    }
}
