(function() {

    var __rand = Math.round(Math.random() * 100000);
    document.write('<div id="widget_' + __rand + '"></div>');
    
    (function(elem) {
    
        var ie = (!window.XMLHttpRequest || document.expando),
            width = 0,
            height = 300,
            tmp,
            params = {},
            html = '<iframe';
        
        if(ie) {
            width = elem.offsetWidth;
        } else {
            tmp = document.defaultView.getComputedStyle(elem, "").getPropertyValue("width");
            width = tmp.replace(/px/,'');
        }
        height = Math.max(height, width*2);
        params = {
            frameBorder: 0,
            marginWidth: 0,
            marginHeight: 0,
            scrolling: "no",
            width: "100%",
            height: height + 'px',
            src:'http://www.sjoraddning.se/widgets/feed/?height='+height+'&amp;width='+width
        }

        for (var key in params ) {
            var val = '"'+params[key]+'"';
            html += ' '+key+'='+val;
        }
    
        html += '></iframe>';
        window.setTimeout(function() {
            elem.innerHTML = html;
        }, 1);

    })(document.getElementById('widget_'+__rand));

})();

