OpenLayers.Feature.WFS.Pics = OpenLayers.Class.create();
OpenLayers.Feature.WFS.Pics.prototype = 
OpenLayers.Class.inherit( OpenLayers.Feature.WFS, {
    
    createMarker: function() {        

        this.marker = OpenLayers.Feature.prototype.createMarker.apply(this); 

        if(this.marker != null) {
            this.marker.events.register("click", this, this.createPopup);
            if(this.layer.opacity && this.layer.opacity != 1) {
                this.marker.setOpacity(this.layer.opacity);
            }
        }

        return this.marker;
    },
    
    /*
    */
    createPopup: function() {
        
        if(this.popup == null) {
            this.popup = OpenLayers.Feature.prototype.createPopup.apply(this, [true]);

            if(this.popup != null) {
                
								//var html = "Etykieta tekstowa"; //+ this.data.pic.file;
                var html = "<br/>Nazwa: "+ this.data.pic.nazwa;
								if (this.data.pic.link != null){
									html += "<br/><br/>Opis: <a href=\"http://" + this.data.pic.link + "\" target=\"_blank\">" + this.data.pic.link + "</a>";
									}
								else {
									html += "<br/><br/>Opis: <a href=\"http://www.sejmik.kielce.pl\" target=\"_blank\">www.sejmik.kielce.pl</a>";//+ this.data.pic.link;
								}
                this.popup.setBackgroundColor("#DDDDDD");
								this.popup.setContentHTML(html);
                //this.popup.setSize(new OpenLayers.Size(100, 80));
                this.layer.map.addPopup(this.popup);              
            }
            return this.popup;
        }
        else {
            this.layer.map.removePopup(this.popup);
            this.popup.destroy();
            this.popup = null;
        }
    },
    
    processXMLNode: function(xmlNode) {
        var data = OpenLayers.Feature.WFS.prototype.processXMLNode.apply(this, arguments);

        //var file = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/wfs", "gml", "TEKST")[0]);
        var opis = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://mapserver.gis.umn.edu/mapserver", "ms", "WARSTWA")[0]);
				var nazwa = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://mapserver.gis.umn.edu/mapserver", "ms", "TEKST")[0]);
        var link = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://mapserver.gis.umn.edu/mapserver", "ms", "URL")[0]);
				//var height = xmlNode.childNodes[1].attributes[1].nodeValue;
				var height = "x";

        var aspect = 1;
        
        var pic = { nazwa: nazwa, opis: opis, link: link};

				data.pic = pic;
        //data.pic = pic;
        //data.icon = new OpenLayers.Icon("http://frumin.net/rpa/trx/pics/fb2br/icons/" + file, isize);

        return data;
        
    },
     
    CLASS_NAME: "OpenLayers.Feature.WFS.Pics"
    
});

OpenLayers.Feature.WFS.Pics2 = OpenLayers.Class.create();
OpenLayers.Feature.WFS.Pics2.prototype = 
OpenLayers.Class.inherit( OpenLayers.Feature.WFS, {
    
    createMarker: function() {        

        this.marker = OpenLayers.Feature.prototype.createMarker.apply(this); 

        if(this.marker != null) {
            this.marker.events.register("click", this, this.createPopup);
            if(this.layer.opacity && this.layer.opacity != 1) {
                this.marker.setOpacity(this.layer.opacity);
            }
        }

        return this.marker;
    },
    
    /*
    */
    createPopup: function() {
        
        if(this.popup == null) {
            this.popup = OpenLayers.Feature.prototype.createPopup.apply(this, [true]);

            if(this.popup != null) {
                
								//var html = "Etykieta tekstowa"; //+ this.data.pic.file;
                var html = "<br/>Nazwa: "+ this.pic.nazwa;
								html += "<br/><br/>Opis: <a href=\"http://www.sejmik.kielce.pl\" target=\"_blank\">www.sejmik.kielce.pl</a>";//+ this.data.pic.link;
                this.popup.setBackgroundColor("#DDDDDD");
								this.popup.setContentHTML(html);
                //this.popup.setSize(new OpenLayers.Size(100, 80));
                this.layer.map.addPopup(this.popup);              
            }
            return this.popup;
        }
        else {
            this.layer.map.removePopup(this.popup);
            this.popup.destroy();
            this.popup = null;
        }
    },
    
    processXMLNode: function(xmlNode) {
        //var data = OpenLayers.Feature.WFS.prototype.processXMLNode.apply(this, arguments);

        //var file = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/wfs", "gml", "TEKST")[0]);
        var szerokosc = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://mapserver.gis.umn.edu/mapserver", "ms", "SZEROKOSC")[0]);
				var nazwa = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://mapserver.gis.umn.edu/mapserver", "ms", "NAZWA")[0]);
        var wysokosc = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://mapserver.gis.umn.edu/mapserver", "ms", "WYSOKOSC")[0]);
				//var height = xmlNode.childNodes[1].attributes[1].nodeValue;
				var height = "x";

        var aspect = 1;
        
        var pic = { nazwa: nazwa, szerokosc: szerokosc, wysokosc: wysokosc};

				//data.pic = pic;
        //data.pic = pic;
        //data.icon = new OpenLayers.Icon("http://frumin.net/rpa/trx/pics/fb2br/icons/" + file, isize);

        return pic;
        
    },
     
    CLASS_NAME: "OpenLayers.Feature.WFS.Pics2"
    
    
    
});


