/*
GMarker.prototype.setMap = function (m) {
    this.map = m;}
GMarker.prototype.getMap = function () {
    return(this.map);}ù
*/
GMap2.prototype.getClassName = function () {
    return("GMap2");}
GMarker.prototype.getClassName = function () {
    return("GMarker");}
GIcon.prototype.getClassName = function () {
    return("GIcon");}
GOverlay.prototype.getClassName = function () {
    return("GOverlay");}
GKeyboardHandler.prototype.getClassName = function () {
    return("GKeyboardHandler");}
GInfoWindowTab.prototype.getClassName = function () {
    return("GInfoWindowTab");}
GPolyline.prototype.getClassName = function () {
    return("GPolyline");}
//GEvent.prototype.getClassName = function () {
//    return("GEvent");}
//GXmlHttp.prototype.getClassName = function () {
//    return("GXmlHttp");}
GDownloadUrl.prototype.getClassName = function () {
    return("GDownloadUrl");}
GPoint.prototype.getClassName = function () {
    return("GPoint");}
GSize.prototype.getClassName = function () {
    return("GSize");}
GBounds.prototype.getClassName = function () {
    return("GBounds");}
GLatLng.prototype.getClassName = function () {
    return("GLatLng");}
GLatLngBounds.prototype.getClassName = function () {
    return("GLatLngBounds");}
GClientGeocoder.prototype.getClassName = function () {
    return("GClientGeocoder");}
GGeocodeCache.prototype.getClassName = function () {
    return("GGeocodeCache");}
GFactualGeocodeCache.prototype.getClassName = function () {
    return("GFactualGeocodeCache");}
GCopyright.prototype.getClassName = function () {
    return("GCopyright");}
GCopyrightCollection.prototype.getClassName = function () {
    return("GCopyrightCollection");}
GTileLayer.prototype.getClassName = function () {
    return("GTileLayer");}
GTileLayerOverlay.prototype.getClassName = function () {
    return("GTileLayerOverlay");}
GMapType.prototype.getClassName = function () {
    return("GMapType");}
GDraggableObject.prototype.getClassName = function () {
    return("GDraggableObject");}
GControlPosition.prototype.getClassName = function () {
    return("GControlPosition");}
GControl.prototype.getClassName = function () {
    return("GControl");}
GScaleControl.prototype.getClassName = function () {
    return("GScaleControl");}
GLargeMapControl.prototype.getClassName = function () {
    return("GLargeMapControl");}
GSmallMapControl.prototype.getClassName = function () {
    return("GSmallMapControl");}
GSmallZoomControl.prototype.getClassName = function () {
    return("GSmallZoomControl");}
GMapTypeControl.prototype.getClassName = function () {
    return("GMapTypeControl");}
GOverviewMapControl.prototype.getClassName = function () {
    return("GOverviewMapControl");}
GProjection.prototype.getClassName = function () {
    return("GProjection");}
GMercatorProjection.prototype.getClassName = function () {
    return("GMercatorProjection");}
//GLog.prototype.getClassName = function () {
//    return("GLog");}
//GXml.prototype.getClassName = function () {
//    return("GXml");}
GXslt.prototype.getClassName = function () {
    return("GXslt");}
GMap.prototype.getClassName = function () {
    return("GMap");}
GAddCopyright.prototype.getClassName = function () {
    return("GAddCopyright");}
GValidateKey.prototype.getClassName = function () {
    return("GValidateKey");}



GMap2.prototype.getMarkers = function () {
    return(this.wa);}

/*
GMap2.prototype.setCenter = function (a,b,c) 
{
	var d=!this.G();
	if(b||i)
	{
		this.Pc()
	}
	this.Ac();
	var e=[];
	var f=null;
	var g=null;
	if(a){
		g=a;
		f=this.N();
		this.L=a
		}
		else
			{
				var h=this.Mb();
				g=h.latLng;
				f=h.divPixel;
				this.L=h.newCenter
				}
				var i=c||this.e||this.Y[0];
				var m;
				if(Yb(b))
				{m=b}
				else 
					if(this.Q){m=this.Q}
					else{m=0}
						var o=this.Vc(m,i,this.Mb().latLng);if(o!=this.Q){e.push([this,Xc,this.Q,o]);this.Q=o}if(i!=this.e){this.e=i;ba(this.uc,function(z){z.aa(i)}
);e.push([this,vb])}var p=this.I();var r=this.t();p.configure(g,f,o,r);p.show();ba(this.Oa,function(z){var B=z.Lc();B.configure(g,f,o,r);B.show()}
);this.Ke(true);if(!this.L){this.L=this.o(this.N())}e.push([this,qb]);e.push([this,oa]);if(d){this.Zh();if(this.G()){e.push([this,rc])}}for(var t=0;t<k(e);++t){s.apply(null,e[t])}};

//{  this.Ta(a,b,c);   }
*/    
GMarker.prototype.redrawMark = function (a) {
    return(this.redraw(a));}
GMarker.prototype.getLink = function () {
    return(this.destinationLink);}
GMarker.prototype.setLink = function (a) {
    this.destinationLink = a;}
GMarker.prototype.getMaxIteratorCoordinate = function () {
    return(this.maxIteratorCoordinate);}
GMarker.prototype.setMaxIteratorCoordinate = function (a) {
    this.maxIteratorCoordinate = a;}
GMarker.prototype.getMinIteratorCoordinate = function () {
    return(this.minIteratorCoordinate);}
GMarker.prototype.setMinIteratorCoordinate = function (a) {
    this.minIteratorCoordinate = a;}
GMarker.prototype.getId = function () {
    return(this.id);}
GMarker.prototype.setId = function (a) {
    this.id = a;}
GMarker.prototype.getLatitude = function() {return(this.p.y);}
GMarker.prototype.setTooltip = function(a) 
{
	this.setTooltipNoResize(a);
	this.deleteObjects();
}
GMarker.prototype.getTooltip = function(a) 
{
	return(this.tooltipRaw);
}
GMarker.prototype.setTooltipNoResize = function(a) 
{
	this.setTitle("");
	var ttClass = "iconTooltip";
	if (this.pendingClassName)
		ttClass = this.pendingClassName;
	this.tooltipRaw = a;
	this.tooltipText = "<div class='" + ttClass + "'>" + a + "</div>";
	if (this.tooltipObject)
		this.tooltipObject.innerHTML = this.tooltipText;
}
GMarker.prototype.setTitle = function(a) {
	this.tooltipText = "";
	PdCompPdMIN(this);
	try {
		eval(PdMIN + ".title = a");
	}
	catch (e) {
		this.pendingTitle = a;
	}
}
GMarker.prototype.deleteObjects = function() {
	if (this.tooltipObject)
	{
	  globalMap.getPane(G_MAP_FLOAT_PANE).removeChild(this.tooltipObject);
		this.tooltipObject = null;
	}
}

GMarker.prototype.setTooltipClass = function(a) {
	this.pendingClassName = a;
	if (this.tooltipObject)
	{
		var showing = (this.tooltipObject.style.display != "none");
		this.deleteObjects();
		if (this.tooltipRaw)
			this.setTooltipNoResize(this.tooltipRaw);
		if (showing)
			this.showTooltip();

	}
	else
		if (this.tooltipRaw)
			this.setTooltipNoResize(this.tooltipRaw);
}

GMarker.prototype.resetTooltipClass = function() {
	this.setTooltipClass("markerTooltip");
}

GMarker.prototype.showTooltip = function() {
	if (this.tooltipText)
	{
		if (!this.tooltipObject)
			initTooltip(this);
		setTTPosition(this);
		this.tooltipObject.style.display = "block";
	}
}

GMarker.prototype.hideTooltip = function() {
	if (this.tooltipObject)
		this.tooltipObject.style.display = "none";
}

GMarker.prototype.setIcon=function(a){this.X = a}

GMarker.prototype.getInternalId = function(i) {
	return(this.internalId);
}

GMarker.prototype.setInternalId = function(i) {
	this.internalId = i;
	this.percentOpacity = 100;
	this.mouseOutEnabled = true;
	this.setImageOn = true;
	this.hidingEnabled = true;
	this.userData = "";
	this.inMouseOver = false;
	this.permitLeft = true;
}

GMarker.prototype.setOpacityNew = function(b) {
	setObjOpacity(this.objId);
	this.percentOpacity = b;
}
GMarker.prototype.setOpacity = function(b) {
	if (b < 0)
		b=0;
	if (b >= 100)
		b=100;
	var c = b / 100;
	this.percentOpacity = b;
	var d = document.getElementById(this.objId);
	if (d)
	{
		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;}
	}
}

function idToElemId(id) {
	return "ttobj" + id;
}

function initTooltip(theObj) {
	theObj.objId = idToElemId(theObj.internalId);
	theObj.anchorLatLng = theObj.point;

	var b = document.createElement('span');
	theObj.tooltipObject = b;
	b.setAttribute('id',theObj.objId);
	//b.innerHTML = theObj.tooltipText+"___________________________";
	b.innerHTML = theObj.tooltipText;

	// append to body for size calculations
	var c = document.body;
	var d = document.getElementById("pdmarkerwork");
	if (d)
		c = d;
	c.appendChild(b);
	b.style.position = "absolute";
	b.style.bottom = "5px";
	b.style.left = "5px";
	b.style.zIndex = 1;
	//b.style.width = 600;
	//b.style.width = 400;
	if (theObj.percentOpacity)
		theObj.setOpacity(theObj.percentOpacity);
	var tempObj = document.getElementById(theObj.objId);
	theObj.ttWidth  = tempObj.offsetWidth;
	theObj.ttHeight = tempObj.offsetHeight;
	c.removeChild(b);

	b.style.zIndex = 600000;
	b.style.bottom = "";
	b.style.left = "";
	// theObj.globalMap.div.appendChild(b);
      globalMap.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}


function setTTPosition(theObj) {
	//var map = theObj.map;
	var pt  = theObj.getPoint();
	//theObj.tooltipObject.style.left = 80 + "px";
	//theObj.tooltipObject.style.top  = 0 + "px";
	//theObj.tooltipObject.innerHTML = "pt.x: "+pt.x+" - py.y: "+pt.y+"<br/>" ;
	var ttPos = latLongToPixel(globalMap, pt, globalMap.getZoom(),theObj);
	var theIcon = theObj.getIcon();
	ttPos.x += Math.floor(theIcon.iconAnchor.x/2);
	ttPos.y -= Math.floor(theIcon.iconAnchor.y/2);
	//theObj.tooltipObject.innerHTML += "ttPos.x: "+ttPos[0]+" - ttPos.y: "+ttPos[1]+"<br/>" ;
	var rightSide = true;
	var bounds = globalMap.getBounds();
	var boundsSpan	= bounds.toSpan();
	var longSpan = boundsSpan.lng();
	var mapWidth = globalMap.getSize().width;

	var v1 = theObj.ttWidth + theIcon.iconSize.width + 6;
	var tooltipWidthInDeg = v1 / mapWidth * longSpan;
	//theObj.tooltipObject.innerHTML += "tooltipWidthInDeg: "+tooltipWidthInDeg+"<br/>";
	//theObj.tooltipObject.innerHTML += "1 -- <br/>";
	//theObj.tooltipObject.innerHTML += "pt.lng() + tooltipWidthInDeg: "+(pt.lng() + tooltipWidthInDeg)+"<br/>";
	//theObj.tooltipObject.innerHTML += "bounds.getNorthEast().lng(): "+bounds.getNorthEast().lng()+"<br/>";
	
	if (((pt.lng() + tooltipWidthInDeg) > bounds.getNorthEast().lng()) && theObj.permitLeft)
		rightSide = false;

	if(ttPos.x<0)ttPos.x*=-1;
	if(ttPos.y<0)ttPos.y*=-1;

	ttPos.x += (theIcon.iconSize.width);
	ttPos.y -= Math.floor(theObj.ttHeight/2);
	if (!rightSide)
		ttPos.x -= (theObj.ttWidth + theIcon.iconSize.width + 10);
	theObj.ttLeft = ttPos.x;
	theObj.ttTop  = ttPos.y;
	//theObj.tooltipObject.innerHTML += "ttLeft: "+theObj.ttLeft+"<br/>" ;
	//theObj.tooltipObject.innerHTML += "ttTop: "+theObj.ttTop+"<br/>" ;
	if (theObj.tooltipObject)
	{
		theObj.tooltipObject.style.left = theObj.ttLeft + "px";
		theObj.tooltipObject.style.top  = theObj.ttTop + "px";
	}
}

var PdMIN = "";

function PdCompPdMIN(marker) {
	if (PdMIN.length == 0)
		for (var i in marker)
			if (eval("typeof marker." + i) == "object")
				try {
					if (eval("typeof marker." + i + "[0].src") != "undefined")
						PdMIN = "this." + i + "[0]";
				}
				catch (e) {}
}

function GToLatLng(b, a)
{
	this.obj = new GLatLng(a,b);
}
GToLatLng.prototype.getLatLngObj = function() {
	return(this.obj);
}
	

function latLongToPixel(globalMap,coord,zoom, theObj) {
	var topLeft = globalMap.getCurrentMapType().getProjection().fromLatLngToPixel(globalMap.fromDivPixelToLatLng(new GLatLng(0,0),true),globalMap.getZoom());
	//theObj.tooltipObject.innerHTML += "topLeft.x: "+topLeft.x+"<br/>" ;
	//theObj.tooltipObject.innerHTML += "topLeft.y: "+topLeft.y+"<br/>" ;
	var point = globalMap.getCurrentMapType().getProjection().fromLatLngToPixel(coord,globalMap.getZoom());
	//theObj.tooltipObject.innerHTML += "point.x: "+point.x+"<br/>" ;
	//theObj.tooltipObject.innerHTML += "point.y: "+point.y+"<br/>" ;
	return new GPoint(topLeft.x - point.x, topLeft.y - point.y);
}

function getNewGMarkert(point, icon, id, idName, link, descr)
{
	markerTo = new GMarker(point, icon);
	markerTo.setInternalId(id);
	//markerTo.setMap(globalMap);
	markerTo.setId(idName);
	markerTo.setLink(link);
	//markerTo.setMaxIteratorCoordinate(maxC);
	//markerTo.setMinIteratorCoordinate(minC);
	markerTo.setTooltip(descr);
	GEvent.addListener(markerTo, "click", 
	function()
		{
			currentLink = this.getLink();
			//this.getMap().openInfoWindow(this.getPoint(),this.getTooltip());
			globalMap.openInfoWindow(this.getPoint(),this.getTooltip());
			//location = this.getLink();
		}
	);	
	GEvent.addListener(markerTo, "mouseover", 
	function()
		{
			if (this.inMouseOver)
				return;
			this.inMouseOver = true;
			if (!this.detailOpen)
				this.showTooltip();
			this.inMouseOver = false;
		}
	);	
	GEvent.addListener(markerTo, "mouseout", 
	function()
		{
				this.hideTooltip();
		}
	);
	return(markerTo);	
}

function include_dom(script_filename) {
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);
    return false;
}

function includi(contesto)
{
	//printMsgBox("includi: "+contesto);
	if(isSelected(contesto))
	{
		if(document.getElementById("wait")) 
		{
			var el = document.getElementById("elementi");
			var nel = document.getElementById("nascondiElementi");
			var w = document.getElementById("wait");
			w.innerHTML = "Caricamento in corso ...";
			nel.style.display = "block";
			nel.style.width = el.offsetWidth+"px";
			nel.style.height = el.offsetHeight+"px";
		}
		globalMap.clearOverlays();
		clearStruct(contesto);
		creaDaCoordinate();
		//setStato(contesto);
		if(document.getElementById("wait")) 
		{
			document.getElementById("wait").innerHTML = "";
			document.getElementById("nascondiElementi").style.display = "none";
		}
	}
	else
	{
		if(document.getElementById("wait")) 
		{
			var el = document.getElementById("elementi");
			var nel = document.getElementById("nascondiElementi");
			var w = document.getElementById("wait");
			w.innerHTML = "Caricamento in corso ...";
			nel.style.display = "block";
			nel.style.width = el.offsetWidth+"px";
			nel.style.height = el.offsetHeight+"px";
		}
		
		include_dom(""+pathWeb+"/js/defs/"+contesto+"_punti.js");
		include_dom(""+pathWeb+"/js/defs/"+contesto+"_coordinate.js");
		//printMsgBox("includi: "+contesto);
		setTimeout("includi_('" + contesto + "', null)",50);
	}
	return(false);
}

function includi_(contesto, startPoint)
{
	//printMsgBox("includi_: "+contesto);
	//printMsgBox("startPoint: "+startPoint);
	tipoIs = eval("typeof is_"+contesto);
	//printMsgBox("tipoIs: "+tipoIs);
	//if(document.getElementById("wait")) document.getElementById("wait").innerHTML = eval("typeof is_"+contesto+"")+"<br>";
	if(tipoIs == 'boolean')
	{
		addAllCoordinate(contesto);
		//printMsgBox("includi_: "+contesto);
		//printMsgBox("startPoint: "+startPoint);
		currentPoint = findStartPointInContesto(contesto, startPoint);
		getDefaults(contesto);
		
		eval("i = min_"+contesto+"");
		//printMsgBox("i: "+i);
		//printMsgBox("zoomDefault: "+zoomDefault);
		//printMsgBox("iconsAssociate[i]: "+iconsAssociate[i]);
		if(typeof globalMap == "object")
			setIconSize(iconsAssociate[i], zoomDefault);

		//printMsgBox("currentPoint: "+currentPoint);
		if(currentPoint!=null && typeof currentPoint != "undefined")
		{
			zoomValue = getInt(zoomDefaultValue[currentPoint]);
			descrizionePunto = descrizioni[currentPoint];
			centerPoint = coordinate[currentPoint];
			printMsgBox("descrizionePunto: "+descrizionePunto);
		}
		else
		{
			//printMsgBox("typeof globalMap: "+(typeof globalMap));
			if(typeof globalMap == "object")
				globalMap.clearOverlays();
		}

		if(lastZoom==0)
			zoomValue = getInt(zoomDefault);
		else
			zoomValue = lastZoom;

		//printMsgBox("zoomValue: "+zoomValue);

		if(centerPoint!=null && typeof centerPoint != "undefined")
			currentLatLngObj = centerPoint.getLatLngObj();
		//printMsgBox("centerPoint: "+(typeof currentLatLngObj));
		//printMsgBox("lat: "+(currentLatLngObj.lat()));
		//printMsgBox("lng: "+(currentLatLngObj.lng()));
		
		//testEl = new GLatLng(44, 7);
		//globalMap.setZoom(zoomValue);
		//testEl = new GPoint(7, 44);
		currentCenter = new GLatLng(currentLatLngObj.lat(),currentLatLngObj.lng());
		var divMap = document.getElementById("map");
		globalMap = new GMap2(divMap,[G_MAP_TYPE, G_SATELLITE_TYPE, G_HYBRID_TYPE],widthImg,heightImg);
		//printMsgBox("prima");
		//printMsgBox("currentCenter");
		globalMap.setCenter(currentCenter, zoomValue);
		globalMap.panTo(currentLatLngObj);
		globalMap.enableContinuousZoom(); 
		globalMap.enableDoubleClickZoom(); 
		globalMap.addControl(new GOverviewMapControl()); 
		globalMap.addControl(new GLargeMapControl());
		globalMap.addControl(new GMapTypeControl());
		//printMsgBox("dopo");
		creaDaCoordinate();
		if(currentPoint!=null)
			globalMap.openInfoWindow(globalMap.getCenter(),descrizionePunto);
		startPoint = null;
		if(document.getElementById("wait")) 
		{
			document.getElementById("wait").innerHTML = "";
			document.getElementById("nascondiElementi").style.display = "none";
		}
		//printMsgBox("fine");
	}
	else
		setTimeout("includi_('" + contesto + "', '" + startPoint + "')",50);
}


function creaDaCoordinate()
{
	// creo i marker
	var k = 0;
	for(var i = 0;(i < coordinate.length);i++)
	{
		if(coordinate[i] && iconsAssociate[i] && points[i][0] && links[i])
		{
			//markerTo = new GTorinoMarker(coordinate[i].getLatLngObj(), iconsAssociate[i], points[i][0], coordiante.length);
			currentCoord = coordinate[i].getLatLngObj();
			markers[k] = getNewGMarkert(currentCoord, iconsAssociate[i], i, points[i][0], links[i], descrizioni[i]);
			globalMap.addOverlay(markers[k++]);
		}
	}
	
	switch(contesto)
	{
		case "tutti":
			setStato("conf");
			setStato("hotel");
			break;
		case "conf":
		case "hotel":
			setStato(contesto);
			break;
		default:
			break;
	}
	
}

function isSelected(contesto)
{
	var retVal = false;
	obj = document.getElementById("sel_"+contesto);
	if(obj) 
		if(!obj.checked) retVal = true;
	return retVal;
}

function setStato(contesto)
{
	obj = document.getElementById("sel_"+contesto);
	if(obj) 
	{ 
		if(eval("typeof is_" + contesto + " != 'undefined'"))
		{ 
			if(eval("is_" + contesto)) 
			{
				obj.className = "sel";
				obj.checked = true;
			}
			else	
			{
				obj.className = "";
				obj.checked = false;
			}
		}
	}
/*
	else
	{
		setTimeout("setStato('" + contesto + "')",2000);
	}
	*/
}

function clearStruct(contesto)
{
	var currentMin = eval("min_" + contesto);
	var currentMax = eval("max_" + contesto);
/*
	printMsgBox("******************");
	printMsgBox("contesto: "+contesto);
	printMsgBox("currentMin: "+currentMin);
	printMsgBox("currentMax: "+currentMax);
	printMsgBox("prima coordinate: "+getStrCoord());
*/
	//for(i = currentMin;i < currentMax;i++)
	{
		coordinate.splice(currentMin,(currentMax-currentMin));
		zoomDefaultValue.splice(currentMin,(currentMax-currentMin));
		iconsAssociate.splice(currentMin,(currentMax-currentMin));
		links.splice(currentMin,(currentMax-currentMin));
		points.splice(currentMin,(currentMax-currentMin));
		descrizioni.splice(currentMin,(currentMax-currentMin));
		//printMsgBox("i: "+i);
	}
	//printMsgBox("dopo coordinate: "+getStrCoord());
	eval("min_" + contesto + " = undefined");
	eval("max_" + contesto + " = undefined");
	eval("is_" + contesto + " = undefined");
	for(i = 0; i< contestiPossibili.length;i++)
	{
		if(eval("typeof min_" + contestiPossibili[i]) != "undefined")
		{
			if(eval("min_" + contestiPossibili[i]+" > " + currentMin))
			{
				eval("min_" + contestiPossibili[i] + " -= " + (currentMax-currentMin));
				eval("max_" + contestiPossibili[i] + " -= " + (currentMax-currentMin));
			}
			//printMsgBox("min_" + contestiPossibili[i] + ": " + eval("min_" + contestiPossibili[i]));
			//printMsgBox("max_" + contestiPossibili[i] + ": " + eval("max_" + contestiPossibili[i]));
		}
	}
}

function setIconSize(icon, zoom)
{
	var currentZoom = globalMap.getZoom();
	if((currentZoom >= zoomDefault) && (lastZoom >= zoomDefault))
		currentZoom = zoom;
	if((currentZoom <= 8) && (lastZoom <= 8))
		currentZoom = zoom;
	//printMsgBox(currentZoom + " - " + lastZoom + " - " + zoomDefault);
	if(icon.iconSize.width>10)
	{
		var currentWidth = icon.iconSize.width * currentZoom / zoom;
		var currentHeight = icon.iconSize.height * currentZoom / zoom;
		icon.iconSize = new GSize(currentWidth, currentHeight);
	}
	//printMsgBox(icon.iconSize.height + " - " + currentZoom + " - " + zoomDefault);
	//printMsgBox(icon.image + " - " + currentWidth + " - " + currentHeight);
}

function addAllCoordinate(contesto)
{
	eval("getStruct_"+contesto+"()");
	eval("getPunti_"+contesto+"()");
	eval("min_"+contesto+" = coordinate.length");
	//printMsgBox(eval("coordinate_"+contesto+".length"));
	var countCoordCont = eval("coordinate_"+contesto+".length");
	var countCoord = coordinate.length;
	for(var i = countCoord; i < (countCoord + countCoordCont);i++)
	{
		coordinate[i] = eval("coordinate_"+contesto+"[i-countCoord]");
		zoomDefaultValue[i] = eval("zoomDefaultValue_"+contesto+"[i-countCoord]");
		iconsAssociate[i] = eval("icon_"+contesto+"");
		links[i] = eval("links_"+contesto+"[i-countCoord]");
		points[i] = eval("points_"+contesto+"[i-countCoord]");
		descrizioni[i] = eval("descrizioni_"+contesto+"[i-countCoord]");
	}
	eval("max_"+contesto+" = i;");
	//printMsgBox(eval("min_"+contesto+""));
	//printMsgBox(eval("max_"+contesto+""));
}

function addAllPoints(contesto)
{
	//printMsgBox("addAllPoints "+contesto);
	eval("getPunti_"+contesto+"()");
	//printMsgBox("1");
	//eval("min_"+contesto+" = points.length");
	//printMsgBox(eval("coordinate_"+contesto+".length"));
	var countPointsCont = eval("points_"+contesto+".length");
	var countPoints = pointsFind.length;
	//printMsgBox("countPointsCont: "+countPointsCont);
	//printMsgBox("countPoints: "+countPoints);
	for(var i = countPoints; i < (countPoints + countPointsCont);i++)
	{
		pointsFind[i] = eval("points_"+contesto+"[i-countPoints]");
	}
	//eval("max_"+contesto+" = i;");
	//printMsgBox(eval("min_"+contesto+""));
	//printMsgBox(eval("max_"+contesto+""));
}

function printMsgBox(str)
{
	if(document.getElementById("debugBox"))
		document.getElementById("debugBox").innerHTML += str+"<br>";
}

function getAllPunti()
{
	getPunti_hotel();
	addAllPoints("hotel");
}

function clearIconsState()
{
	iconsState = Array();
	if((typeof icon_hotel) != "undefined") 
		iconsState[icon_hotel.image] = false;
}

function findStartPoint(startPoint)
{
	retVal = null;
	if(startPoint != null)
	{
		getAllPunti();
		for(var i = 0;(i < pointsFind.length);i++)
		{
			//printMsgBox("nome: "+pointsFind[i][0]+" - starPoint: "+startPoint);
			if(pointsFind[i])
			{
				if(startPoint == pointsFind[i][0])
				{
					currentPoint = i;
					retVal = pointsFind[i][1];
					//printMsgBox("trovato: "+contesto);
					break;
				}
			}
		}
	}
	return retVal;
}

function findStartPointInContesto(contesto, startPoint)
{
	retVal = null;
	if(startPoint != null)
	{
		for(var i = 0;(i < points.length);i++)
		{
			//printMsgBox("nome: "+pointsFind[i][0]+" - starPoint: "+startPoint);
			if(points[i])
			{
				if(startPoint == points[i][0])
				{
					retVal = i;
					//printMsgBox("trovato: "+i);
					break;
				}
			}
		}
	}
	return retVal;
}

function getStrCoord()
{
	str="("+coordinate.length+") -- ";
	for(var i = 0; i < coordinate.length;i++) 
	{
		currentCoord = coordinate[i].getLatLngObj();
		str += currentCoord.lat()+",";
	}
	return str;
}
