/*
BOX FORM CALAELUNA BOOKINGS - HOR
sal9000
v. 00 2010feb
www.calaeluna.com



var url = unescape( String(this.location) );
*/
var dataod = new Date();
var gg, mm, aaaa;
gg = dataod.getDate();
mm = dataod.getMonth();
aaaa = dataod.getFullYear();
var mese = new Array('Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic');
var day_in = gg;	
var month_in = mese[mm];	
var year_in = aaaa;	


function ultimogiorno(mese,anno) {  
d = new Date(aaaa,mm+1,0)  
return d.getDate();
} 	  


function day_out() {  
m = new Date(aaaa,mm,gg+15);
giorno_out = m.getDate(); 
return giorno_out;
}

function month_out() {  
m = new Date(aaaa,mm,gg+15);
mese_out = m.getMonth(); 
return mese[mese_out];
}

function year_out() {  
m = new Date(aaaa,mm,gg+15);
anno_out = m.getFullYear(); 
return anno_out;
}


function controllo(){ 

with(document.form) {  
mese_in=mese_checkin.value;	
mese_in = mese_in.split(' ');
giorno_in=giorno_checkin.value;
data_check_in = new Date(mese_in[1],mese_in[0],giorno_in);
mese_out=mese_checkout.value;	
mese_out = mese_out.split(' ');
giorno_out=giorno_checkout.value;
data_check_out = new Date(mese_out[1],mese_out[0],giorno_out);
today = new Date(aaaa,mm,gg);

if(data_check_in<today) {
alert("Errore nel campo DATA CHECK IN");
return false; 
}
if(data_check_out<today) {
alert("Errore nel campo DATA CHECK OUT");
return false; 
}
if(data_check_out<=data_check_in) {
alert("Errore nel campo DATA CHECK OUT");
return false; 
}
 
}
} 



function crea_form(box_div_name,box_formname) {
testo=
    
	'<form onSubmit="return controllo();" target="_blank" action="http://www.calaeluna.com/ext_search.php" method="POST" name="form" id="form">'+
	
	
	'<input type="hidden" name="anno" value="'+year_in+'"></input>';	   
	
	testo+=
	'<table class="clb_tbl" summary="boxform calaelunabookings.com">'+
	'<tr >'+
	'<td class="head_sn" colspan="2"></td>';	 
	
	testo=testo+
	'<td class="head_dx" align="left" >HOTEL E SERVIZI TURISTICI<br />+39.0784.928087<br /><a href="http://www.calaeluna.com/">www.calaeluna.com</a></td>'+
	
	
	'</tr><tr>'+
	 '<td class="row_middle" colspan="3">prenota le tue vacanze a cala gonone dorgali</td></tr>'+
	'<tr>'+
	'<td class="row_date" >'+
   
	/*   DATA CHECK IN     */
	
	'Data Check-in<br>'+
	'<select class="input" name="giorno_checkin">';
	
  	
	for (i=1; i<=31; i++) {									
										
	testo=testo+					
	'<option value="'+ i +'"'; 
	
	if (i==gg) {
	testo = testo+
	'selected';	
	}
	else {
	testo = testo+
	' ';	
	}
	
	testo=testo+
	
	'>'+ i +'</option>';
	}				                    
									
									
	testo=testo+								
	'</select>'+	
	
	'<select class="input" name="mese_checkin" >';
	
    for (ii=0; ii<12; ii++) {									
										
	testo=testo+					
	'<option value="'+ ii + " " + year_in +'"'; 
	
	if (ii==mm) {
	testo = testo+
	'selected';	
	}
	else {
	testo = testo+
	' ';	
	}
	
	testo=testo+
	
	'>'+ mese[ii] + " " + year_in +'</option>';
	}	
					                    								
									
	testo=testo+								
	'</select>'+
	
	'</td>'+
	'<td class="row_date" >'+
	'Data Check-out<br>'+
	
	/*   DATA CHECK OUT     */
	'<select class="input" name="giorno_checkout">';
	
	for (i=1; i<32; i++) {									
										
	testo=testo+					
	'<option value="'+ i +'"'; 
	
	if (i==day_out()) {
	testo = testo+
	'selected';	
	}
	else {
	testo = testo+
	' ';	
	}
	
	testo=testo+
	
	'>'+ i +'</option>';
	}				                    
																	
	testo=testo+								
	'</select>'+

	'<select class="input" name="mese_checkout" >';

	for (ii=0; ii<12; ii++) {									
										
	testo=testo+					
	'<option value="'+ ii + " " + year_out() +'"';  
	month_out();
	if (ii==mese_out) {
	testo = testo+
	'selected';	
	}
	else {
	testo = testo+
	' ';	
	}
	
	if (ii==month_out()) {
	testo = testo+
	'selected';	
	}
	else {
	testo = testo+
	' ';	
	}
	
	testo=testo+
	
	'>'+ mese[ii] + " " + year_out()  +'</option>';
	}		                    
																	
	testo=testo+								
	'</select>'+

    '</td>'+
	'<td class="row_button"><input class="button" type="submit" value="verifica disponibilit&agrave;" /></td>'+
	'</tr>'+
	'</table>';

   testo = testo + '</form>';
   window.self.document.getElementById(box_div_name).innerHTML=testo;
   
}	

crea_form('boxform_clb_h','form_clb');