var markers = new Array();
var map;

function showHideOnMap(){
	if(document.getElementById("showAll").checked){
		document.getElementById("showAll").checked=false;
		clearAllOnMap();
	} else {
		document.getElementById("showAll").checked=true;
		showAllOnMap();
	}
}
function handleCheckboxShowAllOnMapSelection(){
	if(document.getElementById("showAll").checked){
		showAllOnMap();
	} else {
		clearAllOnMap();
	}
}
function showAllOnMap(){
	document.getElementById("showAllOnMapAdditionalInfo").style.display="block";
	for(i=0;i<markers.length;i++){
		map.addOverlay(markers[i][0]);	
	}
}

function clearAllOnMap(){
	document.getElementById("showAllOnMapAdditionalInfo").style.display="none";
	for(i=0;i<markers.length;i++){
		map.removeOverlay(markers[i][0]);	
	}
}


   //<![CDATA[
// A TextualZoomControl is a GControl that displays textual "Zoom In"// and "Zoom Out" buttons (as opposed to the iconic buttons used in// Google Maps).
function TextualZoomControl() {}
TextualZoomControl.prototype = new GControl();
// Creates a one DIV for each of the buttons and places them in a container
// DIV which is returned as our control element. We add the control to
// to the map container and return the element for the map class to
// position properly.
TextualZoomControl.prototype.initialize = function(map) 
{  	
	var container = document.createElement("div");  
	var zoomInDiv = document.createElement("div");  
	this.setButtonStyle_(zoomInDiv);  
	container.appendChild(zoomInDiv);  
	zoomInDiv.appendChild(document.createTextNode('Przybli\u017C'));  
	GEvent.addDomListener(zoomInDiv, "click", function() { map.zoomIn();  });  
	var zoomOutDiv = document.createElement("div");  
	this.setButtonStyle_(zoomOutDiv);  
	container.appendChild(zoomOutDiv);  
	zoomOutDiv.appendChild(document.createTextNode('Oddal'));  
	GEvent.addDomListener(zoomOutDiv, "click", function() { map.zoomOut();  });  
	map.getContainer().appendChild(container);  return container;
}
	// By default, the control will appear in the top left corner of the// map with 7 pixels of padding.
TextualZoomControl.prototype.getDefaultPosition = function() {  
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50, 7));
}
// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle_ = function(button) {  
	button.style.textDecoration = "none";  
	button.style.color = "rgb(102,102,102)";  
	button.style.backgroundColor = "white";  
	button.style.font = "small Arial";  
	button.style.border = "1px solid black";  
	button.style.padding = "2px";  
	button.style.marginBottom = "3px";  
	button.style.textAlign = "center";  
	button.style.width = "6em";  
	button.style.cursor = "pointer";
    button.style.fontWeight = "bold" ;
 	button.style.fontSize = "10px";
}
	
function createMarker(point,name,image,description,apartmentId,apartmentURL) 
{  
   	var marker = new GMarker(point);  
   	GEvent.addListener(marker, "click", function() {    
   			var onClick = "GDownloadUrl('/fragments/components/addToClipboard.jsp?id=" + apartmentId + "&dt="+(new Date()).getTime()+"',function(data,responseCode){document.getElementById('ClipboardStatus').innerHTML=data;});";
   			var toClipboardUrl = "<a href='javascript:void(0);' onClick=" + onClick + ">do schowka</a>";
   			var info = "<table width='350' cellspacing='0' cellpadding='2'>";
			info += "<tr><td class='linkCommonSmall' align='left' style='border-bottom:1px solid black;padding-right:20px;'><a href='"+encodeURI(apartmentURL)+"'>o obiekcie</a></td><td class='linkCommonSmall' align='right' style='border-bottom:1px solid black;padding-right:20px;'>" + toClipboardUrl + "</td></tr>";
   			info += "<tr><td rowspan=3 valign=top><img src='" + image + "' border=0/></td></tr>";
   			info += "<tr><td class='title'>" + name + "</td></tr>";
			info += "<tr><td class='linkCommonSmall'><a href='"+encodeURI(apartmentURL)+"'>"+ description + "</a></td></tr>";
   			info += "</table>";
   			marker.openInfoWindowHtml(info);  
   		}
   	);  
   	return marker;
}
   
function createMarkerInfo(name,image,description,apartmentId,apartmentURL){
			var onClick = "GDownloadUrl('/fragments/components/addToClipboard.jsp?id=" + apartmentId + "&dt="+(new Date()).getTime()+"',function(data,responseCode){document.getElementById('ClipboardStatus').innerHTML=data;});";
			var toClipboardUrl = "<a href='javascript:void(0);' onClick=" + onClick + ">do schowka</a>";
			var info = "<table width='350' cellspacing='0' cellpadding='2'>";
			info += "<tr><td class='linkCommonSmall' align='left' style='border-bottom:1px solid black;padding-right:20px;'><a href='"+encodeURI(apartmentURL)+"'>o obiekcie</a></td><td class='linkCommonSmall' align='right' style='border-bottom:1px solid black;padding-right:20px;'>" + toClipboardUrl + "</td></tr>";
			info += "<tr><td rowspan=3 valign=top><img src='" + image + "' border=0/></td></tr>";
			info += "<tr><td class='title'>" + name + "</td></tr>";
			info += "<tr><td class='linkCommonSmall'><a href='"+encodeURI(apartmentURL)+"'>"+ description + "</a></td></tr>";
			info += "</table>";
			return info;
}

