// Copyright © 2002-2008 Peter Krefting

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// If you do not have a copy of the GNU General Public License write
// to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
// 02139, USA or visit http://www.gnu.org/

// Check if we are using broken browser (i.e MSIE), that need
// Microsoft-proprietary non-standard code to display transparent PNGs.
function needmsiefudge(url)
{
    var agt=navigator.userAgent.toLowerCase();
    var is_msie = (agt.indexOf('msie') != -1) &&
                  (agt.indexOf('opera') == -1);
    var is_mac = (agt.indexOf('mac') != -1);

    if (is_msie && !is_mac)
    {
        var is_msie5 = (agt.indexOf('msie 5') != -1);
        var is_msie50= (agt.indexOf('msie 5.0') != -1);
        var is_msie6 = (agt.indexOf('msie 6') != -1);
        if (!is_msie50 && (is_msie5 || is_msie6))
        {
            // SVG overrides our logo
            if (url.indexOf('softwolveslogo') != -1)
            {
                var svg;
                try
                {
                    svg = new ActiveXObject("Adobe.SVGCtl");
                }
                catch (e) {}
                if (svg)
                {
                    return 0;
                }
            }
            
            return 1;
        }
    }
    return 0;
}

// Function to rewrite the <h1> to Microsoft-proprietary non-standard
// stuff if needed
// Parameters:
//  url    URL to the image to write and <object> for
//  width  Width of the image
//  height Height of the image
function msiefudgeimage(url, width, height)
{
    if (needmsiefudge(url))
    {
        var header = document.getElementById("logotop");
        header.innerHTML = 
            '<div style="position:relative;width:' + width +
            'px;height:' + height +
            "px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
            url + "',sizingMethod='scale);\">&nbsp;<div style='display:none;'>&nbsp;<\/div><\/div>";
    }
}

