// Infowin class for displaying a miniature info window. Does not
// respond to any events - so you should show and remove the
// overlay yourself as necessary.

function Infowin(latlng, category, pointID, img, pro, html) {

var iconpro=pro.split(",");
var w=parseFloat(iconpro[0]);
var r=parseFloat(iconpro[1]);
var bp=parseFloat(iconpro[2]);


this.ek=0;
	this.category=category;
	this.ID=pointID;
	this.latlng_ = latlng;
	this.html_ = html;
	this.prototype = new GOverlay();


if(w>78){this.ek=36;}

	// Creates the DIV representing the infowindow
	this.initialize = function(map) {
		var div = $('<div />');
		div.css({
			'position' : 'absolute',
			'width' : w
		}).appendTo(map.getPane(G_MAP_FLOAT_PANE))
	
		this.map_ = map;
		this.div_ = div;

		this.update(html);
	}

	this.update = function(html){
		this.html_ = html;
		
		this.div_.empty();
		
		$('<div />').css({
			'background-image' : 'url(/mapicons/infowindow/infow'+img+'-top.png)',
			height : r,
			padding: '0 0 0 0'
		}).appendTo(this.div_);

		
		var content = $('<div/>').css({
			'max-height':'108px'
		}).html(html);
		
		$('<div />').css({
			'background-image' : 'url(/mapicons/infowindow/infow'+img+'-bottom.png)',
			'background-position' : 'bottom left',
			'padding' : '0 '+r+'px '+bp+'px '+r+'px'
		}).append(content).appendTo(this.div_);
		
		this.redraw(true);
	}
	
	// Remove the main DIV from the map pane
	this.remove = function() {
	  this.div_.remove();
	}

	// Copy our data to a new instance
	this.copy = function() {
	  return new Infowin(this.latlng_, this.html_);
	}

	// Redraw based on the current projection and zoom level
	this.redraw = function(force) {
		if (!force) return;

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

		// Now position our DIV based on the DIV coordinates of our bounds
		this.div_.css({
			left : point.x - ((parseFloat(w)-r)/2)+this.ek,
			top : point.y - this.div_.height()
		});
	}
}
