/****************************************************************
*					TDS Date Picker								*
*																*
*	Created By:		Tom Smith	tsmith@tdscode.com			   	*
*	Created Date:	10/25/2000									*
*																*
*	Modified By:	Tom Smith									*
*	Modified Date:	02/06/2003									*
*	Modified Description:										*
*		Updated a problem with the change month.  This occurred	*
*		when the current date was larger than the next months.	*
*		Example: Today 1-31-2003 would fail when going to Feb	*
*		because Feb only had 28 days.  Also fixed the leap year	*
*		problem. Thanks to Bonny Silva for finding these bugs.	*
*****************************************************************
*	For updated releases/changes visit www.tdscode.com			*
*																*
*	This code may be used freely as long as this header is 		*
*	displayed at the top of this file.							*
*																*
*	The calendar was designed for Netscape 4.x - higher	and		*
*	Internet Explorer 4.x - higher.								*
*																*
*	For instructions on using the calendar in visit 			*
*	www.tdscode.com.  Comments and suggestions are welcome.		*
****************************************************************/
/*
document.onkeyup = KeyCheck;
function KeyCheck(e){
   	var KeyID = (window.event) ? event.keyCode : e.keyCode;
   	if(KeyID==27){
   		hideCalendar();
   	}
}
*/
//User defined Variables *** The values may be changed on the variable below
var PREV_COLOR 			= "#E6F3FB";			//Color - color the previous arrow
var NEXT_COLOR 			= "#E6F3FB";			//Color - color for the next arrow
var MONTH_BGCOLOR 		= "#79909E";			//Background Color - color for the Month heading			
var WEEK_BGCOLOR 		= "#FFFFFF";			//Background Color - color for the Weekday headings
var DAY_BGCOLOR 		= "#FFFFFF";			//Background Color - color for the Days
var CUR_DAY_BGCOLOR 	= "#E3F4FB";			//Background Color - color for the Current Day
var CUR_DAY_BOR_COLOR   = "#788EA5";   			//Border Color - color for the border around the current day
var CUR_DAY_COLOR 		= "#7E8E9D"; 			//Font Color - color for the current day
var CUR_DAY_FNT_SIZE 	= "11px"				//Font size of the current day 
var CUR_DAY_WEIGHT	    = "bold";				//Font weight of the current day
var PNI_MOCOLOR 		= "#5D7F9D";			//Background Rollover Color - color to change the previous/next button background when the mouse rolls over
var DAY_MOCOLOR 		= "#CCCCCC";			//Background Rollover Color - color to change the Days background when the mouse rolls over
var HDR_FNT_COLOR 		= "#FFFFFF";			//Font Color - color for the head mounth and year
var DAY_FNT_COLOR 		= "#000000";			//Font Color - color for the Days font
var CAL_BOR_COLOR 		= "#A7A1A5";			//Border Color - color for the border around the calendar
var WEEK_BOR_COLOR		= "#FFFFFF";			//Border Color - color for the border around the Weekday headings
var DAY_BOR_COLOR 		= "#FFFFFF";			//Border Color - color for the border around the Days
//
var IF_CLICK_CLOSE      ="yes";					//If click on the chosen date wiil close the calendar, if no close with X button: YES/NO 
var HOUER_SELECTION		="no";					//If to display the hours selectboxs on the bottom: YES/NO 
var ARROWS_ROW_DISPLAY  ="no";					//The forword and backword date row display: YES/NO
var ARROWS_FOR_SELECT   ="no";					//The forword and backword buttons in the selectbox row: YES/NO
var WEEK_NUMBER	        ="no";					//If to display a wekk number 1-52: YES/NO
var DISPLAY_TODAY		="no";					//If to display the today date on the bottom row
var DATE_FORMAT			="dd/mm/yyyy" 			//DATE FORMAT FOR FUTURE SUPPORT: "DD/MM/YYYY" / "MM/DD/YYYY"
var CALENDAR_DIV_NAME   = "calendar1";          //The name of the containing calendar div (see above document.write)
var FIELD_DAY_BGCOLOR 	= "#EEEFEE";			//Background Color - color for the Current Day FROM THE TEXT FIELD
var FIELD_DAY_BOR_COLOR = "#FF0000";   			//Border Color - color for the border around the current day FROM THE TEXT FIELD
var FIELD_DAY_COLOR 	= "#7E8E9D"; 			//Font Color - color for the current day FROM THE TEXT FIELD
var FIELD_DAY_FNT_SIZE 	= "11px"				//Font size of the current day FROM THE TEXT FIELD
var FIELD_DAY_WEIGHT	= "bold";				//Font weight of the current day FROM THE TEXT FIELD
var BOTTOM_ROW_COLOR	="#454545";				//The color of the footer
var WEEK_NUM_HEAD_COLOR ="#000000";				//The color of the week number head line text
var WEEK_NUM_HEAD_BGCOLOR ="#FFFFFF";				//The color of the week number head line bgcolor
var WEEK_NUM_BOR_COLOR  ="#D4D4D4";				//The color of the week numbers cell border
var WEEK_NUM_BG_COLOR   ="#FFFFFF";				//The color of the week numbers cell bgcolor
var MONTH_SELECTION     = "BUTTONS";            //If the forword and back month will be with selectbox and not arrows: BUTTONS/ARROWS
var MONTH_SELECT_BGCOLOR  = "#A9A7B4"   		//Background Color of the year and month selectbox
var HOUERS_FORMAT       =24;                     //The oures select format 12/24
var YEARS_TO_DISPLAY    = 60;					//How many years will show in the selectbox
var YEAR_TO_START	    =1950;                  //The first year in the year selectbox
var CALENDAR_DIR		="ltr";					//the direction and language of the calendar: LTR/RTL

var submitValue = "";                           //The submit button value
submitValue = "send";

var weekNuberHead ="";
var weekDaysArr = new Array(7);
////var CALENDAR_HEIGHT     = "207px";              //THE CALENDAR SIZE FOR THE SHIM IFRAME
var CALENDAR_WIDTH		= ""; 
////CALENDAR_WIDTH	= "191px";
weekNuberHead="Wk";							//THE week numbers head content text
weekDaysArr[0]="SUN";                       //the week days head content
weekDaysArr[1]="MON";
weekDaysArr[2]="TUE";
weekDaysArr[3]="WED";
weekDaysArr[4]="THU";
weekDaysArr[5]="FRI";
weekDaysArr[6]="SAT";
 
 
 document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1255\">")
 document.write("<div id=\"theCalendarWrapDIv\" style=\"display:none;position:relative; \" class=\"dragme\">");
 document.write("<div id=\""+CALENDAR_DIV_NAME+"\" style=\"position:absolute; visibility: hidden;\"></div>");
 document.write("</div>");
 document.write("<iframe id=\"DivShimCal\" src=\"\" scrolling=\"no\" frameborder=\"0\" style=\"position:absolute;z-index:5; width:5px; heigth:5px; top:0px; left:0px; display:none;\"></iframe>")
	

 
//Global Variables
//Define the different browser types that are supported
var NS4 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4);
var NS6 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==5);
var IE4 = document.all;

//Calendar objects
var calNS4;
var calNS6;
var calIE4;

//Holding Variables
var CALENDAR_HTML = "";
var DISPLAY_DATE = "";
var CURRENT_DATE_FIELD = "";
var CURRENT_DATE_FIELD_ID = "";
var CURRENT_FORM = "";
var OBJECT_TO_ATTACH = "";
var HLD_DIV = "";
var BUILT = "no";
 
//
var theSentDivId = "";
var strBottmRow = "";
var tempWeekVal ="";
var tempWeekFlag = 0;
var currnetDayFlag = 0;
var theDateStr ="";
var theDayStr = "";
var theMounthStr = ""; 
var theYearhStr = "";
var hoursValue ="";
var minutesValue ="";
var tdProperties =""
var selectOpen = 1;
var currentDayStr = "";
//End of Global Variables


//Write out the style sheets
document.write("<style>");

document.write(".dragme{position:relative;}");


document.write(".txtDay { font-size: 9px; color: " + DAY_FNT_COLOR + "; font-family: arial; text-decoration: none;}");
document.write(".weekNuberHead{ font-size: 9px; color: " + WEEK_NUM_HEAD_COLOR + "; font-family: arial; text-decoration: none;}");
if(CALENDAR_DIR=="rtl"){
  document.write(".tdWeekNum { padding: 2px; border-left: 1px solid " + WEEK_NUM_BOR_COLOR + ";background-color:"+ WEEK_NUM_BG_COLOR +"}");
}else{
  document.write(".tdWeekNum { padding: 2px; border-right: 1px solid " + WEEK_NUM_BOR_COLOR + ";background-color:"+ WEEK_NUM_BG_COLOR +"}");
}
document.write(".tdToDay{;background-color:"+ CUR_DAY_BGCOLOR +";border: 1px solid " + CUR_DAY_BOR_COLOR + ";padding: 2px; }");
document.write(".txtToDay{ font-family: arial;font-size: "+CUR_DAY_FNT_SIZE+";font-weight:"+ CUR_DAY_WEIGHT +";color:"+ CUR_DAY_COLOR +";}");

document.write(".tdFieldDay{;background-color:"+ FIELD_DAY_BGCOLOR +";border: 1px solid " + FIELD_DAY_BOR_COLOR + ";padding: 2px; }");
document.write(".txtFieldDay{ font-family: arial;font-size: "+FIELD_DAY_FNT_SIZE+";font-weight:"+ FIELD_DAY_WEIGHT +";color:"+ FIELD_DAY_COLOR +";}");

document.write(".txtMonth { font-size: 11px; color: " + HDR_FNT_COLOR + "; font-family: arial; text-decoration: none;}");
document.write(".tblCalendar { border: 1px solid " + CAL_BOR_COLOR + "; }");
document.write(".tdMonth { padding: 2px;}");
document.write(".tdDayW { padding: 2px; border: 1px solid " + WEEK_BOR_COLOR + "; }");
document.write(".tdDay { padding: 2px; border: 1px solid " + DAY_BOR_COLOR + "; }");
document.write(".btnPrev { font-size: 12px; color: " + PREV_COLOR + "; font-family: arial; font-weight:bold; text-decoration: none;}");
document.write(".btnNext { font-size: 12px; color: " + NEXT_COLOR + "; font-family: arial; font-weight:bold; text-decoration: none;}");
document.write(".selectHours{ font-size: 9px; color: black; font-family: arial; font-weight:normal;}");
document.write("a {text-decoration:none;}");
document.write("</style>");

//This function is used to display the calendar
function showCalendar(field,xPos,yPos,objToCling)
{
	date = CALENDAR_DIV_NAME;
	theSentDivId = date;
	tempWeekFlag = 0;
	
	OBJECT_TO_ATTACH = objToCling;
	
	if (HLD_DIV != date && BUILT == "yes")
	{
		if (NS4)
			calNS4.visibility = 'hidden';
		else if (IE4)
			calIE4.style.visibility = 'hidden';
		else if (NS6)
			calNS6.style.visibility = 'hidden';
		
		BUILT = "no";
		HLD_DIV = date;
	}
		
	if (BUILT == "yes")
	{
		if (NS4)
			calNS4.visibility = 'visible';
		else if (IE4)
			calIE4.style.visibility = 'visible';
		else if (NS6)
			calNS6.style.visibility = 'visible';
		return;
	}


	//Set the Date field to use
	CURRENT_DATE_FIELD = field;
	CURRENT_DATE_FIELD_ID = document.getElementById(CURRENT_DATE_FIELD)
	CURRENT_FORM = document.getElementById(CURRENT_DATE_FIELD).form.name;
	
	//Set the Display Date to null
	DISPLAY_DATE = "";

	//if the field is not empty
	if(CURRENT_DATE_FIELD_ID.value !="" && CURRENT_DATE_FIELD_ID.value.length>6){
      	theDateStr = CURRENT_DATE_FIELD_ID.value.substring(0,10);
		if(DATE_FORMAT=="dd/mm/yyyy"){
			theDayStr = parseInt(theDateStr.substring(0,2));
			theMounthStr = theDateStr.substring(3,5);
		}else{
		    theDayStr = parseInt(theDateStr.substring(3,5));
			theMounthStr = theDateStr.substring(0,2);
		}
		if(theMounthStr.substring(0,0)==0)theMounthStr = theMounthStr *1
		theYearhStr = parseInt(theDateStr.substring(6,10));
		if (HOUER_SELECTION=="yes"){
		  hoursValue = CURRENT_DATE_FIELD_ID.value.substring(11,13);
		  minutesValue = CURRENT_DATE_FIELD_ID.value.substring(14,16);
		}
		DISPLAY_DATE = theMounthStr + "/" + 1 + "/" + theYearhStr
	}
	 //alert(DISPLAY_DATE)

	//DISPLAY_DATE = "9/1/2005"
	
	//Build the Calendar
	buildCalendar();
	
	if (!xPos)
		xPos = "";
	if (!yPos)
		yPos = "";

	//Display the Calendar on the Web page
	if (NS4)
	{
		calNS4 = new Layer(50,this);
		calNS4.document.write(CALENDAR_HTML);
		calNS4.document.close();
		if (xPos != "" || yPos != "")
		{
			this.calNS4.pageX = xPos;
			this.calNS4.pageY = (yPos - 95);
		}
		else
		{
			this.calNS4.pageX = document.layers[date].pageX;
			this.calNS4.pageY = (document.layers[date].pageY - 95);
		}
		calNS4.visibility = 'visible';
	}
	else if (IE4)
	{
		calIE4 = document.all[date];
		
		calIE4.innerHTML = CALENDAR_HTML;
		
		if (xPos != "" || yPos != "")
		{
			calIE4.style.posLeft = xPos;
			calIE4.style.posTop = yPos;
		}
		calIE4.style.visibility = 'visible';
	}
	else if (NS6)
	{
		calNS6 = document.getElementById(date);
		
		calNS6.innerHTML = CALENDAR_HTML;
		if (xPos != "" || yPos != "")
		{
			calNS6.style.top = yPos;
			calNS6.style.left = xPos;
		}
		calNS6.style.visibility = 'visible';
	}
	
	/*if(from_to=='from'){
		calheader.innerHTML = '&nbsp;מתאריך&nbsp;';
	}else{
		calheader.innerHTML = '&nbsp;עד תאריך&nbsp;';
	}*/
	BUILT = "yes";
	//alert(document.getElementById(date).style.width)
	//='500px';
	//
	//displayDivShim(1);
	//
	if(MONTH_SELECTION == "BUTTONS"){
		fillMounth();
		fillYears();
	}
	if(IE4)showHideElements(1);
	if(DISPLAY_TODAY=="yes")drawTodayDate();
	if(HOUER_SELECTION=="yes"){
	 houersSelect();
	 minutesSelect();
	 }
	 strBottmRow ="";
	 
	 if (HOUER_SELECTION=="yes" && CURRENT_DATE_FIELD_ID.value !=""){
	  updateHours();
	  updateMinutes();
	}
	 
	var ooo= document.getElementById(OBJECT_TO_ATTACH)
	popupShow(ooo,'5','5');
	
	getCalendarSize();
	
}

//This function is used to hide the calendar
function hideCalendar()
{

	tempWeekFlag = 0;
	if (BUILT == "no")
		return;
		
	BUILT = "no";
		
	if (NS4)
		calNS4.visibility = 'hidden';
	else if (IE4)
		calIE4.style.visibility = 'hidden';
	else if (NS6)
		calNS6.style.visibility = 'hidden';
		
	if(IE4)showHideElements(0);	
	strBottmRow ="";
	popupHide();
}


//
function callChgCalendarDate(){
  var theStr ="";
  var mounthList = document.getElementById('noHide_mounth');
  var yearsList = document.getElementById('noHide_years');

  theStr = parseInt(mounthList.value)+1 + "/" + 1 + "/" + yearsList.value;
  chgCalendarDate(theStr);
}





//This function is used to change the Calendar Date
function chgCalendarDate(dspDate)
{
     /**/
	//Set the Display to the new Date
	DISPLAY_DATE = dspDate;
     
	//Build the Calendar
	tempWeekFlag = 0;
	buildCalendar();
	
	//Display the Calendar on the Web page
	if (NS4)
	{
		calNS4.document.write(CALENDAR_HTML);
		calNS4.document.close();
	}
	else if (IE4)
		calIE4.innerHTML = CALENDAR_HTML;
	else if (NS6)
		calNS6.innerHTML = CALENDAR_HTML;
		
		
		
		
	// ****************************************************************************
	if(MONTH_SELECTION == "BUTTONS"){
		fillMounth();
		fillYears();
	}
	if(IE4)showHideElements(1);
	if(DISPLAY_TODAY=="yes")drawTodayDate();
	if(HOUER_SELECTION=="yes"){
	 houersSelect();
	 minutesSelect();
	 }
	 if (HOUER_SELECTION=="yes" && CURRENT_DATE_FIELD_ID.value !=""){
	  updateHours();
	  updateMinutes();
	}
	
	getCalendarSize();
	
	 strBottmRow ="";
	
}

//This function is used to change the Date field to the selected calendar date
function chgDate(txtDate)
{
    var theHours = "";
	if(HOUER_SELECTION=="yes"){
	  theHours = " " + document.getElementById('noHide_hourSelect').value;
	  theHours = theHours + ":"  + document.getElementById('noHide_minuteSelect').value;
	}

	
	//update the value in the field
	document.forms[CURRENT_FORM][CURRENT_DATE_FIELD].value = txtDate + theHours;
	
	//Hide the Calendar
	tempWeekFlag = 0;
	if(IF_CLICK_CLOSE == "yes"){
	   hideCalendar();
	}else{
	   getDateFromField();
	   //alert(dspDate)
	   var dspDate = theMounthStr + "/" + 1 + "/" + theYearhStr;
	   //problem is in chgCalendarDate
	   /**/
	   chgCalendarDate(dspDate);
	}
}

//This function is used to Build the Calendar
function buildCalendar()
{
	//Define the Month Names and Month Days Array
	if (CALENDAR_DIR=="ltr"){
	    monthNames = new Array("January","Februrary","March","April","May","June","July","August","September","October","November","Decemeber");
	}else{
	    monthNames = new Array("January","Februrary","March","April","May","June","July","August","September","October","November","Decemeber");
	}
	monthDays 		= new Array(12);
	
	//Entry the Total Days for each Month
	monthDays[0]	= 31;
	monthDays[1]	= 28;
	monthDays[2]	= 31;
	monthDays[3]	= 30;
	monthDays[4]	= 31;
	monthDays[5]	= 30;
	monthDays[6]	= 31;
	monthDays[7]	= 31;
	monthDays[8]	= 30;
	monthDays[9]	= 31;
	monthDays[10]	= 30;
	monthDays[11]	= 31;

	//Determine the Date for the Calendar to Display
	if (DISPLAY_DATE == ""){
		calendarDateObj	= new Date();
	}else{
		calendarDateObj = new Date(DISPLAY_DATE);
	}
	
	//Obtain the Calendar Dates
	calendarDate	= calendarDateObj.getDate();
	calendarDay		= calendarDateObj.getDay();
	calendarMonth	= calendarDateObj.getMonth();
	calendarYear	= calendarDateObj.getFullYear();//calendarDateObj.getYear();
	
	//Obtain Todays Dates
	currentDateObj 	= new Date();
	currentDate 	= currentDateObj.getDate();
	currentDay 		= currentDateObj.getDay();
	currentDayStr   = currentDateObj.getDay(); //to send if fiels is empty
	currentMonth 	= currentDateObj.getMonth();
	currentYear		= currentDateObj.getFullYear();//currentDateObj.getYear();
	
	//*** Fix - TDS 2-06-2003 ***
	if ((calendarMonth == currentMonth) && (calendarYear == currentYear))
	{
		calendarDate = currentDate;
		calendarDay = currentDay;
	}
	
	if (LeapYear(calendarYear))
		monthDays[1] = 29;
	//*** End Fix - 2-06-2003 ***
	
	//Make sure the Year is in the correct century
	calendarYear 	= calendarYear % 100;
	calendarYear 	= ((calendarYear < 50) ? (2000 + calendarYear) : (1900 + calendarYear));


	//Calculate the Blank entries before the 1st of the month
	blankEntry = calendarDate;

	while (blankEntry > 7) 
		blankEntry-= 7;

	blankEntry = calendarDay - blankEntry + 1;
	
	if (blankEntry < 0) 
		blankEntry+= 7;
	
	//Calculate Next Months Date
	nextMonth = (calendarMonth + 2);
	
	if (nextMonth == 13)
	{
		nextMonth = 1;
		nextYear = (calendarYear + 1);
	} 
	else
		nextYear = calendarYear;

	//*** Fix - TDS 2-06-2003 ***
	//nextDate = nextMonth + "/" + currentDate + "/" + nextYear;
	nextDate = nextMonth + "/1/" + nextYear;
	//*** End Fix - 2-06-2003 ***
	
	//Calculate Previous Months Date
	prevMonth = calendarMonth;
	
	if (prevMonth == 0)
	{
		prevMonth = 12;
		prevYear = (calendarYear - 1);
	} 
	else
		prevYear = calendarYear;

	//*** Fix - TDS 2-06-2003 ***
	//prevDate = prevMonth + "/" + currentDate + "/" + prevYear;
	prevDate = prevMonth + "/1/" + prevYear;
	//*** End Fix - 2-06-2003 ***

	//Build the Header for the Calendar
	CALENDAR_HTML = "<table id=\"tblCalendar\" class=\"tblCalendar\" border=0 cellpadding=0 cellspacing=0 dir='"+CALENDAR_DIR+"'>";
	CALENDAR_HTML += "<tr onmousedown=\"enableDrag()\" onmouseup=\"disableDrag()\" style=\"cursor: move;\" dir=\"rtl\"><td ";
	if(WEEK_NUMBER=="yes"){
	  CALENDAR_HTML += "colspan='8'";
	}else{
	  CALENDAR_HTML += "colspan='7'";
	}
    CALENDAR_HTML += " bgcolor='#454545' dir=\"rtl\"><a href='javascript:hideCalendar();'><font class=\"btnPrev\" style='color:#FFFFFF;line-height:15px;'>&nbsp;X&nbsp;</font></a></td></tr>";
	
	
	if(MONTH_SELECTION == "BUTTONS"){
      CALENDAR_HTML+='<tr bgcolor=' + MONTH_SELECT_BGCOLOR +'>';
	  
	  if(WEEK_NUMBER=="yes"){CALENDAR_HTML += "<td colspan=\"8\" align=\"center\">";}else{CALENDAR_HTML += "<td colspan=\"7\" align=\"center\">";}
	  
	  CALENDAR_HTML+='<table border=0 cellpadding=0 cellspacing=0 align=\"center\"><tr>';
	  if(ARROWS_FOR_SELECT=="yes"){
	    CALENDAR_HTML += "<td bgcolor=" + MONTH_BGCOLOR + " align=center class=\"tdMonth\" onMouseOver=mOvr(this,'" + PNI_MOCOLOR + "') onMouseOut=mOut(this,'" + MONTH_BGCOLOR + "') onClick=chgCalendarDate('" + prevDate + "')><a href=javascript:chgCalendarDate('" + prevDate + "')><font class=\"btnPrev\"><<</font></a></td>";
	  }
	  CALENDAR_HTML+='<td><select name=\"noHide_years\" id=\"noHide_years\" class=\"selectHours\" onchange=\"callChgCalendarDate();isdrag = false;\"></select></td><td>&nbsp;&nbsp;</td>';
	  CALENDAR_HTML+='<td><select name=\"noHide_mounth\" id=\"noHide_mounth\" class=\"selectHours\" onchange=\"callChgCalendarDate();isdrag = false;\" ></select></td>';
	  if(ARROWS_FOR_SELECT=="yes"){
	    CALENDAR_HTML+="<td bgcolor=" + MONTH_BGCOLOR + " align=center class=\"tdMonth\" onMouseOver=mOvr(this,'" + PNI_MOCOLOR + "') onMouseOut=mOut(this,'" + MONTH_BGCOLOR + "') onClick=chgCalendarDate('" + nextDate + "')><a href=javascript:chgCalendarDate('" + nextDate + "')><font class=\"btnNext\">>></font></a></td>";
	  }
	  CALENDAR_HTML+='</tr></table></td></tr>';
    }
	
	if(ARROWS_ROW_DISPLAY=="yes"){
		CALENDAR_HTML += "<tr>";
		CALENDAR_HTML += "<td bgcolor=" + MONTH_BGCOLOR + " align=center class=\"tdMonth\" onMouseOver=mOvr(this,'" + PNI_MOCOLOR + "') onMouseOut=mOut(this,'" + MONTH_BGCOLOR + "') onClick=chgCalendarDate('" + prevDate + "')><a href=javascript:chgCalendarDate('" + prevDate + "')><font class=\"btnPrev\"><<</font></a></td>";
		if(WEEK_NUMBER=="yes"){
		   CALENDAR_HTML += "<td bgcolor=" + MONTH_BGCOLOR + " align=center class=\"tdMonth\" colspan=6><font class=\"txtMonth\">" + monthNames[calendarMonth] + " " + calendarYear + "</font></td>";
		}else{
		   CALENDAR_HTML += "<td bgcolor=" + MONTH_BGCOLOR + " align=center class=\"tdMonth\" colspan=5><font class=\"txtMonth\">" + monthNames[calendarMonth] + " " + calendarYear + "</font></td>";
		}
		CALENDAR_HTML += "<td bgcolor=" + MONTH_BGCOLOR + " align=center class=\"tdMonth\" onMouseOver=mOvr(this,'" + PNI_MOCOLOR + "') onMouseOut=mOut(this,'" + MONTH_BGCOLOR + "') onClick=chgCalendarDate('" + nextDate + "')><a href=javascript:chgCalendarDate('" + nextDate + "')><font class=\"btnNext\">>></font></a></td>";
		CALENDAR_HTML += "</tr>";
	}
	
	CALENDAR_HTML += "<tr>";
	if(WEEK_NUMBER=="yes"){CALENDAR_HTML += "<td bgcolor=" +  WEEK_NUM_HEAD_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"weekNuberHead\">"+ weekNuberHead +"</font></td>"}
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[0] +"</font></td>";
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[1] +"</font></td>";
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[2] +"</font></td>";
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[3] +"</font></td>";
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[4] +"</font></td>";
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[5] +"</font></td>";
	CALENDAR_HTML += "<td bgcolor=" + WEEK_BGCOLOR + " align=center class=\"tdDayW\"><font class=\"txtDay\">"+ weekDaysArr[6] +"</font></td>";
	CALENDAR_HTML += "</tr>";
	CALENDAR_HTML += "<tr>";

	
	//Build a blank cell for each Blank Entry before the 1st of the Month
	for (s = 0;s < blankEntry;s++){
		if(WEEK_NUMBER=="yes" && s == 0){
		  tempWeekVal = getWeekNumber((calendarMonth+1) + "/" + 1 + "/" + calendarYear)
		  if(tempWeekVal!=52 && tempWeekVal!=1)tempWeekVal = tempWeekVal-1;
		  CALENDAR_HTML += "<td bgcolor=" + DAY_BGCOLOR + " align=center class=\"tdWeekNum\"><font class=\"txtDay\">"+ tempWeekVal+ "</font></td>";
		  CALENDAR_HTML += "<td bgcolor=" + DAY_BGCOLOR + " align=center class=\"tdDay\"><font class=\"txtDay\">&nbsp;</font></td>";
		}else{
		  CALENDAR_HTML += "<td bgcolor=" + DAY_BGCOLOR + " align=center class=\"tdDay\"><font class=\"txtDay\">&nbsp;</font></td>";
		}
	}

	
	if(WEEK_NUMBER=="yes" && s == 0){
		  tempWeekVal = getWeekNumber((calendarMonth+1) + "/" + 1 + "/" + calendarYear)
		  if(tempWeekVal!=52 && tempWeekVal!=1)tempWeekVal = tempWeekVal-1;
		  CALENDAR_HTML += "<td bgcolor=" + DAY_BGCOLOR + " align=center class=\"tdWeekNum\"><font class=\"txtDay\">"+ tempWeekVal+ "</font></td>";
	}
	
	//Start the Day Counter
	dayCount = 1;

	
	getDateFromField();
	
	
	//Loop through until the total days of calendar month have been reached
	while (dayCount <= monthDays[calendarMonth]) 
	{
		//Start a new table row each time through the loop except the first time
		if (dayCount > 1)
			CALENDAR_HTML += "<tr>";
		
		//Start at the next cell after the blank entries and entry the cells across the row.
		if(WEEK_NUMBER=="yes"){
          if(tempWeekFlag>0){
		    tempWeekVal = getWeekNumber((calendarMonth+1) + "/" + dayCount + "/" + calendarYear)
		    CALENDAR_HTML += "<td bgcolor=" + DAY_BGCOLOR + " align=center class=\"tdWeekNum\" id=\"weedkDayTd\"><font class=\"txtDay\">"+ tempWeekVal+ "</font></td>";
		  }
		  tempWeekFlag = 1;
		}
		for (b = blankEntry;b < 7;b++) 
		{
			//If the Day Counter is greater than the Month total then add blank entries
			  
			  //alert("currentYear = " currentYear)
			    //alert("calendarMonth = " + calendarMonth)
			if (dayCount <= monthDays[calendarMonth])
			{
				if(dayCount.toString().length<2){dayCount = "0"+dayCount};
				tempCalendarMonth = calendarMonth + 1;
				if(tempCalendarMonth.toString().length<2){tempCalendarMonth = "0"+tempCalendarMonth};
				/*tdProperties = "id="+dayCount+" onClick=chgDate('" + dayCount + "/" + (tempCalendarMonth) + "/" + calendarYear + "') ";
				tdData = "<a href=javascript:chgDate('" + dayCount + "/" + (tempCalendarMonth) + "/" + calendarYear + "')><font class=\"txtDay\">&nbsp;" + dayCount + "&nbsp;</font></a>";
				*/
				
				
				if(DATE_FORMAT=="dd/mm/yyyy"){
					tdProperties = "id="+dayCount+" onClick=chgDate('" + dayCount + "/" + (tempCalendarMonth) + "/" + calendarYear + "') ";
				    tdData = "<a href=javascript:chgDate('" + dayCount + "/" + (tempCalendarMonth) + "/" + calendarYear + "')>";
				}else{
				    tdProperties = "id="+dayCount+" onClick=chgDate('" + (tempCalendarMonth) + "/" + dayCount + "/" + calendarYear + "') ";
				    tdData = "<a href=javascript:chgDate('" + (tempCalendarMonth) + "/" + dayCount + "/" + calendarYear + "')>";
				}
				
				//alert("currentDay = " + currentDay + "calendarDay = " + calendarDay + "currentMonth = " + currentMonth + "calendarMonth = " + calendarMonth + "currentYear = " + currentYear + "calendarYear = " + calendarYear)
				
				//If the current day is equal to the calendar day and the
				//current month is equal to the calendar month, check the dates
				if ((currentDay == calendarDay) && (currentMonth == calendarMonth) && (currentYear == calendarYear))
				{
					//If the day counter is equal to the current date then change the color
					if (dayCount == currentDate){
					  
						tdProperties = tdProperties + "class=\"tdToDay\"";
						currentDayStr = dayCount;
					    currnetDayFlag = 1;
					}else{
						  if ((dayCount == theDayStr) && (calendarMonth == parseInt(theMounthStr-1)) && (theYearhStr == calendarYear)){
						   tdProperties = tdProperties + "class=\"tdFieldDay\"";
						   //alert(theDayStr)
						   currnetDayFlag=2;
						   //alert(dayCount + "-" + theDayStr + "-" + calendarMonth + "-" + parseInt(theMounthStr-1))
						  }else{
						   tdProperties = tdProperties + "class=\"tdDay\" onMouseOver=mOvr(this,'" + DAY_MOCOLOR + "') onMouseOut=mOut(this,'" + DAY_BGCOLOR + "') bgcolor=" + DAY_BGCOLOR + "";
						  }
					}
					 
				} 
				else{
					     //: if the date in the text field equal the calendar day and month
						 if ((dayCount == theDayStr) && (calendarMonth == parseInt(theMounthStr-1)) && (theYearhStr == calendarYear)){
						   tdProperties = tdProperties + "class=\"tdFieldDay\"";
						   currnetDayFlag=2;
						 }else{
						   tdProperties = tdProperties + "class=\"tdDay\" onMouseOver=mOvr(this,'" + DAY_MOCOLOR + "') onMouseOut=mOut(this,'" + DAY_BGCOLOR + "') bgcolor=" + DAY_BGCOLOR + "";
						 }
						
					}
				  
				  if(currnetDayFlag==1){ 
					tdData = tdData + "<font class=\"txtToDay\">&nbsp;" + dayCount + "&nbsp;</font></a>"
				 }else{
				 
				    if(currnetDayFlag==2){ 
					  tdData = tdData + "<font class=\"txtFieldDay\">&nbsp;" + dayCount + "&nbsp;</font></a>"
					}else{
					  tdData = tdData + "<font class=\"txtDay\">&nbsp;" + dayCount + "&nbsp;</font></a>"
					}
					currnetDayFlag = 0;
				  }
			        
			} 
			else
			{
				  tdProperties = "class=\"tdToDay\"";
				  tdData = "<font class=\"txtDay\">&nbsp;</font></a>";
			}
		
			//Build the table cells
			CALENDAR_HTML += "<td bgcolor=" + DAY_BGCOLOR + " align=center" + tdProperties + ">" + tdData + "</td>";
		
			//Add to the Day counter
			dayCount++;
			currnetDayFlag = 0;
		}
	
		//End the table row
		CALENDAR_HTML += "</tr>";
		
		//Set the Blank entries to zero
		blankEntry=0;
	}

	//End the table

	CALENDAR_HTML += "<tr>";
	CALENDAR_HTML += "<td bgcolor=" + BOTTOM_ROW_COLOR + " colspan=4 class=\"tdMonth\" id=\"bottomRow\"></td>";
	if(WEEK_NUMBER=="yes"){CALENDAR_HTML += "<td colspan=4 class=\"tdMonth\" bgcolor=" + BOTTOM_ROW_COLOR + " id=\"bottomRowDate\"></td>";}
	else{CALENDAR_HTML += "<td colspan=3 class=\"tdMonth\" bgcolor=" + BOTTOM_ROW_COLOR + " id=\"bottomRowDate\"></td>";}
	CALENDAR_HTML += "</tr>";

	CALENDAR_HTML += "</table>";
	//CALENDAR_HTML += "<iframe id=DivShimCal src='' scrolling=no frameborder=0 style='position:absolute;z-index:5; width:5px; heigth:5px; top:0px; left:0px; display:none;'></iframe>";
	
	
}

//*** Fix - TDS 2-06-2003 ***
//This fuction checks for the Leap Year
function LeapYear(year) 
{
    if ((year/4)   != Math.floor(year/4))   return false;
    if ((year/100) != Math.floor(year/100)) return true;
    if ((year/400) != Math.floor(year/400)) return false;
    return true;
}
//*** End Fix - 2-06-2003 ***

//This function is used to control the mouse over event.
function mOvr(src,clrOver)
{ 

	if(src){
	  src.style.cursor = 'pointer'; 
	  src.bgColor = clrOver;
	}
	/*if (!src.contains(event.fromElement))
	{ 
		src.style.cursor = 'pointer'; 
		src.bgColor = clrOver;
	} */
}

//This function is used to control the mouse out event.
function mOut(src,clrIn)
{ 
	
	if(src){
	  src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	}
	/*if (!src.contains(event.toElement))
	{ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} */
}



//HIDES AND SHOWS THE SELECTBOX / IFRAMES / FLASH IN THE PAGE
function showHideElements(state){
/*
   if (state==0)h='visible';
   else h='hidden';
	tag=document.getElementsByTagName('select');
	for(i=tag.length-1;i>=0;i--){
	  if(tag[i].id.indexOf('noHide')==-1){
	     tag[i].style.visibility=h;
	   }
	}
	tag=document.getElementsByTagName('iframe');
	for(i=tag.length-1;i>=0;i--){
	  if (tag[i].id!='noHide'){// IFRAME SRC
	    tag[i].style.visibility=h;
		}
	 }
	tag=document.getElementsByTagName('object');
	for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;
	*/
}









function displayDivShim(state){
 var divShim = document.getElementById("DivShimCal");
 
 ////var theSentDiv = document.getElementById(theSentDivId);
 var theSentDiv = document.getElementById("tblCalendar");
 //document.getElementById(theSentDivId).style.zIndex = 10;
 //document.getElementById(theSentDivId).style.border = '1px solid green';
//alert(theSentDiv.offsetHeight)
//alert(theSentDiv.style.height)
//alert(theSentDiv.style.top)
//alert(theSentDiv.style.left)
 
  	  divShim.style.display= '';
	 // divShim.style.top =   objId4.style.top;
	 // divShim.style.right =   objId4.style.right;
	 //divShim.style.top = theSentDiv.offsetHeight -122;
	 
	 ///////divShim.style.width = theCalendarWidth;
	 ///////divShim.style.height = theCalendarHeight; 
	 
	 //divShim.style.left = theSentDiv.offsetWidth;
	 
	 divShim.style.border = '1px solid red';
}

function fillMounth(){
	// fill the select
	if (CALENDAR_DIR=="ltr"){
	    monthNames = new Array("January","Februrary","March","April","May","June","July","August","September","October","November","Decemeber");
	}else{
	    monthNames = new Array("January","Februrary","March","April","May","June","July","August","September","October","November","Decemeber");
	}
	
	var mounthList = document.getElementById('noHide_mounth');
	var theValue,theText
	var optionToAdd,listLength 
	var listLength;
	
	
	
	 for(i=0;i<monthNames.length;i++){
	  listLength = mounthList.length;
	theValue = i;
	  theText = monthNames[i];
	  optionToAdd = new Option(theText,theValue);
	  mounthList.options[listLength] = optionToAdd;
	}
	
	if (DISPLAY_DATE == ""){
		calendarDateObj	= new Date();
	}else{
		calendarDateObj = new Date(DISPLAY_DATE);
	}
	///alert(calendarDateObj)
	calendarMonth = calendarDateObj.getMonth();
	mounthList.options[calendarMonth].selected = true;
}



function fillYears(){
	// fill the years select
	
	monthDays = new Array(12);
	
	//Entry the Total Days for each Month
	monthDays[0]	= 31;
	monthDays[1]	= 28;
	monthDays[2]	= 31;
	monthDays[3]	= 30;
	monthDays[4]	= 31;
	monthDays[5]	= 30;
	monthDays[6]	= 31;
	monthDays[7]	= 31;
	monthDays[8]	= 30;
	monthDays[9]	= 31;
	monthDays[10]	= 30;
	monthDays[11]	= 31;

	
	if (DISPLAY_DATE == ""){
		calendarDateObj	= new Date();
	}else{
		calendarDateObj = new Date(DISPLAY_DATE);
	}
	
	 calendarYear	= calendarDateObj.getYear();
	  if (LeapYear(calendarYear))
		monthDays[1] = 29;
	 calendarYear 	= calendarYear % 100;
	 calendarYear 	= ((calendarYear < 50) ? (2000 + calendarYear) : (1900 + calendarYear));
	 

	var yearsList = document.getElementById('noHide_years');
	var theValue,theText
	var optionToAdd,listLength 
	var listLength;
	
	for(i=0;i<YEARS_TO_DISPLAY;i++){
	  listLength = yearsList.length;
	  theValue = parseInt(YEAR_TO_START) + parseInt(i);
	  theText = parseInt(YEAR_TO_START) + parseInt(i);
	  optionToAdd = new Option(theText,theValue);
	  yearsList.options[listLength] = optionToAdd;
	  if(theValue == calendarYear)yearsList.options[i].selected = true;
	}
	
}



function houersSelect(){
   strBottmRow = strBottmRow + "<table cellpadding=\"0\" cellspacing=\"0\" dir=\"ltr\"><tr><td><button onclick=\"hoursMinutesToField();\" style=\"height:16px;font-size:10px;line-height:10px;\">"+submitValue+"</button>&nbsp;</td><td><select name=\"noHide_hourSelect\" id=\"noHide_hourSelect\" class=\"selectHours\" onclick=\"isdrag = false;\" onchange=\"hoursMinutesToField()\"></select></td><td>:</td><td><select name=\"noHide_minuteSelect\" id=\"noHide_minuteSelect\" class=\"selectHours\" onclick=\"isdrag = false;\" onchange=\"hoursMinutesToField()\"></select></td></tr></table>"
   document.getElementById('bottomRow').innerHTML = strBottmRow;
   
   var theHoursSelect = document.getElementById('noHide_hourSelect');
   var theValue,theText
   var optionToAdd,listLength,theNum;
   var theFormat;
   if (HOUERS_FORMAT==24){theFormat=24;}else{theFormat=12;}
   
   for(i=0;i<theFormat;i++){
     listLength = theHoursSelect.length;
	 if (i<10){theNum = "0"+i}else{theNum=i};
	 theValue = theNum
	 theText = theNum;
	 optionToAdd = new Option(theText,theValue);
	 theHoursSelect.options[listLength] = optionToAdd;
   } 
}



function minutesSelect(){

   var theMinutesSelect = document.getElementById('noHide_minuteSelect');
   var theValue,theText;
   var optionToAdd,listLength,theNum;
   var theFormat;
   if (HOUERS_FORMAT==24){theFormat=24;}else{theFormat=12;}
   
   for(i=0;i<=50;i=i+10){
   
    listLength = theMinutesSelect.length;
	
	 if (i<10){theNum = "0"+i}else{theNum=i};
	 theValue = theNum;
	 theText = theNum;
	 optionToAdd = new Option(theText,theValue);
	 theMinutesSelect.options[listLength] = optionToAdd;
   } 
   
}




    var monthNames = new Array(
	"1","2","3","4","5","6","7",
	"8","9","10","11","12");
    var now = new Date();
	var theYear = now.getFullYear();
	var theMonth = monthNames[now.getMonth()]
	var theDay = now.getDate();

function drawTodayDate(){

	theYear = theYear.toString();
	theMonth = theMonth.toString();
	theDay = theDay.toString();

	var theYearArr = new Array();
	var theMonthArr = new Array();
	var theDayArr = new Array();
	
	var strDate = "";
	
	if(CALENDAR_DIR == "ltr"){
	  strDate = "Today is " + theDay+"/"+theMonth+"/"+theYear;
	}else{
	  strDate = "Today is " + theDay+"/"+theMonth+"/"+theYear;
	}

	document.getElementById('bottomRowDate').innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"txtDay\">" + strDate + "</td></tr></table>";
	
}




//to select the  hours value form the field in the select
function updateHours(){
  var theHoursSelect = document.getElementById('noHide_hourSelect');
   hoursValue = CURRENT_DATE_FIELD_ID.value.substring(11,13);	 
  for(i=0;i<theHoursSelect.length;i++){
       if(theHoursSelect.options[i].value.toString() == hoursValue.toString())theHoursSelect.options[i].selected = true;
	}
}


function updateMinutes(){
  var theMinutesSelect = document.getElementById('noHide_minuteSelect');
   minutesValue = CURRENT_DATE_FIELD_ID.value.substring(14,16);
  for(i=0;i<theMinutesSelect.length;i++){
       if(theMinutesSelect.options[i].value.toString() == minutesValue.toString())theMinutesSelect.options[i].selected = true;
	}
}


//send the hours and minutes to the text field when select box is changed
function hoursMinutesToField(){

   if(theDateStr.length<6){
      if(DATE_FORMAT=="dd/mm/yyyy"){
	    theDateStr = currentDayStr+"/"+theMonth+"/"+theYear;
	  }else{
	    theDateStr = currentDayStr+"/"+theDay+"/"+theYear;
	  }
  }
   
   document.forms[CURRENT_FORM][CURRENT_DATE_FIELD].value = "";
   
   if(CURRENT_DATE_FIELD_ID.value.length>6 || CURRENT_DATE_FIELD_ID.value.length == 0 ){
	  theHours = " " + document.getElementById('noHide_hourSelect').value;
	  theHours = theHours + ":"  + document.getElementById('noHide_minuteSelect').value;
	 //Change the Date field
	  document.forms[CURRENT_FORM][CURRENT_DATE_FIELD].value = theDateStr + theHours;
	} 
}


//when called updates the global vars with the current field values
function getDateFromField(){
	    theDateStr = CURRENT_DATE_FIELD_ID.value.substring(0,10);
		if(DATE_FORMAT=="dd/mm/yyyy"){
		  theDayStr = theDateStr.substring(0,2);
		  theMounthStr = theDateStr.substring(3,5);
		 }else{
		  theDayStr = theDateStr.substring(3,5);
		  theMounthStr = theDateStr.substring(0,2);
		 }
		 theYearhStr =  parseInt(theDateStr.substring(6,10))
	 
}



function getCalendarSize(){
  if(IE4){
		if(theShim!=null){
		    var theCalendar = document.getElementById(CALENDAR_DIV_NAME);
			var divShim = document.getElementById("DivShimCal")
			divShim.style.width = (theCalendar.offsetWidth) + "px";
			divShim.style.height = (theCalendar.offsetHeight) + "px";
		 }
  }
}


function enableDrag(){
  selectOpen=0;
}

function disableDrag(){
  selectOpen=1;
}


function selectClicked(){
  if(selectOpen ==1 )selectOpen=0;
  else selectOpen = 1;
  //alert(selectOpen)
}



/////////////    WEEK NUMBER FUNCTIONS  /////////////////////////////
	function getWeekNumber(theDay) {
	var tempD = new Date(theDay);
	var d = new Date(tempD.getFullYear(), tempD.getMonth(), tempD.getDate(), 0, 0, 0);
	var DoW = d.getDay();
	 d.setDate(d.getDate() - (DoW + 6) % 7 + 3);
	 var ms = d.valueOf();
	 d.setMonth(0);
	 d.setDate(4);
	 var theReturndValue = Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
	 return theReturndValue;
	
        /* var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
         var DoW = d.getDay();
         d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
        var ms = d.valueOf(); // GMT
         d.setMonth(0);
        d.setDate(4); // Thu in Week 1
         return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;*/

  }


/////////////    WEEK NUMBER FUNCTIONS  /////////////////////////////











/////////////////////////////  START MENU FUNCTIONS ////////////////////////////////////////
var m_CurrentPopup;
var theShim;
var LeftPos,topPos
////var menuwidth;
////menuwidth = CALENDAR_WIDTH;

var Xoff;
Xoff=3;

function popupHide(e,leftP,topP)
{
	//evt = e || window.event;
	var desElement;
	var srcElement;
	
		
	LeftPos = leftP;
	topPos = topP;
	
	if(typeof(m_CurrentPopup) != "undefined"){
	
				 /*   if (window.event != null)
					{	
						srcElement = e.srcElement;
						desElement = event.toElement
						
					}
					else
					{
						srcElement = e.target;
						desElement = e.relatedTarget;	
					}
					
					if(desElement==null)
					{
						m_CurrentPopup.style.display = 'none';
						return;
					}	
				  
					// ((srcElement.id.indexOf('topMenuTD_')>0) && (desElement.id.indexOf('topMenuPopup_') >0 ))
					  //  return;	
				
				
					p = desElement;
				
				    	while( p != null)
				    	{
				
						if (p.id == m_CurrentPopup.id)
							return;
				
				        	p = p.offsetParent
				    	} 
				
				
					if (m_CurrentPopup == null)
						return;*/
					
					m_CurrentPopup.style.display = 'none';
	
	  }

	
	
	 if(theShim!=null){
	     theShim.style.display = 'none'; // - hide the empty background frame
	  }
	  
	
}

function popupShow(srcObj,leftP,topP)
{
    
	LeftPos = leftP;
	topPos = topP;
	
	var topTD = srcObj; //.offsetParent;
	/*var theObjHeight =  document.getElementById(srcObj.id);
	theObjHeight = theObjHeight.id;
	theObjHeight = theObjHeight.style.height;
	alert(theObjHeight)*/
	//var popTable = topTD.id.replace('b_','menu_');
	
	popTable = document.getElementById('theCalendarWrapDIv');
	theObjHeight = document.getElementById(popTable.id);
	
	if (popTable == null)
		return
	
	if (m_CurrentPopup != null)
		m_CurrentPopup.style.display = 'none'	
	
	var left=0;
    var top = 0;
	var p = topTD
    	while( p != null)
    	{
        	left += p.offsetLeft
        	top += p.offsetTop
        	p = p.offsetParent
    	} 
    
		m_CurrentPopup = popTable;
    	m_CurrentPopup.style.top = ((0) + top + topTD.offsetHeight -parseInt(topPos)) +'px';
    	m_CurrentPopup.style.left = (left + parseInt(LeftPos)) + 'px';
    	m_CurrentPopup.style.display = '';
		m_CurrentPopup.style.zIndex = '1000';
    	m_CurrentPopup.style.position = 'absolute';
		
	
	
	  theShim = document.getElementById("DivShimCal");
	  dropmenuobj = popTable;
      dropmenuobj.x=getposOffset(srcObj, "left")
	  dropmenuobj.y=getposOffset(srcObj, "top")
	
	
	// - THE EMPTY BACKGROUND FRAME FPR SELECT BOX COVER
	 if(IE4){
		if(theShim!=null){
		theShim.style.top = (dropmenuobj.y-8)+"px";
		theShim.style.display = '';
		////theShim.style.width = eval(menuwidth.substring(0,menuwidth.lastIndexOf("px")))+14;
		////theShim.style.height= (menuNum.length)*17+'px';
	    ////theShim.style.height = eval(CALENDAR_HEIGHT.substring(0,CALENDAR_HEIGHT.lastIndexOf("px")));
		theShim.style.left = dropmenuobj.x-Xoff-clearbrowseredge(srcObj, "rightedge")+"px"
		theShim.style.top=(dropmenuobj.y-8)-clearbrowseredge(srcObj, "bottomedge")+srcObj.offsetHeight+"px"
		}
	}
}
/////////////////////////////  END MENU FUNCTIONS ////////////////////////////////////////



function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
	totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
	parentEl=parentEl.offsetParent;
	}
	return totaloffset;
	}
	
	
function clearbrowseredge(obj, whichedge){
	var edgeoffset=-7
	if (whichedge=="rightedge"){
	var windowedge = window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
	var windowedge=window.pageYOffset+window.innerHeight-18
	dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
	if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	}
	return edgeoffset
	}
	
	

////////////////   DRAG AND DROP /////////////////////
var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function movemouse(e)
{
  if (isdrag && selectOpen==0)
  {
    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
	
	// - MOVE SHIM
	var theShim = document.getElementById("DivShimCal");
	theShim.style.left = dobj.style.left; 
	theShim.style.top = dobj.style.top;
    return false;
  }
  
}

function selectmouse(e) 
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "dragme")
  {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
	
  }

  if (fobj.className=="dragme")
  {
    
	
	isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
	// - MOVE SHIM
	/*var theShim = document.getElementById("DivShimCal");
	window.status = dobj.x*/
    return false;
  }
}
// Removed, it caused problems to scroll bars
//document.onmousedown=selectmouse;
//document.onmouseup=new Function("isdrag=false");
////////////////   DRAG AND DROP /////////////////////