function CloudBox(latlng, opts, cloudPic, closeImgFlag) {
	this.latlng_ = latlng;
	this.content_ = opts.content || "" ;
	this.offsetVertical_ = opts.offsetVertical || -119;
	this.offsetHorizontal_ = opts.offsetHorizontal || -100;

	this.className_ = opts.className || "";
	this.height_ = opts.height || 200;
	this.width_ = opts.width || 300;
	
	this.cloudPic_ = cloudPic ;
	this.closeImgFlag_ = closeImgFlag ;
}

CloudBox.prototype = new GOverlay();

CloudBox.prototype.initialize = function(map) {
	var div = document.createElement("div");

//	if (this.className_ != "") {
//		div.className = this.className_;
//	} else {
//	}
	div.style.border = "none";
	div.style.position = "absolute";
	div.style.background = "url('" + this.cloudPic_ + "')";
	div.style.width = this.width_ + "px";
	div.style.height = this.height_ + "px";

	var contentDiv = document.createElement("div");
	contentDiv.innerHTML = this.content_;

	var topDiv = document.createElement("div");
	topDiv.style.textAlign = "right";
	topDiv.style.paddingRight = "10px";
	
	var closeImg ;
	if( this.closeImgFlag_ ) {
		closeImg = document.createElement("img");
		closeImg.src = "images/big-cloud-close.gif";
		topDiv.appendChild(closeImg);
	}

	function removeCloudBox(ib, m) {
		return function() {
			GEvent.trigger(ib, "closeclick");
			m.removeOverlay(ib);
		};
	}

	if( closeImg ) {
		GEvent.addDomListener(closeImg, 'click', removeCloudBox(this, map));
	}

	div.appendChild(topDiv);
	div.appendChild(contentDiv);
	div.style.display = 'none';

	map.getPane(G_MAP_MARKER_PANE).appendChild(div);
	//map.getContainer().appendChild(div);

	this.map_ = map;
	this.div_ = div;
};

CloudBox.prototype.remove = function() {
	this.div_.parentNode.removeChild(this.div_);
};

CloudBox.prototype.copy = function() {
	var opts = {};
	opts.latlng = this.latlng_;
	opts.content = this.content_;
	opts.offsetVertical = this.offsetVertical_;
	opts.offsetHorizontal = this.offsetHorizontal_;

	opts.className = this.className_ || "";
	opts.height = this.height_;
	opts.width = this.width_;
	return new CloudBox(this.latlng, opts);
};

CloudBox.prototype.redraw = function(force) {
	if (!force)
		return;

	var pixPosition = this.map_.fromLatLngToDivPixel(this.latlng_);

	this.div_.style.width = this.width_ + "px";
	this.div_.style.left = (pixPosition.x + this.offsetHorizontal_) + "px";
	this.div_.style.height = this.height_ + "px";
	this.div_.style.top = (pixPosition.y + this.offsetVertical_) + "px";
	this.div_.style.display = 'block';

	var mapWidth = this.map_.getSize().width;
	var mapHeight = this.map_.getSize().height;
	var bounds = this.map_.getBounds();
	var boundsSpan = bounds.toSpan();
	var longSpan = boundsSpan.lng();
	var latSpan = boundsSpan.lat();
	var degWidth = (this.width_ / mapWidth) * longSpan;
	var degHeight = (this.height_ / mapHeight) * latSpan;

	if (this.latlng_.lng() + degWidth > bounds.getNorthEast().lng()) {
		//this.map_.panTo(this.latlng_);
	}

	var bottompt = new GLatLng((this.latlng_.lat() - degHeight), this.latlng_
			.lng());
	if (!bounds.contains(bottompt)) {
		//this.map_.panTo(this.latlng_);
	}

};
