/**
 * @requires OpenLayers/Feature/Vector.js
 * @requires OpenLayers/Geometry/Point.js
 */

OpenLayers.Format.CSV = OpenLayers.Class(OpenLayers.Format, {
	initialize: function(options) {
		OpenLayers.Format.prototype.initialize.apply(this, [options]);
	},
	
	read: function(text) {
		var lines = text.split('\n');
		var features = new Array(lines.length-1);
		for (var lcv = 0; lcv < (lines.length - 1); lcv++) {
			var vals = lines[lcv].split('\t');
			
			features[lcv] = new OpenLayers.Feature.Vector(
				new OpenLayers.Geometry.Point( vals[1], vals[0] ), 
				{
					csv_style: vals[3],
					csv_text: vals[2]
				});
		}
		if (this.internalProjection && this.externalProjection) {
            for (var g = 0, featLength = features.length; g < featLength; g++) {
                features[g].geometry.transform(this.externalProjection,
                                    this.internalProjection);
            }
        }
		return features;
	},
	
	CLASS_NAME: "OpenLayers.Format.CSV" 
});

