function HROSZoomControl() { }
HROSZoomControl.prototype = new GControl();
HROSZoomControl.prototype.initialize = function(map) {
	var container = document.createElement("div");
	var tbdy = document.createElement("tbody");
	var navTable = document.createElement("table");
	
	var firstRow = document.createElement('tr');
	
	var upperLeft = document.createElement('td');
	firstRow.appendChild(upperLeft);
	
	var upperMiddle = document.createElement('td');
	var scrollUp = document.createElement("img");
	scrollUp.setAttribute("src", "http://www.hros.ru/images/map/noord.jpg");
	upperMiddle.appendChild(scrollUp);
	GEvent.addDomListener(scrollUp, "click", function() {
		map.panBy(new GSize(0, 138));
	});	
	firstRow.appendChild(upperMiddle);
	
	var upperRight = document.createElement('td');
	firstRow.appendChild(upperRight);
	tbdy.appendChild(firstRow);

	var secondRow = document.createElement('tr');
	var middleLeft = document.createElement('td');
	var scrollLeft = document.createElement("img");
	scrollLeft.setAttribute("src", "http://www.hros.ru/images/map/west.jpg");
	middleLeft.appendChild(scrollLeft);
	GEvent.addDomListener(scrollLeft, "click", function() {
		map.panBy(new GSize(195, 0));
	});
	secondRow.appendChild(middleLeft);

	var middleCenter = document.createElement('td');
	var scrollCenter = document.createElement("img");
	scrollCenter.setAttribute("src", "http://www.hros.ru/images/map/midden.jpg");
	middleCenter.appendChild(scrollCenter);
	GEvent.addDomListener(scrollCenter, "click", function() {
		map.panTo(new GLatLng(latitude,longitude));
	});
	secondRow.appendChild(middleCenter);

	var middleRight = document.createElement('td');
	var scrollRight = document.createElement("img");
	scrollRight.setAttribute("src", "http://www.hros.ru/images/map/oost.jpg");
	middleRight.appendChild(scrollRight);
	secondRow.appendChild(middleRight);
	GEvent.addDomListener(scrollRight, "click", function() {
		map.panBy(new GSize(-195, 0));
	});
	tbdy.appendChild(secondRow);

	var thirdRow = document.createElement('tr');
	var lowerLeft = document.createElement('td');
	thirdRow.appendChild(lowerLeft);
	
	var lowerCenter = document.createElement('td');
	thirdRow.appendChild(lowerCenter);
	var scrollDown = document.createElement("img");
	scrollDown.setAttribute("src", "http://www.hros.ru/images/map/zuid.jpg");
	lowerCenter.appendChild(scrollDown);
	thirdRow.appendChild(lowerCenter);
	GEvent.addDomListener(scrollDown, "click", function() {
		map.panBy(new GSize(0, -138));
	});
	
	var lowerRight = document.createElement('td');
	thirdRow.appendChild(lowerRight);
	tbdy.appendChild(thirdRow);

	var emptyRow = document.createElement('tr');
	var emptyCell = document.createElement('td');
	emptyRow.appendChild(emptyCell);
	tbdy.appendChild(emptyRow);

	var forthRow = document.createElement('tr');
	var lowestLeft = document.createElement('td');
	var zoominElem = document.createElement("img");
	zoominElem.setAttribute("src", "http://www.hros.ru/images/map/zoomin.jpg");
	lowestLeft.appendChild(zoominElem);
	GEvent.addDomListener(zoominElem, "click", function() {
		map.zoomIn();
	});
	forthRow.appendChild(lowestLeft);
	
	var lowestCenter = document.createElement('td');
	forthRow.appendChild(lowestCenter);
	
	var lowestRight = document.createElement('td');
	var zoomoutElem = document.createElement("img");
	zoomoutElem.setAttribute("src", "http://www.hros.ru/images/map/zoomout.jpg");
	lowestRight.appendChild(zoomoutElem);
	GEvent.addDomListener(zoomoutElem, "click", function() {
		map.zoomOut();
	});
	forthRow.appendChild(lowestRight);
	tbdy.appendChild(forthRow);

	navTable.appendChild(tbdy);
	container.appendChild(navTable);
	map.getContainer().appendChild(container);
	return container;
}

HROSZoomControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}

function HROSMapTypeControl() { }
HROSMapTypeControl.prototype = new GControl();
HROSMapTypeControl.prototype.initialize = function(map) {
	var container2 = document.createElement("div");
	
	var logo = document.createElement("div");
	logo.setAttribute("id", "logo1");
  	container2.appendChild(logo);
  
	var tbdy = document.createElement("tbody");
	var typeTable = document.createElement("table");
	var firstRow = document.createElement('tr');
	
	var left = document.createElement('td');
	var typeMap = document.createElement("img");
	
    typeMap.setAttribute("src", "http://www.hros.ru/images/map/map.jpg");
  
	left.appendChild(typeMap);
	GEvent.addDomListener(left, "click", function() {
		map.setMapType(G_NORMAL_MAP);   
	});	
	firstRow.appendChild(left);
	
	var middle = document.createElement('td');
	var satellite = document.createElement("img");
	
    satellite.setAttribute("src", "http://www.hros.ru/images/map/satellite.jpg");
 
	middle.appendChild(satellite);
	GEvent.addDomListener(satellite, "click", function() {
		map.setMapType(G_SATELLITE_MAP);  
	});
	firstRow.appendChild(middle);

	var right = document.createElement('td');
	var hybrid = document.createElement("img");
	
	  hybrid.setAttribute("src", "http://www.hros.ru/images/map/hybrid.jpg");
  
	right.appendChild(hybrid);
	GEvent.addDomListener(hybrid, "click", function() {
		map.setMapType(G_HYBRID_MAP);   
	});
	firstRow.appendChild(right);
	tbdy.appendChild(firstRow);

	typeTable.appendChild(tbdy);
	container2.appendChild(typeTable);
	map.getContainer().appendChild(container2);
	return container2;
}

HROSMapTypeControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
}



function HROSCreateMap(map,lat,lon,hotelname,hotelstar,hotelinfo){
	var bounds = map.getBounds();
	var sw = bounds.getSouthWest();
	var ne = bounds.getNorthEast();
	var left = sw.lng();
	var right = ne.lng();
	var up = ne.lat();
	var down = sw.lat();
	var icon = new GIcon();
	icon.image = "http://www.hros.ru/images/hros_icon.png";
	icon.iconSize = new GSize(32, 32);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);
	var point = new GLatLng(lat,lon);
	var marker = new GMarker(point, icon);
	map.addOverlay(marker);
	marker.openInfoWindowHtml(hotelinfo);
	return(map);
}




function createMarker(point, number) {  var marker = new GMarker(point);  GEvent.addListener(marker, "click", function() {    marker.openInfoWindowHtml("Marker #<b>" + number + "</b>");  });  return marker;}


function load() {      
	if (GBrowserIsCompatible()) {    
		map = new GMap2(document.getElementById("map"));
		//map.addControl(new HROSZoomControl());
		//map.addControl(new HROSMapTypeControl());
		//map.addControl(new GMapTypeControl());
		//map.addControl(new GScaleControl());
		//map.addControl(new GOverviewMapControl());
		map.enableScrollWheelZoom();
		alert(hotellat);
		window.onresize = adjustHeight;
		map.setCenter(new GLatLng(hotellat, hotellon), 13);
		map = HROSCreateMap(map, hotellat, hotellon, hotelname, hotelstar, hotelinfo);
		
	}    
}

function TLabel(){}
TLabel.prototype.initialize=function(a){
 this.parentMap=a;
 var b=document.createElement('span');
 b.setAttribute('id',this.id);
 b.innerHTML=this.content;
 document.body.appendChild(b);
 b.style.position='absolute';
 b.style.zIndex=1;
 if(this.percentOpacity){this.setOpacity(this.percentOpacity);}
 this.w = document.getElementById(this.id).offsetWidth;
 this.h = document.getElementById(this.id).offsetHeight;
 this.mapTray=a.getPane(G_MAP_MAP_PANE);
 this.mapTray.appendChild(b);
 if(!this.markerOffset){this.markerOffset=new GSize(0,0);}
 this.setPosition();
 GEvent.bind(a,"zoomend",this,function(){this.setPosition()});
 GEvent.bind(a,"moveend",this,function(){this.setPosition()});
}
TLabel.prototype.setPosition=function(a){
 if(a){this.anchorLatLng=a;}
 var b=this.parentMap.fromLatLngToDivPixel(this.anchorLatLng);
 var x=parseInt(b.x);
 var y=parseInt(b.y);
 with(Math){switch(this.anchorPoint){
  case 'topLeft':break;
  case 'topCenter':x-=floor(this.w/2);break;
  case 'topRight':x-=this.w;break;
  case 'midRight':x-=this.w;y-=floor(this.h/2);break;
  case 'bottomRight':x-=this.w;y-=this.h;break;
  case 'bottomCenter':x-=floor(this.w/2);y-=this.h;break;
  case 'bottomLeft':y-=this.h;break;
  case 'midLeft':y-=floor(this.h/2);break;
  case 'center':x-=floor(this.w/2);y-=floor(this.h/2);break;
  default:break;
 }}
 var d=document.getElementById(this.id);
 d.style.left=x-this.markerOffset.width+'px';
 d.style.top=y-this.markerOffset.height+'px';
}
TLabel.prototype.setOpacity=function(b){
 if(b<0){b=0;} if(b>100){b=100;}
 var c=b/100;
 var d=document.getElementById(this.id);
 if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
 if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
 if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
 if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
}
GMap2.prototype.addTLabel=function(a){
 a.initialize(this);
}
GMap2.prototype.removeTLabel=function(a){
 var b=document.getElementById(a.id);
 this.getPane(G_MAP_MAP_PANE).removeChild(b);
 delete(b);
}
var hotellabel = new TLabel();


