// Stuff for the gray, transparent info "bubbles" that are specific to
// the DR site. Also works in IE6.

function changeStackOrder(a){
	a.style.position="relative";
	 var newDate = new Date;
	a.id="towerInfo_"+newDate.getTime();
	
	document.getElementById(a.id).style.zIndex=document.getElementById(a.id).style.zIndex+999;	

}
function changeStackOrderBack(a){
	a.style.position="absolute";
	document.getElementById(a.id).style.zIndex=document.getElementById(a.id).style.zIndex-999;
}

// Horizontal infowindow
function HInfowin(latlng, html) {
    this.latlng_ = latlng;
    this.html_ = html;
    this.prototype = new GOverlay();
 
    // Creates the DIV representing the infowindow
    this.initialize = function(map) {
	var div = $('<div onmouseover=\'changeStackOrder(this);\' onmouseout=\'changeStackOrderBack(this);\'/>');
	div.css({
	      height : 60,
		    position : 'absolute'
		    }).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 />').addClass('towerInfoLeft').css({
		'background-image' : 'url(../../common/images/towerInfoLabel_left.png)',
		    'position' : 'absolute',
		    'width' : 5,
		    'height' : 60,
		    'left' : '-5px',
		    'background-repeat' : 'no-repeat',
		    'background-position' : 'bottom left',
		    'padding' : '0 0 0 0'
		    }).appendTo(this.div_);
 
	var content = $('<div />').addClass('infowin-content').css({
		'position' : 'relative',
		'margin-left' : -5,
		'padding' : '3px 10px 3px 10px',
		'overflow' : 'hidden',
		'height' : 60,
		'min-width' : 160,
		'top' : 0,
		'font-family': 'verdana',
		'font-size' : '11px',
		'color' : '#fff',
		'line-height' : '170%'
	    }).html(html);
		
	// padding: top right bottom left
	$('<div />').addClass('towerInfoRight').css({
		'background-image' : 'url(../../common/images/towerInfoLabel_right_wide.png)',
		    'height' : 60,
			'width' : 160,
		    'background-repeat' : 'no-repeat',
		    'background-position' : 'bottom right',
		    'padding' : '0 0 0 0'
		    }).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 - this.div_.width() - 5,
		    'top' : point.y - 30
		    });
    }
}

