--- openwebmail-cal.pl	Fri Dec 12 07:05:48 2003
+++ openwebmail-cal.pl	Sun Dec 14 14:32:11 2003
@@ -849,7 +849,11 @@
    $day=$days_in_month[$month] if ($day>$days_in_month[$month]); $day=1 if ($day<1);
 
    my ($html, $temphtml);
-   $html = applystyle(readtemplate("dayview.template"));
+   $html = readtemplate("dayview.template");
+   $html .= readtemplate("calpopup.js");
+   $html .= readtemplate("validate.js");
+   $html .= readtemplate("nothing.js");
+   $html = applystyle($html);
 
    $temphtml = startform(-name=>'yearform',
 			 -action=>"$config{'ow_cgiurl'}/openwebmail-cal.pl").
@@ -1200,6 +1204,12 @@
    $html =~ s/\@\@\@WDAY_ARRAY\@\@\@/$temphtml/;
    $temphtml=qq|'$lang_order{1}','$lang_order{2}','$lang_order{3}','$lang_order{4}','$lang_order{5}'|;
    $html =~ s/\@\@\@WORDER_ARRAY\@\@\@/$temphtml/;
+   $temphtml=qq|'$lang_wday_abbrev{0}','$lang_wday_abbrev{1}','$lang_wday_abbrev{2}','$lang_wday_abbrev{3}','$lang_wday_abbrev{4}','$lang_wday_abbrev{5}','$lang_wday_abbrev{6}'|;
+   $html =~ s/\@\@\@WDAYABBREV_ARRAY\@\@\@/$temphtml/;
+   $temphtml=qq|'$lang_month{1}','$lang_month{2}','$lang_month{3}','$lang_month{4}','$lang_month{5}','$lang_month{6}','$lang_month{7}','$lang_month{8}','$lang_month{9}','$lang_month{10}','$lang_month{11}','$lang_month{12}'|;
+   $html =~ s/\@\@\@WMONTH_ARRAY\@\@\@/$temphtml/;
+   $html =~ s/\@\@\@WSTART\@\@\@/$prefs{'calendar_weekstart'}/g;
+   $html =~ s/\@\@\@TODAY\@\@\@/$lang_text{'today'}/g;
    $html =~ s/\@\@\@THISDAY_ONLY\@\@\@/$lang_text{'thisday_only'}/g;
    $html =~ s/\@\@\@THE_WDAY_OF_THISMONTH\@\@\@/$lang_text{'the_wday_of_thismonth'}/g;
    $html =~ s/\@\@\@EVERY_WDAY_THISMONTH\@\@\@/$lang_text{'every_wday_thismonth'}/g;
@@ -1218,11 +1228,13 @@
                                  action=>'caladd');
    $html =~ s/\@\@\@STARTADDITEMFORM\@\@\@/$temphtml/;
 
+   $temphtml = iconlink("cal-popup.gif", $lang_text{'calendar'}, qq|href="javascript:nothing();" onClick="calPopup(this,'additemformpopupCal',-175,15,'AddItemForm','valiDate');"|);
+   $temphtml .= qq|&nbsp;$lang_text{'calfmt_yearmonthday'}|;
+   $html =~ s/\@\@\@ITEMDATEMENU\@\@\@/$temphtml/g;
 
-   $html =~ s/\@\@\@ITEMDATEMENU\@\@\@/$lang_text{'calfmt_yearmonthday'}/g;
    $temphtml = popup_menu(-name=>'year',
                           -values=>[1970..2037],
-                          -onChange=>"valiDate()",
+                          -onChange=>"valiDate('AddItemForm')",
                           -default=>$year,
                           -override=>'1');
    $html =~ s/\@\@\@YEAR\@\@\@/$temphtml/g;
@@ -1230,7 +1242,7 @@
    $temphtml = popup_menu(-name=>'month',
                           -values=>[1..12],
                           -default=>$month,
-                          -onChange=>"valiDate()",
+                          -onChange=>"valiDate('AddItemForm')",
                           -labels=>\%lang_month,
                           -override=>1);
    $html =~ s/\@\@\@MONTH_STR\@\@\@/$temphtml/g;
@@ -1238,7 +1250,7 @@
    $temphtml = popup_menu(-name=>'day',
                           -values=>[1..31],
                           -default=>$day,
-                          -onChange=>"valiDate()",
+                          -onChange=>"valiDate('AddItemForm')",
                           -override=>'1');
    $html =~ s/\@\@\@DAY\@\@\@/$temphtml/g;
 
@@ -1811,7 +1823,11 @@
    my ($year, $month, $day, $index)=@_;
 
    my ($html, $temphtml);
-   $html = applystyle(readtemplate("editcalendar.template"));
+   $html = readtemplate("editcalendar.template");
+   $html .= readtemplate("calpopup.js");
+   $html .= readtemplate("validate.js");
+   $html .= readtemplate("nothing.js");
+   $html = applystyle($html);
 
    my $calbookfile=dotpath('calendar.book');
 
@@ -1830,6 +1846,12 @@
    $html =~ s/\@\@\@WDAY_ARRAY\@\@\@/$temphtml/;
    $temphtml=qq|'$lang_order{1}','$lang_order{2}','$lang_order{3}','$lang_order{4}','$lang_order{5}'|;
    $html =~ s/\@\@\@WORDER_ARRAY\@\@\@/$temphtml/;
+   $temphtml=qq|'$lang_wday_abbrev{0}','$lang_wday_abbrev{1}','$lang_wday_abbrev{2}','$lang_wday_abbrev{3}','$lang_wday_abbrev{4}','$lang_wday_abbrev{5}','$lang_wday_abbrev{6}'|;
+   $html =~ s/\@\@\@WDAYABBREV_ARRAY\@\@\@/$temphtml/;
+   $temphtml=qq|'$lang_month{1}','$lang_month{2}','$lang_month{3}','$lang_month{4}','$lang_month{5}','$lang_month{6}','$lang_month{7}','$lang_month{8}','$lang_month{9}','$lang_month{10}','$lang_month{11}','$lang_month{12}'|;
+   $html =~ s/\@\@\@WMONTH_ARRAY\@\@\@/$temphtml/;
+   $html =~ s/\@\@\@WSTART\@\@\@/$prefs{'calendar_weekstart'}/g;
+   $html =~ s/\@\@\@TODAY\@\@\@/$lang_text{'today'}/g;
    $html =~ s/\@\@\@THISDAY_ONLY\@\@\@/$lang_text{'thisday_only'}/g;
    $html =~ s/\@\@\@THE_WDAY_OF_THISMONTH\@\@\@/$lang_text{'the_wday_of_thismonth'}/g;
    $html =~ s/\@\@\@EVERY_WDAY_THISMONTH\@\@\@/$lang_text{'every_wday_thismonth'}/g;
@@ -1854,10 +1876,13 @@
    $days_in_month[2]++ if ( ($year%4)==0 && (($year%100)!=0||($year%400)==0) );
    $day=$days_in_month[$month] if ($day>$days_in_month[$month]); $day=1 if ($day<1);
 
-   $html =~ s/\@\@\@ITEMDATEMENU\@\@\@/$lang_text{'calfmt_yearmonthday'}/g;
+   $temphtml = qq|$lang_text{'calfmt_yearmonthday'}&nbsp;|;
+   $temphtml .= iconlink("cal-popup.gif", $lang_text{'calendar'}, qq|href="javascript:nothing();" onClick="calPopup(this,'editcalendarpopupCal',25,15,'editcalendar','valiDate');"|);
+   $html =~ s/\@\@\@ITEMDATEMENU\@\@\@/$temphtml/g;
+
    $temphtml = popup_menu(-name=>'year',
                           -values=>[1970..2037],
-                          -onChange=>"valiDate()",
+                          -onChange=>"valiDate('editcalendar')",
                           -default=>$year,
                           -override=>'1');
    $html =~ s/\@\@\@YEAR\@\@\@/$temphtml/g;
@@ -1865,7 +1890,7 @@
    $temphtml = popup_menu(-name=>'month',
                           -values=>[1..12],
                           -default=>$month,
-                          -onChange=>"valiDate()",
+                          -onChange=>"valiDate('editcalendar')",
                           -labels=>\%lang_month,
                           -override=>1);
    $html =~ s/\@\@\@MONTH_STR\@\@\@/$temphtml/g;
@@ -1873,7 +1898,7 @@
    $temphtml = popup_menu(-name=>'day',
                           -values=>[1..31],
                           -default=>$day,
-                          -onChange=>"valiDate()",
+                          -onChange=>"valiDate('editcalendar')",
                           -override=>'1');
    $html =~ s/\@\@\@DAY\@\@\@/$temphtml/g;
 
