
var Albergo =  CreateHTTP();
var Calendario = CreateHTTP();
var SelPersone = CreateHTTP();
var UpdatePersone = CreateHTTP();




function dettaglioAlbergo(OorC,target,idAlloggio){
	if(OorC)
	{
	Albergo.open("POST", "../offerte/SchedaAlbergo.cfm", true);	
	loadXMLDoc(Albergo,"isAjax=true&idAlloggio=" + idAlloggio ,target);
	}
	else {
	target.innerHTML="<div style=\"margin:0;\" ><hr noshade=\"true\"  style=\"color:#B4B300;margin:0px;\" width=\"100%\"   size=\"1\"><a  class=\"TitoloPacchetti\" href=\"#\" onClick=\"dettaglioAlbergo(true,document.getElementById('sistemazione')," + idAlloggio + ");return false;\" >+ CLICCA QUI e vedi dettagli Alloggio</a></div>";
	}
}



function dettaglioDisponibilita(OorC,target,STRNGparma,fafter){

//	document.getElementById('TempDate').value=STRNGparma
	if(OorC)
	{
   // target.innerHTML='../offerte/SchedaDisponibilita.cfm?'+STRNGparma
	Calendario.open("POST", "../offerte/SchedaDisponibilita.cfm", true);	
	loadXMLDoc(Calendario,STRNGparma ,target,null,null,fafter);
	}
	else {
	target.innerHTML="<div style=\"margin:0;\" ><a  class=\"TitoloPacchetti\" href=\"#\" onClick=\"dettaglioDisponibilita(true,document.getElementById('Disponibilita'),'" + STRNGparma + "');return false;\" >+ CLICCA QUI e scegli la data di inizio</a><hr noshade=\"true\"  style=\"color:#B4B300;margin:0px;\" width=\100%\"   size=\"1\"><\div>";
	}
}

function updateQuantity(STRNGparma){
	
	UpdatePersone.open("POST", "../offerte/VistaCalendario.cfm", true);	
 	//document.getElementById('TempDate').value=STRNGparma;
     
	loadXMLDoc(UpdatePersone,STRNGparma,document.getElementById('TabCalendario'),'<!--fine-->',true,2)

}

function selectDate(obj){
	
	VALORE = obj.getAttribute('valore');
	STATO=obj.getAttribute('stato');
	TIPO=obj.getAttribute('tipo');
    SELEZ=obj.getAttribute('Selezione');
	IDBOOK=obj.getAttribute('idBook');
	MAXQUANTITA=obj.getAttribute('maxquantita');
	PREZZO=obj.getAttribute('prezzo');
	
	if (obj.getAttribute('Selezione') == '0') SELEZ = false;
	else if (obj.getAttribute('Selezione') == '1') SELEZ = true;
	Old=document.getElementById('dataListPrezzi').value
	Old=Old.replace('/','');Old=Old.replace('/','');
	try{
	Old = document.getElementById(Old)
	OldSTATO=Old.getAttribute('stato');
	OldTIPO=Old.getAttribute('tipo');
	Old.setAttribute('Selezione',false);
	document.getElementById(Old.id+'_a').style.backgroundColor="";
	if(OldTIPO == 'festa') document.getElementById(Old.id+'_a').className = 'festa' 
	else document.getElementById(Old.id+'_a').className = '';
	if(OldSTATO == '1') Old.className = 'selez'; 
	else if(OldSTATO == '2') Old.className = 'noDisp';
	else Old.className = '' ;
	}catch(e){;}
	
		a = document.getElementById('squantita').length;
		while (document.getElementById('squantita').length >= 1){
			document.getElementById('squantita').options[a]=null;
		   	a--; }
	a=1;

		while (a <= MAXQUANTITA){
		  tn = a*document.getElementById('squantita').getAttribute('Npersone')
					   
			document.getElementById('squantita').options[a-1]= new Option(tn,a)
			
		   	a++; }
	//	document.getElementById('quantita').value=1;	
	
	document.getElementById(obj.id+'_a').style.backgroundColor="#E2E9EE";
	obj.setAttribute('Selezione',true);

	document.getElementById('dataListPrezzi').value = VALORE;


	//N = VALORE.split('/');
	

    dTemp = new Date(VALORE)

	document.getElementById('dataStartb').value = VALORE;
	document.getElementById('dataArrivo').innerHTML = formatDate(dTemp,"dd/MM/yyyy");
	TMnum = Number(document.getElementById('nPersone').innerHTML);

	document.getElementById('VistaTotale').innerHTML = PREZZO / TMnum ;
	
	Tprez = document.getElementById('VistaTotale').innerHTML
	resa = Number(Tprez);	
    document.getElementById('VistaTotale').innerHTML = resa.toCurrency(2);
	TMnum = Number(document.getElementById('squantita').value);
	document.getElementById('CostoTotale').innerHTML = PREZZO*TMnum;
	Tprez = document.getElementById('CostoTotale').innerHTML
	resa = Number(Tprez);	
    document.getElementById('CostoTotale').innerHTML = resa.toCurrency(2);
	document.getElementById('CurrentBookID').value = IDBOOK;
	Rit = document.getElementById('dataPartenza');
	Drr= Rit.getAttribute('durata')
	N = VALORE.split('/');
    dTemp = new Date(N[0],N[1]-1 ,N[2])
 	dateAdd(dTemp,'d',parseInt(Drr))
	Rit.innerHTML = formatDate(dTemp,"dd/MM/yyyy");
	document.getElementById('dataListPrezzi').value = VALORE ;
	document.getElementById('MaxQuantita').value = MAXQUANTITA
	
	}