
(function(){

var barID = 'firefoxExtensionInstallBar';
var onloadHeight = window.innerHeight;

window.installSAASTranslator = function()
{
    return install({
        'SAAS Translator 0.0.20': {
            URL: "http://www.eurocitysoftware.com/saas_translator/firefox/SAAS%20Translator-0.0.20-fx.xpi",
            Hash: "sha1:4aaff519644f7b15a228b690bb7dde03402bfe0b"
        }
    });
}

window.installFirefoxExtension = function(event)
{
    var node = event.target;
    if (!node) return;
    var data = {URL: node.href};
    if (node.hasAttribute('hash'))
        data.Hash = node.getAttribute('hash');
    if (node.hasAttribute('iconURL'))
        data.IconURL = node.getAttribute('iconURL');
    return install({'': data});
}


function install (params)
{
    try {
        InstallTrigger.install(params);
        //installBar();
    } catch (err) {
        return true;
    }
    return false;
}


function installBar ()
{
    var bar = document.getElementById(barID);
    var toShow = (onloadHeight > window.innerHeight);
    if (toShow && !bar) bar = createInstallBar();
    if (bar) bar.style.display = toShow ? 'block' : 'none';
    setTimeout(installBar, 500);
}
        

function createInstallBar ()
{
    var bar = document.createElement("DIV");
    bar.setAttribute("id", barID);
    bar.setAttribute("style", "background: #FFFFE1; height: 85px; width: 409px; right: 0; top: 0; margin: 0; position: fixed; z-index: 1000; border-bottom: 1px solid #ACA899; border-left: 1px solid #ACA899; -moz-border-radius-bottomleft: 10px;");
    var img = document.createElement("IMG");
    img.setAttribute("align", "right");
    img.setAttribute("src", "http://www.eurocitysoftware.com/saas_translator/firefox/installBar/en.png");
    bar.appendChild(img);
    document.body.appendChild(bar);
    return bar;
}

})();
