function openMasterview(BaseTableTxt, RecordID)
{
	var Link, thisWindow
	var MasterviewWidth, MasterviewHeight, MasterviewTopLoc, MasterviewLeftLoc

	Link = "masterview.asp?RecordID=" + RecordID + "&BaseTableTxt=" + BaseTableTxt
	
	MasterviewWidth = (screen.availWidth - 20) 
	MasterviewHeight =(screen.availHeight - 70) 
	
	if (window.top.screenLeft < 1) {
		MasterviewLeftLoc = window.top.screenLeft;
	} else if (window.top.screenLeft > screen.availWidth) {
		MasterviewLeftLoc =  screen.width;
	} else {
		MasterviewLeftLoc = 0;
	}
	if (window.top.screenTop < 1) {
		MasterviewTopLoc = window.top.screenTop;
	} else if (window.top.screenTop > screen.availHeight) {
		MasterviewTopLoc =  screen.height;
	} else {
		MasterviewTopLoc= 0;
	}
	//alert(window.top.screenLeft + "|" + MasterviewLeftLoc + "|" + window.top.screenTop + "|" + MasterviewTopLoc + "|");
	thisWindow = window.open(Link,BaseTableTxt + RecordID,'width=' + MasterviewWidth + ',height=' + MasterviewHeight + ',top=' + MasterviewTopLoc + ',left=' + MasterviewLeftLoc + ',status=1,resizable');
	
	thisWindow.focus(); 
	
	
}


//Function encodes a string so that it is safe in a url and returns it
function URLEncode(eStr)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = eStr;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} 

	return encoded;

};

//// Begins : Javascript code for the Updated Calendar Inputs that now use floating div instead of modal window.

	var popCalActive = 0    
      
	function genPopCalDiv()
	{
		if (document.getElementById('PopCalDiv') == null) 
		{ 
			document.write("<div id='PopCalDiv' style='width:160px; height:98px; background-color:white; border:solid black 0px; display: none; position:absolute; z-index:100'   onmouseover='popCalActive=1;' onmouseout='popCalActive=0;' onBlur='javascript: blurPopCal();'></div>");
			document.write("<iframe id='DivShim' src='javascript:false;' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; display:none;'></iframe>");
		}
		
	}    
	
	
	function getPosition(obj){
		var left = 0;
		var top  = 0;
 
		while (obj.offsetParent){
			left += obj.offsetLeft;
			top  += obj.offsetTop;
			obj   = obj.offsetParent;
		}
		left += obj.offsetLeft;
		top  += obj.offsetTop;

		

		return {x:left, y:top};
	}
	
	
	function showPopCal(objCalIcon)
	{
		var objPopCalDiv = document.getElementById('PopCalDiv');
		var objDivShim = document.getElementById('DivShim');
		
		objPopCalDiv.style.display = "block";
		
		var CalPos = getPosition(objCalIcon)
		
		
		objPopCalDiv.style.pixelLeft = ((CalPos.x+objPopCalDiv.clientWidth) < document.body.scrollWidth ? (CalPos.x) : (document.body.scrollWidth-objPopCalDiv.clientWidth));
		objPopCalDiv.style.pixelTop = ((CalPos.y-objPopCalDiv.clientHeight) > 0 ? (CalPos.y-objPopCalDiv.clientHeight) : (CalPos.y+objCalIcon.clientHeight));			

		


		if (objPopCalDiv.style.pixelTop < document.body.scrollTop) {
			document.body.scrollTop = objPopCalDiv.style.pixelTop;
		}		
		
		if ((objPopCalDiv.style.pixelLeft+objPopCalDiv.clientWidth) > document.body.clientWidth) {
			document.body.scrollLeft = ((objPopCalDiv.style.pixelLeft+objPopCalDiv.clientWidth) - document.body.clientWidth);
		}				

		
		objDivShim.style.width = objPopCalDiv.clientWidth;
		objDivShim.style.height = objPopCalDiv.clientHeight;
		objDivShim.style.pixelTop = objPopCalDiv.style.pixelTop;
		objDivShim.style.pixelLeft = objPopCalDiv.style.pixelLeft;
		objDivShim.style.zIndex = objPopCalDiv.style.zIndex - 1;
		objDivShim.style.display = "block";
		
	

	}
	
	
	function hidePopCal()
	{
		document.getElementById('PopCalDiv').style.display = "none";
		document.getElementById('DivShim').style.display = "none";
	}	
	
    
	var goCalendarSpanRef;
	var goCalIcon;
	function genPopCal(CalendarSpanRef, CalIcon, NowDate, NowMonth, NowYear, FormName, FieldName)
    {
		 
	 
		    
        var arrMonthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        var strPopCal = ""


	    if (NowDate != "")
	    {
    	    NowDate = new Date(NowDate);
    	    NowMonth = NowDate.getMonth();
		    NowYear = NowDate.getFullYear();
	    }
	    else
	    {
		    NowDate = new Date();
    		
		    if (NowMonth == "")	NowMonth = NowDate.getMonth();
		    else				NowMonth = parseInt(NowMonth);
    		
		    if (NowYear == "")  NowYear = NowDate.getFullYear();	
		    else				NowYear = parseInt(NowYear);
	    }
    	
    	
	    var BeginOfMonth = new Date(NowYear, NowMonth, 1);
        var FirstDay = BeginOfMonth.getDay();
	    var BeginDate = new Date(BeginOfMonth.getYear(), BeginOfMonth.getMonth(), BeginOfMonth.getDate()-FirstDay)
    	
    	
	    if (NowMonth == 0)
	    {
		    PrevMonth = 11;
		    PrevYear = NowYear - 1;
	    }
	    else
	    {
		    PrevMonth = NowMonth - 1;
		    PrevYear = NowYear;
	    }
	    if (NowMonth == 11)
	    {
		    NextMonth = 0;
		    NextYear = NowYear + 1;
	    }
	    else
	    {
		    NextMonth = NowMonth + 1;
		    NextYear = NowYear;
	    }
    	
    	
    	
    	
    	
    	 
	    strPopCal += '<table border="0" cellspacing="1" cellpadding="0" bgcolor="Black">';
	    strPopCal += '<tr bgcolor="#060E6F">';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM">';
	    strPopCal += '<Span onClick="javascript: genPopCal(goCalendarSpanRef, goCalIcon, \'\', \'' + PrevMonth + '\', \'' + PrevYear + '\', \'' + FormName + '\', \'' + FieldName + '\');" class="text" onmouseover=this.style.cursor="hand">';
	    strPopCal += '<img src="images/back.gif" width=16 height=16 border=0>';
	    strPopCal += '</Span>';
	    strPopCal += '</td>';
	    strPopCal += '<td colspan=5 align="CENTER" valign="CENTER"><font color="White" face="Verdana,Arial,Helvetica" size="-2">';
	    strPopCal += '<b>' + arrMonthNames[NowMonth] + '&nbsp;' + NowYear + '</b>';
	    strPopCal += '</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">';
	      strPopCal += '<Span onClick="javascript: genPopCal(goCalendarSpanRef, goCalIcon, \'\', \'' + NextMonth + '\', \'' + NextYear + '\', \'' + FormName + '\', \'' + FieldName + '\');" class="text" onmouseover=this.style.cursor="hand">';
	    strPopCal += '<img src="images/forward.gif" width=16 height=16 border=0>';
	    strPopCal += '</Span>';
	    strPopCal += '</td>';
	    strPopCal += '</tr>';
	    strPopCal += '<tr bgcolor="#060E6F">';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Sun</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Mon</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Tue</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Wed</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Thr</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Fri</font></td>';
	    strPopCal += '<td width="20" align="CENTER" valign="BOTTOM"><font color="White" face="Verdana,Arial,Helvetica" size="-2">Sat</font></td>';	
    	

	    //Write first week including last month
    	
	    var TempDate = new Date(BeginDate)
    	
	    while (TempDate < BeginOfMonth)	
	    {
		    if (TempDate.getDay() == 0)
			    strPopCal += '</tr><tr>';
		    strPopCal += '<td align="CENTER" valign="MIDDLE" bgcolor="Gray"><font color="Black" face="Verdana,Arial,Helvetica" size="-2">';
		    strPopCal += WriteDay(TempDate, CalendarSpanRef, CalIcon, FormName, FieldName);
		    strPopCal += '</font></td>';
    		
		    TempDate.setDate(TempDate.getDate() + 1);
	    }
    	
	    //Write middle of month

    	
	    while (TempDate.getMonth() == NowMonth)
	    {
	    var TempDay=TempDate.getDate();
		var TempMonth=TempDate.getMonth();
		var TempYear=TempDate.getFullYear();
		
		var currentDate=new Date();
		var currentDay=currentDate.getDate();
		var currentMonth=currentDate.getMonth();
		var currentYear=currentDate.getFullYear();
	
		    if (TempDate.getDay() == 0)
			    strPopCal += '</tr><tr>';
    			
		///    if (TempDate == Date())
		   if (TempDay == currentDay && TempMonth == currentMonth && TempYear == currentYear)
		  
		    {
			    strPopCal += '<td align="CENTER" valign="MIDDLE" bgcolor="#99ccff"><font face="Verdana,Arial,Helvetica" size="-2" color="Black">';
			    strPopCal += WriteDay(TempDate, CalendarSpanRef, CalIcon,FormName, FieldName);
			    strPopCal += '</font></td>';
		    }
		    else
		    {
			    strPopCal += '<td align="CENTER" valign="MIDDLE" bgcolor="Silver"><font face="Verdana,Arial,Helvetica" size="-2" color="Black">';
    			strPopCal += WriteDay(TempDate, CalendarSpanRef, CalIcon,FormName, FieldName);
			    strPopCal += '</font></td>';
		    }
    		
		    TempDate.setDate(TempDate.getDate() + 1);
	    }	
	    
	    
    	//Write last Week
    	
    	while (TempDate.getDay() > 0)
    	{
			strPopCal += '<td align="CENTER" valign="MIDDLE" bgcolor="Gray"><font face="Verdana,Arial,Helvetica" size="-2" color="Black">';
			strPopCal += WriteDay(TempDate, CalendarSpanRef, CalIcon,FormName, FieldName);
			strPopCal += '</font></td>';    		
			
    		TempDate.setDate(TempDate.getDate() + 1);
    	}	    
    		
    	
		strPopCal += '</tr>';

	    strPopCal += '<tr bgcolor="#060E6F">';
        strPopCal += '<td colspan=7 align="CENTER" valign="BOTTOM">';
	    strPopCal += '<Span onClick="javascript: hidePopCal();" style="color: #ffffff; text-decoration: underline; font-size: 12px;" onmouseover=this.style.cursor="hand">';
	    strPopCal += 'Close';
	    strPopCal += '</Span>';	    
	    strPopCal += '</td>';	
	    strPopCal += '</tr>';
	    
		strPopCal += '</table>';
	    
	    
	    document.getElementById('PopCalDiv').innerHTML = strPopCal;
	    
		if (CalIcon != "")
		{
			showPopCal(CalIcon);
		}	     
    	

    }


    var goCalendarSpanRef;

    function processDateClick(ReturnDate, FormName, FieldName) {
	   
		var objReturnField = goCalendarSpanRef.all(FieldName);
		var objReturnFieldid = objReturnField.id
		var IConID = objReturnFieldid + "_Date_CalIcon"
		ReturnDate = new Date(ReturnDate);

        objReturnField.value=(ReturnDate.getMonth()+1) + '/' + ReturnDate.getDate() + '/' + ReturnDate.getYear();
        objReturnField.fireEvent("onchange");
        objReturnField.fireEvent("onkeypress");
       
        document.getElementById(IConID).focus();
        hidePopCal();
    }

	function WriteDay(TempDate, CalendarSpanRef, CalIcon, FormName, FieldName)
    {
    		
	    goCalendarSpanRef = CalendarSpanRef;
	    goCalIcon = CalIcon;
	    var strWriteDay = ""
    	
	    strWriteDay += '<span onClick="processDateClick(\'' + TempDate + '\', \'' + FormName + '\', \'' + FieldName + '\')" class=text onmouseover=this.style.cursor="hand">';
		
		var TempDay=TempDate.getDate();
		var TempMonth=TempDate.getMonth();
		var TempYear=TempDate.getFullYear();
		
		var currentDate=new Date();
		var currentDay=currentDate.getDate();
		var currentMonth=currentDate.getMonth();
		var currentYear=currentDate.getFullYear();
		// Compare TempDate values to currentDate values. If both date matches it shows date in blue color.	
	//    if (TempDay == currentDay && TempMonth == currentMonth && TempYear == currentYear)
	//		strWriteDay += '<font color=blue>';
    	
			strWriteDay += TempDate.getDate();
    	
	//    if (TempDay == currentDay && TempMonth == currentMonth && TempYear == currentYear)
	//	    strWriteDay += '</font>';
    	
	    strWriteDay += '</Span>';
    	
    	return strWriteDay;
    }

    function blurPopCal()
    {
		if (popCalActive == 0)
			hidePopCal();
					
    }
    
//// Ends : Javascript code for the Updated Calendar Inputs that now use floating div instead of modal window.



/*Nagesh Chopra :: Sept 10, 2007 */
/*****ToggleAllDayEvent******:: Function to toggle All Day Event setting; disables/enables time fields of the DateTime input accordingly and defaults the time part of DateTime inputs.
********Parameters*********
poForm --> object reference to the containing form.
pbAllDayYN --> boolean value (0/1) for All Day Event
psStartInputName --> name of the Start DateTime Input
psEndInputName --> name of the End DateTime Input.
*/

function ToggleAllDayEvent(poForm, pbAllDayYN, psStartInputName, psEndInputName)
{
    /*set object references for the form fields of Start DateTime Input*/
    var loStartInput = poForm.all(psStartInputName);
    var loStartInput_Date = poForm.all(psStartInputName + "_Date");
    var loStartInput_Time = poForm.all(psStartInputName + "_Time");

    /*set object references for the form fields of End DateTime Input*/
    var loEndInput = poForm.all(psEndInputName);
    var loEndInput_Date = poForm.all(psEndInputName + "_Date");
    var loEndInput_Time = poForm.all(psEndInputName + "_Time");

    if(pbAllDayYN) 
    {/*Yes, it is an all day event*/
        $ProgrammaticChangeFormField(loStartInput_Time, ''); 
        $ProgrammaticChangeFormField(loStartInput, loStartInput_Date.value+' '+'12:00 AM'); 
//        DisableFormField(loStartInput_Time);  
        HideElement(poForm.all(psStartInputName + "_TimeSpan"));

        $ProgrammaticChangeFormField(loEndInput_Time, '');
        $ProgrammaticChangeFormField(loEndInput, loEndInput_Date.value+' '+'12:00 AM');
//        DisableFormField(loEndInput_Time);
        HideElement(poForm.all(psEndInputName + "_TimeSpan"));
    } 
    else 
    {/*No, it is not an all day event*/
//        $ProgrammaticChangeFormField(loStartInput, loStartInput_Date.value+' '+loStartInput_Time.value);
        GetUTCTimeFromFormInputs(poForm, psStartInputName, pbAllDayYN)
//        EnableFormField(loStartInput_Time)
        UnHideElement(poForm.all(psStartInputName + "_TimeSpan"));
        
//        $ProgrammaticChangeFormField(loEndInput, loEndInput_Date.value+' '+loEndInput_Time.value);
        GetUTCTimeFromFormInputs(poForm, psEndInputName, pbAllDayYN)
//        EnableFormField(loEndInput_Time)
        UnHideElement(poForm.all(psEndInputName + "_TimeSpan"));
    }
}


function DisableFormField(poFormField)
{
    poFormField.disabled=true; 
    poFormField.className+=' disabled';     
}

function EnableFormField(poFormField)
{
    poFormField.disabled=false;
    poFormField.className=poFormField.className.replace('disabled', '');
}

function HideElement(poElement)
{
    poElement.style.visibility = 'hidden'; 
//    poElement.style.display = 'none';
}

function UnHideElement(poElement)
{
    poElement.style.visibility = 'visible'; 
//    poElement.style.display = 'inline';
}

/*Nagesh Chopra :: Sept 11, 2007 */
/*****CalcDateTime******:: Function to calculate/populate the DateTime input's hidden field with a DateTime value. It reads the date & time values from the corresponding fields of the DateTime Input, combines these values and sends that DateTime value in the hidden field intended to have the combined DateTime value for the InputType.
Also, it sets default time For DateTime if time part is empty and date part is not empty.
********Parameters*********
poForm --> object reference to the containing form.
psDateTimeInputName --> name of the DateTime input.
*/
function CalcDateTime(poForm, psDateTimeInputName)
{
    /*set object references for the form fields of the DateTime Input*/
    var loDateTimeInput = poForm.all(psDateTimeInputName);
    var loDateTimeInput_Date = poForm.all(psDateTimeInputName + "_Date");
    var loDateTimeInput_Time = poForm.all(psDateTimeInputName + "_Time");
    
    var lsDateTime, lsDate, lsTime;
    
    /*set/read the DateTime input's field values*/
    lsDateTime = "";
    lsDate = loDateTimeInput_Date.value.trim();
    lsTime = loDateTimeInput_Time.value.trim();
    
    //Set Default Time For DateTime if time part is empty and date part is not empty.
    if (lsTime == "" && lsDate != "")   {   lsTime = "12:00 AM";    }
    
    /*Combine the date & time values to get a DateTime value*/
    lsDateTime = lsDate + " " + lsTime;
    lsDateTime = lsDateTime.trim();
    
    /*Save the combined DateTime value in the intended field of the DateTime Input*/
    $ProgrammaticChangeFormField(loDateTimeInput, lsDateTime);
}

/*Nagesh Chopra*/
/*****GetUTCTimeFromFormInputs**** ::
Function to Get/Calculate UTC time from local time filled in form fields 
and populate the designated form field with the UTC time.
***Parameters*** ::
poForm -> object, reference to the containing form.
psDateTimeInputName -> string, name of the DateTime input field on the form.
pbAllDayYN -> boolean, Y/N value for the All Day event.
***Returns*** ::
Directly populates the designated form field with the UTC time.
*/
function GetUTCTimeFromFormInputs(poForm, psDateTimeInputName, pbAllDayYN)
{
    /*set object references for the form fields of the DateTime Input*/
    var loDateTimeInput = poForm.all(psDateTimeInputName);
    var loDateTimeInput_Date = poForm.all(psDateTimeInputName + "_Date");
    var loDateTimeInput_Time = poForm.all(psDateTimeInputName + "_Time");
    var loDateTimeInput_TimeZone = poForm.all(psDateTimeInputName + "_TimeZone");
    
    var lsDateTime, lsDate, lsTime, lnTimeZoneID, loDateTime;

    /*set/read the DateTime input's field values*/
    lsDateTime = "";
    lsDate = loDateTimeInput_Date.value.trim();
    lsTime = loDateTimeInput_Time.value.trim();
    lnTimeZoneID = loDateTimeInput_TimeZone.value;
    
    /*Set pbAllDayYN to default 0; if this optional parameter is not provided or has null value*/
    if (pbAllDayYN != 1)
    {   pbAllDayYN = 0;     }
    
    //Set Default Time For DateTime if time part is empty and date part is not empty.
    if (lsTime == "" && lsDate != "")   {   lsTime = "12:00 AM";    }
    
    /*Combine the date & time values to get a DateTime value*/
    lsDateTime = lsDate + " " + lsTime;
    lsDateTime = lsDateTime.trim();
    loDateTime = new Date(lsDateTime);
 	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var dateObj = new Date(loDateTime);	
	var matchArray = lsDate.match(datePat); // is the format 2 number year?
	if (matchArray == null) {		
			loDateTime.setYear(loDateTime.getFullYear()+100);
	}
    var lsDateTimeFormatMask = "mm/dd/yyyy hh:MM:ss TT";

    /*Convert to UTC time, if  .... */
    if (!pbAllDayYN /*Not a All Day Event*/
            && !isNaN(loDateTime) /*AND Not an Invalid DateTime value*/
            && (lnTimeZoneID != '') /*AND lnTimeZoneID is not empty*/
            && !isNaN(lnTimeZoneID) /*and lnTimeZoneID is a numeric value*/            
        ) 
    {
        loDateTime = LocalToUTCTime(loDateTime, lnTimeZoneID);
        lsDateTime = loDateTime.format(lsDateTimeFormatMask);
    }
    /*Save the combined DateTime value in the intended field of the DateTime Input*/
    $ProgrammaticChangeFormField(loDateTimeInput, lsDateTime);
}

/*Nagesh Chopra*/
/*****GetLocalTimeFromFormInputs**** ::
Function to Get/Calculate Local time from UTC time filled in form fields 
and populate the designated form field with the Local time.
***Parameters*** ::
poForm -> object, reference to the containing form.
psDateTimeInputName -> string, name of the DateTime input field on the form.
pnTimeZoneID -> numeric, TimeZoneID for the timezone of source local time.
pbAllDayYN -> boolean, Y/N value for the All Day event.
***Returns*** ::
Directly populates the designated form field with the local time.
*/
function GetLocalTimeFromFormInputs(poForm, psDateTimeInputName, pnTimeZoneID, pbAllDayYN)
{
    /*set object references for the form fields of the DateTime Input*/
    var loDateTimeInput = poForm.all(psDateTimeInputName);
    var loDateTimeInput_Date = poForm.all(psDateTimeInputName + "_Date");
    var loDateTimeInput_Time = poForm.all(psDateTimeInputName + "_Time");
    
    var lsDateTime, lsDate, lsTime, loDateTime;
   
    /*set/read the DateTime input's field values*/
    lsDateTime = loDateTimeInput.value.trim();
    var loDateTime = new Date(lsDateTime);
    lsDate = "";
    lsTime = "";

    /*Set pbAllDayYN to default 0; if this optional parameter is not provided or has null value*/
    if (pbAllDayYN != 1)
    {   pbAllDayYN = 0;     }
   
    var lsDateFormatMask = "mm/dd/yyyy";
    var lsTimeFormatMask = "hh:MM:ss TT";
    
    /*Convert to Local time, if .... */
    if (!pbAllDayYN /*Not a All Day Event*/
            && !isNaN(loDateTime) /*AND Not an Invalid DateTime value*/
            && (pnTimeZoneID != '') /*AND pnTimeZoneID is not empty*/
            && !isNaN(pnTimeZoneID) /*and pnTimeZoneID is a numeric value*/
        ) 
    {
        loDateTime = UTCToLocalTime(loDateTime, pnTimeZoneID);
    }
    
    //Break the DateTime value to Date & Time parts 
    lsDate = loDateTime.format(lsDateFormatMask);
    lsTime = loDateTime.format(lsTimeFormatMask);    
    //Save the Date & Time values in the intended fields of the DateTime Input*/
    loDateTimeInput_Date.value = lsDate;
    loDateTimeInput_Time.value = lsTime;

}


/*Nagesh Chopra*/
/*****EndTimeCalc***** ::
Function to calcualte the EndTime (one hour ahead of Start time) for a StartEndTime input.
*/
function EndTimeCalc(poForm, psStartTimeInputName, psEndTimeInputName, psStartDateInputName, psEndDateInputName)
{
	/*set object references for the form fields of Start & End Time*/
	var loStartTimeInput = poForm.all(psStartTimeInputName);
	var loEndTimeInput = poForm.all(psEndTimeInputName);
	
	/*get form's time fields values*/
	var lsStartTime = loStartTimeInput.value;
	var lsEndTime = loEndTimeInput.value;
	/*Manipulate the time values to get formatted Time*/
	var lsStartTime_fmt = GetFormattedTime(lsStartTime);
	var lsEndTime_fmt = GetFormattedTime(lsEndTime);
	var lsNewEndTime_fmt = '';

	// If formatted start time not blank, proceed.
	if (lsStartTime_fmt != '')
	{
		/*Manipulate the time values to get formatted DateTime*/
		var lsStartTime_dtfmt = GetDateFromTime(lsStartTime_fmt);
		var lsEndTime_dtfmt = GetDateFromTime(lsEndTime_fmt);

		/*get form's date fields values*/
		var lsStartDate = poForm.all(psStartDateInputName).value;
		var lsEndDate = poForm.all(psEndDateInputName).value;

		// If EndTime blank, change it to one hour past the StartTime.
		// OR
		// If EndDate same as StartDate, and EndTime before StartTime,
		// make EndTime 1hr after StartTime.					
		if ( (lsEndTime == '') || ((lsStartDate == lsEndDate) && (lsEndTime_dtfmt < lsStartTime_dtfmt)))
		{
			lsNewEndTime_fmt = GetNewEndTime(lsStartTime_dtfmt, lsStartTime_fmt);
			$ProgrammaticChangeFormField(loEndTimeInput, lsNewEndTime_fmt);
			
			// Make the start time look nice.
			$ProgrammaticChangeFormField(loStartTimeInput, lsStartTime_fmt);
		}
	}
}	


function EndDateCalc(poForm, psStartDateInputName, psEndDateInputName)
{
	/*set object references for the form fields of Start & End Date*/
	var loStartDateInput = poForm.all(psStartDateInputName);
	var loEndDateInput = poForm.all(psEndDateInputName);
	
	/*get form's date fields values*/
	var lsStartDate = loStartDateInput.value;
	var lsEndDate = loEndDateInput.value;
	
	/*Manipulate the date values to get formatted Date*/
	var lsStartDate_dtfmt = new Date(lsStartDate); 
	var lsEndDate_dtfmt = new Date(lsEndDate);

    if (!isNaN(lsStartDate_dtfmt) /*if StartDate is valid date*/
        &&((lsEndDate == '') /*AND (If EndDate blank, OR, EndDate before StartDate*/
            || (lsEndDate_dtfmt < lsStartDate_dtfmt)) 
        )
    {/*then... set EndDate same as StartDate*/
	    $ProgrammaticChangeFormField(loEndDateInput, lsStartDate);
    }
}	


function EndTimeZoneCalc(poForm, psStartTimeZoneInputName, psEndTimeZoneInputName)
{
	/*set object references for the form fields of Start & End TimeZones*/
	var loStartTimeZoneInput = poForm.all(psStartTimeZoneInputName);
	var loEndTimeZoneInput = poForm.all(psEndTimeZoneInputName);
	
	/*get form's timezone fields values*/
	var lsStartTimeZone = loStartTimeZoneInput.value;
	var lsEndTimeZone = loEndTimeZoneInput.value;
	
    if(lsStartTimeZone != lsEndTimeZone) /*if start & end timezone values are different*/
    {/*then...set EndTimeZone same as StartTimeZone*/
	    $ProgrammaticChangeFormField(loEndTimeZoneInput, lsStartTimeZone);
	}
}


function disableFields(formreff, fields) {
    var fieldsArray = fields.split(',');
    for (var i = 0; i < fieldsArray.length; i++) {
        var fieldNameArray = fieldsArray[i].split('$');
        var fieldName = fieldNameArray[0];
        var inputType = fieldNameArray[1];
        var sectionsortInt = fieldNameArray[2];
        var subsortInt = fieldNameArray[3];

        switch (inputType) {
            case "24":
                var compositeFieldName = fieldName + "_" + sectionsortInt + "_" + subsortInt;
                if (document.getElementsByName(compositeFieldName)[0] != null) {
                    document.getElementsByName(compositeFieldName)[0].disabled = true;
                }
                if (document.getElementsByName(compositeFieldName)[1] != null) {
                    document.getElementsByName(compositeFieldName)[1].disabled = true;
                }
                break;
            case "14":
                var compositeFieldName = fieldName + "_" + sectionsortInt + "_" + subsortInt;
                if (formreff.all(fieldName) != null) {
                    formreff.all(fieldName).disabled = true;
                }
                if (document.getElementsByName(compositeFieldName)[0] != null) {
                    document.getElementsByName(compositeFieldName)[0].disabled = true;
                }
                break;
            case "15":
                var compositeFieldName = fieldName + "_CalIcon";
                if (formreff.all(fieldName) != null) {
                    formreff.all(fieldName).disabled = true;
                }
                if (document.getElementById(compositeFieldName) != null) {
                    document.getElementById(compositeFieldName).disabled = true;
                }
                break;
            default:
                if (formreff.all(fieldName) != null) {
                    formreff.all(fieldName).disabled = true;
                }
        }
    }
}