// JavaScript Document

//Google map------http://maps.google.it/maps?f=q&hl=it&geocode=&time=&date=&ttype=&q=hotel+traiano+roma&ie=UTF8&ll=41.898188,12.497635&spn=0.112951,0.2314&z=12&iwloc=B&om=1
	
	
	function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
      //  map.addControl(new GSmallMapControl());
		map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
       // map.addControl(new ContourIntervalControl());
        map.addControl(new GScaleControl());
        map.addControl(new GOverviewMapControl(new GSize(110, 110)));
        map.enableDoubleClickZoom();
        map.enableContinuousZoom();
        map.setCenter(new GLatLng(41.897422,12.483859), 12);
		
		
        // Create our "tiny" marker icon
        var icon = new GIcon();
        icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
        icon.iconSize = new GSize(12, 20);
        icon.iconAnchor = new GPoint(5, 1);
        icon.infoWindowAnchor = new GPoint(5, 1);
		
		

        // Add 10 markers to the map at random locations
		var point = new GLatLng(41.897054,12.483859);		
		
		function createMarker_1(point) {
		var marker = new GMarker(point, icon);
		GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml("<h3>Hotel Traiano</h3>HOTEL 4 STELLE ROMA CENTRO<p>Via 4 Novembre, 154 00187 Rome (Lazio) - Tel:06 6783862 <br> </p>");
		});
		return marker;
		}
		
        map.addOverlay(createMarker_1(point));
		
		
		
      }
    }

//-------------------FINR GOOGLE MAP----------------------------------------------------------------------------------------------------------------


//Contatti
function inviaFormContatti() {
	
	var str = document.FormContatti.nome.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo Nome");
		return;}
	
	var str = document.FormContatti.cog.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo Cognome");
		return;}
		
	var str = document.FormContatti.tel.value;
	var re = /^[0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo Telefono");
		return;}

	var str = document.FormContatti.valmail.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo E-mail");
		return;}
		
	var str = document.FormContatti.mess.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo Messaggio");
		return;}
		
	if(document.FormContatti.RadioGroup1[1].checked){
	alert("Per inviare il messaggio accettare il trattamento dei dati personali selezionando la voce Accetta.")
	return;
	}

document.FormContatti.submit();
	}

//Preventivi
function inviaFormPreventivi() {
	
	var str = document.FormPreventivi.referente.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo Referente");
		return;}
	
	var str = document.FormPreventivi.tel.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo Telefono");
		return;}
		

	var str = document.FormPreventivi.mail.value;
	var re = /^[A-Za-z0-9]/;
	
		if (!re.test(str)) {
		alert("Compilare correttamente il campo E-mail");
		return;}
		
		
	if(document.FormPreventivi.RadioGroup1[1].checked){
	alert("Per inviare il messaggio accettare il trattamento dei dati personali selezionando la voce Accetta.")
	return;
	}

document.FormPreventivi.submit();
	}


//apri chiudi / Faq
function toggleLayer(whichLayer) {
  var elem, vis;
  if(document.getElementById) // this is the way the standards work
    elem = document.getElementById(whichLayer);
  else if(document.all) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if(document.layers) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}



	function controllaFormPrenotazione()
	{
		var strErr="";
		
		
		
		if(document.prenotazioni.dal_g.selectedIndex==0)
		{
			strErr+="Il campo Giorno Dal è obbligatorio.\n";
		}

		if(document.prenotazioni.dal_m.selectedIndex==0)
		{
			strErr+="Il campo Mese Dal è obbligatorio.\n";
		}

		if(document.prenotazioni.dal_a.selectedIndex==0)
		{
			strErr+="Il campo Anno Dal è obbligatorio.\n";
		}

		if(document.prenotazioni.al_g.selectedIndex==0)
		{
			strErr+="Il campo Giorno Al è obbligatorio.\n";
		}

		if(document.prenotazioni.al_m.selectedIndex==0)
		{
			strErr+="Il campo Mese Al è obbligatorio.\n";
		}

		if(document.prenotazioni.al_a.selectedIndex==0)
		{
			strErr+="Il campo Anno Al è obbligatorio.\n";
		}

		if(document.prenotazioni.dal_g.value<10)
		{
			dal_giorno="0"+document.prenotazioni.dal_g.value;
		}
		else
		{
			dal_giorno=document.prenotazioni.dal_g.value;
		}
		
		if(document.prenotazioni.dal_m.value<10)
		{
			dal_mese="0"+document.prenotazioni.dal_m.value;
		}
		else
		{
			dal_mese=document.prenotazioni.dal_m.value;
		}
		
		if(document.prenotazioni.al_g.value<10)
		{
			al_giorno="0"+document.prenotazioni.al_g.value;
		}
		else
		{
			al_giorno=document.prenotazioni.al_g.value;
		}
		
		if(document.prenotazioni.al_m.value<10)
		{
			al_mese="0"+document.prenotazioni.al_m.value;
		}
		else
		{
			al_mese=document.prenotazioni.al_m.value;
		}
		
		dal_anno=document.prenotazioni.dal_a.value;
		al_anno=document.prenotazioni.al_a.value;
		
		data_dal="";
		data_al="";
		
		if(dal_giorno!="" && dal_mese!="" && dal_anno!="")
		{
			data_dal=dal_anno+"-"+dal_mese+"-"+dal_giorno;
		}
		
		if(al_giorno!="" && al_mese!="" && al_anno!="")
		{
			data_al=al_anno+"-"+al_mese+"-"+al_giorno;
		}
		
		if(data_dal!="" && data_al!="" && data_dal>=data_al)
		{
			strErr+="- La data di fine soggiorno "+data_al+" deve essere posteriore a quella di inizio del soggiorno.\n";
		}


	var str = document.prenotazioni.persone.value;
	var re = /^[0-9]/;
	
		if (!re.test(str)) {
		strErr+="- Indicare il numero di persone.\n";
		}

		

	var str = document.prenotazioni.camere.value;
	var re = /^[0-9]/;
	
		if (!re.test(str)) {
		strErr+="- Indicare il numero di camere.\n";
		}



		if(strErr!="")
		{
			alert("ATTENZIONE!\n\n" + strErr + "\n");
			return false;
		}
		else 
		{

			//var mia_url = 'http://booking.ngsservice.net/ricerca.asp'
			//var sito_url = document.location
			
			//if(mia_url!=sito_url){document.prezzi.target = '_blank'}
			document.prenotazioni.submit();
			return true;
		}
	}


	function controllaFormPrenotazioneUK()
	{
		var strErr="";
		
		
		
		if(document.prenotazioni.dal_g.selectedIndex==0)
		{
			strErr+="Day From is a required field.\n";
		}

		if(document.prenotazioni.dal_m.selectedIndex==0)
		{
			strErr+="Month From is a required field.\n";
		}

		if(document.prenotazioni.dal_a.selectedIndex==0)
		{
			strErr+="Year From is a required field.\n";
		}

		if(document.prenotazioni.al_g.selectedIndex==0)
		{
			strErr+="Day To is a required field.\n";
		}

		if(document.prenotazioni.al_m.selectedIndex==0)
		{
			strErr+="Month To is a required field.\n";
		}

		if(document.prenotazioni.al_a.selectedIndex==0)
		{
			strErr+="Year To is a required field.\n";
		}

		if(document.prenotazioni.dal_g.value<10)
		{
			dal_giorno="0"+document.prenotazioni.dal_g.value;
		}
		else
		{
			dal_giorno=document.prenotazioni.dal_g.value;
		}
		
		if(document.prenotazioni.dal_m.value<10)
		{
			dal_mese="0"+document.prenotazioni.dal_m.value;
		}
		else
		{
			dal_mese=document.prenotazioni.dal_m.value;
		}
		
		if(document.prenotazioni.al_g.value<10)
		{
			al_giorno="0"+document.prenotazioni.al_g.value;
		}
		else
		{
			al_giorno=document.prenotazioni.al_g.value;
		}
		
		if(document.prenotazioni.al_m.value<10)
		{
			al_mese="0"+document.prenotazioni.al_m.value;
		}
		else
		{
			al_mese=document.prenotazioni.al_m.value;
		}
		
		dal_anno=document.prenotazioni.dal_a.value;
		al_anno=document.prenotazioni.al_a.value;
		
		data_dal="";
		data_al="";
		
		if(dal_giorno!="" && dal_mese!="" && dal_anno!="")
		{
			data_dal=dal_anno+"-"+dal_mese+"-"+dal_giorno;
		}
		
		if(al_giorno!="" && al_mese!="" && al_anno!="")
		{
			data_al=al_anno+"-"+al_mese+"-"+al_giorno;
		}
		
		if(data_dal!="" && data_al!="" && data_dal>data_al)
		{
			strErr+="- The date of check out "+data_al+" must be later than the check in "+data_dal+".\n";
		}


	var str = document.prenotazioni.persone.value;
	var re = /^[0-9]/;
	
		if (!re.test(str)) {
		strErr+="- People is a required field.\n";
		}

		

	var str = document.prenotazioni.camere.value;
	var re = /^[0-9]/;
	
		if (!re.test(str)) {
		strErr+="- Rooms is a required field.\n";
		}



		if(strErr!="")
		{
			alert("ATTENTION!\n\n" + strErr + "\n");
			return false;
		}
		else 
		{

			//var mia_url = 'http://booking.ngsservice.net/ricerca.asp'
			//var sito_url = document.location
			
			//if(mia_url!=sito_url){document.prezzi.target = '_blank'}
			document.prenotazioni.submit();
			return true;
		}
	}
