// JavaScript Document
//var expdata = new Object();
//var markers = new Array;
//var markers_overlay = new Array;
//var activeListItem = null;

var foto = null;
//var map = null;
var icon = null;
var iconb = null;

var mia_lat = null;
var mia_lng = null;
var id_corrente = null;

//function GUnload() {
var lat_ini = new Array;
var lng_ini = new Array;
var markers = new Array;
var markers_overlay = new Array;

var ind = Math.round(5*Math.random());
// coordinate casuali per inizio
lat_ini[0]=42.15734816743497;
lat_ini[1]=46.52863469527167;
lat_ini[2]=40.58058466412761;
lat_ini[3]=54.52108149544362;
lat_ini[4]=42.15734816743497;
lat_ini[5]=42.15734816743497;

lng_ini[0]=12.791664123535156;
lng_ini[1]=2.9443359375;
lng_ini[2]=-4.5703125;
lng_ini[3]=-3.9990234375;
lng_ini[4]=12.791664123535156;
lng_ini[5]=12.791664123535156;


/*
 icon = new GIcon();
 icon.image = "http://www.suskype.com/images/sus_off.png";
 icon.shadow = "http://www.suskype.com/images/sus_off.png";
 icon.iconSize = new GSize(18, 31);
 icon.shadowSize = new GSize(18, 31);
 icon.iconAnchor = new GPoint(6, 1);
 icon.infoWindowAnchor = new GPoint(5, 1);

 iconb = new GIcon();
 iconb.image = "http://www.suskype.com/images/sus_on.png";
 iconb.shadow = "http://www.suskype.com/images/sus_on.png";
 iconb.iconSize = new GSize(18, 31);
 iconb.shadowSize = new GSize(18, 31);
 iconb.iconAnchor = new GPoint(6, 1);
 iconb.infoWindowAnchor = new GPoint(5, 1);
*/

 icon = new GIcon();
 icon.image = "images/marker_off.png";
 icon.shadow="images/marker_shadow.png";
 icon.iconSize = new GSize(27, 30);
 icon.shadowSize=new GSize(43,30);
 icon.iconAnchor = new GPoint(12, 29);
 icon.infoWindowAnchor = new GPoint(12, 29);
 

 iconb = new GIcon();
 //iconb.image = "http://www.suskype.com/images/lorenzone63.png";
 iconb.image = "images/marker_on.png";
 icon.shadow="images/marker_shadow.png";
 iconb.iconSize = new GSize(27, 30);
 icon.shadowSize=new GSize(43,30);
 iconb.iconAnchor = new GPoint(12, 29);
 iconb.infoWindowAnchor = new GPoint(12, 29);

 iconbig = new GIcon();
 //iconbig.image = "http://www.suskype.com/images/2_big.png";
 iconbig.image = "images/2_big.png";
 iconbig.iconSize = new GSize(24, 24);
 iconbig.iconAnchor = new GPoint(12, 24);
 iconbig.infoWindowAnchor = new GPoint(16, 5); 
 
//};
// messaggio di benvenuto
//var WINDOW_HTML = '<div style="width: 150px; padding-right: 0px">I realizzatori di Suskype vi danno il benvenuto!!!<\/div>';

function AngoloTL() {
}
AngoloTL.prototype = new GControl();
AngoloTL.prototype.initialize = function(map) {
  var container = document.createElement("img");
  container.src = "images/cornerSXTop.png";
  map.getContainer().appendChild(container);
  return container;
}
AngoloTL.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0));
}

function AngoloTR() {
}
AngoloTR.prototype = new GControl();
AngoloTR.prototype.initialize = function(map) {
  var container = document.createElement("img");
  container.src = "images/cornerDXTop.png";
  map.getContainer().appendChild(container);
  return container;
}
AngoloTR.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0));
}

function AngoloBL() {
}
AngoloBL.prototype = new GControl();
AngoloBL.prototype.initialize = function(map) {
  var container = document.createElement("img");
  container.src = "images/cornerSXBottom.png";
  map.getContainer().appendChild(container);
  return container;
}
AngoloBL.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(0, 0));
}

function AngoloBR() {
}
AngoloBR.prototype = new GControl();
AngoloBR.prototype.initialize = function(map) {
  var container = document.createElement("img");
  container.src = "images/cornerDXBottom.png";
  map.getContainer().appendChild(container);
  return container;
}
AngoloBR.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(0, 0));
}



function carico_video_ajax(video) {
$.get("mostra_video_ajax.php?id_video="+video, function(datiDiRitorno){
$('#video').html(datiDiRitorno);
$('#video').show();
});
}


function TBZZ(id){
		// stop default behaviour
		//event.preventDefault();
		// remove click border
		//this.blur();
	
		// get caption: either title or name attribute
		var caption = this.title || this.name || "";
		
		// get rel attribute for image groups
		var group = this.rel || false;
		
		// display the box for the elements href
		TB_show('', 'mostra_video.php?id_video=' + id + '&KeepThis=true&TB_iframe=true&height=370&width=445', false);
}




function load_registrazione() {
		      if (GBrowserIsCompatible()) {
		        
				map = new GMap2(document.getElementById("map_registrazione"));
		        map.addControl(new GLargeMapControl());
		        map.addControl(new GMapTypeControl());
				
                if (document.iscrizione.i_lng.value == '')
				{
				     var center = new GLatLng(45.36758436884978, 9.95361328125);
		        }
				else
				{
				     var center = new GLatLng(document.iscrizione.i_lat.value, document.iscrizione.i_lng.value);
				}
				
				map.setCenter(center, 4);
		        marker = new GMarker(center, {draggable: true});

		        GEvent.addListener(marker, "dragstart", function() {
		          map.closeInfoWindow();
		        });
		
		        GEvent.addListener(marker, "dragend", function() {
				
		          marker.openInfoWindowHtml("Trascina il marker per <br>indicarne la posizione esatta sulla cartina");
				  var point = marker.getPoint(); 
				  document.iscrizione.i_lng.value = point.lng();
				  document.iscrizione.i_lat.value = point.lat();
		        });
		
		        map.addOverlay(marker);
		
		      }
		    }


function geocodeMe( ){
   geocoder = new GClientGeocoder();
   address = document.iscrizione.i_indirizzo.value + "," + document.iscrizione.i_cap.value + " " +  document.iscrizione.i_citta.value + ", Italia ";
   level = 1;
   geocoder.getLocations(address, addAddressToMap);
}			
			var level;
			// 1: provo con tutto
			// 2: provo con la citta
			// 3: provo solo con il CAP
			
		    function addAddressToMap(response) {
		      map.clearOverlays();
		      if (!response || response.Status.code != 200) {
			  	if( level == 1 ){
					level = 2;
					address = document.iscrizione.i_cap.value + " " +  document.iscrizione.i_citta.value + ", Italia ";
				    geocoder.getLocations(address, addAddressToMap);
				} else if( level == 2 ){
					level = 3;
					address = document.iscrizione.i_cap.value + ", Italia ";
				    geocoder.getLocations(address, addAddressToMap);		
				} else {
					alert("Impossibile geocodificare l'indirizzo.<br /> Procedere al piazzamento manualmente o provare a riformulare l'indirizzo.");
				}
		        } else {
		        place = response.Placemark[0];
		        point = new GLatLng(place.Point.coordinates[1],
		                            place.Point.coordinates[0]);
		        
				//marker = new GMarker(center, {draggable: true});
				
				marker = new GMarker(point, {draggable: true});

			  	 GEvent.addListener(marker, "dragstart", function() {
		          map.closeInfoWindow();
		        });
		
		        GEvent.addListener(marker, "dragend", function() {
				
		          marker.openInfoWindowHtml("Trascina il marker per <br>indicarne la posizione esatta sulla cartina");
				  var point = marker.getPoint(); 
				  document.iscrizione.i_lng.value = point.lng();
				  document.iscrizione.i_lat.value = point.lat();
		        });


		        map.addOverlay(marker);
		        marker.openInfoWindowHtml(place.address + '<br>' +
		          '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode + "<br>Accuratezza:" + place.AddressDetails.Accuracy );
				  document.iscrizione.i_lng.value = point.lng();
				  document.iscrizione.i_lat.value = point.lat();
		      }
			  
			  
			  
		    }			

function load() {
start_nifty();

var WINDOW_HTML = '';

WINDOW_HTML += '<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\table\" width=\"220\">';
WINDOW_HTML += "<tr><td align=\"center\" valign=\"top\">";
WINDOW_HTML += '<img src="zeppa.gif" border="0" width="1" height="10" align="absmiddle"><br>';		  
WINDOW_HTML += 'I realizzatori di Suskype vi danno il benvenuto!!!';
WINDOW_HTML += '</td></tr>';		  
WINDOW_HTML += '</table>';


      if (GBrowserIsCompatible()) {
        

		var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(lat_ini[ind], lng_ini[ind]), 4, G_SATELLITE_MAP);
        
		var marker = new GMarker(new GLatLng(lat_ini[ind], lng_ini[ind]), iconbig);
		
		//map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        //var marker = new GMarker(new GLatLng(37.4419, -122.1419));
		
        map.addOverlay(marker, iconbig);
        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(WINDOW_HTML);
        });
        marker.openInfoWindowHtml(WINDOW_HTML);

      }
    }

	
	


function load_dati(m) {
$("#caricamento").empty();
$("#caricamento").append(carico);
start_nifty();

	  parametri = m.split('|');
	  //alert('record: '+righe_cat[parametri[1]].titolo_annuncio);

      //alert('csono load_dati: '+parametri[0]);

      if (GBrowserIsCompatible()) {
 
        // Categoria singola
		
		//alert(parametri[0]+'&nbsp;|&nbsp;'+parametri[1])
		
		if(parametri[0]=='categoria')
		{
		    $('#titolo').empty();
			$('#titolo').append(righe_cat[parametri[1]].descrizione_categoria);
			
			//alert('cc:'+righe_cat[parametri[1]].descrizione_categoria);
			
            //$('#titolo').append('<h2 style="color:#00adef; font-size: 18px;">annuncio :&nbsp;'+righe_cat[parametri[1]].descrizione_categoria+'</h2>');

			var map = new GMap2(document.getElementById("map"));
	        map.addControl(new GSmallMapControl());
	        map.addControl(new GMapTypeControl());
			map.addControl(new AngoloTL());
            map.addControl(new AngoloBL());
            map.addControl(new AngoloTR());
            map.addControl(new AngoloBR());
			map.setCenter(new GLatLng(righe_cat[parametri[1]].lat, righe_cat[parametri[1]].lng), 13);
	        var titolo = righe_cat[parametri[1]].titolo_annuncio;
			var marker = new GMarker(new GLatLng(righe_cat[parametri[1]].lat, righe_cat[parametri[1]].lng), {icon:icon, title:titolo});
	
	        map.addOverlay(marker);
	        
			//if(righe_cat[parametri[1]].id_ini=='')
	        //{ 
			  GEvent.addListener(marker, "click", function() {
	          marker.openInfoWindowHtml(righe_cat[parametri[1]].html);
	          });
			  marker.openInfoWindowHtml(righe_cat[parametri[1]].html);
            //}
			//else
			//{
			//  GEvent.addListener(marker, "click", function() {
	        //  marker.openInfoWindowHtml(righe_cat[parametri[1]].html);
	        //  });
			//   marker.openInfoWindowHtml(righe_cat[parametri[1]].html);
			//}
        }
        // speciale singolo
		if(parametri[0]=='speciali')
		{
			$('#titolo').empty();
            $('#titolo').append('<h2 style="color:#00adef; font-size: 18px;">'+righe_spe[parametri[1]].azienda+'</h2>');
			var map = new GMap2(document.getElementById("map"));
	        map.addControl(new GSmallMapControl());
	        map.addControl(new GMapTypeControl());
			map.addControl(new AngoloTL());
            map.addControl(new AngoloBL());
            map.addControl(new AngoloTR());
            map.addControl(new AngoloBR());
			map.setCenter(new GLatLng(righe_spe[parametri[1]].lat, righe_spe[parametri[1]].lng), 13);
	        var titolo = righe_spe[parametri[1]].azienda;
			var marker = new GMarker(new GLatLng(righe_spe[parametri[1]].lat, righe_spe[parametri[1]].lng), {icon:icon, title:titolo});
	
	        map.addOverlay(marker);

            //if(righe_spe[parametri[1]].id_inis=='')
	        //{ 
			   GEvent.addListener(marker, "click", function() {
	           marker.openInfoWindowHtml(righe_spe[parametri[1]].html);
			   });
               marker.openInfoWindowHtml(righe_spe[parametri[1]].html);
			//}
			//else
			//{
            //   GEvent.addListener(marker, "click", function() {
	        //   marker.openInfoWindowHtml(righe_spe[parametri[1]].html);
			//   });
			//   marker.openInfoWindowHtml(righe_spe[parametri[1]].html);
			//}
        
		
		
		}

        // Tutti di questa categoria
		if(parametri[0]=='tutte_categorie')
		{
			id_corrente = '';
			var recordPerPagina = 20;
			var maxn = ( parseInt(parametri[1]) + recordPerPagina );
			if( maxn > righe_cat.length ){
				maxn = righe_cat.length;
			}
			$('#titolo').empty();
			$('#titolo').append(righe_cat[0].titolo);
			
		    //$('#titolo').empty();
            //$('#titolo').append('<h2 style="color:#00adef; font-size: 18px;">'+righe_cat[0].descrizione_categoria+'</h2>');
            //$('#titolo').append('Annunci');
			//alert('righe_cat: '+righe_cat.length);
			var map = new GMap2(document.getElementById("map"));
	        var bounds = new GLatLngBounds(); 
			map.clearOverlays();
			map.addControl(new GSmallMapControl());
	        map.addControl(new GMapTypeControl());
			map.addControl(new AngoloTL());
            map.addControl(new AngoloBL());
            map.addControl(new AngoloTR());
            map.addControl(new AngoloBR());
			map.enableDoubleClickZoom();
			map.setCenter(new GLatLng(0,0),0);
			
			// ====== set up marker mouseover tooltip div ======
            //var tooltip = document.createElement("div");
            //map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
            //tooltip.style.visibility="hidden";
			
		    var ctr=0;
			var mio_i = '';
			for( i = parametri[1]; i < maxn; i++ )
			{
			 ctr++;
           	  var point = new GLatLng(righe_cat[i].lat, righe_cat[i].lng);
	          iconm = new GIcon();
              iconm.image = "images/marker_off"+ctr+".png";
              iconm.shadow="images/marker_shadow.png";
              iconm.iconSize = new GSize(27, 30);
              iconm.shadowSize=new GSize(43,30);
              iconm.iconAnchor = new GPoint(12, 29);
              iconm.infoWindowAnchor = new GPoint(12, 29);
			  
			  var marker = createMarker(point, i, iconm, ctr);
			  markers[i] = marker;
			  map.addOverlay(marker); //Estendi i bordi della mappa
	          bounds.extend(point);

			  if( righe_cat[i].id_ini!='0' )
              {
			  	 righe_cat[i].id_ini = '0';
				 GEvent.trigger(markers[i], "click");	  
				 //$('#tab'+ctr).css({ background: "blue" });      
				 //$('#tab'+ctr).addClass("freccia");
			  }


	        } 
        	// zoomma e centra
	        map.setZoom(map.getBoundsZoomLevel(bounds));
			//map.setMapType(G_SATELLITE_MAP);
       	    var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
	        var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2; 
	        map.setCenter(new GLatLng(clat,clng)); 			

			//scrollto(getid('body'));
		}




        // Tutti di questo speciale
		if(parametri[0]=='tutti_speciali')
		{
		     id_corrente = '';
			 var recordPerPagina = 40;
			 var maxn = ( parseInt(parametri[1]) + recordPerPagina );
			 if( maxn > righe_spe.length ){
			 	maxn = righe_spe.length;
			 }
			//alert(parametri[1]);
		    $('#titolo').empty();
            if(righe_spe[0].descrizione_categoria!='')
			{
			  //$('#titolo').append('<h2 style="color:#00adef; font-size: 18px;">'+righe_spe[0].descrizione_categoria+'&nbsp;-&nbsp;'+righe_spe[0].descrizione_provincia+'</h2>');
			  $('#titolo').append(righe_spe[0].titolo);
			}
			
			
			
			//alert('righe_cat: '+righe_cat.length);
			var map = new GMap2(document.getElementById("map"));
	        var bounds = new GLatLngBounds(); 
			map.clearOverlays();
			map.addControl(new GSmallMapControl());
	        map.addControl(new GMapTypeControl());
			map.addControl(new AngoloTL());
            map.addControl(new AngoloBL());
            map.addControl(new AngoloTR());
            map.addControl(new AngoloBR());
			map.enableDoubleClickZoom();
			map.setCenter(new GLatLng(0,0),0);
			
			//alert('lungh:'+righe_spe.length);
			
			//for (var i = 0; i < righe_spe.length; i++)
		    var ctr=0;
			var mio_i = '';
			for( i = parametri[1]; i < maxn; i++ )
			{
			 ctr++;
	          //alert(i+'|'+max);
           	  var point = new GLatLng(righe_spe[i].lat, righe_spe[i].lng);
              
			  iconm = new GIcon();
              iconm.image = "images/marker_off"+ctr+".png";
              iconm.shadow="images/marker_shadow.png";
              iconm.iconSize = new GSize(27, 30);
              iconm.shadowSize=new GSize(43,30);
              iconm.iconAnchor = new GPoint(12, 29);
              iconm.infoWindowAnchor = new GPoint(12, 29);
	          
			  var marker = createMarker1(point, i, iconm, ctr);
	          //var marker_overlay = createMarker1(point, i, iconb);
  
 		      markers[i] = marker;
			  //markers_overlay[i] = marker_overlay;
			  
			  map.addOverlay(marker); //Estendi i bordi della mappa
	          bounds.extend(point);
			  
			  if( righe_spe[i].id_inis!='0' )
              {
			  	 righe_spe[i].id_inis = '0';
				 GEvent.trigger(markers[i], "click");	  
				 //$('#tab'+ctr).css({ background: "blue" });      
				 //$('#tab'+ctr).addClass("freccia");
			  }

			  
	        } 
			
        	// zoomma e centra
	        map.setZoom(map.getBoundsZoomLevel(bounds));
			//map.setMapType(G_SATELLITE_MAP);
       	    var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
	        var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2; 
	        map.setCenter(new GLatLng(clat,clng)); 			
			
		//scrollto(getid('body'));	
		}


      }

$("#caricamento").empty();
$("#caricamento").append(scarico);

}

   function onMouseOverMe( me, id, mio_id ){
		if(id_corrente!=mio_id)
		{
		   me.className = 'test2';
        }
		markers[id].setImage("images/marker_on"+mio_id+".png");
		//map.removeOverlay(markers[id]);
		//map.addOverlay(markers_overlay[id]);
		//map.panTo(new GLatLng(lat1, long1));
	    // attivo fumetto
		//GEvent.trigger(markers[id], "click");
         //$("#mymaps1_contenitore").html("<b>"+righe_spe[id].id+"|"+righe_spe[id].azienda+"<br>"+righe_spe[id].indirizzo+"|"+righe_spe[id].descrizione_provincia+"</b>");
	  }

 
	  //function onMouseOutMe( me, id ){
	  function onMouseOutMe( me, id, mio_id ){
	  	 if(id_corrente!=mio_id)
		 {
		      me.className = "test";
         }
		  markers[id].setImage("images/marker_off"+mio_id+".png");
		  //map.removeOverlay(markers_overlay[id]);
		  //map.addOverlay(markers[id]);
		  // per posizionare la cartina alla posizione originale
		  //map.setCenter(new GLatLng(mia_lat,mia_lng)); 


	  }
         
		 var activeMe = "";
		 var activeID = "";
		 function onClickMe(me, id, mio_id) { 
		  //var activeMe = "";
		  //var activeID = "";
		  id_corrente = mio_id;
		  
		  //if( activeID != '' ){
		  //	activeMe.style.backgroundColor = "#FFFFFF";
		  //} 
		  //me.style.backgroundColor = "#FDFF00";

		  GEvent.trigger(markers[id], "click");
		  activeID = id;
		  activeMe = me;
		  //map.centerAndZoom('12.4879','41.9069','5'); 
		  
		  //$("#mymaps1_contenitore").html("<b>"+righe_spe[id].id+"<br>|"+righe_spe[id].azienda+"<br><br>"+righe_spe[id].indirizzo+"|"+righe_spe[id].descrizione_provincia+"<br><br></b>");
		  
		  }

		 function onClickMeCat(me, id, mio_id) { 
		  //var activeMe = "";
		  //var activeID = "";
		  id_corrente = mio_id;
		  
		  //if( activeID != '' ){
		  //	activeMe.style.backgroundColor = "#FFFFFF";
		  //} 
		  //me.style.backgroundColor = "#FDFF00";

		  GEvent.trigger(markers[id], "click");
		  activeID = id;
		  activeMe = me;
		  //map.centerAndZoom('12.4879','41.9069','5'); 
		  
		  //$("#mymaps1_contenitore").html("<b>"+righe_cat[id].descrizione_categoria+"<br>|"+righe_cat[id].titolo_annuncio+"<br>"+righe_cat[id].annuncio+"<br></b>");
		  
		  }

function createMarker(point, i, icon, mio_id) {
  //var marker = new GMarker(point,icon);
  var titolo = righe_cat[i].titolo_annuncio;
  var marker = new GMarker(point, {icon:icon, title:titolo});
  //alert('id='+righe_spe[i].id+' id_inis='+righe_spe[i].id_inis );
  GEvent.addListener(marker, "click", function() { 
	var multimedia = '';
	var html = righe_cat[i].html;
    marker.openInfoWindowHtml(html);
	id_corrente = mio_id;
	$('#tab'+mio_id).addClass("freccia");
    $('#123').hide();
     //$("#mymaps1_contenitore").html("<b>"+righe_cat[i].descrizione_categoria+"<br>|"+righe_cat[i].titolo_annuncio+"<br>"+righe_cat[i].annuncio+"<br></b>");

	 /*
	 if(righe_cat[i].fotopiccola!='')
	 {
		  multimedia = multimedia+'<img src="foto_annunci/'+righe_cat[i].fotopiccola+'" border="0" vspace="5" hspace="5"></br>';
	 }
	 if(multimedia!='')
	 {
      $("#mymaps1").show();
	  $('#mymaps1_contenitore').highlightFade({color:'yellow', speed:900});
      $("#mymaps1_contenitore").html(multimedia);
	 }
	 else
	 {
	   $("#mymaps1").hide();
	 }
	 */


 	$('#titolo').empty();
    //$('#titolo').append(righe_cat[i].titolo_annuncio+'&nbsp;|&nbsp;'+righe_cat[i].descrizione_categoria);
    $('#titolo').append(righe_cat[i].descrizione_categoria);
 
 
   });

   // Switch icon on marker mouseover and mouseout
   GEvent.addListener(marker, "mouseover", function() {
     marker.setImage("images/marker_on"+mio_id+".png");
	   $('#tab'+mio_id).addClass("test2");
	   
	   h = $('#tab_1_'+mio_id).height() + 2;
        if( ( $.browser.msie ) || ( $.browser.safari ) ){
        //if( $.browser.msie ){
          h += 2;
        }
	   offs = 0;
	   v = $('#listahoteltbs').children();
	   for( i = 0; i < v.length; i++ ){
        if( v[i].id == 'tab_1_'+mio_id ){
          break;
        }
        offs += $('#'+ v[i].id).height() + 2;
        if( ( $.browser.msie ) || ($.browser.safari) ){
          offs += 2;
        }
     }
     
	 if( ( offs + h ) > $('#listahoteltbs').height() + document.getElementById('listahoteltbs').scrollTop ){
        document.getElementById('listahoteltbs').scrollTop = ( ( offs + h ) - ( $('#listahoteltbs').height() ) );
	 }
     if( offs < document.getElementById('listahoteltbs').scrollTop ){
        document.getElementById('listahoteltbs').scrollTop = offs;
	 }
	});
	
    GEvent.addListener(marker, "mouseout", function() {
     marker.setImage("images/marker_off"+mio_id+".png");
	 $('#tab'+mio_id).removeClass("test2");
     });

    GEvent.addListener(marker, "infowindowclose", function() {
	 //alert('chiuso'+mio_id);
     id_corrente = '';
 	 $('#tab'+mio_id).removeClass();
	 $('#tab'+mio_id).addClass("test");
	 });
   
   return marker;
}

function createMarker1(point, i, icon, mio_id) { 
  //var marker = new GMarker(point,icon);
  var titolo = righe_spe[i].azienda;
  var marker = new GMarker(point, {icon:icon, title:titolo});
  //alert('id='+righe_spe[i].id+' id_inis='+righe_spe[i].id_inis );
  GEvent.addListener(marker, "click", function() { 
    var multimedia = '';
	var html = righe_spe[i].html;
    marker.openInfoWindowHtml(html);
	id_corrente = mio_id;
	$('#tab'+mio_id).addClass("freccia");
	$('#123').hide();
	/*
	for( m = 1; m < 9; m++ ){
		if(righe_spe[i]["foto_"+m]!='')
		{
		  multimedia = multimedia+'<img src="foto_speciali/'+righe_spe[i]["foto_"+m]+'" border="0" vspace="5" hspace="5"></br>';
		}
	 }
	 for( m = 1; m < 4; m++ ){
		if(righe_spe[i]["video_"+m]!='')
		{
		  multimedia = multimedia+righe_spe[i]["video_"+m]+'</br>';
		}
	 }
	//alert(multimedia);
	if(multimedia!='')
	{
      $("#mymaps1").show();
	  $('#mymaps1_contenitore').highlightFade({color:'yellow', speed:900});
      $("#mymaps1_contenitore").html(multimedia);
	}
	else
	{
	  $("#mymaps1").hide();
	}
	*/
	
	
	$('#titolo').empty();
    $('#titolo').append(righe_spe[i].azienda);
	
	
	
   });

   // Switch icon on marker mouseover and mouseout
   GEvent.addListener(marker, "mouseover", function() {
     marker.setImage("images/marker_on"+mio_id+".png");
	   $('#tab'+mio_id).addClass("test2");
	   
	   h = $('#tab_1_'+mio_id).height() + 2;
        if( ( $.browser.msie ) || ( $.browser.safari ) ){
        //if( $.browser.msie ){
          h += 2;
        }
	   offs = 0;
	   v = $('#listahoteltbs').children();
	   for( i = 0; i < v.length; i++ ){
        if( v[i].id == 'tab_1_'+mio_id ){
          break;
        }
        offs += $('#'+ v[i].id).height() + 2;
        if( ( $.browser.msie ) || ($.browser.safari) ){
          offs += 2;
        }
     }
     
	 if( ( offs + h ) > $('#listahoteltbs').height() + document.getElementById('listahoteltbs').scrollTop ){
        document.getElementById('listahoteltbs').scrollTop = ( ( offs + h ) - ( $('#listahoteltbs').height() ) );
	 }
     if( offs < document.getElementById('listahoteltbs').scrollTop ){
        document.getElementById('listahoteltbs').scrollTop = offs;
	 }
	});
	
    GEvent.addListener(marker, "mouseout", function() {
     marker.setImage("images/marker_off"+mio_id+".png");
	 $('#tab'+mio_id).removeClass("test2");
     });

    GEvent.addListener(marker, "infowindowclose", function() {
	 //alert('chiuso'+mio_id);
     id_corrente = '';
 	 $('#tab'+mio_id).removeClass();
	 $('#tab'+mio_id).addClass("test");
	 });
   
   return marker;


   } // from http://groups.google.com/group/Google-Maps-API/browse_frm/thread/4cedb228f3a86ea0/    
