/* Calender 1.0    writen by alper konuralp    */

var calwin = null;

var func = null;

var Aylar = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var Gunler = new Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" );

var dhtml = new Array();

dhtml[0] =  "<html>\n" +

            "      <head>\n" +

          "            <title>Calendar</title>\n" +

          "            <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1254\">\n" +

          "            <sc" + "ript language=javascript>\n" +

          "                    function cal(g,a,y) {\n"+

          "                        parent.opener.calendar(g,a,y);\n"+

          "                    }\n\n"+

          "                    function endof(gun,ay,yil) {\n"+

          "                             parent.opener.func(gun,ay,yil);\n"+

          "                             window.close();\n"+

          "                    }\n"+

          "            " + "<" + "/" + "script>\n"+

          "      </head>\n"+

          "      <body bgcolor=\"#ffffff\">\n"+

          "            <table width=100% height=100% cellspacing=1 cellpadding=1 border=0 bgcolor=\"#dddddd\">\n"+

          "                   <tr>\n"+

          "                       <td align=center bgcolor=\"#cccccc\">\n"+

          "                         <table border=0 width=100%>\n"+

          "                         <tr>\n"+

          "                         <td bgcolor=\"#bbbbbb\" align=center width=1%>\n"+

          "                           <font color=\"#FFFFFF\">\n"+

          "                                 <a href=\"javascript:cal(";



dhtml[1] =  ")\">\n"+

          "                                    <font face=\"verdana\" size=\"2\" color=\"#000000\">\n"+

          "                                          &lt;\n"+

          "                                    </font>\n"+

          "                                 </a>\n"+

          "                         </td>\n"+

          "                         <td bgcolor=\"#F5F5F5\" align=center width=48%>\n"+

          "                                    <font face=\"verdana\" size=\"2\" color=\"#333333\">\n"+

          "                                     ";



dhtml[2] = "\n" +

           "                                    </font>\n" +

           "                         </td>\n" +

           "                         <td bgcolor=\"#bbbbbb\" align=center width=1%>\n" +

           "                                 <a href=\"javascript:cal(";



dhtml[3] = ")\">\n" +

           "                                    <font face=\"verdana\" size=\"2\" color=\"#000000\">\n" +

           "                                          &gt;\n" +

           "                                    </font>\n" +

           "                                 </a>\n" +

           "                         </td>\n" +

           "                         <td bgcolor=\"#bbbbbb\" align=center width=1%>\n" +

           "                                 <a href=\"javascript:cal(";



dhtml[4] = ")\">\n" +

           "                                    <font face=\"verdana\" size=\"2\" color=\"#000000\">\n" +

           "                                          &lt;\n" +

           "                                    </font>\n" +

           "                                 </a>\n" +

           "                         </td>\n" +

           "                         <td bgcolor=\"#F5F5F5\" align=center width=48%>\n" +

           "                                    <font face=\"verdana\" size=\"2\" color=\"#333333\">\n" +

           "                                     ";



dhtml[5] = "\n" +

           "                                    </font>\n" +

           "                         </td>\n" +

           "                         <td bgcolor=\"#bbbbbb\" align=center width=1%>\n" +

           "                                 <a href=\"javascript:cal(";



dhtml[6] = ")\">\n" +

           "                                    <font face=\"verdana\" size=\"2\" color=\"#000000\">\n" +

           "                                          &gt;\n" +

           "                                    </font>\n" +

           "                                 </a>\n" +

           "                         </td>\n" +

           "                         </tr>\n" +

           "                         </table>\n" +

           "                       </td>\n" +

           "                   </tr>\n" +

           "                   <tr>\n" +

           "                       <td align=center>\n" +

           "                           <font face=\"verdana\" size=\"2\">\n" +

           "                           <table bgcolor=\"#FFFFFF\" cellpadding=1 cellspacing=1 border=0>\n" +

           "                                  <tr>\n" +

           "                                      <td bgcolor=\"#bbbbbb\" align=center valign=middle width=12%>\n" +

           "                                          <font face=\"verdana\" size=\"2\">\n" +

           "                                                wk\n" +

           "                                          </font>\n" +

           "                                      </td>\n";



dhtml[7] = "                           </table>\n" +

           "                           </font>\n" +

           "                       </td>\n" +

           "                   </tr>\n" +

           "                   <tr>\n" +

           "                       <td align=center>\n" +

           "                         <nobr><form>\n" +

           "                           <input type=\"button\" name=\"tamam\" value=\"Close\" onclick=\"window.close();\" />\n" +

           "                         </form></nobr>\n" +

           "                       </td>\n" +

           "                   </tr>\n" +

           "            </table>\n" +

           "      </body>\n" +

           "</html>\n";





function calendar(gun, ay, yil) {

         cdate = new Date(yil, ay-1, gun);

         gun = cdate.getDate();

         ay = cdate.getMonth()+1;

         yil = cdate.getFullYear();

         cdate2 = new Date(yil, ay-1, 1);

         cdate3 = new Date(yil, 0, 1);

         cdate4 = cdate - cdate3;

         cdate5 = Math.floor(cdate4 / 604800000) + 1;

         cdate6 = cdate2 - ((cdate2.getDay() - 1) * 86400000);

         cdate10 = new Date();



         calwin = window.open("", "CalWin", "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=290,height=190");

         calwin.document.clear();

         calwin.document.open();

         reshtml  = dhtml[0] + "1," + (ay - 1) + "," + yil;

         reshtml += dhtml[1] + Aylar[cdate.getMonth()];

         reshtml += dhtml[2] + "1," + (ay + 1) + "," + yil;

         reshtml += dhtml[3] + "1," + ay + "," + (yil - 1);

         reshtml += dhtml[4] + cdate.getFullYear();

         reshtml += dhtml[5] + "1," + ay + "," + (yil + 1);

         reshtml += dhtml[6];

         for(j=0; j<7; j++) {

             reshtml += "                                      <td bgcolor=\"#bbbbbb\" align=center valign=middle width=12%>\n";

             if(j==5 || j==6)

                     reshtml += "                                          <font face=\"verdana\" size=\"2\" color=\"red\">\n";

             else

                     reshtml += "                                          <font face=\"verdana\" size=\"2\" color=\"blue\">\n";

             reshtml += "                                                " + Gunler[j] + "\n";

             reshtml += "                                          </font>\n";

             reshtml += "                                      </td>\n";

         }

         reshtml += "                                  </tr>\n";

         for(i=0; i<5; i++) {

             reshtml += "                                  <tr>\n";

             reshtml += "                                      <td bgcolor=\"#bbbbbb\" align=center valign=middle width=12%>\n";

             reshtml += "                                          <font face=\"verdana\" size=\"2\">\n";

             reshtml += "                                                " + (cdate5 + i) + "\n";

             reshtml += "                                          </font>\n";

             reshtml += "                                      </td>\n";

           for(j=0; j<7; j++) {

             cdate7 = new Date(cdate6 + (((i*7) + j) * 86400000));



             if((cdate7.getDate() == cdate10.getDate()) && (cdate7.getMonth() == cdate10.getMonth()) && (cdate7.getYear() == cdate10.getYear())) {

                       reshtml += "                                      <td bgcolor=\"#eeefff\" align=center valign=middle width=12%>\n";

             }

             else {

                    if(cdate7.getMonth() == cdate.getMonth())

                       reshtml += "                                      <td bgcolor=\"#bbbbbb\" align=center valign=middle width=12%>\n";

                    else

                       reshtml += "                                      <td bgcolor=\"#999999\" align=center valign=middle width=12%>\n";



             }



             reshtml += "                                        <a href=\"javascript:endof(" + cdate7.getDate() + "," + (cdate7.getMonth()+1) + "," + cdate7.getYear() + ")\">\n";

             if(j==5 || j==6)

                     reshtml += "                                          <font face=\"verdana\" size=\"2\" color=\"red\">\n";

             else

                     reshtml += "                                          <font face=\"verdana\" size=\"2\" color=\"blue\">\n";

             reshtml += "                                                " + cdate7.getDate() + "";

             reshtml += "                                          </font>\n";

             reshtml += "                                        </a>\n";

             reshtml += "                                      </td>\n";

           }

           reshtml += "                                  </tr>\n";

         }



         reshtml += dhtml[7];



         calwin.document.write(reshtml);

         calwin.document.close();

}



function MakeCal(gunu, ayi, yili, funct) {

         func = funct;

         calendar(gunu,ayi,yili);

}



function selecttesec(obj, value) {

   if(obj.type=="select-one") {

      for(k=0; k<obj.length; k++) {

           if(obj.options[k].value == value) obj.options[k].selected=true;

      }

   }

}







