var cvMultipleGooglemaps = new Class({

	Implements: [Chain, Options],

	options: {
		map_prev_width: 300,				//map height
		map_prev_height: 200,				//map width
		map_type: 'G_SATELLITE_MAP',		//type of the map
	},

	initialize: function(options){
		this.setOptions(options);  

		if(!GBrowserIsCompatible()){
			alert('browser not compatible');
		}

		this.maps = [];
		this.mapType();
		this.preparePrevMaps();

		if(this.maps.length == 0){return ; }

		this.initPrevEasyMaps();
	},

	initPrevEasyMaps: function(){
		this.maps.each(function(map){
			this.loadPrevMap(map);
		},this);
	},

	mapType: function(){
		switch(this.options.map_type){
			case 'G_NORMAL_MAP':
				this.maptype = G_NORMAL_MAP;
			break

			case 'G_SATELLITE_MAP':
				this.maptype = G_SATELLITE_MAP;
			break

			case 'G_HYBRID_MAP':
				this.maptype = G_HYBRID_MAP;
			break

			case 'G_PHYSICAL_MAP':
				this.maptype = G_PHYSICAL_MAP;
			break

			default:
				alert('Sorry, unknown map type');
			break
		}
	},

	loadPrevMap: function(div){
		$(div).set('styles', {
			'height': this.options.map_prev_height,
			'width': this.options.map_prev_width
		});

		var map = new GMap2($(div));
		map.setMapType(this.maptype);
        map.setCenter(new GLatLng( 53.10349, 5.14542 ), 10);
	},

	preparePrevMaps: function(rEl){
		var maps_div = [];
		var div_maps = (rEl) ? rEl : $$('div.googlemaps');

		div_maps.each(function(div){
			if(div.id && div.id.test(/^googlemaps/i)){
				if(div.id.length > 7 && !this.maps.contains(div.id)){
					this.maps.push(div.id);
				}
				maps_div.push(div);
			}
		},this);
	}
});