// funzione per caricare gli swf senza blocco
function generatorflash(versione,larghezza,altezza,allineamento,nomefile,menu,coloreSfondo,traspSfondo,qualita) {

var N1;
	
	N1=('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + versione + '"WIDTH="' + larghezza + '" HEIGHT="' + altezza + '" align="' + allineamento + '">');
	N1= N1+ ('<PARAM NAME="movie" VALUE="' + nomefile + '">'); 			//Nome del file
	N1= N1+ ('<PARAM NAME="menu" VALUE=False>');						//Visibilità del menu - true (visible) - false (invisibile)
	N1= N1+ ('<PARAM NAME="bgcolor" VALUE="' + coloreSfondo + '"> ');	//Colore dello sfondo - es. #000000 (nero)
	N1= N1+ ('<PARAM NAME="wmode" VALUE="' + traspSfondo + '"> ');		//Trasparenza dello sfondo - normal (normale) - opaque (opaco) - transparent (trasparente)
	N1= N1+ ('<PARAM NAME="quality" VALUE="' + qualita + '">');			//Qualita del file - low (bassa) - medium (media) - high (alta) - best (migliore)
	N1= N1+ ('<PARAM NAME="allowScriptAccess" VALUE="sameDomain"> ');	//Sicurezza - non toccare

	N1= N1+ ('<embed src="' + nomefile + '" quality=high WIDTH="' + larghezza + '" HEIGHT="' + altezza + '" align="' + allineamento + '" bgcolor="' + coloreSfondo + '" wmode="' + traspSfondo + '" menu="' + menu + '" quality="' + qualita + '" TYPE="application/x-shockwave-flash"');
	N1= N1+ ('PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></OBJECT>')

	document.write(N1);
}

// funzione per aprile le pop up
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// funzione per gestire i rollOver sui loghi del gruppo
function hideshow(which1, which2){
if (!document.getElementById)
return
	which1.style.display="inline"
	which2.style.display="none"
}

// funzione per aggiungere ai preferiti
function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "");
}

function Menu(links) {
	location.href = links[links.selectedIndex].value;
}

function expandSearch() {
	
	if(document.getElementById("expand").className == "titExpand")
	{
		document.getElementById("expand").className = "";
		
		var flashSearchMov = new SWFObject("/it/swf/ricercaGalleria.swf", "mymovie", "575", "157", "7,0,0,0", "#FFFFFF");
		flashSearchMov.addParam("quality", "high");
		flashSearchMov.addParam("wmode", "transparent");
		flashSearchMov.addParam("quality", "high");
		flashSearchMov.write("flashSearch");
		
		var flashOpenMov = new SWFObject("/it/swf/apertureStraordinarie.swf", "mymovie", "275", "312", "7,0,0,0", "#FFFFFF");
		flashSearchMov.addParam("quality", "high");
		flashSearchMov.addParam("wmode", "transparent");
		flashSearchMov.addParam("quality", "high");
		flashOpenMov.write("flashOpen");
	}
	else
	{
		document.getElementById("expand").className = "titExpand";
		
		document.getElementById("flashSearch").innerHTML="";
				
		var flashOpen = new SWFObject("/it/swf/apertureStraordinarieSmall.swf", "mymovie", "275", "157", "7,0,0,0", "#FFFFFF");
		flashOpen.addVariable("wmode", "transparent");
		flashOpen.addVariable("menu", "false");
		flashOpen.addVariable("quality", "high");
		flashOpen.write("flashOpen");
	}
}

function expandSearchEn() {
	
	if(document.getElementById("expand").className == "titExpand")
	{
		document.getElementById("expand").className = "";
		
		var flashSearchMov = new SWFObject("/it/swf/ricercaGalleria_EN.swf", "mymovie", "575", "157", "7,0,0,0", "#FFFFFF");
		flashSearchMov.addParam("quality", "high");
		flashSearchMov.addParam("wmode", "transparent");
		flashSearchMov.addParam("quality", "high");
		flashSearchMov.write("flashSearch");
		
		var flashOpenMov = new SWFObject("/it/swf/apertureStraordinarie_EN.swf", "mymovie", "275", "204", "7,0,0,0", "#FFFFFF");
		flashSearchMov.addParam("quality", "high");
		flashSearchMov.addParam("wmode", "transparent");
		flashSearchMov.addParam("quality", "high");
		flashOpenMov.write("flashOpen");
	}
	else
	{
		document.getElementById("expand").className = "titExpand";
		
		document.getElementById("flashSearch").innerHTML="";
				
		var flashOpen = new SWFObject("/it/swf/apertureStraordinarieSmall_EN.swf", "mymovie", "275", "157", "7,0,0,0", "#FFFFFF");
		flashOpen.addVariable("wmode", "transparent");
		flashOpen.addVariable("menu", "false");
		flashOpen.addVariable("quality", "high");
		flashOpen.write("flashOpen");
	}
}

function setHtml(txtProgetto){
	if (txtProgetto == "1")
	{
		document.getElementById("txtProgettiHome").innerHTML="<a href='/it/2_1.asp'>La Porta del Garda, centro commerciale situato a Gavardo (BS) copre un'area di 10.000 mq e conter&agrave; 27 negozi di svariate merceologie.</a>";
		document.getElementById("link1").className = "linkActive";
		document.getElementById("link2").className = "";	
	}
	if (txtProgetto == "2")
	{
		document.getElementById("txtProgettiHome").innerHTML="<a href='/it/2_1.asp'>La Porta del Garda, centro commerciale situato a Gavardo (BS) copre un'area di 10.000 mq e conter&agrave; 27 negozi di svariate merceologie.</a>";
		document.getElementById("link2").className = "linkActive";
		document.getElementById("link1").className = "";			
	}
		
}

function load() {
    var _lang;
    try {
        _lang = lang;
    } catch(e) {
        _lang = "it";
    }
	if (GBrowserIsCompatible()) {
	  var gmarkers = [];
	  var htmls = [];
	  var i = 0;
	  
	  // Icone personalizzate
	  
	  // Icona per centri aperti
	  var greenIcon = new GIcon();
	  greenIcon.image = "/it/images/markerGreen.png";
	  greenIcon.iconSize = new GSize(20, 22);
	  greenIcon.iconAnchor = new GPoint(0, 22);
	  greenIcon.infoWindowAnchor = new GPoint(-8, 20);
	
	  /// Icona per centri di prossima apertura
	  var redIcon = new GIcon();
	  redIcon.image = "/it/images/markerRed.png";
	  redIcon.iconSize = new GSize(20, 22);
	  redIcon.iconAnchor = new GPoint(0, 22);
	  redIcon.infoWindowAnchor = new GPoint(-8, 15);
	  
	  /// Icona per centri blu
	  var blueIcon = new GIcon();
	  blueIcon.image = "/it/images/markerBlue.png";
	  blueIcon.iconSize = new GSize(20, 22);
	  blueIcon.iconAnchor = new GPoint(0, 22);
	  blueIcon.infoWindowAnchor = new GPoint(-8, 15);
	  
	  // Creo l'array di icone
	  var icons = [];
	  icons[0] = greenIcon;
	  icons[1] = redIcon;
	  icons[2] = blueIcon;
	
	  // the icon information is passed to this function
	  function createMarker(point,name,html,icontype) {
		var marker = new GMarker(point,icons[icontype]);
		GEvent.addListener(marker, "click", function() {
			//marker.openInfoWindowHtml(html);
			ew.openOnMarker(marker,html);
			map.panTo(point);
		});
		// save the info we need to use later for the side_bar
		gmarkers[i] = marker;
		htmls[i] = html;
		i++;
		return marker;
	  }
	
	  function myclick(i) {
		gmarkers[i].openInfoWindowHtml(htmls[i]);
	  }
	
	  var map = new GMap2(document.getElementById("mapHeader"));
	  map.enableScrollWheelZoom();
	  map.addControl(new GLargeMapControl());
	  map.addControl(new GHierarchicalMapTypeControl());
	  map.addMapType(G_PHYSICAL_MAP);
	  map.setCenter(new GLatLng(45.25, 11.00), 7, G_PHYSICAL_MAP);  
	  
	  // Create an EWindow
	  ew = new EWindow(map, E_STYLE_1);
	  map.addOverlay(ew);

	  // Leggi dati dall'xml
	  var request = GXmlHttp.create();
	  request.open("GET", "/"+_lang+"/xml/centri.xml", true);
	  request.onreadystatechange = function() {
		if (request.readyState == 4) {
		  var xmlDoc = GXml.parse(request.responseText);
		  // obtain the array of markers and loop through it
		  var markers = xmlDoc.documentElement.getElementsByTagName("marker");
		  
		  for (var i = 0; i < markers.length; i++) {
			// obtain the attribues of each marker
			var lat = parseFloat(markers[i].getAttribute("lat"));
			var lng = parseFloat(markers[i].getAttribute("lng"));
			var point = new GLatLng(lat,lng);
			var html = markers[i].getAttribute("html");
			var label = markers[i].getAttribute("label");
			var icontype = parseInt(markers[i].getAttribute("icontype"));
			// create the marker
			var marker = createMarker(point,label,html,icontype);
			map.addOverlay(marker);
		  }
		}
	  }
	  request.send(null);
	}
	
	else {
	  alert("Sorry, the Google Maps API is not compatible with this browser");
	}
  
	// ========== Close the EWindow if theres a map click ==========
	GEvent.addListener(map, "click", function(marker,point) {
		if (point) {
			ew.hide();
		}
	});
	
	//----- Stop page scrolling if wheel over map ---- 
	function wheelevent(e)
	{
		if (!e) e = window.event;
		if (e.preventDefault) e.preventDefault();
		e.returnValue = false;
	}
	var mappaScroll = document.getElementById("mapHeader");
	GEvent.addDomListener(mappaScroll, "DOMMouseScroll", wheelevent);
	mappaScroll.onmousewheel = wheelevent;

}

function VediAttesa()
{
    var element; 
    
	element = document.getElementById("msgAttesa");
	element.style.display = "inline";
}
