
googleMaps = function(options) {
		
    var defaults = {
        div: 'myMap',
        imageUrl: '/images/icons/map',
        latitude: 41.9442,
        longitude: -70.02914,
        zoom: 12,
        width: '558',
        height: '320'
    };
		
    this.opts = jQuery.extend(defaults, options);		
    this.opts.jDiv = jQuery('#' + this.opts.div);

};
		
googleMaps.prototype.opts = {};
googleMaps.prototype.map = null;


googleMaps.prototype.load = function() {
		
    this.opts.jDiv.css({
        position: 'relative',
        width: this.opts.width + 'px',
        height: this.opts.height + 'px',
        zIndex: '1'
    });

    latlng = new google.maps.LatLng(this.opts.latitude, this.opts.longitude);
    options = {
        zoom: this.opts.zoom,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    this.map = new google.maps.Map(document.getElementById(this.opts.div), options);

};
	
googleMaps.prototype.addIcon = function(icon, point, title, text) {
		
    icon = this.opts.imageUrl + '/icons/map/' + icon + '.gif';

    var infowindow = new google.maps.InfoWindow({
        content: "<h3 style='padding-top: 0;'>" + title + "</h3>" + text
    });

    var marker = new google.maps.Marker({
        position: point,
        map: this.map,
        title: title,
        icon: icon
    });

    google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(this.map, marker);
    });

};
	
googleMaps.prototype.addFeed = function(url, callback) {

    var self = this;

    jQuery.get(url, {}, function(xml) {
        jQuery('item', xml).each(function(i) {
            itemdata = jQuery(this);
            title = itemdata.find("title").text();
            text = itemdata.find("description").text();
            latitude = itemdata.find("latitude").text();
            longitude = itemdata.find("longitude").text();
            icon = itemdata.find("icon").text();

            point = self.point(latitude, longitude);
            self.addIcon(icon, point, title, text);

        });

        callback.call();

    });
}

googleMaps.prototype.center = function(point) {
    this.map.setCenter(point)
};
	
googleMaps.prototype.point = function(latitude, longitude) {
    return new google.maps.LatLng(latitude, longitude);
};
	

document.write(unescape("%3Cscript src='http://maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));

	
