var opts = {maxWidth:100};

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
var showed = 0;



var tempX = 0
var tempY = 0

function getMouseXY(e) {
		  if (IE) { // grab the x-y pos.s if browser is IE
		    tempX = event.clientX + document.body.scrollLeft
		    tempY = event.clientY + document.body.scrollTop
		  } else {  // grab the x-y pos.s if browser is NS
		    tempX = e.pageX
		    tempY = e.pageY
		  }  
		  // catch possible negative values in NS4
		  if (tempX < 0){tempX = 0}
		  if (tempY < 0){tempY = 0}  

 
//		  mylayer = $('smileyinfo');
//		  mylayer.style.top = tempY-6 + 'px';
//		  mylayer.style.left = tempX+10 + 'px';

		  return true;
}

    function createMarker(point,html,url) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "mouseover", function() { marker.openInfoWindowHtml(html, opts); });
        GEvent.addListener(marker, "click", function() { document.location.href=url });
        return marker; 
    }

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2($("hotellistgooglemap"));
        var center = new GLatLng(coor_latitude, coor_longitude);        
        map.addControl(new GLargeMapControl());
        map.setCenter(center, coor_zoom);
	  }
			  
	}
	
	function hideMarkers() {
	   for (var i = 0; i < myMarkers.length; i++) 
	   {
	      if (MarkersPreferred[i] == 0) {
			 myMarkers[i].hide();
		  } 
	   }		
	}	

	
	function showMyHotelMap(idx) {
		removeAllMarkers(); //levesszük az összes bubit
	
		var marker = createMarker(new GLatLng(Markerscoorlat[idx], Markerscoorlong[idx]), MarkersInfo[idx], MarkersUrl[idx]);
		map.addOverlay(marker);
        var location = marker.getLatLng();
        marker.openInfoWindowHtml(MarkersInfo[idx], opts);
        map.setCenter(location, map.getZoom());


		//pozíciók beállítása
		  var myWidth = 0, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		    myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		    myHeight = document.body.clientHeight;
		  }
	
		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
		    //Netscape compliant
		    scrOfY = window.pageYOffset;
		    scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		    //DOM compliant
		    scrOfY = document.body.scrollTop;
		    scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		    //IE6 standards compliant mode
		    scrOfY = document.documentElement.scrollTop;
		    scrOfX = document.documentElement.scrollLeft;
		  }

          scrollWidth = document.body.scrollWidth;
          scrollHeight = document.body.scrollHeight;
		  	
          $("hotellistgooglemapcontainer").style.top = Math.round((myHeight - 440) / 2) + scrOfY + "px";
          $("hotellistgooglemapcontainer").style.left = Math.round((myWidth - 600) / 2) + "px";
        
          $("hotellistgooglemapshadow").style.top = Math.round((myHeight - 440) / 2) + scrOfY + 6 + "px";
          $("hotellistgooglemapshadow").style.left = Math.round((myWidth - 600) / 2) + 6 + "px";

          $("overlay").style.width = scrollWidth  + "px";
          $("overlay").style.height = scrollHeight + "px";
        
        
        //megjelenítés
        $("hotellistgooglemapcontainer").fade(1);
        $("hotellistgooglemapshadow").fade(0.3);
        $("overlay").fade(0.5);


	}
	
	function hideMyHotelMap() {
		//$("hotellistgooglemapcontainer").style.display = "none";
        $("hotellistgooglemapcontainer").fade(0);
        $("hotellistgooglemapshadow").fade(0);		
        $("overlay").fade(0);
	}
	
	function removeMarker(idx)
	{		
   		if( idx >= 0 && idx < markersArray.length )
   		{
      		map.removeOverlay(myMarkers[idx]);
 	    }   
	}


	function removeAllMarkers()
	{
	   map.clearOverlays();
	   myMarkers = new Array();
	}

































window.addEvent('domready', function() {
        document.onmousemove = getMouseXY;

	var el = $('smileyinfo');
	el.setStyles({
		display:'block',
		opacity: 0
	});

	var smileys = document.getElements('img.smileyicon');
	smileys.addEvents({
		'mouseenter': function(e) { e.stop(); el.style.top = tempY-6 + 'px'; el.style.left = tempX+10 + 'px'; el.fade(1); },
		'mouseleave': function(e) { e.stop(); el.fade(0); }
	});


	$('hotellistgooglemapcontainer').setStyles({
		display:'block',
		opacity: 0
	});
	$('hotellistgooglemapshadow').setStyles({
		display:'block',
		opacity: 0
	});

	$('overlay').setStyles({
		display:'block',
		opacity: 0
	});
	load();

});


