// JavaScript Document
 /* CLASSE CHE DISEGNA IL BALOON NELLA MAPPA */
    var i=0;
    var MEgmbaloon = function(map,baloonId){
    	mapId = map.getContainer().id;
	this.map = map;
	this.content = document.createElement('div');
	this.content.id = baloonId;
	this.content.style.position="absolute";
	if (baloonId) this.content_id=baloonId;
	    else this.content_id = "baloon_"+(i++);
	this.content.className = "baloon";
	this.mapId = mapId;

	this.destroy = function (){
	    
	    if (document.getElementById(this.content_id)){
		document.getElementById(mapId).removeChild(document.getElementById(this.content_id));
		
	    }
	    
	};
	
	this.create = function(point,content){   
	    this.content.innerHTML = content.innerHTML;	    
	    this.px_coords = this.map.fromLatLngToContainerPixel(point);
	    var baloon_height = parseInt(this.content.style.height);
	    var baloon_width = parseInt(this.content.style.width);
	    var hOffset = this.hOffset ? parseInt(this.hOffset) : 0;
	    var vOffset = this.vOffset ? parseInt(this.vOffset) : 0;
	    
	    this.content.style.top=(parseInt(this.px_coords.y)-(baloon_height + parseInt(this.vOffset)))+"px";
	    this.content.style.cursor = "default";
	    this.content.style.left=(this.px_coords.x + hOffset + 20)+"px";
	    
		if (parseInt(this.px_coords.x) + baloon_width + hOffset + 30 >  parseInt(map.getContainer().style.width)){
		
		this.content.style.left=(parseInt(this.px_coords.x) - (baloon_width+30-hOffset))+"px";
	    }
	    if (parseInt(this.content.style.top) - vOffset <0){
		this.content.style.top=(parseInt(this.px_coords.y)/2)+"px";   
	    }
	    
	    
	    document.getElementById(this.mapId).appendChild(this.content);
	    
	}
	
	this.setVOffset = function(offset){
	    this.vOffset = offset;
	}
	this.setHOffset = function(offset){
	    this.hOffset = offset;
	}
	this.setBackground = function(string){
	    this.content.style.background = string;
	}
	this.setBorder = function(string){
	    this.content.style.border = string;
	}
	this.setWidth = function(string){
	    this.content.style.width = string;
	    
	}
	this.setHeight = function(string){
	    this.content.style.height = string;
	    
	}
	this.setPadding = function(string){
	    this.content.style.padding = string;
	}
	this.setFontSize = function(string){
	    this.content.style.fontSize = string;
	}
	
	this.setOverflowX = function(string){
	    this.content.style.overflowX = string;
	}
	
	this.setOverflowY = function(string){
	    this.content.style.overflowY = string;
	}
    }
    /* FINE CLASSE CHE DIEGNA IL BALOON NELLA MAPPA */