/*
* Author: diegomrp
* Copyright: Inditex 2007
*/

function cWindow(map){
	this.map=map;
	this.visible=false;
}

cWindow.prototype=new GOverlay();

cWindow.prototype.initialize = function(map){
	var div=document.createElement("div");
	div.style.position="absolute";
	map.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(div);
	this.div = div;
}

cWindow.prototype.redraw = function(force) {
	if (!this.visible) {
		return;
	}
	var p = this.map.fromLatLngToDivPixel(this.point);
	this.div.style.left   = (p.x + this.offset.x) + "px";
	this.div.style.bottom = (-p.y + this.offset.y) + "px";
}

cWindow.prototype.openOnMap = function(point, html,offset) {
	this.offset = offset||new GPoint(0,0);
	this.point = point;
	this.div.innerHTML =html;
	this.visible = true;
	this.show();
	this.redraw(true);
}

cWindow.prototype.openOnMarker = function(marker,html) {
	var vx = marker.getIcon().iconAnchor.x - marker.getIcon().infoWindowAnchor.x;
	var vy = marker.getIcon().iconAnchor.y - marker.getIcon().infoWindowAnchor.y;
	this.openOnMap(marker.getPoint(), html, new GPoint(vx,vy));
}

cWindow.prototype.show = function() {
	this.div.style.display="";
	this.visible = true;
}

cWindow.prototype.hide = function() {
	this.div.style.display="none";
	this.visible = false;
}

cWindow.prototype.remove = function() {
	this.div.parentNode.removeChild(this.div);
	this.visible=false;
}