
var xmlResult = null;


function addDataInputPlus(valore, id, nome) {

var splitted = valore.split("/");
if(splitted.length != 3) {
	var oggi = new Date();
	var giorno = oggi.getDate();
	var mese = oggi.getMonth() + 1;
	var anno = oggi.getFullYear();
	giorno++;
}

var newval = giorno + "/" + mese + "/" + anno;

return addDataInput(newval, id, nome);

}


function addDataInput(valore, id, nome) {

var mesiArray = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");

var splitted = valore.split("/");
if(splitted.length != 3) {
	var oggi = new Date();
	var giorno = oggi.getDate();
	var mese = oggi.getMonth() + 1;
	var anno = oggi.getFullYear();
} else {
	var giorno = parseInt(parseVal(splitted[0]));
	var mese = parseInt(parseVal(splitted[1]));
	var anno = parseInt(parseVal(splitted[2]));
}

var giorniMese = 32 - (new Date(anno, mese - 1, 32).getDate());

var input = "<span id='" + id + "_giorno_span'>";
input += "<select name='" + nome + "_giorno' id='" + id + "_giorno' class='calendario_giorno'>";
input += "<option value='0'>&nbsp;</option>";
for(var i = 1; i <= giorniMese; i++) {
	input += "<option value='" + i + "'";
	if(giorno == i)
		input += " selected='selected'";
	input += ">" + i + "</option>";
}
input += "</select>";
input += "</span>";

input += "<select onchange='updateGiorniCalendario(\"" + id + "_giorno_span\", \"" + id + "_mese\", \"" + id + "_anno\");' name='" + nome + "_mese' id='" + id + "_mese' class='calendario_mese'>";
input += "<option value='0'>&nbsp;</option>";
for(var i = 1; i <= mesiArray.length; i++) {
	input += "<option value='" + i + "'";
	if(mese == i)
		input += " selected='selected'";
	input += ">" + mesiArray[i - 1] + "</option>";
}
input += "</select>";

input += "<input style='width: 50px;' type='text' onchange='updateGiorniCalendario(\"" + id + "_giorno_span\", \"" + id + "_mese\", \"" + id + "_anno\");' name='" + nome + "_anno' id='" + id + "_anno' maxlength='4' value='";
input += anno;
input += "' class='calendario_anno'/>";

return input;

}


function addOraInput(valore, id, nome) {

var splitted = valore.split(":");
if(splitted.length != 2) {
	var oggi = new Date();
	var ora = oggi.getHours();
	var minuto = oggi.getMinutes();
	minuto = minuto - (minuto % 5);
	ora++;
} else {
	var ora = parseInt(parseVal(splitted[0]));
	var minuto = parseInt(parseVal(splitted[1]));
	minuto = minuto - (minuto % 5);
}

var input = "<select name='" + nome + "_ora' id='" + id + "_ora' class='orario_ora'>";
for(var i = 0; i < 24; i++) {
	input += "<option value='" + i + "'";
	if(ora == i)
		input += " selected='selected'";
	input += ">" + i + "</option>";
}
input += "</select>";

input += "<select name='" + nome + "_minuto' id='" + id + "_minuto' class='orario_minuto'>";
for(var i = 0; i < 59; i = i + 5) {
	input += "<option value='" + i + "'";
	if(minuto == i)
		input += " selected='selected'";
	input += ">" + i + "</option>";
}
input += "</select>";

return input;

}


function checkTipoParking() {

var id_parcheggio = document.getElementById('parcheggio').value;

for(var i=0; i < parcheggi.length; i++) {
	if(parcheggi[i][0] == id_parcheggio) {
		if(parcheggi[i][2] == '1') {
			document.getElementById('coperto').disabled = false;
			document.getElementById('coperto_label').style.color = 'black';
		} else {
			document.getElementById('coperto').disabled = true;
			document.getElementById('coperto').checked = false;
			document.getElementById('scoperto').checked = true;
			document.getElementById('coperto_label').style.color = 'lightgray';
		}

		if(parcheggi[i][3] == '1') {
			document.getElementById('scoperto').disabled = false;
			document.getElementById('scoperto_label').style.color = 'black';
		} else {
			document.getElementById('scoperto').disabled = true;
			document.getElementById('scoperto').checked = false;
			document.getElementById('coperto').checked = true;
			document.getElementById('scoperto_label').style.color = 'lightgray';
		}

		// TODO
		
		return;
	}
}

}


function loadFormPrenotazione() {

xmlResult = null;

var html = "";

html += "<form id='parcheggioForm' class='formPrenotazione' action='javascript: formSend(\"parcheggioForm\", \"ajax.php\", \"action=calcola\", null, calcolaPrezzo, \"xml\");' method='post'>";
html += "<table>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Parcheggio *</label></td>";
html += "<td>";
html += "<select id='parcheggio' name='parcheggio' onchange='checkTipoParking();'>";

for(var i=0; i < parcheggi.length; i++) {
	html += "<option value='" + parcheggi[i][0] + "'>" + parcheggi[i][1] + "</option>";
}

html += "</select>";
html += "</td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'>";

html += "<input type='radio' name='tipo' id='coperto' value='coperto' checked='checked'/> <label class='normal' id='coperto_label'>Coperto</label>";
html += "<input type='radio' name='tipo' id='scoperto' value='scoperto'/> <label class='normal' id='scoperto_label'>Scoperto</label>";
html += "<span id='tettoia_help'><input type='radio' name='tipo' id='tettoia' value='tettoia'/> <label class='normal' id='tettoia_label'>Tettoia</label></span>";

html += "<div class='tooltip'>";
html += "<img src='images/tettoia.jpg'/>";
html += "</div>";

html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Data di ingresso *</label></td>";
html += "<td>";
html += addDataInput("", "data_ingresso", "data_ingresso");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Ora di ingresso *</label></td>";
html += "<td>";
html += addOraInput("", "ora_ingresso", "ora_ingresso");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Data di uscita *</label></td>";
html += "<td>";
html += addDataInputPlus("", "data_uscita", "data_uscita");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Ora di uscita *</label></td>";
html += "<td>";
html += addOraInput("", "ora_uscita", "ora_uscita");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Numero automobili *</label></td>";
html += "<td><input type='text' value='' name='automobili' id='automobili' style='width: 100px;'/></td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='submit' value='Calcola'/></td>";
html += "</tr>";

html += "</table>";

html += "</form>";

html += "<div id='risultato' style='text-align: center; width: 100%;'></div>";

var div = document.getElementById('form_prenotazione');
div.innerHTML = html;

$("#tettoia_help").tooltip({ effect: 'slide'});

}


function loadFormPrenotazioneEng() {

xmlResult = null;

var html = "";

html += "<form id='parcheggioForm' class='formPrenotazione' action='javascript: formSend(\"parcheggioForm\", \"ajax.php\", \"action=calcola\", null, calcolaPrezzoEng, \"xml\");' method='post'>";
html += "<table>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Parking *</label></td>";
html += "<td>";
html += "<select id='parcheggio' name='parcheggio' onchange='checkTipoParking();'>";

for(var i=0; i < parcheggi.length; i++) {
	html += "<option value='" + parcheggi[i][0] + "'>" + parcheggi[i][1] + "</option>";
}

html += "</select>";
html += "</td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'>";
html += "<input type='radio' name='tipo' id='coperto' value='coperto' checked='checked'/> <label class='normal' id='coperto_label'>Indoor</label>";
html += "<input type='radio' name='tipo' id='scoperto' value='scoperto'/> <label class='normal' id='scoperto_label'>Outdoor</label>";
html += "<span id='tettoia_help'><input type='radio' name='tipo' id='tettoia' value='tettoia'/> <label class='normal' id='tettoia_label'>Covered</label></span>";

html += "<div class='tooltip'>";
html += "<img src='images/tettoia.jpg'/>";
html += "</div>";

html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Date of arrival at the parking *</label></td>";
html += "<td>";
html += addDataInput("", "data_ingresso", "data_ingresso");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Time of arrival *</label></td>";
html += "<td>";
html += addOraInput("", "ora_ingresso", "ora_ingresso");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Date of return to airport *</label></td>";
html += "<td>";
html += addDataInputPlus("", "data_uscita", "data_uscita");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Time of return to airport *</label></td>";
html += "<td>";
html += addOraInput("", "ora_uscita", "ora_uscita");
html += "</td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Number of cars *</label></td>";
html += "<td><input type='text' value='' name='automobili' id='automobili' style='width: 100px;'/></td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='submit' value='Get price'/></td>";
html += "</tr>";

html += "</table>";

html += "</form>";

html += "<div id='risultato' style='text-align: center; width: 100%;'></div>";

var div = document.getElementById('form_prenotazione');
div.innerHTML = html;

$("#tettoia_help").tooltip({ effect: 'slide'});

}


function calcolaPrezzo(xml) {

if(checkXml(xml) == false)
	return;

try {
	var giorni = xml.getElementsByTagName('giorni')[0].firstChild.nodeValue;
	var prezzo = xml.getElementsByTagName('prezzo')[0].firstChild.nodeValue;

} catch(error) {
	return;
}

xmlResult = xml;

var html = "";
html += "<div style='text-align: center; margin: 0 auto; margin-top: 20px; font-size: 16px;'>";
html += "<div style='margin-bottom: 5px;'><label class='normal'>Numero di giorni:</label> " + giorni + "</div>";
html += "<div style='margin-bottom: 5px;'><label class='normal'>Prezzo parcheggio:</label> " + prezzo + " &euro;</div>";
html += "<div style='margin-bottom: 20px;'><input type='button' value='Prenota' onclick='formAnagrafica();'/></div>";
html += "</div>";

var div = document.getElementById('risultato');
div.innerHTML = html;

}


function calcolaPrezzoEng(xml) {

if(checkXml(xml) == false)
	return;

try {
	var giorni = xml.getElementsByTagName('giorni')[0].firstChild.nodeValue;
	var prezzo = xml.getElementsByTagName('prezzo')[0].firstChild.nodeValue;

} catch(error) {
	return;
}

xmlResult = xml;

var html = "";
html += "<div style='text-align: center; margin: 0 auto; margin-top: 20px; font-size: 16px;'>";
html += "<div style='margin-bottom: 5px;'><label class='normal'>Number of days:</label> " + giorni + "</div>";
html += "<div style='margin-bottom: 5px;'><label class='normal'>Parking price:</label> " + prezzo + " &euro;</div>";
html += "<div style='margin-bottom: 20px;'><input type='button' value='Book' onclick='formAnagraficaEng();'/></div>";
html += "</div>";

var div = document.getElementById('risultato');
div.innerHTML = html;

}


function formAnagraficaEng() {

var xml = xmlResult;

try {
	var id_parcheggio = xml.getElementsByTagName('parcheggio')[0].getAttribute('id');
	var automobili = xml.getElementsByTagName('parcheggio')[0].getAttribute('automobili');
	var parcheggio = xml.getElementsByTagName('parcheggio')[0].firstChild.nodeValue;
	var tipo = xml.getElementsByTagName('tipo')[0].firstChild.nodeValue;
	var ingresso = xml.getElementsByTagName('ingresso')[0].firstChild.nodeValue;
	var giorno_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('giorno');
	var mese_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('mese');
	var anno_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('anno');
	var ora_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('ora');
	var minuto_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('minuto');
	var uscita = xml.getElementsByTagName('uscita')[0].firstChild.nodeValue;
	var giorno_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('giorno');
	var mese_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('mese');
	var anno_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('anno');
	var ora_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('ora');
	var minuto_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('minuto');
	var giorni = xml.getElementsByTagName('giorni')[0].firstChild.nodeValue;
	var prezzo = xml.getElementsByTagName('prezzo')[0].firstChild.nodeValue;
	var prezzo_nosconto = xml.getElementsByTagName('nosconto')[0].firstChild.nodeValue;
	var risparmio = xml.getElementsByTagName('risparmio')[0].firstChild.nodeValue;

} catch(error) {
	alert(error);
	return;
}

var html = "";

html += "<form id='parcheggioForm' class='formPrenotazione' action='javascript: formSend(\"parcheggioForm\", \"ajax.php\", \"action=prenota\", null, prenotazioneEng, \"xml\");' method='post'>";

/*
html += "<input type='hidden' name='parcheggio' value='" + document.getElementById('parcheggio').value + "'/>";

html += "<input type='hidden' name='tipo' value='";
if(document.getElementById('coperto').checked == true)
	html += "coperto";
else if(document.getElementById('scoperto').checked == true)
	html += "scoperto";
else
	return;
html += "'/>";
html += "<input type='hidden' name='data_ingresso_giorno' value='" + document.getElementById('data_ingresso_giorno').value + "'/>";
html += "<input type='hidden' name='data_ingresso_mese' value='" + document.getElementById('data_ingresso_mese').value + "'/>";
html += "<input type='hidden' name='data_ingresso_anno' value='" + document.getElementById('data_ingresso_anno').value + "'/>";
html += "<input type='hidden' name='ora_ingresso_ora' value='" + document.getElementById('ora_ingresso_ora').value + "'/>";
html += "<input type='hidden' name='ora_ingresso_minuto' value='" + document.getElementById('ora_ingresso_minuto').value + "'/>";
html += "<input type='hidden' name='data_uscita_giorno' value='" + document.getElementById('data_uscita_giorno').value + "'/>";
html += "<input type='hidden' name='data_uscita_mese' value='" + document.getElementById('data_uscita_mese').value + "'/>";
html += "<input type='hidden' name='data_uscita_anno' value='" + document.getElementById('data_uscita_anno').value + "'/>";
html += "<input type='hidden' name='ora_uscita_ora' value='" + document.getElementById('ora_uscita_ora').value + "'/>";
html += "<input type='hidden' name='ora_uscita_minuto' value='" + document.getElementById('ora_uscita_minuto').value + "'/>";
html += "<input type='hidden' name='automobili' value='" + document.getElementById('automobili').value + "'/>";
*/

html += "<input type='hidden' name='parcheggio' value='" + id_parcheggio + "'/>";
html += "<input type='hidden' name='tipo' value='" + tipo + "'/>";
html += "<input type='hidden' name='data_ingresso_giorno' value='" + giorno_ingresso + "'/>";
html += "<input type='hidden' name='data_ingresso_mese' value='" + mese_ingresso + "'/>";
html += "<input type='hidden' name='data_ingresso_anno' value='" + anno_ingresso + "'/>";
html += "<input type='hidden' name='ora_ingresso_ora' value='" + ora_ingresso + "'/>";
html += "<input type='hidden' name='ora_ingresso_minuto' value='" + minuto_ingresso + "'/>";
html += "<input type='hidden' name='data_uscita_giorno' value='" + giorno_uscita + "'/>";
html += "<input type='hidden' name='data_uscita_mese' value='" + mese_uscita + "'/>";
html += "<input type='hidden' name='data_uscita_anno' value='" + anno_uscita + "'/>";
html += "<input type='hidden' name='ora_uscita_ora' value='" + ora_uscita + "'/>";
html += "<input type='hidden' name='ora_uscita_minuto' value='" + minuto_uscita + "'/>";
html += "<input type='hidden' name='automobili' value='" + automobili + "'/>";

html += "<table>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Name *</label></td>";
html += "<td><input type='text' value='' name='nome' id='nome'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Surname *</label></td>";
html += "<td><input type='text' value='' name='cognome' id='cognome'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>E-mail *</label></td>";
html += "<td><input type='text' value='' name='email' id='email'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Mobile phone *</label></td>";
html += "<td><input type='text' value='' name='cellulare' id='cellulare'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Number of passengers *</label></td>";
html += "<td><input type='text' value='' name='passeggeri' id='passeggeri'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='normal'>Return flight number</label></td>";
html += "<td><input type='text' value='' name='volo_ritorno' id='volo_ritorno'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Flight origin *</label></td>";
html += "<td><input type='text' value='' name='volo_provenienza' id='volo_provenienza'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='normal'>Agency code</label></td>";
html += "<td><input type='text' value='' name='codice_agenzia' id='codice_agenzia'/></td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Parking</label></td>";
html += "<td>" + parcheggio + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td>&nbsp;</td>";
if(tipo == "coperto")
	tipo = "indoor";
else if(tipo == "scoperto")
	tipo = "outdoor";
else if(tipo == "tettoia")
	tipo = "covered";
html += "<td>" + tipo + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Date and time of arrival at the parking</label></td>";
html += "<td>" + ingresso + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Date and time of return to airport</label></td>";
html += "<td>" + uscita + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Number of days</label></td>";
html += "<td>" + giorni + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Number of cars</label></td>";
html += "<td>" + automobili + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Parking price</label></td>";
html += "<td><strike>" + prezzo_nosconto + " &euro;</strike></td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Total price</label></td>";
html += "<td>" + prezzo + " &euro;</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Saving</label></td>";
html += "<td>" + risparmio + " &euro;</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Payment</label></td>";
html += "<td>In parking</td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='checkbox' name='newsletter' id='newsletter' checked='checked'/> <label for='newsletter' style='padding-left: 0.5em;'>Subscribe to newsletter Abycar Srl</label></td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='checkbox' value='accetto' name='accettazione' id='accettazione'/> <b>I accept</b> the <a href='privacy-abycar.pdf' target='_new'>Privacy Policy</a> and <a href='condizioni-generali-abycar.pdf' target='_new'>Terms of parking</a></td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='submit' value='Accept'/> <input type='button' value='Cancel' onclick='loadFormPrenotazione();'/></td>";
html += "</tr>";

html += "</table>";

html += "</form>";

var div = document.getElementById('form_prenotazione');
div.innerHTML = html;

}


function formAnagrafica() {

var xml = xmlResult;

try {
	var id_parcheggio = xml.getElementsByTagName('parcheggio')[0].getAttribute('id');
	var automobili = xml.getElementsByTagName('parcheggio')[0].getAttribute('automobili');
	var parcheggio = xml.getElementsByTagName('parcheggio')[0].firstChild.nodeValue;
	var tipo = xml.getElementsByTagName('tipo')[0].firstChild.nodeValue;
	var ingresso = xml.getElementsByTagName('ingresso')[0].firstChild.nodeValue;
	var giorno_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('giorno');
	var mese_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('mese');
	var anno_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('anno');
	var ora_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('ora');
	var minuto_ingresso = xml.getElementsByTagName('ingresso')[0].getAttribute('minuto');
	var uscita = xml.getElementsByTagName('uscita')[0].firstChild.nodeValue;
	var giorno_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('giorno');
	var mese_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('mese');
	var anno_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('anno');
	var ora_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('ora');
	var minuto_uscita = xml.getElementsByTagName('uscita')[0].getAttribute('minuto');
	var giorni = xml.getElementsByTagName('giorni')[0].firstChild.nodeValue;
	var prezzo = xml.getElementsByTagName('prezzo')[0].firstChild.nodeValue;
	var prezzo_nosconto = xml.getElementsByTagName('nosconto')[0].firstChild.nodeValue;
	var risparmio = xml.getElementsByTagName('risparmio')[0].firstChild.nodeValue;

} catch(error) {
	alert(error);
	return;
}

var html = "";

html += "<form id='parcheggioForm' class='formPrenotazione' action='javascript: formSend(\"parcheggioForm\", \"ajax.php\", \"action=prenota\", null, prenotazione, \"xml\");' method='post'>";

/*
html += "<input type='hidden' name='parcheggio' value='" + document.getElementById('parcheggio').value + "'/>";

html += "<input type='hidden' name='tipo' value='";
if(document.getElementById('coperto').checked == true)
	html += "coperto";
else if(document.getElementById('scoperto').checked == true)
	html += "scoperto";
else
	return;
html += "'/>";
html += "<input type='hidden' name='data_ingresso_giorno' value='" + document.getElementById('data_ingresso_giorno').value + "'/>";
html += "<input type='hidden' name='data_ingresso_mese' value='" + document.getElementById('data_ingresso_mese').value + "'/>";
html += "<input type='hidden' name='data_ingresso_anno' value='" + document.getElementById('data_ingresso_anno').value + "'/>";
html += "<input type='hidden' name='ora_ingresso_ora' value='" + document.getElementById('ora_ingresso_ora').value + "'/>";
html += "<input type='hidden' name='ora_ingresso_minuto' value='" + document.getElementById('ora_ingresso_minuto').value + "'/>";
html += "<input type='hidden' name='data_uscita_giorno' value='" + document.getElementById('data_uscita_giorno').value + "'/>";
html += "<input type='hidden' name='data_uscita_mese' value='" + document.getElementById('data_uscita_mese').value + "'/>";
html += "<input type='hidden' name='data_uscita_anno' value='" + document.getElementById('data_uscita_anno').value + "'/>";
html += "<input type='hidden' name='ora_uscita_ora' value='" + document.getElementById('ora_uscita_ora').value + "'/>";
html += "<input type='hidden' name='ora_uscita_minuto' value='" + document.getElementById('ora_uscita_minuto').value + "'/>";
html += "<input type='hidden' name='automobili' value='" + document.getElementById('automobili').value + "'/>";
*/

html += "<input type='hidden' name='parcheggio' value='" + id_parcheggio + "'/>";
html += "<input type='hidden' name='tipo' value='" + tipo + "'/>";
html += "<input type='hidden' name='data_ingresso_giorno' value='" + giorno_ingresso + "'/>";
html += "<input type='hidden' name='data_ingresso_mese' value='" + mese_ingresso + "'/>";
html += "<input type='hidden' name='data_ingresso_anno' value='" + anno_ingresso + "'/>";
html += "<input type='hidden' name='ora_ingresso_ora' value='" + ora_ingresso + "'/>";
html += "<input type='hidden' name='ora_ingresso_minuto' value='" + minuto_ingresso + "'/>";
html += "<input type='hidden' name='data_uscita_giorno' value='" + giorno_uscita + "'/>";
html += "<input type='hidden' name='data_uscita_mese' value='" + mese_uscita + "'/>";
html += "<input type='hidden' name='data_uscita_anno' value='" + anno_uscita + "'/>";
html += "<input type='hidden' name='ora_uscita_ora' value='" + ora_uscita + "'/>";
html += "<input type='hidden' name='ora_uscita_minuto' value='" + minuto_uscita + "'/>";
html += "<input type='hidden' name='automobili' value='" + automobili + "'/>";

html += "<table>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Nome *</label></td>";
html += "<td><input type='text' value='' name='nome' id='nome'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Cognome *</label></td>";
html += "<td><input type='text' value='' name='cognome' id='cognome'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>E-mail *</label></td>";
html += "<td><input type='text' value='' name='email' id='email'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Cellulare *</label></td>";
html += "<td><input type='text' value='' name='cellulare' id='cellulare'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Numero di passeggeri totale *</label></td>";
html += "<td><input type='text' value='' name='passeggeri' id='passeggeri'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='normal'>Numero volo di ritorno</label></td>";
html += "<td><input type='text' value='' name='volo_ritorno' id='volo_ritorno'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='obbligo'>Provenienza volo *</label></td>";
html += "<td><input type='text' value='' name='volo_provenienza' id='volo_provenienza'/></td>";
html += "</tr>";

html += "<tr>"; 
html += "<td><label class='normal'>Codice agenzia</label></td>";
html += "<td><input type='text' value='' name='codice_agenzia' id='codice_agenzia'/></td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Parcheggio</label></td>";
html += "<td>" + parcheggio + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td>&nbsp;</td>";
html += "<td>" + tipo + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Data di ingresso</label></td>";
html += "<td>" + ingresso + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Data di uscita</label></td>";
html += "<td>" + uscita + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Numero di automobili</label></td>";
html += "<td>" + automobili + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Numero di giorni</label></td>";
html += "<td>" + giorni + "</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Prezzo parcheggio</label></td>";
html += "<td><strike>" + prezzo_nosconto + " &euro;</strike></td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Prezzo totale</label></td>";
html += "<td>" + prezzo + " &euro;</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Risparmio</label></td>";
html += "<td>" + risparmio + " &euro;</td>";
html += "</tr>";

html += "<tr>";
html += "<td><label class='normal'>Pagamento</label></td>";
html += "<td>In parcheggio</td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='checkbox' name='newsletter' id='newsletter' checked='checked'/> <label for='newsletter' style='padding-left: 0.5em;'>Iscriviti alla newsletter di Abycar Srl</label></td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='checkbox' value='accetto' name='accettazione' id='accettazione'/> <b>Accetto</b> l'<a href='privacy-abycar.pdf' target='_new'>Informativa sulla privacy</a> e le <a href='condizioni-generali-abycar.pdf' target='_new'>Condizioni generali di parcheggio</a></td>";
html += "</tr>";

html += "<tr>";
html += "<td colspan='2' class='doubletd'><input type='submit' value='Conferma'/> <input type='button' value='Annulla' onclick='loadFormPrenotazione();'/></td>";
html += "</tr>";

html += "</table>";

html += "</form>";

var div = document.getElementById('form_prenotazione');
div.innerHTML = html;

}


function prenotazione(xml) {

if(checkXml(xml) == false)
	return;

var urlPdf = xml.getElementsByTagName('message')[0].firstChild.nodeValue;

html = "<div style='font-size: 1.2em; margin: 1em 0;'>";
html += "<div style='margin-bottom: 0.5em;'>La richiesta di prenotazione &egrave; andata a buon fine</div>";
html += "<div style='margin-bottom: 0.5em;'>E' stato inviato un messaggio di conferma al suo indirizzo email</div>";
html += "<div style='margin-bottom: 0.5em;'><a href='" + urlPdf + "'>Scarica la ricevuta della prenotazione in formato PDF</a></div>";
html += "</div>";

var div = document.getElementById('form_prenotazione');
div.innerHTML = html;

window.scrollTo(0, getOffset("form_prenotazione", "top"));

}


function prenotazioneEng(xml) {

if(checkXml(xml) == false)
	return;

var urlPdf = xml.getElementsByTagName('message')[0].firstChild.nodeValue;

html = "<div style='font-size: 1.2em; margin-bottom: 1em 0;'>";
html += "<div style='margin-bottom: 0.5em;'>Booking request has been successful </div>";
html += "<div style='margin-bottom: 0.5em;'>A confirmation message was sent to your email address </div>";
html += "<div style='margin-bottom: 0.5em;'><a href='" + urlPdf + "'>Download the receipt of the booking in PDF format</a></div>";
html += "</div>";

var div = document.getElementById('form_prenotazione');
div.innerHTML = html;

window.scrollTo(0, getOffset("form_prenotazione", "top"));

}

