<?php

##################################################################################
#    PHP-RESIDENCE
#    Copyright (C) 2001-2009 by Marco Maria Francesco De Santis (marco@digitaldruid.net)
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    any later version accepted by Marco Maria Francesco De Santis, which
#    shall act as a proxy as defined in Section 14 of version 3 of the
#    license.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
##################################################################################



global $id_select_dates_menu;
if (!$id_select_dates_menu) $id_select_dates_menu = 0;
$id_select_dates_menu++;
if (!$standalone_dates_menu) $events = " onChange=\\\"update_selected_dates('$id_select_dates_menu')\\\"";
else $id_select_dates_menu++;



echo "<script type=\"text/javascript\">
<!--
document.write(\"<select name=\\\"$name_date_var\\\" id=\\\"id_sdm$id_select_dates_menu\\\"$events>\");
";
if ($show_blank_option) echo "document.write(\"<option value=\\\"\\\"$blank_selected>----<\/option>\");
";


if ($last_dates_menu != $file) {
$hide_default_dates = 1;
echo "giorni = new Array($d_names);
mesi = new Array($m_names);
opz = \"\";
";
$periods_num = count($d_increment);
$day_name = "";
for ($num1 = 0 ; $num1 < $periods_num ; $num1++) if ($d_increment[$num1] != 7) $day_name = "+giorni[d.getDay()]";
for ($num1 = 0 ; $num1 < $periods_num ; $num1++) {
echo "giorno = ".$d_ini_menu[$num1].";
mese = ".$m_ini_menu[$num1].";
anno = ".$y_ini_menu[$num1].";
for (n1 = 1 ; n1 <= ".$n_dates_menu[$num1]." ; n1++) {
d = new Date(anno,mese,giorno);
anno = d.getFullYear();
mese = d.getMonth();
giorno = d.getDate();
opz += \"<option value=\\\"\"+anno+\"-\"+agg_zero((mese + 1))+(mese + 1)+\"-\"+agg_zero(giorno)+giorno+\"\\\">\"+mesi[mese]+\" \"+agg_zero(giorno)+giorno".$day_name."+\", \"+anno+\"<\/option>\";
giorno = giorno + ".$d_increment[$num1].";
} // fine for n1
";
} # fine for $num1

if ($date_selected) echo "document.write(opz.replace(\"$date_selected\\\">\",\"$date_selected\\\" selected>\"));";
else echo "document.write(opz);";
} # fine if ($last_dates_menu != $file)

else {
if ($date_selected) echo "document.write(opz.replace(\"$date_selected\\\">\",\"$date_selected\\\" selected>\"));";
else echo "document.write(opz);";
} # fine else if ($last_dates_menu != $file)

echo "
document.write(\"<\/select>\");
//-->
</script>";

echo "<input type=\"button\" class=\"dbutton\" id=\"bcal$id_select_dates_menu\" onclick=\"mos_cal($id_select_dates_menu)\" value=\"..\">
<div id=\"cal$id_select_dates_menu\" class=\"datepick\"></div>";






?>