function RSSHandler(n) {
    this.k = n;
};

RSSHandler.prototype = {
    e: function(ps) {
        var d; if (document.all && !window.opera) {
            d = new ActiveXObject("Microsoft.XMLDOM");
            d.loadXML(ps.responseText);
        }
        else {
            d = new DOMParser().parseFromString(ps.responseText, 'text/xml');
        }
        var c = d.getElementsByTagName('item');
        var geoLat = null;
        var geoLon = null;
        for (i = 0; i < c.length; i++) {
            var m = 0; var l = 0; var g = 0; var f = 99; for (j = 0; j < c[i].childNodes.length; j++) {
                if (c[i].childNodes[j].nodeType != 1) { continue; }
                if (c[i].childNodes[j].tagName == 'title') {
                    var cleanTitle = c[i].childNodes[j].firstChild.nodeValue;
                    var title = c[i].childNodes[j].firstChild.nodeValue;
                }
                if (c[i].childNodes[j].tagName == 'link') {
                    var link = c[i].childNodes[j].firstChild.nodeValue;
                }
                if (c[i].childNodes[j].tagName == 'ProviderLogo') {
                    var provLogo = '<img alt="P4" src="./images/TrafikkInfo/' + c[i].childNodes[j].firstChild.nodeValue + '" style="vertical-align: middle" />';
                }
                if (c[i].childNodes[j].tagName == 'pubDate') {
                    var pDate = c[i].childNodes[j].firstChild.nodeValue;
                }
                if (c[i].childNodes[j].tagName == 'Picture') { var p = './images/TrafikkInfo/' + c[i].childNodes[j].firstChild.nodeValue; }
                if (c[i].childNodes[j].tagName == 'Latitude') { geoLat = c[i].childNodes[j].firstChild.nodeValue; }
                if (c[i].childNodes[j].tagName == 'Longitude') { geoLon = c[i].childNodes[j].firstChild.nodeValue; }
                if (geoLat != null && geoLon != null && p != null && pDate != null && provLogo && link != null && title != null) {
                    var coords = new Coordinate(Number(geoLat), Number(geoLon));
                    var backgroundimage = './images/TrafikkInfo/TrafikkDetaljHeading.png';
                    var headerDiv_1 = '<div style="background-image:url(\'';
                    var headerDiv_2 = '\'); height: 26px; font-family: Verdana; font-size:small; color:Black; width:340px; border-style:none">';
                    var headerDiv_3 = '<table><tr><td></td></tr><tr><td style="padding-left:15px"><b>Trafikkinfo:</b></td></tr></table></div>';
                    var titleDiv_1 = '<div style="background:white; font-family: Verdana; font-size:small; color:Black; width:340px">';
                    var titleDiv_2 = '<table style="width:340px"><tr style="height: 50px"><td colspan="2" style="padding-left:15px"><b>';
                    var titleDiv_3 = '</b></td></tr>';
                    var nTitle = headerDiv_1 + backgroundimage + headerDiv_2 + headerDiv_3 + titleDiv_1 + titleDiv_2 + title + titleDiv_3;  //+ +titleDiv_4;
                    var linkDiv_1 = '<tr style="height:50px"><td colspan="2" style="padding-left:15px">';
                    var linkDiv_2 = '</td></tr><tr><td style="padding-left:15px; valign="middle">Levert&nbsp;av:</td><td align="left" style="width:330px">'
                    var linkDiv_3 = '</td></tr><tr><td colspan="2" style="padding-left:15px; font-size:smaller">Sist&nbsp;oppdatert:&nbsp;'
                    var linkDiv_4 = '</table></div>';
                    var nLink = linkDiv_1 + link + linkDiv_2 + provLogo + linkDiv_3 + pDate + linkDiv_4;
                    nTitle = nTitle + nLink;
                    this.k.addAnnotation(new Annotation(coords, nTitle, null, p, 0, -48, null, null, 'p4-traffic-group'));
                    geoLat = null;
                    geoLon = null;
                    p = null;
                    pDate = null;
                    provLogo = null;
                    link = null;
                    title = null;
                }
            }
        }
    }
,
    loadGeoRSS: function(url) {
        new Ajax.Request(url, { method: 'get', onSuccess: this.e.bind(this), onFailure: function() { alert('Unable to load RSS url.') } });
    }
};
