//////////////////////////////////////////////////////////////////////////////////
//////	Different overlays for map popups
//////////////////////////////////////////////////////////////////////////////////


// Tooltip for upper map city display
function ToolTip(marker,index,html,width) {
	this.html_ = html;
	this.index_ = index;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}

ToolTip.prototype = new GOverlay();

ToolTip.prototype.initialize = function(map) {
	var div = document.createElement("div");
	div.style.display = 'none';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	
	this.map_ = map;
	this.container_ = div;
}

ToolTip.prototype.remove = function() {
	this.container_.parentNode.removeChild(this.container_);
}

ToolTip.prototype.copy = function() {
	return new ToolTip(this.html_);
}

ToolTip.prototype.redraw = function(force) {
	if (!force) return;
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	if(this.index_==1){
		this.container_.style.left = (pixelLocation.x + 42) + "px";
		this.container_.style.top = (pixelLocation.y - 9) + "px";
	}else{
		this.container_.style.left = (pixelLocation.x + 22) + "px";
		this.container_.style.top = (pixelLocation.y - 9) + "px";
	}
	this.container_.style.width = this.width_;
	
	//one line to desired width
	this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}

GMarker.prototype.ToolTipInstance = null;

GMarker.prototype.openToolTip = function(content,index) {
	//don't show the tool tip if there is acustom info window
	if(this.ToolTipInstance == null) {
		this.ToolTipInstance = new ToolTip(this,index,content)
		map.addOverlay(this.ToolTipInstance);
	}
}

GMarker.prototype.closeToolTip = function() {
	if(this.ToolTipInstance != null) {
		map.removeOverlay(this.ToolTipInstance);
		this.ToolTipInstance = null;
	}
}






//Infowindow for mouseover display in top map
function mouseWindow(marker,index,html,width) {
	this.html_ = html;
	this.index_ = index;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}
mouseWindow.prototype = new GOverlay();
mouseWindow.prototype.initialize = function(map) {
	var div = document.createElement("div");
	div.style.display = 'none';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	
	this.map_ = map;
	this.container_ = div;
}
mouseWindow.prototype.remove = function() {
	this.container_.parentNode.removeChild(this.container_);
}
mouseWindow.prototype.copy = function() {
	return new mouseWindow(this.html_);
}
mouseWindow.prototype.redraw = function(force) {
	if (!force) return;
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	if(this.index_==1){
		this.container_.style.left = (pixelLocation.x + 36) + "px";
	}else{
		this.container_.style.left = (pixelLocation.x + 16) + "px";
	}
	this.container_.style.top = (pixelLocation.y + 8) + "px";
	//this.container_.style.width = '297px';
	this.container_.style.display = 'block';
	this.container_.style.bgColor  = 'transparent';
	
	//one line to desired width
	//this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}
GMarker.prototype.mouseWindowInstance = null;
GMarker.prototype.openmouseWindow = function(content,index) {
	//don't show the tool tip if there is acustom info window
	if(this.mouseWindowInstance == null) {
		this.mouseWindowInstance = new mouseWindow(this,index,content)
		pixelLocation = map.fromLatLngToDivPixel(this.getPoint());
		allowedBounds = map.getBounds();
		//if(!allowedBounds.contains(map.fromDivPixelToLatLng(GPoint(pixelLocation.x, pixelLocation.y)))){
			//resize
		//}
		map.addOverlay(this.mouseWindowInstance);
	}
}
GMarker.prototype.closemouseWindow = function() {
	if(this.mouseWindowInstance != null) {
		map.removeOverlay(this.mouseWindowInstance);
		this.mouseWindowInstance = null;
	}
}





//Infowindow for text display in bottom map
function infoWindow(marker,html,width) {
	this.html_ = html;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}
infoWindow.prototype = new GOverlay();
infoWindow.prototype.initialize = function(map) {
	var div = document.createElement("div");
	div.style.display = 'none';
	map_zoom.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	
	this.map_ = map_zoom;
	this.container_ = div;
}
infoWindow.prototype.remove = function() {
	this.container_.parentNode.removeChild(this.container_);
}
infoWindow.prototype.copy = function() {
	return new infoWindow(this.html_);
}
infoWindow.prototype.redraw = function(force) {
	if (!force) return;
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = (pixelLocation.x + 20) + "px";
	this.container_.style.top = (pixelLocation.y - 30) + "px";
	//this.container_.style.width = '297px';
	this.container_.style.display = 'block';
	this.container_.style.bgColor  = 'transparent';
	
	//one line to desired width
	//this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}
GMarker.prototype.infoWindowInstance = null;
GMarker.prototype.openinfoWindow = function(content) {
	//don't show the tool tip if there is acustom info window
	if(this.infoWindowInstance == null) {
		this.infoWindowInstance = new infoWindow(this,content)
		pixelLocation = map.fromLatLngToDivPixel(this.getPoint());
		allowedBounds = map.getBounds();
		//if(!allowedBounds.contains(map.fromDivPixelToLatLng(GPoint(pixelLocation.x, pixelLocation.y)))){
			//resize
		//}
		map.addOverlay(this.infoWindowInstance);
	}
}
GMarker.prototype.closeinfoWindow = function() {
	if(this.infoWindowInstance != null) {
		map.removeOverlay(this.infoWindowInstance);
		this.infoWindowInstance = null;
	}
}






//Moviewindow for movie display in bottom map
function movieWindow(marker,html,width) {
	this.html_ = html;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}
movieWindow.prototype = new GOverlay();
movieWindow.prototype.initialize = function(map) {
	var div = document.createElement("div");
	div.style.display = 'none';
	map_zoom.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	
	this.map_ = map_zoom;
	this.container_ = div;
}
movieWindow.prototype.remove = function() {
	this.container_.parentNode.removeChild(this.container_);
}
movieWindow.prototype.copy = function() {
	return new movieWindow(this.html_);
}
movieWindow.prototype.redraw = function(force) {
	if (!force) return;
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = (pixelLocation.x + 100) + "px";
	this.container_.style.top = (pixelLocation.y - 230) + "px";
	//this.container_.style.width = '297px';
	this.container_.style.display = 'block';
	this.container_.style.bgColor  = 'transparent';
	
	//one line to desired width
	//this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}
GMarker.prototype.movieWindowInstance = null;
GMarker.prototype.openmovieWindow = function(content) {
	//don't show the tool tip if there is acustom info window
	if(this.movieWindowInstance == null) {
		this.movieWindowInstance = new movieWindow(this,content)
		pixelLocation = map.fromLatLngToDivPixel(this.getPoint());
		allowedBounds = map.getBounds();
		//if(!allowedBounds.contains(map.fromDivPixelToLatLng(GPoint(pixelLocation.x, pixelLocation.y)))){
			//resize
		//}
		map.addOverlay(this.movieWindowInstance);
	}
}
GMarker.prototype.closemovieWindow = function() {
	if(this.movieWindowInstance != null) {
		map.removeOverlay(this.movieWindowInstance);
		this.movieWindowInstance = null;
	}
}






//audioWindow for movie display in bottom map
function audioWindow(marker,html,width) {
	this.html_ = html;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}
audioWindow.prototype = new GOverlay();
audioWindow.prototype.initialize = function(map) {
	var div = document.createElement("div");
	div.style.display = 'none';
	map_zoom.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	
	this.map_ = map_zoom;
	this.container_ = div;
}
audioWindow.prototype.remove = function() {
	this.container_.parentNode.removeChild(this.container_);
}
audioWindow.prototype.copy = function() {
	return new audioWindow(this.html_);
}
audioWindow.prototype.redraw = function(force) {
	if (!force) return;
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = (pixelLocation.x + 100) + "px";
	this.container_.style.top = (pixelLocation.y - 130) + "px";
	//this.container_.style.width = '297px';
	this.container_.style.display = 'block';
	this.container_.style.bgColor  = 'transparent';
	
	//one line to desired width
	//this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}
GMarker.prototype.audioWindowInstance = null;
GMarker.prototype.openaudioWindow = function(content) {
	//don't show the tool tip if there is acustom info window
	if(this.audioWindowInstance == null) {
		this.audioWindowInstance = new audioWindow(this,content)
		pixelLocation = map.fromLatLngToDivPixel(this.getPoint());
		allowedBounds = map.getBounds();
		//if(!allowedBounds.contains(map.fromDivPixelToLatLng(GPoint(pixelLocation.x, pixelLocation.y)))){
			//resize
		//}
		map.addOverlay(this.audioWindowInstance);
	}
}
GMarker.prototype.closeaudioWindow = function() {
	if(this.audioWindowInstance != null) {
		map.removeOverlay(this.audioWindowInstance);
		this.audioWindowInstance = null;
	}
}






// Imagewindow for image display in bottom map
function imageWindow(marker,html,width) {
	this.html_ = html;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}
imageWindow.prototype = new GOverlay();
imageWindow.prototype.initialize = function(map) {
	var div = document.createElement("div");
	div.style.display = 'none';
	map_zoom.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	
	this.map_ = map_zoom;
	this.container_ = div;
}
imageWindow.prototype.remove = function() {
	this.container_.parentNode.removeChild(this.container_);
}
imageWindow.prototype.copy = function() {
	return new imageWindow(this.html_);
}
imageWindow.prototype.redraw = function(force) {
	if (!force) return;
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = (pixelLocation.x - 470) + "px";
	this.container_.style.top = (pixelLocation.y - 200) + "px";
	//this.container_.style.width = '297px';
	this.container_.style.display = 'block';
	this.container_.style.bgColor  = 'transparent';
	
	//one line to desired width
	//this.container_.style.whiteSpace = 'nowrap';
	if(this.width_ != 'auto') this.container_.style.overflow = 'hidden';
	this.container_.style.display = 'block';
}
GMarker.prototype.imageWindowInstance = null;
GMarker.prototype.openimageWindow = function(content) {
	//don't show the tool tip if there is acustom info window
	if(this.imageWindowInstance == null) {
		this.imageWindowInstance = new imageWindow(this,content)
		pixelLocation = map.fromLatLngToDivPixel(this.getPoint());
		allowedBounds = map.getBounds();
		//if(!allowedBounds.contains(map.fromDivPixelToLatLng(GPoint(pixelLocation.x, pixelLocation.y)))){
			//resize
		//}
		map.addOverlay(this.imageWindowInstance);
	}
}
GMarker.prototype.closeimageWindow = function() {
	if(this.imageWindowInstance != null) {
		map.removeOverlay(this.imageWindowInstance);
		this.imageWindowInstance = null;
	}
}