

function agg_zero (c) {
r = "";
if (c < 10) {
r = "0";
} // fine if (c < 10)
return r;
} // fine function agg_zero



function update_sel_dates(id) {
var sel_opt=document.getElementById("id_sdp"+id);
var other_id = id;
if (Math.ceil(id/2) != Math.floor(id/2)) other_id++;
else other_id--;
other_sel_opt = document.getElementById("id_sdp"+other_id);
var num_sel = sel_opt.selectedIndex;
var other_num_sel = other_sel_opt.selectedIndex;
if (other_sel_opt.options[other_sel_opt.selectedIndex].text != "----") {
var add_ns = 0;
var o_add_ns = 0;
if (sel_opt.options[0].text == "----") add_ns = 1;
if (other_sel_opt.options[0].text == "----") o_add_ns = 1;
if ((other_id > id) && ((num_sel - add_ns) >= (other_num_sel - o_add_ns))) var new_sel_opt = num_sel - add_ns + o_add_ns + 1;
if ((other_id < id) && ((num_sel - add_ns) <= (other_num_sel - o_add_ns))) var new_sel_opt = num_sel - add_ns + o_add_ns - 1;
if (new_sel_opt >= 0) other_sel_opt.selectedIndex = new_sel_opt;
} // fine if (other_sel_opt.options[other_sel_opt.selectedIndex].text != "----")
} // fine function update_sel_dates



function crea_date () {
var giorni = new Array(" Do"," Lu"," Ma"," Me"," Gi"," Ve"," Sa");
var mesi = new Array("Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic");
opz = "";

var oggi = new Date();
var m_oggi = oggi.getMonth();
var g_oggi = oggi.getDate();
var a_oggi = oggi.getFullYear();
var data_oggi = a_oggi+"-"+agg_zero((m_oggi + 1))+(m_oggi + 1)+"-"+agg_zero(g_oggi)+g_oggi;

giorno = 7;
mese = 2;
anno = 2009;

for (n1 = 1 ; n1 <= 365 ; n1++) {
d = new Date(anno,mese,giorno);
mese = d.getMonth();
giorno = d.getDate();
anno = d.getFullYear();
data_corr = anno+"-"+agg_zero((mese + 1))+(mese + 1)+"-"+agg_zero(giorno)+giorno;
if (data_corr > data_oggi) {
opz += "<option value=\""+data_corr+"\">"+mesi[mese]+" "+agg_zero(giorno)+giorno+", "+anno+"</option>";
} // fine if (data_corr >= data_oggi)
giorno = giorno + 1;
} // fine for n1

} // fine function crea_date
