function AccoMarker(name,price,id, title, lat, lng,im,issmallmap)
{
	this.price = price;
	this.id=id;
	this.name = name;
	this.title = '<a href="/accommodation/index.html?acco_id='+id+'">'+title+'<\/a>';
	this.tabs=[];
	this.location = new google.maps.LatLng(lat, lng);
	this.letteredIcon = new google.maps.Icon(baseIcon);
	this.issmallmap=issmallmap;
    if(im)this.letteredIcon.image = im;
	else this.letteredIcon.image = "http://www.google.com/mapfiles/markerA.png";
    
    /*for (var i=0;i<accomarkers.length;i++) {
        var pt = accomarkers[i];
        if(pt.location.lat()==lat && pt.location.lng()==lng){
            if(pt.tabs.length==0)
                pt.tabs.push(new GInfoWindowTab("Tab #1", pt.title));
            pt.tabs.push(new GInfoWindowTab("Tab #1", this.title))
            return;
        }
    } THE TAB FUNCTION*/
	map.addOverlay(this.createMarker());
	bounds.extend(this.location);
	//map.addOverlay(this.createLabel());
	
	this.info = document.getElementById(name);
	this.infoMax = document.getElementById(name + "-max");
}

AccoMarker.prototype.showInfo = function()
{
    if(this.issmallmap){
        // show info window outside the map
        var infowindow = document.getElementById('infowindow');
        if(infowindow){
            var pos = map.fromLatLngToDivPixel(this.marker.getPoint());
            pos.x += map.getContainer().offsetLeft;
            pos.y += map.getContainer().offsetTop;
            pos.y -= parseInt(infowindow.style.height);
            pos.y -= this.marker.getIcon().iconSize.height;
            if(pos.y<0)
            	pos.y=0;
            infowindow.style.left = pos.x + 'px';
            infowindow.style.top = pos.y + 'px';
            infowindow.style.display="";
            
            document.getElementById('infowindowdata').innerHTML=this.title;}
            
    }else{
        /*if(this.tabs.length>0)
            this.marker.openInfoWindowTabs(this.tabs);
        else THE TAB FUNCTION*/
            this.marker.openInfoWindow(this.title);
    }
}

AccoMarker.prototype.createMarker = function()
{
	var marker = new google.maps.Marker(this.location, { icon:this.letteredIcon, title:this.name+" Accommodation(s)"});
	var project = this;

	    //google.maps.Event.addListener(marker, "click",function() { project.accoMouseover(); });
	    
	    GEvent.addListener(marker, 'mouseover', function() { project.accoMouseover(); });
	    //GEvent.addListener(marker, 'mouseout', function() { accoMouseout(); });

	this.marker = marker;
	gmarkers.push(marker);
	accomarkers.push(this);
	return marker;
}

AccoMarker.prototype.accoMouseover = function(){
	//alert(this.title);
	if(this.marker.overlay==null)
		this.marker.overlay = new InfoWindow(this, 87, 45, 'map-info-window', 91, -24);
	if(activemarker)
		map.removeOverlay(activemarker.marker.overlay);
	activemarker=this;
	map.addOverlay(this.marker.overlay);
}

//AccoMarker.prototype.accoMouseout = function(){
function accoMouseout(){
	//map.removeOverlay(this.overlay);
	_timeout = setTimeout('clearActive()', 1000);
}

function clearActive(){
	if(activemarker)
		map.removeOverlay(activemarker.marker.overlay);
}
function reinittimeout(){
	clearTimeout(_timeout);
	_timeout=false;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
    return [curleft,curtop];
}


function InfoWindow(marker, divWidth, divHeight, divClassName, anchorOffsetX, anchorOffsetY) 
{
	this.marker = marker;
	this.divHeight = divHeight;
	this.divWidth = divWidth;
	this.divClassName = divClassName;
	
	this.anchorOffsetX = anchorOffsetX;
	
	if (null == this.anchorOffsetX)
	{
		this.anchorOffsetX = 0;
	}
	
	this.anchorOffsetY = anchorOffsetY;
	
	if (null == this.anchorOffsetY)
	{
		this.anchorOffsetY = 0;
	}
	
}

InfoWindow.prototype = new GOverlay();

InfoWindow.prototype.initialize = function(map) 
{

  var div = document.createElement("div");
  div.style.position = "absolute";
  div.style.height = this.divHeight + 'px';
  div.style.width = this.divWidth + 'px';
  div.onmouseover = function() {
	  reinittimeout();
  }
  div.onmouseout = function() {
	  accoMouseout();
  }
  //div.style.background-color = 'blue';
  div.className = this.divClassName;
  var prspan = document.createElement("span");
  prspan.className = this.divClassName+'-price';
  prspan.innerHTML = this.marker.price+'&#8364;';
  div.innerHTML = this.marker.title+'- ';
  div.appendChild(prspan);
 
  div.style.left 	= (map.fromLatLngToDivPixel(this.marker.marker.getPoint()).x - this.anchorOffsetX)+ 'px';
  div.style.top 	= (map.fromLatLngToDivPixel(this.marker.marker.getPoint()).y - this.divHeight - this.anchorOffsetY) + 'px';

  map.getPane(G_MAP_FLOAT_PANE).appendChild(div);

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

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

InfoWindow.prototype.redraw = function(force) 
{
  this.div_.style.left 	= (this.map_.fromLatLngToDivPixel(this.marker.marker.getPoint()).x - this.anchorOffsetX)+ 'px';
  this.div_.style.top = (this.map_.fromLatLngToDivPixel(this.marker.marker.getPoint()).y - this.divHeight - this.anchorOffsetY) + 'px';
}

/*var MyOverlay = function(marker) {
  this.marker = marker;
  this.initialize();
}

MyOverlay.prototype.initialize = function() {
  this.overlay = new google.maps.Overlay();
  var div = document.createElement("div");
  div.className = 'mywindow';
  div.style.position = "absolute";
  div.innerHTML = this.marker.title;

  offsetX = 193;
  offsetY = 261;

  div.style.top = (map.fromLatLngToDivPixel(this.marker.getPoint()).y - offsetY) + 'px';
  div.style.left = (map.fromLatLngToDivPixel(this.marker.getPoint()).x - offsetX) + 'px';

  div.onclick = closeOverlay;
  this._map = map;
  this._div = div;

  map.getPane(G_MAP_FLOAT_PANE).appendChild(div); 
}
MyOverlay.prototype.remove = function(){
	  this._div.parentNode.removeChild(this._div);
	}
	MyOverlay.prototype.redraw = function() {
	}
function closeOverlay() {
	map.removeOverlay(this.overlay);
}*/






