var domMap = new Class({
	map : null,
	markerStore:null,
	Implements:[Options,Events],
	options: {
		center:[0,0],
		zoom:9,
		size:[450,450]
	},
	initialize:function(id,opt){
		// setting options...
		if($defined(opt.size) && opt.size =='max'){
			var sizes = $(window).getSize();
			opt.size = [sizes.x,sizes.y];
		}		
		this.setOptions(opt);
		this.setupMap(id);
	},
	setMarkerStore:function(store){
		this.markerStore = store;
	},
	getMarkerStore:function(){
		return this.markerStore;
	},
	getMarkers:function(){
		var store = this.getMarkerStore();
		if($defined(store)){
			return store.getMarkers();
		}
	},
	getVisibleMarkers:function(){
		var store = this.getMarkerStore();
		if($defined(store)){
			return store.getVisibleMarkers();
		}
	},
	setupMap:function(id){
		try{
			var googleMap = new GMap2(document.getElementById(id), {
				size:new GSize(parseInt(this.getOptions().size[0]),parseInt(this.getOptions().size[1]))
			});
			googleMap.setCenter(new GLatLng( parseFloat(this.getOptions().center[0]),parseFloat(this.getOptions().center[1]) ), parseInt(this.getOptions().zoom));
			googleMap.addControl(new GLargeMapControl3D(),new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,33)));
			googleMap.addControl(new GMapTypeControl());
			this.map = googleMap;
		}catch(e){
			this.log('unable to create map');
			return false;
		}
	},
	getOptions:function(){
		return this.options;
	},
	getMap:function(){
		return this.map;
	},
	populateMarker:function(){
		var markers = this.getMarkers();
		var map = this.getMap();
		if($defined(markers)){
			markers.each(function(el,index){
				map.addOverlay(el);
				if(el.myElement.hidden){
					el.hide();
				}
			});
		}
	},
	setCenter:function(long,lat,zoom){
		var map = this.getMap();
		map.setCenter(new GLatLng(parseFloat(lat),parseFloat(long) ), parseInt(zoom));
	return this;
	},
	openMarker:function(cat,uid){
		var markers = this.getMarkers();
		var map = this.getMap();
		markers.each(function(el,index){
			if(cat == el.myElement.category && uid == el.myElement.uid ){
				var markerLatLng = el.getLatLng();
				map.setCenter(markerLatLng);
				map.panTo(markerLatLng);
				GEvent.trigger(el, "click" ); 
			}	
		});
	},
	log:function(data){
		if($defined(console)) console.log(data);
	}
});
