	//=======================================================================================================================
//Random BG 
function bgrandom(){
var Immagini = new Array();
Immagini[0] = "/images/sfondi/01.jpg";
Immagini[1] = "/images/sfondi/02.jpg";
Immagini[2] = "/images/sfondi/03.jpg";
Immagini[3] = "/images/sfondi/04.jpg";
Immagini[4] = "/images/sfondi/06.jpg";
Immagini[5] = "/images/sfondi/07.jpg";
Immagini[6] = "/images/sfondi/08.jpg";
Immagini[7] = "/images/sfondi/09.jpg";
Immagini[8] = "/images/sfondi/10.jpg";
Immagini[9] = "/images/sfondi/11.jpg";
Immagini[10] = "/images/sfondi/12.jpg";
Immagini[11] = "/images/sfondi/13.jpg";
Immagini[12] = "/images/sfondi/14.jpg";
Immagini[13] = "/images/sfondi/15.jpg";
Immagini[14] = "/images/sfondi/16.jpg";
Immagini[15] = "/images/sfondi/17.jpg";
Immagini[15] = "/images/sfondi/18.jpg";
Immagini[15] = "/images/sfondi/19.jpg";
Immagini[15] = "/images/sfondi/20.jpg";
Immagini[15] = "/images/sfondi/21.jpg";
Immagini[15] = "/images/sfondi/22.jpg";
Immagini[15] = "/images/sfondi/23.jpg";
Immagini[15] = "/images/sfondi/24.jpg";

var rdn = Math.floor(Math.random() * Immagini.length);
document.write("<img name='header' src="+ Immagini[rdn] +" width='377' height='235' border='0' id='invidia_r3_c3'/>")
//document.write("<body background=" + Immagini[rdn] + " >");
}
//=======================================================================================================================
//MAPPAGGIO

//<![CDATA[
var map = null;
var geocoder = null;
var gdir;
var addressMarker;
var directionsPanel;
var directions;
var GMapMode = "";
var GMapBBLocation = "Largo Marteri di Ciccetti, Subiaco Italia";
var GMapLocLat = 41.92437;
var GMapLocLon = 13.09790;

function inizialize() {
	if (GBrowserIsCompatible()) {
		map      = new GMap2(document.getElementById("map_canvas"));
		gdir     = new GDirections(map, document.getElementById("directions"));
		geocoder = new GClientGeocoder();
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		gdir.load(GMapBBLocation);
		if (GMapMode=="" || GMapMode=="location") {
			map.setCenter(new GLatLng(GMapLocLat,GMapLocLon), 12);
			var point  = new GLatLng(GMapLocLat,GMapLocLon);
          	map.addOverlay(new GMarker(point));
			var marker = new GMarker(point);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml("<img src='images/logo_mappa.gif' alt='B&Berto' />");
			marker.openInfoWindowHtml("Ristorante Invidia");
		}
	}
}
function showDirection(lat,lon,addr) {
	showDirectionsDiv();
	GEvent.addListener(gdir, "load", onGDirectionsLoad);
	GEvent.addListener(gdir, "error", handleErrors);
	setDirections(addr, GMapBBLocation, "it_IT");
	gmapPrintLink(addr,lat+","+lon);
}
function setDirections(fromAddress, toAddress, locale) {
  gdir.load("from: " + fromAddress + " to: " + toAddress,
		   {"locale": locale });
}
function showDirectionsDiv() {
	myDivDirObj = document.getElementById("directions");
	myDivMapObj = document.getElementById("map_canvas");
	if (myDivDirObj.style.display=="none"){
		myDivMapObj.style.width   = "550px";
		myDivDirObj.style.display = "inline";
	}
}
function hideDirectionsDiv() {
	myDivDirObj = document.getElementById("directions");
	myDivMapObj = document.getElementById("map_canvas");
	if (myDivDirObj.style.display=="inline"){
		myDivMapObj.style.width   = "550px";
		myDivDirObj.style.display = "none";
	}
}
function handleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	 alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	 alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	 alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	 alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	 alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
   else alert("An unknown error occurred.");
}
function onGDirectionsLoad(){ 
}
function startSearchDirection(){ 
	formobj = document.cgsearch
	if(!formobj.fromAddress.value || formobj.fromAddress.value == "") { 
	  
	  alert("Inserire la località della ricerca personalizzata");
	  
	  formobj.fromAddress.focus();
	  return false;
	} else { 
	  setDirections(formobj.from.value, formobj.to.value, formobj.locale.value);
	  return false;
	}
}

