// Title: Date picker
// Description: Lets you pick a date
// Version: 1.0
// Date: 05/02/2002 (mm-dd-yyyy)
// Author: Amit Chugh <amit.chugh@ncr.com>; <achugh00@hotmail.com>
// Notes: Permission given to use this script in any kind of applications if
//        header lines are left unchanged. Feel free to contact the author
//        for feature requests and/or donations

// ******************************************************************
// You can change below the following line to customize this display.
// ******************************************************************
// First working day of the week. Set this value to 1 for all countries where Monday 
// is the first working day. Set it to 5 for Arabic countries where first working day 
// is Saturday.

var gWinCal;
var gValueDelimiter;
var gFieldObject;
var gWillSelectTime = "false";
var gCallBack = "false";
var gCallBackEvent = "";
var gSelectedTime=" 20:00";
var bFirstWorkingDay = 1;
var sDateFormat = "MM/DD/YYYY";
var sPopupWindowName = "EFM";
// Previous Button
var sPreviousImageSrc = "../images/calprev.gif"
var iPreviousImageWidth = 16;
var iPreviousImageHeight = 16;

// Next Button
var sNextImageSrc = "../images/calnext.gif"
var iNextImageWidth = 16;
var iNextImageHeight = 16;

// Up Button
var sUpImageSrc = "../images/up.gif"
var iUpImageWidth = 16;
var iUpImageHeight = 16;

// Down Button
var sDownImageSrc = "../images/Down.gif"
var iDownImageWidth = 16;
var iDownImageHeight = 16;

// CSS variables
var hPopupWindowBg = "#FFFFFF";
var hCalendarBg = "#D4D0C8";
var hCalendarBorder = "#FFFFFF";
var hCalendarBoderThickness = "1";

var sButtonFont = "Verdana, Arial, Helvetica, sans-serif";
var sButtonFontSize = "10px";
var sButtonFontWeight = "bold";
var hButtonTextColor = "#FFFFFF"
var hButtonBg = "#2e3e8d";

var sWeekDayFont = "Verdana, Arial, Helvetica, sans-serif";
var sWeekDayFontSize = "9px";
var sWeekDayFontWeight = "bold";
var sWeekDayTextColor = "#FFFFFF";
var sWeekDayBg = "#A5A39D";
var sWeekDayTextAlign = "center";

var sWorkingDayFont = "Verdana, Arial, Helvetica, sans-serif";
var sWorkingDayFontSize = "9px";
var sWorkingDayFontWeight = "normal";
var sWorkingDayTextColor = "#000000";
var sWorkingDayBg = "#FFFFFF";
var sWorkingDayTextAlign = "center";

var sWeekEndFont = "Verdana, Arial, Helvetica, sans-serif";
var sWeekEndFontSize = "9px";
var sWeekEndFontWeight = "normal";
var sWeekEndTextColor = "#000000";
var sWeekEndBg = "#D3DEDE";
var sWeekEndTextAlign = "center";

var sTodayFont = "Verdana, Arial, Helvetica, sans-serif";
var sTodayFontSize = "9px";
var sTodayFontWeight = "bold";
var sTodayTextColor = "#000000";
var sTodayBg = "#A5A39D";
var sTodayTextAlign = "center";
var sTimePickerFont = "Verdana";
var sTimePickerFontSize = "8pt";
// ***************************************
// DO NOT CHANGE ANYTHING BELOW THIS LINE.
// ***************************************

// Name of the months
var arMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
// Name of the week days
var arWeekDays = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
// Weekend calculation
var iWeekendStartDay;
// Calender HTML String
var sHTML = "";
if ((bFirstWorkingDay-2) < 0)
  iWeekendStartDay = 7 + (bFirstWorkingDay-2);
else
  iWeekendStartDay = bFirstWorkingDay - 2;

var iWeekendEndDay;
if ((bFirstWorkingDay-1) < 0)
  iWeekendEndDay = 7 + (bFirstWorkingDay-1);
else
  iWeekendEndDay = bFirstWorkingDay - 1;


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// datetime parsing and formatting routines. modify them if you wish other datetime format
function stringToDate (sDate) {
  var index = sDate.indexOf (" ");
  if (index > 0)
    sDate = sDate.substring (0, index);

// This function will convert the string into date data type
// based on the global variable "sDateFormat" value. Currently
// it can only handle MM/DD/YYYY, DD/MM/YYYY, YYYY/MM/DD formats only.
	var regDate = /^(\d+)\/(\d+)\/(\d+)$/;
	if (!regDate.exec(sDate)) {
		alert("Invalid Datetime format: "+ sDate);
    return false;
  }
  switch(sDateFormat) {
    case "MM/DD/YYYY" :
      return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2));
      break;
    case "DD/MM/YYYY" :
      return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
      break;
    case "YYYY/MM/DD" :
      return (new Date (RegExp.$1, RegExp.$2-1, RegExp.$3));
      break;
    default :
      return false;
   }
}

function dateToString (dt) {

  switch(sDateFormat) {
    case "MM/DD/YYYY" :
      return (new String ((dt.getMonth()+1) + "/" + dt.getDate()  + "/" + dt.getFullYear()));
      break;
    case "DD/MM/YYYY" :
      return (new String (dt.getDate() + "/" + (dt.getMonth()+1) + "/" + dt.getFullYear()));
      break;
    case "YYYY/MM/DD" :
      return (new String ((dt.getFullYear()+ "/" + dt.getMonth()+1) + "/"  + dt.getDate()));
      break;
    default :
      return false;
   }
}

function formatDateToMMDDYYYY(val) {

     var vTemp = val.split("/");
     return padIt(vTemp[0]) + "/" + padIt(vTemp[1]) + "/" + vTemp[2];
}
function padIt(item) {

     if (item.length == 1) {
         return "0" + item;
     } else {
         return item;
     }

}

// This function will write the selected value in the associated object.
// This function is called by the popup window to return back the selected date.
function SelectedDate(obj, value) {
var id;
var todaysDate;
var errMsg;

todaysDate = new Date();
errMsg = new String("Selected date exist in future.\nChanging date to Today's Date.");


  if((id=MM_findObj(obj)) !=null) {
  // If the selected date exist in future give an alert and change the date
  // to today's date
  // commented out, allow any date entry
  //  if (stringToDate(value) < todaysDate) {
  //    alert(errMsg);
  //    id.value = dateToString(todaysDate);
  //  }
  //  else {
      //the value may include the time, will also be passed to the formatter
        var formattedValue = formatDateToMMDDYYYY(value); 
        if (gValueDelimiter == null || gValueDelimiter == "") {
            id.value = formatDateToMMDDYYYY(value);
            //if (gFieldObject != null)
            //    gFieldObject.value = formatDateToMMDDYYYY(value);;
        }
        else {
            var org = id.value;
            if (org != null) {
                //make sure the value ends with delimiter
                var location = org.length - gValueDelimiter.length;
                if (location == 0) {
                    id.value = "";
                }
                else if (location > 0) {
                    var tag = org.substring (location);
                    if (tag != gValueDelimiter)
                        id.value += gValueDelimiter;
                }
            }
            id.value += formatDateToMMDDYYYY(value);
        }
  //  }
    if (gCallBack == "true") {
        dateValueSelected (id, gCallBackEvent);
    }
  }
  else {
    alert("Object not found.");
  }
}
function calendar (obj)
{
    gCallBack = "false";
    gValueDelimiter = "";
    gWillSelectTime = "false";
	gSelectedTime	="";
	gFieldObject = obj;
    DisplayCalendar (obj.name, obj.value);
}
function calendar_datetime (obj)
{
    gCallBack = "false";
    gValueDelimiter = "";
    gWillSelectTime = "true";
	gSelectedTime	="";
	var index = obj.value.indexOf (" ");
	if (index > 0)
	    gSelectedTime = obj.value.substring (index);
	gFieldObject = obj;
    DisplayCalendar (obj.name, obj.value);
}
function callback_calendar (obj, callback_event)
{
    gCallBack = "true";
    gCallBackEvent = callback_event;
    gValueDelimiter = "";
    gWillSelectTime = "false";
	gSelectedTime	="";
	gFieldObject = obj;
    DisplayCalendar (obj.name, obj.value);
}

function addup_calendar (obj, delimiter)
{
    gCallBack = "false";
    gValueDelimiter = delimiter;
    gWillSelectTime = "false";
	gSelectedTime	="";
	gFieldObject = obj;
	var value = obj.value;
	if (value != null) {
        var values = value.split (delimiter);
        if (values.length > 0)
            value = values[values.length - 1];
	}
    DisplayCalendar (obj.name, value);
}
function trimRight (tstr, blank)
{
    while(tstr.charAt(tstr.length - blank.length) == blank) 
       tstr = tstr.substring(0,tstr.length-blank.length-1); 
    return tstr; 
} 
function addup_calendar_time (obj, delimiter)
{
    gCallBack = "false";
    gValueDelimiter = delimiter;
    gWillSelectTime = "true";   
	gSelectedTime	= " 20:00"; 
	gFieldObject = obj;
	if (obj.value != null) {
	    var lastValue = trimRight (obj.value, delimiter);
        var values = lastValue.split (delimiter);
        if (values.length > 0) {
            var lastSel = values[values.length - 1];
            var vTemp =lastSel.split(" ");
            if (vTemp.length > 1)
                gSelectedTime = " " + vTemp[1];
            gSelectedTime = trimRight (gSelectedTime, delimiter);
        }
	}
    DisplayCalendar (obj.name, obj.value);
}

function setSelectedTime (value)
{
    gSelectedTime = value;
}
function DisplayCalendar(obj,value) {
var id;

// Get the object reference
if((id=MM_findObj(obj)) !=null) {
// Check if the supplied date is a valid date
	var dt = ((value == "" || value == null) ?  new Date() : stringToDate(value));
// Calculate the First Day of the Month
	var dtFirstDay = new Date(dt);
	dtFirstDay.setDate(1);
// Calculate the Last Day of the Month
  var dtLastDay = new Date(dt);
  dtLastDay.setMonth(dt.getMonth() + 1);
	dtLastDay.setDate(0);
// Previous Month
  var dtPreviousMonth = new Date(dt);
  dtPreviousMonth.setMonth(dtPreviousMonth.getMonth() - 1)
// Next month
  var dtNextMonth = new Date(dt);
  dtNextMonth.setMonth(dtNextMonth.getMonth() + 1)
// Previous Year
  var dtPreviousYear = new Date(dt);
  dtPreviousYear.setYear(dtPreviousYear.getFullYear() - 1)
// Previous Year
  var dtNextYear = new Date(dt);
  dtNextYear.setYear(dtNextYear.getFullYear() + 1)


// HTML code of the pop up window
	var sHTMLCode = new String (
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n"+
    "                      \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"+
		"<html>\n"+
		"<head>\n"+
		"<script type=\"text/javascript\" language=\"javascript\"></script>\n"+
    " <title>" + sPopupWindowName + "</title>\n"+
    " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"+
    "\n"+
    "<style type=\"text/css\">\n"+
    "<!--\n"+
    "body {background-color: " + hPopupWindowBg + "}\n"+
    ".CalendarBg {background-color: " + hCalendarBg + "}\n"+
    ".CalendarBorder {background-color: " + hCalendarBorder + "}\n"+
    ".Button {font-family: " + sButtonFont + "; font-size: " + sButtonFontSize + "; font-weight: " + sButtonFontWeight + "; color: " + hButtonTextColor + "; background-color: " + hButtonBg + "}\n"+
    ".ColumnHeading {font-family: " + sWeekDayFont + "; font-size: " + sWeekDayFontSize + "; font-weight: " + sWeekDayFontWeight + "; color: " + sWeekDayTextColor + "; background-color: " + sWeekDayBg + "; text-align: " + sWeekDayTextAlign + "}\n"+
    ".WorkingDay {font-family: " + sWorkingDayFont + "; font-size: " + sWorkingDayFontSize + "; font-weight: " + sWorkingDayFontWeight + "; color: " + sWorkingDayTextColor + "; background-color: " + sWorkingDayBg + "; text-align: " + sWorkingDayTextAlign + "}\n"+
    ".WorkingDay a:link {color: " + sWorkingDayTextColor + "; text-decoration: underline}\n"+
    ".WorkingDay a:visited {color: " + sWorkingDayTextColor + "; text-decoration: underline}\n"+
    ".WorkingDay a:hover {color: " + sWorkingDayTextColor + "; text-decoration: underline}\n"+
    ".WorkingDay a:active {color: " + sWorkingDayTextColor + "; text-decoration: underline}\n"+
    ".WeekEnd {font-family: " + sWeekEndFont + "; font-size: " + sWeekEndFontSize + "; font-weight: " + sWeekEndFontWeight + "; color: " + sWeekEndTextColor + "; background-color: " + sWeekEndBg + "; text-align: " + sWeekEndTextAlign + "}\n"+
    ".WeekEnd a:link {color: " + sWeekEndTextColor + "; text-decoration: underline}\n"+
    ".WeekEnd a:visited {color: " + sWeekEndTextColor + "; text-decoration: underline}\n"+
    ".WeekEnd a:hover {color: " + sWeekEndTextColor + "; text-decoration: underline}\n"+
    ".WeekEnd a:active {color: " + sWeekEndTextColor + "; text-decoration: underline}\n"+
    ".Today {font-family: " + sTodayFont + "; font-size: " + sTodayFontSize + "; font-weight: " + sTodayFontWeight + "; color: " + sTodayTextColor + "; background-color: " + sTodayBg + "; text-align: " + sTodayTextAlign + "}\n"+
    ".Today a:link {color: " + sTodayTextColor + "; text-decoration: underline}\n"+
    ".Today a:visited {color: " + sTodayTextColor + "; text-decoration: underline}\n"+
    ".Today a:hover {color: " + sTodayTextColor + "; text-decoration: underline}\n"+
    ".Today a:active {color: " + sTodayTextColor + "; text-decoration: underline}\n"+
    ".timePicker {font-family: " + sTimePickerFont +";font-size:"+sTimePickerFontSize+";}\n"+
    ".Empty {font-family: " + sWorkingDayFont + "; font-size: " + sWorkingDayFontSize + "; font-weight: " + sWorkingDayFontWeight + ";}\n"+
    "-->\n"+
    "</style>\n"+
    "\n"+
		"</head>\n"+
		"<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n"+
		"<table class=\"CalendarBorder\" cellpadding=\"0\" cellspacing=\""+hCalendarBoderThickness+"\" border=\"0\" width=\"100%\">\n"+
		" <tr><td class=\"CalendarBg\">\n"+
		"  <table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"   <tr>\n"+
    "    <td class=\"Button\" align=\"left\"><a href=\"javascript:window.opener.setSelectedTime(document.forms[0].pick_time.value);window.opener.DisplayCalendar('" + obj + "', '" + dateToString(dtPreviousMonth) + "');\">"+
		"<img src=\"" + sPreviousImageSrc + "\" width=\"" + iPreviousImageWidth + "\" height=\"" + iPreviousImageHeight + "\" border=\"0\""+
		" alt=\"Previous Month (" + dateToString(dtPreviousMonth) + ")\"></a></td>\n"+
		"    <td class=\"Button\" align=\"center\" colspan=\"3\">" + arMonths[dt.getMonth()] + " " + 
		getYearSelectorHtml (dt, obj) + 
		"</td>\n"+
		"    <td class=\"Button\" align=\"center\"><a href=\"javascript:window.opener.setSelectedTime(document.forms[0].pick_time.value);window.opener.DisplayCalendar('" + obj + "', '" + dateToString(dtNextYear) + "');\">"+
		"<img src=\"" + sUpImageSrc + "\" width=\"" + iUpImageWidth + "\" height=\"" + iUpImageHeight + "\" border=\"0\""+
		" alt=\"Next Year (" + dateToString(dtNextYear) + ")\"></a></td>\n"+
		"    <td class=\"Button\" align=\"center\"><a href=\"javascript:window.opener.setSelectedTime(document.forms[0].pick_time.value);window.opener.DisplayCalendar('" + obj + "', '" + dateToString(dtPreviousYear) + "');\">"+
		"<img src=\"" + sDownImageSrc + "\" width=\"" + iDownImageWidth + "\" height=\"" + iDownImageHeight + "\" border=\"0\""+
		" alt=\"Previous Year (" + dateToString(dtPreviousYear) + ")\"></a></td>\n"+
		"    <td class=\"Button\" align=\"right\"><a href=\"javascript:window.opener.setSelectedTime(document.forms[0].pick_time.value);window.opener.DisplayCalendar('" + obj +"', '" + dateToString(dtNextMonth) + "');\">"+
		"<img src=\"" + sNextImageSrc + "\" width=\"" + iNextImageWidth + "\" height=\"" + iNextImageHeight + "\" border=\"0\""+
		" alt=\"Next Month (" + dateToString(dtNextMonth) + ")\"></a></td>\n"+
    "   </tr>\n"
    
	);
 
  dtCurrentDay = new Date(dtFirstDay);
	// Display weekdays column heading
	sHTMLCode += "   <tr>\n";
	for (var wd=0; wd<7; wd++)
		sHTMLCode += "    <td class=\"ColumnHeading\">" + arWeekDays[(bFirstWorkingDay + wd)%7] + "</td>\n";
  
	sHTMLCode += "   </tr>\n";
	// Display calendar dates
	while (dtCurrentDay.getMonth() == dt.getMonth()) {
		sHTMLCode += "   <tr>\n";
		for (var wd=0; wd<7; wd++) {
    // Do not show dates of previous & next month
      if ((dtCurrentDay.getDay() == ((bFirstWorkingDay + wd)%7)) && 
          (dtCurrentDay.getMonth() == dt.getMonth())) {
      // To pick the right CSS class
				if (dtCurrentDay.getDate() == dt.getDate())
					// Todays date
					sHTMLCode += "    <td class=\"Today\">";
				else if (dtCurrentDay.getDay() == iWeekendStartDay || dtCurrentDay.getDay() == iWeekendEndDay)
					// Weekend days
					sHTMLCode += "    <td class=\"WeekEnd\">";
				else
					// Working days of current month
					sHTMLCode += "    <td class=\"WorkingDay\">";
      
      // Current Day of the month
				sHTMLCode += "<a href=\"javascript:window.opener.SelectedDate('" + obj + "', '" + dateToString(dtCurrentDay) + "'+document.forms[0].pick_time.value); window.close();\">";
				sHTMLCode += dtCurrentDay.getDate()+"</a></td>\n";
      
			  dtCurrentDay.setDate(dtCurrentDay.getDate() + 1);
      }
      else
        sHTMLCode += "    <td class=\"Empty\">&nbsp;</td>\n";
		}
		sHTMLCode += "   </tr>\n";
	}
	// Close the HTML tags
	sHTMLCode += "  </table>\n" +
		" </td>\n</tr>\n"+
    "</table>\n";

    if (gWillSelectTime == "true") {
        sHTMLCode += "<table width='100%' border='0' cellspacing=0 cellpadding=0><tr><td align='center' class='timePicker'><form method='POST' action='--WEBBOT-SELF--'>" +
                            "Time:<select size='1' name='pick_time' clsss='timePicker'>";
		sHTMLCode += 			"<option value=' 06:00' "+ getSelectionTag(" 06:00") +">06:00am</option>";
		sHTMLCode += 			"<option value=' 06:15' "+ getSelectionTag(" 06:15") +">06:15am</option>";
		sHTMLCode += 			"<option value=' 06:30' "+ getSelectionTag(" 06:30") +">06:30am</option>";
		sHTMLCode += 			"<option value=' 06:45' "+ getSelectionTag(" 06:45") +">06:45am</option>";
		sHTMLCode += 			"<option value=' 07:00' "+ getSelectionTag(" 07:00") +">07:00am</option>";
		sHTMLCode += 			"<option value=' 07:15' "+ getSelectionTag(" 07:15") +">07:15am</option>";
		sHTMLCode += 			"<option value=' 07:30' "+ getSelectionTag(" 07:30") +">07:30am</option>"; 
		sHTMLCode += 			"<option value=' 07:45' "+ getSelectionTag(" 07:45") +">07:45am</option>";
		sHTMLCode += 			"<option value=' 08:00' "+ getSelectionTag(" 08:00") +">08:00am</option>"; 
		sHTMLCode += 			"<option value=' 08:15' "+ getSelectionTag(" 08:15") +">08:15am</option>"; 
		sHTMLCode += 			"<option value=' 08:30' "+ getSelectionTag(" 08:30") +">08:30am</option>"; 
		sHTMLCode += 			"<option value=' 08:45' "+ getSelectionTag(" 08:45") +">08:45am</option>"; 
		sHTMLCode += 			"<option value=' 09:00' "+ getSelectionTag(" 09:00") +">09:00am</option>"; 
		sHTMLCode += 			"<option value=' 09:15' "+ getSelectionTag(" 09:15") +">09:15am</option>"; 
		sHTMLCode += 			"<option value=' 09:30' "+ getSelectionTag(" 09:30") +">09:30am</option>"; 
		sHTMLCode += 			"<option value=' 09:45' "+ getSelectionTag(" 09:45") +">09:45am</option>"; 
		sHTMLCode += 			"<option value=' 10:00' "+ getSelectionTag(" 10:00") +">10:00am</option>"; 
		sHTMLCode += 			"<option value=' 10:15' "+ getSelectionTag(" 10:15") +">10:15am</option>"; 
		sHTMLCode += 			"<option value=' 10:30' "+ getSelectionTag(" 10:30") +">10:30am</option>"; 
		sHTMLCode += 			"<option value=' 10:45' "+ getSelectionTag(" 10:45") +">10:45am</option>"; 
		sHTMLCode += 			"<option value=' 11:00' "+ getSelectionTag(" 11:00") +">11:00am</option>"; 
		sHTMLCode += 			"<option value=' 11:15' "+ getSelectionTag(" 11:15") +">11:15am</option>"; 
		sHTMLCode += 			"<option value=' 11:30' "+ getSelectionTag(" 11:30") +">11:30am</option>"; 
		sHTMLCode += 			"<option value=' 11:45' "+ getSelectionTag(" 11:45") +">11:45am</option>"; 
		sHTMLCode += 			"<option value=' 12:00' "+ getSelectionTag(" 12:00") +">12:00pm</option>"; 
		sHTMLCode += 			"<option value=' 12:15' "+ getSelectionTag(" 12:15") +">12:15pm</option>"; 
		sHTMLCode += 			"<option value=' 12:30' "+ getSelectionTag(" 12:30") +">12:30pm</option>"; 
		sHTMLCode += 			"<option value=' 12:45' "+ getSelectionTag(" 12:45") +">12:45pm</option>"; 
		sHTMLCode += 			"<option value=' 13:00' "+ getSelectionTag(" 13:00") +">01:00pm</option>"; 
		sHTMLCode += 			"<option value=' 13:15' "+ getSelectionTag(" 13:15") +">01:15pm</option>"; 
		sHTMLCode += 			"<option value=' 13:30' "+ getSelectionTag(" 13:30") +">01:30pm</option>"; 
		sHTMLCode += 			"<option value=' 13:45' "+ getSelectionTag(" 13:45") +">01:45pm</option>"; 
		sHTMLCode += 			"<option value=' 14:00' "+ getSelectionTag(" 14:00") +">02:00pm</option>"; 
		sHTMLCode += 			"<option value=' 14:15' "+ getSelectionTag(" 14:15") +">02:15pm</option>"; 
		sHTMLCode += 			"<option value=' 14:30' "+ getSelectionTag(" 14:30") +">02:30pm</option>"; 
		sHTMLCode += 			"<option value=' 14:45' "+ getSelectionTag(" 14:45") +">02:45pm</option>"; 
		sHTMLCode += 			"<option value=' 15:00' "+ getSelectionTag(" 15:00") +">03:00pm</option>"; 
		sHTMLCode += 			"<option value=' 15:15' "+ getSelectionTag(" 15:15") +">03:15pm</option>"; 
		sHTMLCode += 			"<option value=' 15:30' "+ getSelectionTag(" 15:30") +">03:30pm</option>"; 
		sHTMLCode += 			"<option value=' 15:45' "+ getSelectionTag(" 15:45") +">03:45pm</option>"; 
		sHTMLCode += 			"<option value=' 16:00' "+ getSelectionTag(" 16:00") +">04:00pm</option>"; 
		sHTMLCode += 			"<option value=' 16:15' "+ getSelectionTag(" 16:15") +">04:15pm</option>"; 
		sHTMLCode += 			"<option value=' 16:30' "+ getSelectionTag(" 16:30") +">04:30pm</option>"; 
		sHTMLCode += 			"<option value=' 16:45' "+ getSelectionTag(" 16:45") +">04:45pm</option>"; 
		sHTMLCode += 			"<option value=' 17:00' "+ getSelectionTag(" 17:00") +">05:00pm</option>"; 
		sHTMLCode += 			"<option value=' 17:15' "+ getSelectionTag(" 17:15") +">05:15pm</option>"; 
		sHTMLCode += 			"<option value=' 17:30' "+ getSelectionTag(" 17:30") +">05:30pm</option>"; 
		sHTMLCode += 			"<option value=' 17:45' "+ getSelectionTag(" 17:45") +">05:45pm</option>"; 
		sHTMLCode += 			"<option value=' 18:00' "+ getSelectionTag(" 18:00") +">06:00pm</option>"; 
		sHTMLCode += 			"<option value=' 18:15' "+ getSelectionTag(" 18:15") +">06:15pm</option>"; 
		sHTMLCode += 			"<option value=' 18:30' "+ getSelectionTag(" 18:30") +">06:30pm</option>"; 
		sHTMLCode += 			"<option value=' 18:45' "+ getSelectionTag(" 18:45") +">06:45pm</option>"; 
		sHTMLCode += 			"<option value=' 19:00' "+ getSelectionTag(" 19:00") +">07:00pm</option>"; 
		sHTMLCode += 			"<option value=' 19:15' "+ getSelectionTag(" 19:15") +">07:15pm</option>"; 
		sHTMLCode += 			"<option value=' 19:30' "+ getSelectionTag(" 19:30") +">07:30pm</option>"; 
		sHTMLCode += 			"<option value=' 19:45' "+ getSelectionTag(" 19:45") +">07:45pm</option>"; 
		sHTMLCode += 			"<option value=' 20:00' "+ getSelectionTag(" 20:00") +">08:00pm</option>"; 
		sHTMLCode += 			"<option value=' 20:15' "+ getSelectionTag(" 20:15") +">08:15pm</option>"; 
		sHTMLCode += 			"<option value=' 20:30' "+ getSelectionTag(" 20:30") +">08:30pm</option>"; 
		sHTMLCode += 			"<option value=' 20:45' "+ getSelectionTag(" 20:45") +">08:45pm</option>"; 
		sHTMLCode += 			"<option value=' 21:00' "+ getSelectionTag(" 21:00") +">09:00pm</option>"; 

                             "</select>" + 
                     "</form></td</tr></table>>";
    }
    else {
        sHTMLCode += "<form method='POST' action='--WEBBOT-SELF--'>" +
                            "<input type='hidden' name='pick_time' value=''/>" +
                     "</form>";
    }

	sHTMLCode += "</body>\n" +	"</html>\n";

    // Store the HTML in a page level variable
    sHTML = sHTMLCode; 


    var winHeight = "160";
    if (gWillSelectTime == "true") {
        winHeight = 196;
    }

	var bWindow = window.open("../js/cal.html", "DatePicker", "width=200,height=" + winHeight + ",status=no,resizable=no,top=200,left=200");
	bWindow.opener = self;
/*	var calendarDocument = bWindow.document;
	calendarDocument.write (sHTMLCode);
	gWinCal = bWindow;
	calendarDocument.close();

//document.forms[0].pick_time.value  + 

*/	
}
else
  alert("Object not found.");
}

function getHTML() {
  return sHTML;
}

function getSelectionTag (value)
{
    return (value == gSelectedTime)?"selected":"";
}

function getYearSelectorHtml (dateSelected, obj)
{
    var yearSelected = dateSelected.getFullYear ();
    var monthDay = "";
    var param2 = ""
    switch(sDateFormat) {
      case "MM/DD/YYYY" :
        monthDay = new String ((dateSelected.getMonth()+1) + "/" + dateSelected.getDate()  + "/");
        param2 = "'" + monthDay + "'+this.value";
        break;
      case "DD/MM/YYYY" :
        monthDay = new String (dateSelected.getDate() + "/" + (dateSelected.getMonth()+1)  + "/");
        param2 = "'" + monthDay + "'+this.value";
        break;
      case "YYYY/MM/DD" :
        monthDay = new String ((dateSelected.getMonth()+1) + "/" + dateSelected.getDate()  + "/");
        param2 = "this.value" + "'" + monthDay + "'";
        break;
    }
    var jsCode = "window.opener.setSelectedTime(document.forms[0].pick_time.value);window.opener.DisplayCalendar('" + obj + "'," + param2 + ");";
    var slice = "<select size='1' name='year' onchange=\"" + jsCode + "\">";
    var thisYear = new Date().getFullYear();
    var lower = yearSelected - 30;
    if (yearSelected != thisYear)
        lower = yearSelected - 10;
    var upper = thisYear + 2;
    for (count = upper; count > lower; --count) {
        slice += "<option value='" + count + "'";
        if (count == yearSelected)
            slice +=" selected ";
        slice +=">" + count + "</option>";
    }
    slice += "</select>";
    return slice;
}
