function controllo_date(a,p)
{
	var data1=a;
	var data2=p;
	var oggetto1=new Date(parseInt(data1.substr(6),10),parseInt(data1.substr(3,2),10)-1,parseInt(data1.substr(0,2),10));
	var oggetto2=new Date(parseInt(data2.substr(6),10),parseInt(data2.substr(3,2),10)-1,parseInt(data2.substr(0,2),10));
	if(oggetto2-oggetto1<0)
	{
		alert("Achtung, das Feld 'Abreise' ist vor dem Feld 'Ankunft' gewaehlt worden");
		return false;
	}
	if(oggetto2-oggetto1<432000000)
	{
		alert("ACHTUNG, bitte beachten Sie das die Mindestmietdauer 5 Tage betraegt. Bitte aendern Sie das Anreise- oder Abreisedatum.");
		return false;
	}
 	return true;
}
function validate_invio()
{
	if(document.form_pren.codice.value==0)
	{
		alert("Achtung, das Feld 'Kodex Mietobjekt' ist nicht gewaehlt worden");
		return false;
	}
	if( (document.form_pren.arrivo1.value=='' || document.form_pren.partenza1.value=='') && (document.form_pren.arrivo2.value=='' || document.form_pren.partenza2.value=='') )
	{
		alert("Achtung, es muessen beide Felder 'Ankunft' und 'Abreise' ausgefuellt werden");
		return false;
	}
	if(!controllo_date(document.form_pren.arrivo1.value,document.form_pren.partenza1.value))
		return false;
	if(!controllo_date(document.form_pren.arrivo2.value,document.form_pren.partenza2.value))
		return false;
	if(document.form_pren.arrivo2.value!=''&&document.form_pren.partenza2.value!=''&&document.form_pren.durata.value==0)
	{
		alert("Achtung, das Feld 'Aufenthaltszeitraum' ist nicht gewaehlt worden");
		return false;
	}
	if(document.form_pren.cognome.value.length<3||document.form_pren.cognome.value=='Nachname eintragen')
	{
		alert("Achtung! Eingetragener Nachname nicht entsprechend");
		document.form_pren.cognome.select();
		document.form_pren.cognome.focus();
		return false;
	}
	if(document.form_pren.nome.value.length<3||document.form_pren.nome.value=='Vorname eintragen')
	{
		alert("Achtung! Eingegebener Vorname ist nicht entsprechend, nochmals eingeben");
		document.form_pren.nome.select();
		document.form_pren.nome.focus();
		return false;
	}
	if(document.form_pren.persone.value==0)
	{
		alert("Achtung! 'Personenanzahl' waehlen");
		return false;
	}
	var espressione = /^[_a-zäÄöÖüÜß0-9+-]+(\.[_a-zäÄöÖüÜß0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if(!espressione.test(document.form_pren.mail.value))
	{
		alert("Achtung! Eingegebene e-Mail Adresse ist nicht gueltig!");
		return false;
	}
	if(!espressione.test(document.form_pren.conf_mail.value))
	{
		alert("Achtung! Bestaetigte e-Mail Adresse ist nicht gueltig!");
		return false;
	}
	if(document.form_pren.mail.value!=document.form_pren.conf_mail.value)
	{
		alert("Achtung! e-Mail Adresse und bestaetigte e-Mail Adresse muessen uebereinstimmen!");
		return false;
	}
	if(document.form_pren.conosciuto.value==0)
	{
		alert("Achtung! Sie haben das Feld \n'Wie haben Sie unsere Webseite kennen gelernt nicht ausgefuellt'");
		return false;
	}
	if(document.form_pren.messaggio.value=='Nachricht schreiben')
		document.form_pren.messaggio.value='';
}

function apri(link)
{
	window.open(link,'','width='+screen.width+',height='+screen.height+',left=0,top=0,resizable,menubar,toolbar,location,scrollbars,status');
}
function indirizzi()
{
	var pathname=window.location.pathname;
	pos1=pathname.lastIndexOf('/');
	pos2=pathname.indexOf('.');
	pagina=pathname.substring(pos1+1,pos2);
	if(pagina=='index'||pos2==-1)
		document.write("<a class='sommario'>home</a>");
	else
	{
		document.write("<a href='index.php' class='sommario'>home</a><a class='sommario'> > ");
		if(pagina=='Kontakt')
			document.write("Kontakt");
		if(pagina=='Buchungsbedingungen')
			document.write("Buchungsbedingungen");
		if(pagina=='Mietbedingungen')
			document.write("Mietbedingungen");
		if(pagina=='Im_Preis_inklusive')
			document.write("Im Preis inklusive");
		if(pagina=='Zahlbar_vor_Ort')
			document.write("Zahlbar vor Ort");
		if(pagina=='Zusaetzliche_Leistung')
			document.write("Zusaetzliche Leistung");
		if(pagina=='Buchungsvorgang')
			document.write("Buchungsvorgang");
		if(pagina=='eMail_senden')
			document.write("<a href='come_prenotare.php' class='sommario'>Buchungsvorgang</a><a class='sommario'> > eMail senden");
		if(pagina=='Betreuung_vor_Ort')
			document.write("Betreuung vor Ort");
		if(pagina=='Durchschnittstemperaturen')
			document.write("Durchschnittstemperaturen");
		if(pagina=='Legende')
			document.write("Legende");
		if(pagina=='Nuetzliche_Links')
			document.write("Nuetzliche Links");
		if(pagina=='Suche')
		{
			document.write("Suche - Seite ");
			pathname=window.location.href;
			pos1=pathname.indexOf('=');
			pos2=pathname.indexOf('&');
			numero=pathname.substring(pos1+1,pos1+2);
			document.write(numero);
		}
		document.write("</a>");
	}
}
function avviso()
{
	control=0;
	for(i=0;i<5;i++)
	{
		if(document.form.elements[i].value!=0)
		{
			control=1;
			break;
		}
	}
	if(control==0)
		alert("Wenn kein Kriterium eingegeben wird, werden alle Mietobjekt angezeigt");
	ricerca();
}
function cancella()
{
	for(i=0;i<5;i++)
		document.form.elements[i].value=0;
	ricerca();
}
function ricerca()
{
	document.cookie = 'siciliainvilla=' + document.form.menu0.value + '&' + document.form.menu1.value + '&' + document.form.menu2.value + '&' + document.form.menu3.value + '&' + document.form.menu4.value;
	window.location.href='Suche.php?p=1&m0=' + document.form.menu0.value + '&m1=' + document.form.menu1.value + '&m2=' + document.form.menu2.value + '&m3=' + document.form.menu3.value + '&m4=' + document.form.menu4.value + '&s=1';
}
function cambio_pagina(n,s)
{
	aux=document.cookie.substring(15,24);
	window.location.href='Suche.php?p=' + n + '&m0='  + document.form.menu0.value + '&m1=' + document.form.menu1.value + '&m2=' + document.form.menu2.value + '&m3=' + document.form.menu3.value + '&m4=' + document.form.menu4.value + '&s=' + s;
}
function ricerca_posizione(menu,valore)
{
	for(i=0;i<5;i++)
		document.form.elements[i].value=0;
	document.form.elements[menu].value=valore;
	ricerca();
}
