isMessenger = !!isMessenger;
var c = false; 
var j,m,calLocation,theYearObj,theDayObj,myDay,myMonth,myYear;
var prevMonth,prevYear,subsequentMonth,subsequentYear,yOffset;
var theElement = 'mydate1';
var thisClass="f";
var thisStyle = "";
var cVisible = false;
var recurModEndCal = false;
var gWeekDays= 7; // number of days 
var gNow = new Date();

gNow.setDate( todayDay);
gNow.setMonth(todayMonth-1);
gNow.setYear(todayYear);

var vNowDay = gNow.getDate() ;
var vNowMonth = gNow.getMonth();
var vNowYear = gNow.getFullYear();
var today;

today = new Date(gNow);

var dow = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var months_short = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
var callCloseFunct = "Calendar.Close('" + this.gType + "','" + this.INLINE + "')";
var day_headers = [Su, Mo, Tu, We, Th, Fr, Sa, Su, Mo, Tu, We, Th, Fr];  //Objects come from Index pages that use localized text
if (weekBeginsDay == "") weekBeginsDay = 0;

weekBeginsDay = parseInt(weekBeginsDay); 
if (weekBeginsDay >= gWeekDays || weekBeginsDay < 0)  
	weekBeginsDay = 0;

var day_header = copyDayHeaders(day_headers);


function copyDayHeaders(day_headers){
	var tmp = new Array(gWeekDays);
	for (var i=0; i<gWeekDays; i++){
		tmp[i] = day_headers[i+weekBeginsDay];	// shift by offset
	}
	return tmp;
}
function name_values(instring) {
	var vars = new Array();
	rc = "\235";
	instring = instring.replace(/\\\;/g, rc);
	var pattern = /[a-zA-Z0-9]+\=[:#a-zA-Z0-9\. \235]+/gi;
	var y = instring.match(pattern);
	for (i=0; i<y.length; i++) {
		var s = y[i].split("=");
		s[1] = s[1].replace(rc, ";");
		vars[i] = "v_" + s[0];
		eval(vars[i] + " = '" + s[1] + "'");
	}
	return vars;
}
var onClickFnCode = "";
var orig_onClickFnCode = "";
function onClickFn(pday) {
	if (pday.substring(0,2)=='08')
		myMonth = 7;
	else if (pday.substring(0,2)=='09')
		myMonth = 8;
	else 
		myMonth = parseInt(pday.substring(0,2)) - 1;

	if(pday.substring(3,5)=='08')
		myDay = 7;
	else if(pday.substring(3,5)=='09')
		myDay = 8;
	else
		myDay = parseInt(pday.substring(3,5)) - 1 ;
	myYear = pday.substring(6,10);
	myMonth=(theElement == 'mydate4' || theElement == 'mydate5') ? myMonth+1 : myMonth;
	myDay=(theElement == 'mydate4' || theElement == 'mydate5' || theElement == 'mydate7') ? myDay+1 : myDay;
	if (theElement == 'mydate7')
		return; 
	
	fromMonth = theMonthObj.value;
	fromYear = theYearObj.value;
	theMonthObj.options[myMonth].selected = true;
	
	for (var selYear=0; selYear<theYearObj.options.length; selYear++)
	{
		if (theYearObj.options[selYear].value==myYear)
			theYearObj.options[selYear].selected = true;
	}
	if (theElement=='mydate4')
		updateDay('start');
	else if (theElement=='mydate5')
		updateDay('due');
	else if (theElement=='mydate1'|| theElement=='mydate2' || theElement=='mydate3')
	{
		toMonth = theMonthObj.value;
		toYear = theYearObj.value;
		doTheDays(theDayObj,theMonthObj,theYearObj);
	}
	theDayObj.options[myDay].selected = true;
	var cTemp = 'nothing';
	if (theElement=='mydate1')
		cTemp = 'start'
	else if (theElement=='mydate2')
		cTemp = 'end'	
	if (cTemp != 'nothing')
	{
		if  (cTemp == 'start')
		{
			//fromMonth = document.myform.itemEndDateMonth.value;
			//fromYear = document.myform.itemEndDateYear.value;
			//doTheDays(document.myform.itemEndDateDay,document.myform.itemEndDateMonth,document.myform.itemEndDateYear,'true');
		}
		syncEndDT(hDuration,minDuration);
	}
}
// custom string
var v_CloseOnSelect, v_AppendOrReplace, v_AppendChar, v_ReturnData;
var v_InlineX, v_InlineY, v_Title;

var weekend = [0,6];
var weekendColor = "white";
var fontface = "tahoma";
var fontsize = "11px";
var ggWinCal;           // global variable pointing to the calendar window
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
Calendar.Months = [janFull, febFull, marFull, aprFull, mayFull, junFull,
	julFull, augFull, sepFull, octFull, novFull, decFull];
Calendar.DOMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
Calendar.lDOMonth = [31,29,31,30,31,30,31,31,30,31,30,31];
Calendar.DOW = dow;
Calendar.supportedFormats = ["MM/DD/YYYY", "MM/DD/YY", "DD/MON/YYYY", "DD/MON/YY"];
Calendar.count = 0;
Calendar.Format = null;
Calendar.gInitText = "MSN Calendar";
function Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type) {
	Calendar.count += 1;
	if ((p_month == null) && (p_year == null))      return;
	if (p_WinCal == null)
		this.gWinCal = ggWinCal;
	else
		this.gWinCal = p_WinCal;
	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
		if (p_month=='11')
		{	subsequentMonth = 1;
			subsequentYear = parseInt(p_year) + 1;
			prevMonth = 11;
			prevYear = parseInt(p_year);
		}
		else if (p_month=="0")
		{	subsequentMonth = parseInt(p_month) + 2;
			subsequentYear = parseInt(p_year);
			prevMonth = 12;
			prevYear = parseInt(p_year) - 1;
		}
		else
		{
			subsequentMonth = parseInt(p_month) + 2;
			subsequentYear = parseInt(p_year);
			prevMonth = parseInt(p_month);
			prevYear = parseInt(p_year);
		}
		subsequentMonth = (subsequentMonth.toString().length < 2) ? "0" + subsequentMonth : subsequentMonth;
		prevMonth = (prevMonth.toString().length < 2) ? "0" + prevMonth : prevMonth;
/* ***** end block  *** */	
	}
	if (p_type == null)
		this.gType = "POPUP";		// Default is popup
	else
		this.gType = p_type;
	if (this.gType == "INLINE") {
		this.WHO = "";
		this.INLINE = "Calendar";	// Inline Calendar Layer name
		this.codeINLINE = "";		// Calendar code constructed in this var
	} else
		this.WHO = "window.opener.";
	this.gYear = p_year;
	this.gFormat = p_format;
	this.gBGColor = "white";
	this.gFGColor = "black";
	this.gTextColor = "black";
	this.gHeaderColor = "black";
	this.gReturnItem = p_item;
	this.gTitle = "";
}
Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.get_dow = Calendar_get_dow;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.CreateCalendarLayer = Calendar_CreateCalendarLayer;
Calendar.Close = Calendar_Close;
Calendar.Lwwrite = Calendar_Lwwrite;
Calendar.MoveTo = Calendar_MoveTo;
function Calendar_get_month(monthNo) {
	return Calendar.Months[monthNo];
}
function Calendar_get_dow(dayNo) {
	return Calendar.DOW[dayNo];
}
function Calendar_get_daysofmonth(monthNo, p_year) {
	if ((p_year % 4) == 0) {
			if ((p_year % 100) == 0 && (p_year % 400) != 0)
					return Calendar.DOMonth[monthNo];

			return Calendar.lDOMonth[monthNo];
	} else
			return Calendar.DOMonth[monthNo];
}
function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/* 
	Will return an 1-D array with 1st element being the calculated month 
	and second being the calculated year 
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();
	if (incr == -1) {
		// backward
		if (p_Month == 0) {
				ret_arr[0] = 11;
				ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
				ret_arr[0] = parseInt(p_Month) - 1;
				ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// forward
		if (p_Month == 11) {
				ret_arr[0] = 0;
				ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
				ret_arr[0] = parseInt(p_Month) + 1;
				ret_arr[1] = parseInt(p_Year);
		}
	}
	return ret_arr;
}
// create and discard one object before the prototype object can exist.
new Calendar();
Calendar.prototype.setFormat = function(pFormat) {
	for (j=0; j<Calendar.supportedFormats.length; j++) {
		if (Calendar.supportedFormats[j] == pFormat)
			Calendar.Format = pFormat;
	}
}
Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";
	// Begin Table Drawing code
	vCode = vCode + "<table width=150 BORDER=0 CELLSPACING=0 CELLPADDING=3 BGCOLOR='white'>";
	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode = vCode + vHeader_Code + vData_Code;
	vCode = vCode + "</TABLE>";
	return vCode;
}


Calendar.prototype.onclickfn = function() {
	var whois = this.WHO + 
				((this.gType == "POPUP") ? "document." : "window.document.") + 
				this.gReturnItem + ".value";
	var apchar = (this.returnMode == "Replace") ? " = " : " = ";
	var retCode = "apchar = ''" +
					((this.returnMode == "Replace") ? ";" : " + ") +
					"((" + whois + " == '') ? '' : '');\n" +
				whois + apchar + "apchar + pday;\n";
	return retCode;
}

Calendar.prototype.show = function() {
	if (IC_Locale=='1041'||IC_Locale=='1042'||IC_Locale=='2052'||IC_Locale=='1028'||IC_Locale=='3076')
		var month_Title =  this.gYear + locYear + " " + this.gMonthName + locMonth;
	else
		var month_Title = this.gMonthName + " " + this.gYear;
	var vCode = "";
	if (this.gType == "POPUP")
		this.gWinCal.document.open();
	// setting up document
	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	if (this.gType == "POPUP")
		this.wwrite("<script language='javascript'>" + 
			"function onClickFn(pday) {\n" +
			this.onclickfn() + "}\n<\/script>");
	else
		orig_onClickFnCode = this.onclickfn();
	this.wwrite("</head>");
	this.wwrite("<body " + "link=\"" + this.gLinkColor + "\" " + 
			"vlink=\"" + this.gLinkColor + "\" " + "alink=\"" + this.gLinkColor + "\" " +
			"text=\"" + this.gTextColor + "\">");
	this.wwrite("<table width=150 BORDER=0 CELLPADDING=0 class='leftBarBg'><TR><TD>" +  
	"<TABLE width='150' align='center'>" + "<TR><TD class='leftBarBg' COLSPAN=2 align='CENTER'>");  // inner table
	// Show navigation buttons
	var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
	var prevMM = prevMMYYYY[0];
	var prevYYYY = prevMMYYYY[1];
	var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
	var nextMM = nextMMYYYY[0];
	var nextYYYY = nextMMYYYY[1];
	this.wwrite("<TABLE ALIGN=center BORDER=0 CELLSPACING=0 class='leftBarBg' width='100%'><TR height=20><TD title='" + IC_previous + "' width='13' ALIGN=center onClick=\"" + this.WHO + "Build(" + "'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "', '" + this.gType + "'" + ")\"; alt='" + IC_previous + "' style='cursor:hand'>");
	this.wwrite("<img src='"+imgServer+"arrow_left.gif' alt='" + IC_previous + "'>" + "</TD><TD width='80%' NOWRAP ALIGN=center class='tab' onClick='event.cancelBubble=true'>");
	this.wwrite(month_Title + "</TD><TD title='" + IC_next + "' width='14' ALIGN=center onClick=\"" + this.WHO + "Build(" + "'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "', '" + this.gType + "'" + ")\"; alt='" + IC_previous + "' style='cursor:hand'>");
	this.wwrite("<img src='"+imgServer+"arrow_right.gif' alt='" + IC_next + "'>" + "</TD>");
	this.wwrite("</TR><tr><td colspan='7' align=center class=box>");
	// Get the complete calendar code for the month
	vCode = this.getMonthlyCalendarCode();
	this.wwrite(vCode);
	this.wwrite("</TD></TR><tr><td colspan=7 align=center onClick='event.cancelBubble=true'>");
//  today is:
	this.wwrite(IC_TodayIs + IC_LocColon + " ");
	var monthNumb = today.getMonth() + 1;
	monthNumb = (monthNumb.toString().length < 2) ? "0" + monthNumb : monthNumb;
	var todayDay = today.getDate();
	todayDay = (todayDay.toString().length < 2) ? "0" + todayDay : todayDay;
	this.wwrite("<A HREF='javascript:" + closecodeI + "' " +
					"onClick=\"onClickFn('" + monthNumb  + "/" + 
					todayDay + "/" + today.getFullYear() + 
					"');" + closecodeP +
					"\">" + IC_TodayDate + "<\/A>");
	this.wwrite("<HR></td></tr><TR><TD colspan=2 align=center onClick=\"event.cancelBubble=true\">"+ 
	"<A HREF='javascript:c=true;" +
	this.WHO + "Calendar.Close(\"" + this.gType + "\", \"" + this.INLINE + "\");' " +
	"class=bigbold>" + IC_Cancel +
	"</A></td></TR></TABLE>");
	this.wwrite("</body></html>");
	if (this.gType == "POPUP")
		this.gWinCal.document.close();
	if (this.gType == "INLINE")
		Calendar.Lwwrite(this.codeINLINE, this.INLINE);

	if (isMessenger) 
	{
		var DivRef = document.getElementById('Calendar');
		var ifrRef = document.getElementById('DivShim');

		DivRef.style.display = "block";
		ifrRef.style.width = DivRef.offsetWidth;
		ifrRef.style.height = DivRef.offsetHeight;
    		ifrRef.style.top = DivRef.style.top;
	    	ifrRef.style.left = DivRef.style.left;
    		ifrRef.style.zIndex = DivRef.style.zIndex - 1;
	    	ifrRef.style.display = "block";
	}		

}
function Calendar_Close(pType, pINLINE) {
	
	var ifrRef = document.getElementById('DivShim');

	ifrRef.style.display = "none";
	if (pType == "POPUP")
		ggWinCal.close();
	if (pType == "INLINE")
	{

		
		if (theElement == 'mydate7' && false == c){
				showDayPicker(myYear, myMonth, myDay);
		}	
		Calendar.Lwwrite(Calendar.gInitText, pINLINE)
		//var inObj = new Array(theElement,document.myform.itemEndDateYear); 
		showCal(inObj);
	}
}
Calendar.prototype.showY = function() {
	var vCode = "";
	var i;
	var vr, vc, vx, vy;             // Row, Column, X-coord, Y-coord
	var vxf = 285;                  // X-Factor
	var vyf = 200;                  // Y-Factor
	var vxm = 10;                   // X-margin
	var vym = 75;
	this.gWinCal.document.open();
	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("<style type='text/css'>\n<!--");
	for (i=0; i<12; i++) {
		vc = i % 3;
		if (i>=0 && i<= 2)      vr = 0;
		if (i>=3 && i<= 5)      vr = 1;
		if (i>=6 && i<= 8)      vr = 2;
		if (i>=9 && i<= 11)     vr = 3;
		vx = parseInt(vxf * vc) + vxm;
		vy = parseInt(vyf * vr) + vym;
		this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
	}
	this.wwrite("-->\n</style>");
	this.wwrite("</head>");
	this.wwrite("<font face='" + fontface + "' size=2><strong>");
	this.wwrite("Year : " + this.gYear);
	this.wwrite("</strong><br />");
	// Navigation buttons
	var prevYYYY = parseInt(this.gYear) - 1;
	var nextYYYY = parseInt(this.gYear) + 1;
	this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
			"javascript:window.opener.Build(" + 
			"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
			");" +
			"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
			"javascript:window.opener.Build(" + 
			"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
			");" +
			"\">>><\/A>]</TD></TR></TABLE><BR>");
	// Complete calendar code for each month
	var j;
	for (i=11; i>=0; i--) {
		this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
		this.gMonth = i;
		this.gMonthName = Calendar.get_month(this.gMonth);
		vCode = this.getMonthlyCalendarCode();
		this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
		this.wwrite(vCode);
		this.wwrite("</DIV>");
	}
	this.wwrite("</font><BR></body></html>");
	this.gWinCal.document.close();
}
Calendar.prototype.cal_header = function() {
	var vCode = "";
	vCode = vCode + "<TR onClick='event.cancelBubble=true'>";
	for (var dh=0; dh<day_header.length - 1; dh++)
		vCode = vCode + "<TD WIDTH='14%' align='center'>" + day_header[dh] + "</TD>";
	vCode = vCode + "<TD WIDTH='16%' align='center' class='dayofweek'>" + day_header[6] + "</TD>";
	vCode = vCode + "</TR><tr height=1><td colspan=7 class='boxHd'></td></tr>";
	return vCode;
}
Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);
	
	var vFirstDay=vDate.getDay();	

	// shift by offset to correct position
	if (weekBeginsDay > vFirstDay){		
		vFirstDay = gWeekDays - weekBeginsDay + vFirstDay; // overlap
	}else
		vFirstDay-= weekBeginsDay;
	
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	if (this.gMonth==0)
		var pLastDay=Calendar.get_daysofmonth(11, this.gYear-1);
	else
		var pLastDay=Calendar.get_daysofmonth(this.gMonth-1, this.gYear);
	if (this.closeable) {
		closecodeP = ((this.gType=="POPUP") ? "window.close();" : "");
		closecodeI = "Calendar.Close(\"" + this.gType + "\", \"" + this.INLINE + "\"); ";
	} else {
		closecodeP = "";
		closecodeI = "void(0);' ";
	}
	var vOnLastDay=0;
	var pdays=pLastDay-vFirstDay;
	var vCode = "";
	// Previous month
	vCode = vCode + "<TR>";
	for (i=0; i<vFirstDay; i++) {
		pdays=pdays+1;
		vCode = vCode + 
		"<A HREF='javascript:" + closecodeI + "' " + "onClick=\"onClickFn('" + prevMonth + "/" + 
		pdays + "/" + prevYear + "');" + closecodeP + "\">" +
		"<TD valign='middle' WIDTH='14%' style='color:#999999;' onMouseOver='className=\"linkOn\"'  onMouseOut='className=\"linkOff\"' align='center'" + thisStyle + ">" + 
			pdays + "</TD></a>";
	}

	var whois = this.WHO + 
				((this.gType == "POPUP") ? "document." : "window.document.") + 
				this.gReturnItem + ".value";
	// The rest of the 1st week
	
	for (j=vFirstDay; j<7; j++) {
		vCode = vCode + 
				"<A HREF='javascript:" + closecodeI + "' " + "onClick=\"onClickFn('" + 
				((this.returnData == "Date") ? this.format_data(vDay) : this.format_dow(vDay)) + "');" + 
				closecodeP + "\">" + "<TD valign='middle' WIDTH='14%' style='color:#000033;' onMouseOver='className=\"linkOn\"'  onMouseOut='className=\"linkOff\"' align='center'" + this.write_weekend_string(j) + 
				thisStyle + ">" + this.format_day(vDay) + "</TD></A>";
		vDay=vDay + 1;
	}
	vCode = vCode + "</TR>";
// the rest of the weeks
	for (k=2; k<7; k++) {
		vCode = vCode + "<TR>";
		for (j=0; j<7; j++) {
			vCode = vCode + 
				"<A HREF='javascript:" + closecodeI + "' " +
					"onClick=\"onClickFn('" + 			
					((this.returnData == "Date") ? 
					this.format_data(vDay) : 
					this.format_dow(vDay)) + 
					"');" + 
					closecodeP +
					"\">" + "<TD valign='middle' WIDTH='14%' style='color:#000033;' onMouseOver='className=\"linkOn\"'  onMouseOut='className=\"linkOff\"' align='center'" + this.write_weekend_string(j) + thisStyle + ">" + 
					this.format_day(vDay) + 
					
					"</TD>" + "<\/A>";
			vDay=vDay + 1;

			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
			}
		}
		if (j == 7)
			vCode = vCode + "</TR>";
		if (vOnLastDay == 1)
			break;
	}
	// the rest of last week
	for (m=1; m<(7-j); m++) {
			vCode = vCode + 
			"<A HREF='javascript:" + closecodeI + "' " + "onClick=\"onClickFn('" + subsequentMonth + 
			"/0" + m + "/" + subsequentYear + "');" + closecodeP + "\"><TD valign='middle' WIDTH='14%' style='color:#999999;' onMouseOver='className=\"linkOn\"'  onMouseOut='className=\"linkOff\"' align='center'" + thisStyle + ">&nbsp;" +
			m + "&nbsp;</TD></a>";
	}
	return vCode;
}
Calendar.prototype.format_day = function(vday) {

	if (vday == vNowDay-1 && this.gMonth == vNowMonth && this.gYear == vNowYear)
	{
		thisClass='today';
		thisStyle = " style='font-weight:bold;background-color:#FFFAE0;border:1px solid #000066;padding:2px;'";	//Fix bug 55444
	}
	else
	{
		thisClass='normal';
		thisStyle = "";
	}
	return (vday);
}
Calendar.prototype.write_weekend_string = function(vday) {
	var i;
	// Return special formatting for the weekend day.
	for (i=0; i<weekend.length; i++) {
			if (vday == weekend[i])
					return ("");  //(" BGCOLOR=\"" + weekendColor + "\"");
	}
	return "";
}
Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	var sMonth = months_short[vNowMonth];
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vY2 = new String(this.gYear.substr(2,2));
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
	switch (this.gFormat) {
			case "MM\/DD\/YYYY" :
				vData = vMonth + "\/" + vDD + "\/" + vY4;
				break;
			case "MM\/DD\/YY" :
				vData = vMonth + "\/" + vDD + "\/" + vY2;
				break;
			case "DD\/MON\/YYYY" :
				vData = vDD + "\/" + vMon + "\/" + vY4;
				break;
			case "DD\/MON\/YY" :
				vData = vDD + "\/" + vMon + "\/" + vY2;
				break;
			default :
				vData = vMonth + "\/" + vDD + "\/" + vY4;
	}
	return vData;
}
Calendar.prototype.format_dow = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
	var vDate = new Date(vMonth + "\/" + vDD + "\/" + vY4);
	vData = Calendar.get_dow(vDate.getDay());
	return vData;
}
Calendar.prototype.wwrite = function(wtext) {
	if (this.gType == "POPUP")
		this.gWinCal.document.writeln(wtext);
	else {
		this.codeINLINE += wtext;
	}
}
Calendar.prototype.wwriteA = function(wtext) {
	if (this.gType == "POPUP")
		this.gWinCal.document.write(wtext);
	else {
		this.codeINLINE += wtext;
	}
}
function Calendar_CreateCalendarLayer(pLeft, pTop, pInitText) {
	if (pInitText == null)
		pInitText = Calendar.gInitText;
	else
		Calendar.gInitText = pInitText;

	v_InlineX = pLeft;
	v_InlineY = pTop;

	document.writeln("<DIV ID=\"" + "Calendar" + "\" STYLE=\"" + 
		"position:absolute;top:" + pTop + ";left:" + pLeft + ";z-index=4" + 
		"\">" + pInitText + "<\/DIV>");

	document.writeln("<iframe  id=\"DivShim\"  src=\"javascript:false;\"  scrolling=\"no\"  frameborder=\"0\"  style=\"position:absolute; top:0px; left:0px; display:none;\"></iframe>");

	
	
}
function Calendar_Lwwrite(pText, pINLINE) {
	document.all[pINLINE].innerHTML = pText;
}
function Calendar_MoveTo(pX, pY, pINLINE) {
	document.all[pINLINE].style.top = pY;
	document.all[pINLINE].style.left = pX;
}
function Build(p_item, p_month, p_year, p_format, p_type, p_custom) {
	var p_WinCal = ggWinCal;
if (typeof(p_item.name)!='undefined')
	theElement = p_item.name;
if (theElement=='mydate1')
{
	theYearObj = document.myform.itemStartDateYear;		// Used as signalling element
	theMonthObj = document.myform.itemStartDateMonth;
	theDayObj = document.myform.itemStartDateDay;
	recurModEndCal = false;
}
else if (theElement=='mydate2')
{
	//theYearObj = document.myform.itemEndDateYear;
	//theMonthObj = document.myform.itemEndDateMonth;
	//theDayObj = document.myform.itemEndDateDay;
	recurModEndCal = false;
}
else if (theElement=='mydate4')
{
	theYearObj = document.myform.taskStartDateYear;
	theMonthObj = document.myform.taskStartDateMonth;
	theDayObj = document.myform.taskStartDateDay;
	recurModEndCal = false;
}
else if (theElement=='mydate5')
{
	theYearObj = document.myform.taskDueDateYear;	
	theMonthObj = document.myform.taskDueDateMonth;
	theDayObj = document.myform.taskDueDateDay;
	recurModEndCal = false;
}
else if (theElement=='mydate7')
{
	theMonthObj = null;
	theYearObj = null;
	recurModEndCal = false;
}
else
{
	theYearObj = document.myform.recurrenceEndDateYear;
	theMonthObj = document.myform.recurrenceEndDateMonth;
	theDayObj = document.myform.recurrenceEndDateDay;
	recurModEndCal = true;
}	
	gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type);
	// Customize Calendar
	gCal.gBGColor="white";
	gCal.gLinkColor="black";
	gCal.gTextColor="black";
	gCal.gHeaderColor="black";
	if (p_custom && p_custom != "")
		var vvars = name_values(p_custom);
	gCal.closeable = v_CloseOnSelect?((v_CloseOnSelect == "Yes") ? true : false): false;
	gCal.returnMode = v_AppendOrReplace?v_AppendOrReplace : "Replace";
	gCal.returnData = v_ReturnData?v_ReturnData : "Date";
	// Character to be added For Append mode
	gCal.appendChar = (gCal.returnMode == "Append")?v_AppendChar ? v_AppendChar : ";" : "";
	// specific messenger for recurr day picker.
	if(isMessenger &&  calLocation.name == "iCalendar3"){
		gCal.InlineX = 145;
	}else{	
		gCal.InlineX = (getXY(calLocation).left-2); 
	}
	yOffset = 20   // (grpCal)?-197:20;    // un comment this line if want the popup cal drop up

	if (recurModEndCal)
		yOffset = -40;
	// messenger overwrites this.
	if( isMessenger && calLocation.name == "iCalendar3"){
		yOffset = -120; 
	}	

	gCal.InlineY = (getXY(calLocation).top+yOffset);  //v_InlineY ? v_InlineY : 100;
	if (gCal.gType == "INLINE")
		Calendar.MoveTo(gCal.InlineX, gCal.InlineY, gCal.INLINE);
	gCal.gTitle = v_Title ? v_Title : gCal.gMonthName + "/" + gCal.gYear;
	 gCal.show();
}
//Monthly Calendar Code begins
function show_calendar() {
	/* 
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year  : 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_item  : Return Item.
		p_type	: POPUP/INLINE Calendar
		p_custom: String of customizable name/value pair parameters
	*/
       c = false; 
	p_item = arguments[0];
	if (arguments[1] == null)
		p_month = new String(gNow.getMonth());
	else
		p_month = (typeof(arguments[1]) == "number")?arguments[1].toString():arguments[1];
	if (arguments[2] == "" || arguments[2] == null)
		p_year = new String(gNow.getFullYear().toString());
	else
		p_year = (typeof(arguments[2]) == "number")?arguments[2].toString():arguments[2];
	if (arguments[3] == null)
		p_format = "MM/DD/YYYY";
	else
		p_format = (typeof(arguments[3]) == "string")?arguments[3]:"MM/DD/YYYY";
	if (arguments[4] == null)
		p_type = "POPUP";
	else
		p_type = (typeof(arguments[4]) == "string" && 
					(arguments[4] == "POPUP" || arguments[4] == "INLINE"))?arguments[4]:"POPUP";
	if (arguments[5] == null)
		p_custom = "CloseOnSelect=Yes;AppendOrReplace=Replace;AppendChar=';';ReturnData=Date;Title=Popup Date Picker;";
	else
		p_custom = typeof(arguments[5]) == "string"?arguments[5]:"CloseOnSelect=Yes;AppendOrReplace=Replace;AppendChar=';';ReturnData=Date;Title=Popup Date Picker;";
	if (p_type == "POPUP") {
		vWinCal = window.open("", "Calendar", 
				"width=200,height=260,status=no,resizable=no");
		vWinCal.opener = self;
		ggWinCal = vWinCal;
	}
	Build(p_item, p_month, p_year, p_format, p_type, p_custom);
	cVisible = true;
}

function popCalClickHandle()
{
	if (cVisible)
	{
		Calendar.Close('INLINE','Calendar');
		cVisible=false;
	}
}

