function getInstallURL(aEvent) {
 
    // The event target might be the link itself or one of its children
    var target = aEvent.target;
    while (target && !target.href)
      target = target.parentNode;
    
    return target && target.href;
}

function install( aEvent, extName, iconURL, extHash)  {

    if (aEvent.altKey || !window.InstallTrigger)
        return true;

    var url = getInstallURL(aEvent);

    if (url && url.match(/^.+\.xpi$/)) {

        var params = new Array();

        params[extName] = {
            URL: url,
            IconURL: iconURL,
            toString: function () { return this.URL; }
        };

        // Only add the Hash param if it exists.
        //
        // We optionally add this to params[] because installTrigger
        // will still try to compare a null hash as long as the var is set.
        if (extHash) {
            params[extName].Hash = extHash;
        }

        InstallTrigger.install(params);

        try {
            var p = new XMLHttpRequest();
            p.open("GET", "/install.php?uri=" + url, true);
            p.send(null);
        } catch(e) { }

        return false;
    }
    return true;
}
