mapLayerVisibility = new Array();
mapHiddenMarkers = new Array();
mapLayerAddMarkers = new Array();

function hideMarker(id){
	if(mapHiddenMarkers[id]!=true){
    	eval('map.removeOverlay(marker'+id+');');
    	mapHiddenMarkers[id] = true;
	}
}

function showMarker(id){
	if(mapHiddenMarkers[id]==true){
    	eval('map.addOverlay(marker'+id+');');
    	mapHiddenMarkers[id] = false;
	}
}

function checkBounds() {
	// Perform the check and return if OK
	if (allowedBounds.contains(map.getCenter())) {
  		return;
	}
	// It`s not OK, so find the nearest allowed point and move there
	var C = map.getCenter();
	var X = C.lng();
	var Y = C.lat();

	var AmaxX = allowedBounds.getNorthEast().lng();
	var AmaxY = allowedBounds.getNorthEast().lat();
	var AminX = allowedBounds.getSouthWest().lng();
	var AminY = allowedBounds.getSouthWest().lat();

	if (X < AminX) {X = AminX;}
	if (X > AmaxX) {X = AmaxX;}
	if (Y < AminY) {Y = AminY;}
	if (Y > AmaxY) {Y = AmaxY;}
	map.setCenter(new GLatLng(Y,X));

}


function createMarker(point, image){
	var icon = new GIcon();
	icon.image = image[0];
	icon.iconSize = new GSize(image[1], image[2]);
	subt = image[2] / 100 * 10;
	subt = Math.ceil(subt);
	var anchor = image[2] - subt;
	icon.iconAnchor= new GPoint(10, anchor);
	var marker = new GMarker(point,icon);

	return marker;
}

function createSimpleMarker(point,html,image){
	var icon = new GIcon();
	icon.image = image[0];
	icon.iconSize = new GSize(image[1], image[2]);
	subt = image[2] / 100 * 11;
	subt = Math.ceil(subt);
	var anchor = image[2] - subt;
	icon.iconAnchor= new GPoint(10, anchor);
	var infoanchor = image[2] / 3;
	infoanchor = Math.floor(infoanchor);
	icon.infoWindowAnchor = new GPoint(infoanchor, 2);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});

	return marker;
}

function createTabMarker(point, tabs,image){
	var icon = new GIcon();
	icon.image = image[0];
	icon.iconSize = new GSize(image[1], image[2]);
	subt = image[2] / 100 * 11;
	subt = Math.ceil(subt);
	var anchor = image[2] - subt;
	icon.iconAnchor= new GPoint(10, anchor);
	var infoanchor = image[2] / 3;
	icon.infoWindowAnchor = new GPoint(infoanchor, 2);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindowTabsHtml(tabs);
	});
	return marker;
}

function hideMapLayer(id){
	eval('hideMapLayer'+id+'();');
	mapLayerVisibility[id]=0;
}

function showMapLayer(id){
	eval('showMapLayer'+id+'();');
	mapLayerVisibility[id]=1;
}

function tilechk(){
	paragraphs = map.getContainer().getElementsByTagName('p').length;
	if(paragraphs>4){
		map.zoomOut(false,true);
	}
}

function toggleMapLayer(id){
	if(mapLayerVisibility[id]==1){
	    hideMapLayer(id);
	}else{
	    showMapLayer(id);
	}
}

function wheelevent(e){
	if (!e) e = window.event;
	if (e.preventDefault) e.preventDefault();
	e.returnValue = false;
}

