var ie4, ns4, ns6;
ie = document.all;
ns4 = document.layers;
ns6 = document.getElementById && !document.all;
flag =0;

function getElement(id) {
    if (document.all) return document.all[id];
    else if (document.getElementById)
    return document.getElementById(id);
    else
    return false;
}

function followmouse(e) {
if(flag == 0){
    var xcoord=15;
    var ycoord=15;
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
    var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
    
    if (typeof e != "undefined") {
        if (docwidth - e.pageX < 380) {
            xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
        }
        else {
            xcoord += e.pageX;
        }
        if (docheight - e.pageY < (currentimageheight + 110)) {
            ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
        }
        else {
            ycoord += e.pageY;
        }
    }
    else if (typeof window.event != "undefined") {
        if (docwidth - event.clientX < 380) {
            xcoord = event.clientX + truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
        }
        else {
            xcoord += truebody().scrollLeft+event.clientX
        }
        if (docheight - event.clientY < (currentimageheight + 110)) {
            ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
        }
        else {
            ycoord += truebody().scrollTop + event.clientY;
        }
    }
    if(ns6 || ie ) {
        document.getElementById('special_layer').style.left = (xcoord)+'px';
        document.getElementById('special_layer').style.top = (ycoord)+'px';
    }
	 
	 }
	 flag =1;
   // if(ie) {
     //   document.getElementById('iframe1').style.left = (xcoord)+'px';
      //  document.getElementById('iframe1').style.top = (ycoord)+'px';
   /// }
}

function truebody() {
    return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
var currentimageheight = 270;


        	



function showGoogleMaps(e,lg,lt,zm, w,h,n) {
    flag = 0;
    sHtml ="";
    sHtml = sHtml + '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;text-align:right">';
	 sHtml = sHtml + '<a style="cursor:hand" onclick="hideGoogleMaps()">X</a>';
    sHtml = sHtml + '<div id="gmap" style="width: 400px; height: 300px"></div>';
    sHtml = sHtml + '</div>';
	
	 
	 
	 
	 document.getElementById("special_layer").innerHTML = sHtml;
    currentimageheight = h;
	  if(ie)
		 followmouse();
	  else	
		followmouse(e);

	 setTimeout( function() {var showmaps = new ShowMap( document.getElementById('gmap'), lt , lg  ,zm,  n, 745 );}, 1000);
	 
   
    if(ns6 || ie ) {
        document.getElementById('special_layer').style.visibility = 'visible';
    }

    //if(ie) {
      //  document.getElementById('iframe1').style.visibility = 'visible';
    ///}
}

function hideGoogleMaps() {
    if(ns6 || ie) {
        document.getElementById('special_layer').style.visibility = 'hidden';
        document.getElementById('special_layer').style.left = "-500px";
    }
  //  if(ie) {
    //    document.getElementById('iframe1').style.visibility = 'hidden';
    //}
    document.onmousemove=""
}
var map;
var point;

function ShowMap( Elem, Latitude, Longtude, Zoom , Opis, Placeid) {
    this.latitude  = Latitude;
    this.longtude  = Longtude;
    this.zoom   = Zoom;
    this.element= Elem;
    this.opis = Opis;
    this.placeid = Placeid;
    this.show();
}



ShowMap.prototype.show = function() 
{
 if (GBrowserIsCompatible()) {
	map   = new GMap2( this.element );
	point = new GLatLng( this.latitude, this.longtude );
	map.setCenter( point, this.zoom );
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.enableContinuousZoom();

   
    
													
		var icon = new GIcon();
		icon.image = "http://www.odkryjpolske.pl/mapgoogle/p4.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(37, 47);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);						
							
	var marker = new GMarker(point , icon)
	map.addOverlay( marker );
	var opisik = this.opis;
	
	if(opisik !="")
	{
	    marker.openInfoWindowHtml(opisik);

	    GEvent.addListener(marker, "click", function() {
	        marker.openInfoWindowHtml(opisik);
	    });
	}
	
   }	

}



document.write('<div id="special_layer" style="z-index:6;visibility:hidden;position:absolute;"></div>');