/**************************************************************
WEBGRID EXP Version 1.0
Copyright © 2002, Yusuf Wiryonoputro. All rights reserved.
**************************************************************/

function WebGridEXP(objName)
	{
	this.httpObj = new ActiveXObject("Microsoft.XMLHTTP");
	
	this.divStatusBar = "divStatusBar" + objName;
	this.objName = objName;

	this.UrlGET;
	this.UrlPOST;	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	this.action = ""
	this.NumOfDisplayedRecords = 0;//iDisplayedRecords
	this.dsoPersistNew; //waktu save(), new record disave di sini, gunanya pada saat render lagi, kalo errordimasukkan lagi ke grid utk re-entry
	
	this.OrderBy="";
	this.OrderType="";
	this.ShowPage=1;
	this.PageSize=7;
	this.NumOfPages;
	this.dso;
	
	this.viewUnexpError = true;
	
	this.FormatDate = "Mdyyyy"	//English(United States)
	this.DateSeparator = "/"		//for example : 08/19/2002		


	this.useBtnDelete=true;//default value
	this.useBtnAddNew=true;
	this.useBtnDelete=true;
	this.useBtnSave=true;
	
	
	this.COLUMNS
	this.IDENTITY
	this.INPUTTYPES
	this.CAPTIONS
	this.CELLWIDTH
	this.CELLHEIGHT	= 23

	
	this.ImgURL = ""
	
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td>")
	document.write("<div id='grid"+this.objName + "'></div>")
	document.write("<div style='font-family:Arial;font-size:x-small;color:red' align=left id='" + this.divStatusBar + "'></div>")
	document.write("<div id='idErr"+this.objName + "'></div>")
	document.write("<div id='divUnexpErr"+this.objName + "' style='display:none'><textarea class=UnexpErr rows=20 cols=100 id='idUnexpErr"+this.objName+"' name='idUnexpErr"+this.objName+"'></textarea></div>")
	document.write("<input type=hidden id=idActiveCell"+this.objName+" name=idActiveCell"+this.objName+">")
	document.write("<div id='dsoLookup" + this.objName + "'></div>")
	document.write("</td><td></table>")

	var sHTML="";
	sHTML+="<div id='lookupbox"+this.objName+"' style='position:absolute;display:none;'>"
	sHTML+="		<table border='0' cellpadding='0' cellspacing='0' width=5% bgcolor=#f2f4f8 ID='Table1'>"
	sHTML+="		<col><col width=13>"
	sHTML+="		<tr>"
	sHTML+="		<td width=100% nowrap>"
	sHTML+="				<div class='bar' style='padding-left: 5px;'>"
	sHTML+="				<font size=2 face=tahoma color=white><b><span id=lookuptitle"+this.objName+"></span></b></font>&nbsp;"
	sHTML+="				</div>"
	sHTML+="		</td>"
	sHTML+="		<td style='cursor:hand' onclick='"+this.objName+".removeLookupFocus();'>	"
	sHTML+="				<div class='bar'>"
	sHTML+="				<font size=2 face=tahoma color=white><b>X</b></font>&nbsp;"
	sHTML+="				</div>"
	sHTML+="		</td>"
	sHTML+="		</tr>"
	sHTML+="		<tr>"
	sHTML+="		<td colspan=2 style='border-left: #336699 1px solid;border-right: #336699 1px solid;border-bottom: #336699 1px solid;'>"
	sHTML+="				<table align=center cellpadding=0 cellspacing=0 width=100%><col width=20><col>"
	sHTML+="					<tr><td rowspan=3 width=20 valign=top bgcolor=#b0c3e1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td height=3></td></tr>"
	sHTML+="					<tr><td>"
	sHTML+="					<div style='overflow:auto;height:172;BORDER: LightSteelblue 0px solid;'>"
	sHTML+="					<div id='lookupcontent"+this.objName+"'></div>"
	sHTML+="					</div>"
	sHTML+="				</td></tr>"
	sHTML+="				<tr><td height=30>&nbsp;</td></tr>"
	sHTML+="				</table>"
	sHTML+="		</td>"
	sHTML+="		</tr>"
	sHTML+="		</table>"
	sHTML+="</div>"
	document.write(sHTML)
	
	sHTML="";
	sHTML+="<div id='calbox"+this.objName+"' style='position:absolute;display:none;'>"
	sHTML+="		<table border='0' cellpadding='0' cellspacing='0' width=170 bgcolor=Gainsboro ID='Table2'>"
	sHTML+="		<col><col width=13>"
	sHTML+="		<tr>"
	sHTML+="		<td width=100% nowrap>"
	sHTML+="				<div class='bar' style='padding-left: 5px;'>"
	sHTML+="				<font size=2 face=tahoma color=white><b>Calendar</b></font>&nbsp;"
	sHTML+="				</div>"
	sHTML+="		</td>"
	sHTML+="		<td style='cursor:hand' onclick='"+this.objName+".removeLookupFocus();'>"
	sHTML+="				<div class='bar'>"
	sHTML+="				<font size=2 face=tahoma color=white><b>X</b></font>&nbsp;"
	sHTML+="				</div>"
	sHTML+="		</td>"
	sHTML+="		</tr>"
	sHTML+="		<tr>"
	sHTML+="		<td colspan=2 style='border-left: #336699 1px solid;border-right: #336699 1px solid;border-bottom: #336699 1px solid;' valign=top>"
	
	sHTML+="				<table align=center cellpadding=0 cellspacing=0 width=100%><col width=20><col width=150>"
	sHTML+="					<tr><td rowspan=2 width=20 valign=top bgcolor=#b0c3e1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width=200>"
	sHTML+="					<div id='calcontent"+this.objName+"' align=center></div>"
	sHTML+="				</td></tr>"
	sHTML+="				</table>"
		
	sHTML+="		</td>"
	sHTML+="		</tr>"
	sHTML+="		</table>"
	sHTML+="</div>"	
	document.write(sHTML)
	
	
	this.QueryString = "";
	this.getData = getData;
	this.send = send;
	this.checkReadyState = checkReadyState;
	this.renderData = renderData;
	this.sort = sort;
	this.GoToPage = GoToPage;
	this.ChangePageSize = ChangePageSize;
	
	this.setLookupData = setLookupData;
	this.removeLookupFocus = removeLookupFocus;
	this.setLookupFocus = setLookupFocus;
	this.displayLookup = displayLookup;
	this.selectItem = selectItem;
	
	this.displayCalendar = displayCalendar;
	this.drawCalendar = drawCalendar;
	this.selectDate = selectDate;
	
	this.displayLookupLarge = displayLookupLarge;
	
	this.IsIdentitiy = IsIdentitiy
	this.Delete = Delete;
	
	this.IsRequired = IsRequired;
	this.Save = Save;
	
	this.getError = getError
	
	this.recordClicked = recordClicked;
	this.SelectedRecord;
	
	this.getCell = getCell;
	
	this.onLoadAction="";
	}

/************************************************************************************************
	Accessing Cell
*************************************************************************************************/
function getCell(row,col)
	{
	if(this.NumOfDisplayedRecords==1)
		{
		if(this.INPUTTYPES[col][0]=="Boolean")
			{
			return eval("inp"+col+this.objName).checked;
			}
		else
			{
			return eval("inp"+col+this.objName).value;
			}
		}
	else
		{
		if(this.INPUTTYPES[col][0]=="Boolean")
			{
			return eval("inp"+col+this.objName)[row].checked;
			}
		else
			{
			return eval("inp"+col+this.objName)[row].value;
			}
		}
	}

	
/************************************************************************************************
	V A R I O U S   L O O K U P   F U N C T I O N
*************************************************************************************************/
function recordClicked(iRow,iColumn,ActionCalled)
	{
	var arrVal = new Array()
	arrVal[0]=this.COLUMNS[iColumn]
	for (var i = 0 ; i < this.COLUMNS.length; i++)
		{
		if(this.NumOfDisplayedRecords>1)
			{		
			arrVal[i+1]=(eval("inp"+i+this.objName)[iRow].value)
			}
		else
			{
			arrVal[i+1]=(eval("inp"+i+this.objName).value)
			}
		}

	this.SelectedRecord = arrVal	
	
	eval(ActionCalled)
	}
function displayLookupLarge(url, rowIndex, idTarget1, idTarget2, width, height)//consider all params are already using +objName
	{
	this.setLookupFocus()
	
	//var popleft=((document.body.clientWidth - 480) / 2)+window.screenLeft; 
	//var poptop=(((document.body.clientHeight - 520) / 2))+window.screenTop;		
	//window.open(url,"NewWindow","scrollbars=YES,width=480,height=520,left="+popleft+",top="+poptop)	
	var arrInput = new Array(rowIndex, idTarget1, idTarget2);
	//input config : width, height
	
	var arrOutput = window.showModalDialog(url,arrInput,"dialogHeight: "+height+"px; dialogWidth: "+width+"px; edge: Raised; center: Yes; help: No; resizable: No; status: Yes;");	
	if(arrOutput!=null)
		{
		if(rowIndex==-1)//New	
			{
			eval(idTarget1).value=arrOutput[0];
			eval(idTarget2).value=arrOutput[1];	
			}
		else
			{	
			if(this.NumOfDisplayedRecords>1)
				{
				eval(idTarget1)[rowIndex].value=arrOutput[0];
				eval(idTarget2)[rowIndex].value=arrOutput[1];
				}
			else
				{
				eval(idTarget1).value=arrOutput[0];
				eval(idTarget2).value=arrOutput[1];			
				}
			}
		}
	else
		{
		//remove focus (red border)
		this.removeLookupFocus()
		}
	}
	

function displayCalendar(idImg,rowIndex,idTarget,sType)
	{
	this.setLookupFocus()
	
	d = new Date();
	this.drawCalendar(rowIndex,idTarget,d.getMonth()+1,d.getYear(),sType)
	eval("calbox"+this.objName).style.display='block'
	
	
	//set position
	myTop = 0
	stmp = ""
	while(eval("idImg" + stmp).tagName!="BODY")
		{
		//alert(eval("idImg" + stmp).tagName)
		stmp += ".offsetParent"
		myTop += eval("idImg" + stmp).offsetTop
		}

	myLeft = 0
	stmp = ""
	while(eval("idImg" + stmp).tagName!="BODY")
		{
		//alert(eval("idImg" + stmp).tagName)
		stmp += ".offsetParent"
		myLeft += eval("idImg" + stmp).offsetLeft
		}		
	myLeft = myLeft - eval("calbox"+this.objName).clientWidth
	
		
	/*
	myLeft = (idImg.offsetParent.offsetLeft+idImg.offsetLeft+11)- eval("calbox"+this.objName).clientWidth
	myTop  =  idImg.offsetParent.offsetTop+idImg.offsetTop + 71	*/
	/*
	myLeft= ( eval("gridTab"+this.objName).clientWidth/2 - eval("calbox"+this.objName).clientWidth/2 ) + 15
	myTop = ( eval("gridTab"+this.objName).clientHeight/2 - eval("calbox"+this.objName).clientHeight/2 ) + 15
	eval("calbox"+this.objName).style.pixelLeft = myLeft
	eval("calbox"+this.objName).style.pixelTop = myTop-15 */
	/*
	myLeft= event.clientX - eval("calbox"+this.objName).clientWidth - 5
	myTop = event.clientY + 5 */
	eval("calbox"+this.objName).style.pixelLeft = myLeft
	eval("calbox"+this.objName).style.pixelTop = myTop
	}
	
function selectDate(rowIndex,idTarget,arrVal,sValTime)
	{
	//alert(arrVal[0])//month
	//alert(arrVal[1])//date
	//alert(arrVal[2])//year
	switch(this.FormatDate)
		{
		case "ddMMyyyy":
			if(arrVal[1]<10)arrVal[1]="0"+arrVal[1]
			if(arrVal[0]<10)arrVal[0]="0"+arrVal[0]
			vVal = arrVal[1]+this.DateSeparator+arrVal[0]+this.DateSeparator+arrVal[2]
			break;
		case "MMddyyyy":			
			if(arrVal[0]<10)arrVal[0]="0"+arrVal[0]
			if(arrVal[1]<10)arrVal[1]="0"+arrVal[1]
			vVal = arrVal[0]+this.DateSeparator+arrVal[1]+this.DateSeparator+arrVal[2]
			break;
		case "yyyyMMdd":
			if(arrVal[0]<10)arrVal[0]="0"+arrVal[0]
			if(arrVal[1]<10)arrVal[1]="0"+arrVal[1]
			vVal = arrVal[2]+this.DateSeparator+arrVal[0]+this.DateSeparator+arrVal[1]
			break;
		case "dMyyyy":
			vVal = arrVal[1]+this.DateSeparator+arrVal[0]+this.DateSeparator+arrVal[2]
			break;
		case "Mdyyyy":
			vVal = arrVal[0]+this.DateSeparator+arrVal[1]+this.DateSeparator+arrVal[2]
			break;
		case "yyyyMd":
			vVal = arrVal[2]+this.DateSeparator+arrVal[0]+this.DateSeparator+arrVal[1]
			break;
		defult:
			alert("Wrong date format.Please check configuration.")
			break;		
		}
	
	if(sValTime!="") vVal = vVal + " " + sValTime; 
			
	if(rowIndex==-1)//New
		{
		eval(idTarget).value=vVal;
		}
	else
		{
		if(this.NumOfDisplayedRecords>1)
			{
			eval(idTarget)[rowIndex].value=vVal;
			}
		else
			{
			eval(idTarget).value=vVal;	
			}
		}
	eval("calbox"+this.objName).style.display="none";
	}
	
	
	
function setLookupData(id,src)
	{
	var sHTML = "";
	sHTML += "<xml id="+id+" src='"+src+"'></xml>"
	eval("dsoLookup"+this.objName).innerHTML = eval("dsoLookup"+this.objName).innerHTML + sHTML;
	}

function removeLookupFocus()
	{
	if(eval("idActiveCell"+this.objName).value!="")
		{
		eval(eval("idActiveCell"+this.objName).value).style.border = "red solid 0px";
		eval(eval("idActiveCell"+this.objName).value).style.background = "whitesmoke";		
		eval("lookupbox"+this.objName).style.display='none';
		eval("calbox"+this.objName).style.display='none';
		}
	}
	
function setLookupFocus()
	{
	eval(eval("idActiveCell"+this.objName).value).style.border = "gray solid 1px";
	eval(eval("idActiveCell"+this.objName).value).style.background = "white";		
	}	
	
function displayLookup(idImg, idDSO, rowIndex, idTarget1, idTarget2, title)
	{
	this.setLookupFocus()
	
	var sHTML = ""
	
	var oOriginal = idDSO.documentElement.selectSingleNode("Original")
	var RowLength = oOriginal.childNodes.length;
		
	sHTML += "<table width=100%>"
	for(var i=0;i<RowLength;i++) //for each rows
		{
		vVal1 = oOriginal.childNodes(i).childNodes(0).text;//field ke 0 sbg value
		vVal2 = oOriginal.childNodes(i).childNodes(1).text;//field ke 1 sbg displayed
		
		sHTML += "<tr style=\"cursor:'hand'\"><td  onmouseover=\"this.style.cssText='border: red solid 1px';\" onmouseout=\"this.style.cssText='border: Gainsboro solid 1px'\" nowrap style=\"border: Gainsboro solid 1px;\" onclick=\""+this.objName+".selectItem(" + rowIndex + "," + idTarget1 + "," + idTarget2 + ",'"+vVal1+"','"+vVal2+"')\">" + vVal1 + "-" + vVal2 + "</td></tr>"
		
		}
	sHTML += "</table>"

	eval("lookuptitle"+this.objName).innerHTML = title
	eval("lookupcontent"+this.objName).innerHTML = sHTML
	eval("lookupbox"+this.objName).style.display = "block"

	//set position
	myTop = 0
	stmp = ""
	while(eval("idImg" + stmp).tagName!="BODY")
		{
		//alert(eval("idImg" + stmp).tagName)
		stmp += ".offsetParent"
		myTop += eval("idImg" + stmp).offsetTop
		}

	myLeft = 0
	stmp = ""
	while(eval("idImg" + stmp).tagName!="BODY")
		{
		//alert(eval("idImg" + stmp).tagName)
		stmp += ".offsetParent"
		myLeft += eval("idImg" + stmp).offsetLeft
		}		
	myLeft = myLeft - eval("lookupbox"+this.objName).clientWidth

	/*
	myLeft= ( eval("gridTab"+this.objName).clientWidth/2 - eval("lookupbox"+this.objName).clientWidth/2 ) + 15
	myTop = ( eval("gridTab"+this.objName).clientHeight/2 - eval("lookupbox"+this.objName).clientHeight/2 ) + 15
	eval("lookupbox"+this.objName).style.pixelLeft = myLeft
	eval("lookupbox"+this.objName).style.pixelTop = myTop-15 */
	/*
	myLeft= event.clientX - eval("lookupbox"+this.objName).clientWidth - 5
	myTop = event.clientY + 5 */
	
	eval("lookupbox"+this.objName).style.pixelLeft = myLeft
	eval("lookupbox"+this.objName).style.pixelTop = myTop
	}	
	
function selectItem(rowIndex, idTarget1, idTarget2, val1, val2)
	{
	if(rowIndex==-1)//New
		{
		eval(idTarget1).value=val1;
		eval(idTarget2).value=val2;	
		}
	else
		{	
		if(this.NumOfDisplayedRecords>1)
			{
			eval(idTarget1)[rowIndex].value=val1;
			eval(idTarget2)[rowIndex].value=val2;
			}
		else
			{
			eval(idTarget1).value=val1;
			eval(idTarget2).value=val2;		
			}
		}
	eval("lookupbox"+this.objName).style.display = "none"
	}	
	
/************************************************************************************************
	G R I D   N A V I G A T I O N   F U N C T I O N
*************************************************************************************************/
function sort(sNewOrderBy)
	{
	if(sNewOrderBy == this.OrderBy)
		{
		if(this.OrderType=="ASC") 
			{
			this.OrderType = "DESC";
			}
		else
			{
			this.OrderType = "ASC";
			}
		}
	else
		{
		this.OrderBy = sNewOrderBy;
		this.OrderType = "ASC";
		}
	this.getData();
	}
function GoToPage(iNewShowPage)
	{
	this.ShowPage = iNewShowPage;
	this.getData();
	}
function ChangePageSize(iNewPageSize)
	{
	this.PageSize = iNewPageSize;
	this.getData();
	}


/************************************************************************************************
	G E N E R I C   D A T A   E X C H A N G E   F U N C T I O N
*************************************************************************************************/
function getData()
	{
	//alert(this.name)
	this.action = "getData"
	this.send("",this.UrlGET+ "?OrderBy=" + this.OrderBy + "&OrderType=" + this.OrderType + "&ShowPage=" + this.ShowPage + "&PageSize=" + this.PageSize + "&" + this.QueryString);
	}	

function send(sData,sTarget)
	{
	this.httpObj.Open("POST", sTarget, true, "", "");
	this.httpObj.setRequestHeader("Content-Type","text/xml");
	this.httpObj.Send(sData);

    eval(this.divStatusBar).innerHTML = ""
	this.checkReadyState(this.objName)//Special Case : need to pass Object Name (objName)
	}	

// Special Case : need to pass Object Name (objName) 
function checkReadyState(sObjName)
	{
	oGrid = eval(sObjName)
	
    if (oGrid.httpObj.readyState == 4)
		{
		eval(oGrid.divStatusBar).innerHTML = "Done"

		if(oGrid.action=="Save" || oGrid.action=="Delete")
			{
			if(oGrid.httpObj.ResponseXML.xml!="")
				{
				oGrid.dso = oGrid.httpObj.ResponseXML
				oGrid.getError()
				oGrid.renderData()
				}
			else
				{
				alert("Server Side Error : please check configuration.")
				
				if(oGrid.viewUnexpError)
					{
					eval("idUnexpErr"+oGrid.objName).value = oGrid.httpObj.ResponseText;
					eval("divUnexpErr"+oGrid.objName).style.display = "block";
					}
				}
			}

		if(oGrid.action=="getData") 
			{
			if(oGrid.httpObj.ResponseXML.xml!="")
				{
				oGrid.dso = oGrid.httpObj.ResponseXML
				oGrid.renderData()
				}
			else
				{
				alert("Server Side Error : please check configuration.")

				if(oGrid.viewUnexpError)
					{
					eval("idUnexpErr"+oGrid.objName).value = oGrid.httpObj.ResponseText;
					eval("divUnexpErr"+oGrid.objName).style.display = "block";
					}
				}			
			}
        }
    else
		{
        AnimateWindowStatus(eval(sObjName).divStatusBar);
 		window.setTimeout("this.checkReadyState('"+sObjName+"')", 50);
        }
	}


/************************************************************************************************
	D I S P L A Y / R E N D E R   D A T A
*************************************************************************************************/
function renderData()
	{
	//alert(this.dso.xml)
	
	/***********************************************************
		Clear idActiveCell 
		(that may contains previous active Cell information)
	************************************************************/	
	eval("idActiveCell"+this.objName).value = ""
	
	
	/***********************************************************
		Start creating table to display data
	************************************************************/
	var sHTML = "";
	sHTML += "<table id='gridTab"+this.objName+"' style='table-layout:fixed' cellpadding=0 cellspacing=0 border=0 width=10>";//width=10 to press	
	
	/***********************************************************
		Set fixed cell width based on GRID["CellWidth"].
		The first cell (column) is for checkbox (for selecting record).
	************************************************************/
	nCol=0
	
	if(this.useBtnDelete) sHTML += "<col width=18>";
	for(i=0;i<this.CELLWIDTH.length;i++)
		{
		if(this.CELLWIDTH[i]!=null)
			{
			sHTML += "	<col width="+this.CELLWIDTH[i]+">";
			nCol+=1
			}
		}
		
	/***********************************************************
		Get total width
	************************************************************/
	var totWidth;
	
	if(this.useBtnDelete)
		totWidth = 18
	else
		totWidth = 0
		
	for(i=0;i<this.CELLWIDTH.length;i++)
		{
		if(this.CELLWIDTH[i]!=null)
			{
			totWidth += this.CELLWIDTH[i]
			}
		}
	
	//idHorLine.innerHTML = "<BR>"	
	
	
	
	
	var oOriginal = this.dso.documentElement.selectSingleNode("Original")
	this.NumOfDisplayedRecords = oOriginal.childNodes.length; //Get number of records
	
	var oPageProperty = this.dso.documentElement.selectSingleNode("PageProperty")
	this.ShowPage = oPageProperty.childNodes(0).text;
	this.PageSize = oPageProperty.childNodes(1).text;
	this.NumOfPages = oPageProperty.childNodes(2).text;
	this.OrderBy = oPageProperty.childNodes(3).text;
	this.OrderType = oPageProperty.childNodes(4).text;

	sHTML += "<tr>";
	if(this.useBtnDelete)
		sHTML += "	<td colspan="+((nCol*1)+1)+">";//use checkbox
	else
		sHTML += "	<td colspan="+nCol+">";
		
	sHTML += "<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td align=left valign=top>"//sub table

	if(this.NumOfDisplayedRecords>0)
		{	
		/***********************************************************
			Page Size
		************************************************************/				
		sHTML += "	Records per Page : ";
		sHTML += "	<SELECT id=inpPageSize"+this.objName+" name=inpPageSize"+this.objName+" onchange=\""+this.objName+".ChangePageSize(this.value)\">";
		if(this.PageSize==5){sHTML += "<OPTION value=5 selected>5</OPTION>";}		else{sHTML += "	<OPTION value=5>5</OPTION>";}
		if(this.PageSize==7){sHTML += "<OPTION value=7 selected>7</OPTION>";}		else{sHTML += "	<OPTION value=7>7</OPTION>";}		
		if(this.PageSize==10){sHTML += "<OPTION value=10 selected>10</OPTION>";}		else{sHTML += "	<OPTION value=10>10</OPTION>";}			if(this.PageSize==15){sHTML += "<OPTION value=15 selected>15</OPTION>";}		else{sHTML += "	<OPTION value=15>15</OPTION>";}
		if(this.PageSize==20){sHTML += "<OPTION value=20 selected>20</OPTION>";}		else{sHTML += "	<OPTION value=20>20</OPTION>";}
		sHTML += "	</SELECT>";	
		}
		
	sHTML += "</td><td align=right valign=top>"//sub table
		
	sHTML += "Page&nbsp;:&nbsp;";
	

	/***********************************************************
		Number of Pages
	************************************************************/
	for(j=1;j<=this.NumOfPages;j++)
		{
		if(j==this.ShowPage)
			sHTML += "<span>" + j + "</span>&nbsp; ";
		else
			sHTML += "<span onclick=\""+this.objName+".GoToPage('" + j + "')\" style='text-decoration:underline;cursor:hand'>" + j + "</span>&nbsp; ";
		}
		
	sHTML += "</td></tr></table>"//sub table
		
	sHTML += "	</td>";			
	sHTML += "</tr>";


	/***********************************************************
			
		Space
		
	************************************************************/
	if(this.useBtnDelete)
		sHTML += "<tr><td height=5 colspan="+(nCol*1+1)+"></td></tr>";//use checkbox
	else
		sHTML += "<tr><td height=5 colspan="+nCol+"></td></tr>";		



	/***********************************************************
			
		Display Header + add sorting functionality
		
	************************************************************/
		
	sHTML += "<tr bgcolor=#f1eee9>";

	
	if(this.useBtnDelete)
		sHTML += "	<td class=fieldBar>&nbsp;</td>";//use checkbox
	
	for (var i = 0 ; i < this.COLUMNS.length; i++)
		{
		switch(this.INPUTTYPES[i][0])
			{
			case "" :
				//do nothing
				break;
			default :
				if(this.INPUTTYPES[i][0].indexOf("LookupSmall")==0)//this is lookup
						{
						indx = this.INPUTTYPES[i][1]
						sHTML += "	<td nowrap class=fieldBar onclick=\""+this.objName+".sort('" + this.COLUMNS[indx] + "');\" onmouseover=\"this.style.background='Lavender'\" onmouseout=\"this.style.background='#f1eee9'\">&nbsp;<u>" + this.CAPTIONS[i] + "</u>&nbsp;</td>";
						}
				else if(this.INPUTTYPES[i][0].indexOf("LookupLarge")==0)//this is lookup
						{
						indx = this.INPUTTYPES[i][1]
						sHTML += "	<td nowrap class=fieldBar onclick=\""+this.objName+".sort('" + this.COLUMNS[indx] + "');\" onmouseover=\"this.style.background='Lavender'\" onmouseout=\"this.style.background='#f1eee9'\">&nbsp;<u>" + this.CAPTIONS[i] + "</u>&nbsp;</td>";
						}
				else
						{	
						if(this.INPUTTYPES[i][0]=="Number")
							sHTML += "	<td nowrap align=right class=fieldBar onclick=\""+this.objName+".sort('" + this.COLUMNS[i] + "');\" onmouseover=\"this.style.background='Lavender'\" onmouseout=\"this.style.background='#f1eee9'\">&nbsp;<u>" + this.CAPTIONS[i] + "</u>&nbsp;</td>";
						else
							sHTML += "	<td nowrap class=fieldBar onclick=\""+this.objName+".sort('" + this.COLUMNS[i] + "');\" onmouseover=\"this.style.background='Lavender'\" onmouseout=\"this.style.background='#f1eee9'\">&nbsp;<u>" + this.CAPTIONS[i] + "</u>&nbsp;</td>";
						}
				break;
			}
		}
	sHTML += "</tr>";
	

	/***********************************************************
		Parse Records
	************************************************************/
	for(var i=0;i<this.NumOfDisplayedRecords;i++) //for each rows
		{
		sHTML += "<tr bgcolor=white>"
			
		if(this.useBtnDelete)
			{
			sHTML += "<td class=Cell valign=top>"
			sHTML += "<INPUT  type='checkbox'  id=chkRow" + this.objName + "  name=chkRow" + this.objName + "  "
			sHTML += "        style='margin-left:1;margin-top:4;width:15;height:15'></td>" //use checkbox
			}
				
		for(var j=0;j<this.COLUMNS.length;j++) //for each fields in a row
			{
			vVal = oOriginal.childNodes(i).childNodes(j).text;
			
			switch(this.INPUTTYPES[j][0])
				{
				case "" :
					//do nothing
					break;
				case "Image" :
					nw = this.CELLWIDTH[j]-2
					iseditable=this.INPUTTYPES[j][2]
					if(vVal!="")
						{
						sHTML += "<td class=Cell align=center style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;' valign=top>"
						sHTML += "<INPUT class=CellInp maxlength=255 style='height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";display:none;' type='text' "
						sHTML += "       id=inp" + j + this.objName + " name=inp" + j + this.objName + " "
						sHTML += "       value=\"" + doEsc(vVal) + "\" "
						sHTML += "       onblur=\"this.style.border='gray 0 solid';this.style.display='none';"
						sHTML += "                if("+this.NumOfDisplayedRecords+"==1)"//do not use array operation
						sHTML += "                  {"
						sHTML += "                  if(this.value==''){inpImg"+j+this.objName+".src='"+this.ImgURL+"/empty.jpg'}"
						sHTML += "                  else{inpImg" + j + this.objName + ".src=this.value;}"
						sHTML += "                  }"
						sHTML += "                else"//use array operation
						sHTML += "                  {"
						sHTML += "                  if(this.value==''){inpImg"+j+this.objName+"["+i+"].src='"+this.ImgURL+"/empty.jpg'}"
						sHTML += "                  else{inpImg"+j+this.objName+"["+i+"].src=this.value;}"
						sHTML += "                  }\" >"
						sHTML += "<div style=\"width:"+nw+";height="+this.CELLHEIGHT+"\">"
						if(iseditable)
							{
							sHTML += "<span onclick=\""+this.objName+".removeLookupFocus();"
							sHTML += "                if("+this.NumOfDisplayedRecords+"==1)"//do not use array operation
							sHTML += "                  {"
							sHTML += "                  inp"+j+this.objName+".style.display='block';"
							sHTML += "                  inp"+j+this.objName+".style.border='gray 1 solid';"
							sHTML += "                  inp"+j+this.objName+".select()"
							sHTML += "                  }"
							sHTML += "                else"//use array operation
							sHTML += "                  {"
							sHTML += "                  inp"+j+this.objName+"["+i+"].style.display='block';"
							sHTML += "                  inp"+j+this.objName+"["+i+"].style.border='gray 1 solid';"
							sHTML += "                  inp"+j+this.objName+"["+i+"].select()}\" "
							sHTML += "      style='cursor:hand;height:20'><u>Edit</u></span>"
							sHTML += "<br>"
							}
						else
							{
							sHTML += "<span style='height:20'>&nbsp;</span>"
							sHTML += "<br>"
							}
						
						sHTML += "<image style='cursor:hand' onclick=\"window.open('"+vVal+"')\" "
						sHTML += "       id=inpImg" + j + this.objName + " name=inpImg"+j+this.objName+" src='" + vVal + "'>"
						sHTML += "</div></td>";	
						}
					else
						{
						sHTML += "<td class=Cell align=center style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;' valign=top>"
						sHTML += "<INPUT class=CellInp maxlength=255 style='height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";display:none;' type='text' "
						sHTML += "       id=inp" + j + this.objName + " name=inp" + j + this.objName + " "
						sHTML += "       value=\"" + doEsc(vVal) + "\" "
						sHTML += "       onblur=\"this.style.border='gray 0 solid';this.style.display='none';"
						sHTML += "                if("+this.NumOfDisplayedRecords+"==1)"//do not use array operation
						sHTML += "                  {"
						sHTML += "                  if(this.value==''){inpImg"+j+this.objName+".src='"+this.ImgURL+"/empty.jpg'}"
						sHTML += "                  else{inpImg" + j + this.objName + ".src=this.value;}"
						sHTML += "                  }"
						sHTML += "                else"//use array operation
						sHTML += "                  {"
						sHTML += "                  if(this.value==''){inpImg"+j+this.objName+"["+i+"].src='"+this.ImgURL+"/empty.jpg'}"
						sHTML += "                  else{inpImg"+j+this.objName+"["+i+"].src=this.value;}"
						sHTML += "                  }\" >"
						sHTML += "<div style=\"width:"+nw+";height="+this.CELLHEIGHT+"\">"
						if(iseditable)
							{
							sHTML += "<span onclick=\""+this.objName+".removeLookupFocus();"
							sHTML += "                if("+this.NumOfDisplayedRecords+"==1)"//do not use array operation
							sHTML += "                  {"
							sHTML += "                  inp"+j+this.objName+".style.display='block';"
							sHTML += "                  inp"+j+this.objName+".style.border='gray 1 solid';"
							sHTML += "                  inp"+j+this.objName+".select()"
							sHTML += "                  }"
							sHTML += "                else"//use array operation
							sHTML += "                  {"
							sHTML += "                  inp"+j+this.objName+"["+i+"].style.display='block';"
							sHTML += "                  inp"+j+this.objName+"["+i+"].style.border='gray 1 solid';"
							sHTML += "                  inp"+j+this.objName+"["+i+"].select()}\" "
							sHTML += "       style='cursor:hand;height:20'><u>Edit</u></span>"
							sHTML += "<br>"
							}
						else
							{
							sHTML += "<span style='height:20'>&nbsp;</span>"
							sHTML += "<br>"
							}
						sHTML += "<image id=inpImg"+j+" name=inpImg"+j+this.objName+" src='"+this.ImgURL+"/empty.jpg'>"
						sHTML += "</div></td>";					
						}
					break;						
					
				case "Link" :
					nw = this.CELLWIDTH[j]-2
					actioncalled = this.INPUTTYPES[j][1]

					sHTML += "<td class=Cell  align=center style='height:"+this.CELLHEIGHT+";BACKGROUND-COLOR:whitesmoke;' valign=top>"
					sHTML += "<INPUT type='hidden' id=inp" + j + this.objName+ " name=inp" + j + this.objName + " "
					sHTML += "       value='" + doEsc(vVal) + "'>"
					sHTML += "<INPUT type='text' readonly "
					sHTML += "       onmouseover=\"this.style.border='red 1 solid'\"  "
					sHTML += "       onmouseout=\"this.style.border='whitesmoke 1px solid'\" "
					sHTML += "       onclick=\""+this.objName+".recordClicked("+i+","+j+",'"+actioncalled+"')\"  "
					sHTML += "       class=CellInp  "
					sHTML += "       style='height:"+((this.CELLHEIGHT*1) - 3)+";cursor:hand;width="+nw+";border:whitesmoke 1px solid;"
					sHTML += "                       background-color:whitesmoke;font-size: x-small;' "
					sHTML += "       value='" + doEsc(vVal) + "'>"
					sHTML += "</td>";
					break;						
					
				case "Boolean" :
					iseditable=this.INPUTTYPES[j][1]
					if(iseditable)
						{
						if(vVal=="False")
							{
							sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";' align=center valign=top>"
							sHTML += "<INPUT id=inp" + j + this.objName+" name=inp" + j + this.objName+" "
							sHTML += "       type='checkbox' style='width:15;height:15;margin-top:4;'></td>";
							}
						else
							{
							sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";' align=center valign=top>"
							sHTML += "<INPUT id=inp" + j + this.objName+" name=inp" + j + this.objName+" "
							sHTML += "       type='checkbox' style='width:15;height:15;margin-top:4;' checked></td>";
							}
						}
					else
						{
						if(vVal=="False")
							{
							sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;' align=center valign=top>"
							sHTML += "<INPUT disabled id=inp" + j + this.objName+" name=inp" + j + this.objName+" "
							sHTML += "       type='checkbox' style='width:15;height:15;margin-top:4;'></td>";
							}
						else
							{
							sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;' align=center valign=top>"
							sHTML += "<INPUT disabled id=inp" + j + this.objName+" name=inp" + j + this.objName+" "
							sHTML += "       type='checkbox' style='width:15;height:15;margin-top:4;' checked></td>";
							}
						}
					break;
				case "Date" :
					nw = this.CELLWIDTH[j]-21//100 => width:79;
					sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
					sHTML += "<INPUT id=inp" + j + this.objName+" name=inp" + j + this.objName + " readonly class=CellInp "
					sHTML += "       style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";background-color:whitesmoke;\" value=\"" + vVal + "\">"
					sHTML += "<IMG align=top style='cursor:hand' "
					sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!='')("+this.objName+".removeLookupFocus());"
					sHTML += "               if("+this.NumOfDisplayedRecords+"==1)"
					sHTML += "                 {"
					sHTML += "                 idActiveCell"+this.objName+".value='inp"+j+this.objName+"'"
					sHTML += "                 }"
					sHTML += "               else"
					sHTML += "                 {"
					sHTML += "                 idActiveCell"+this.objName+".value='inp"+j+this.objName+"["+i+"]'"
					sHTML += "                 };"
					sHTML += "               "+this.objName+".displayCalendar(this," + i + ",'inp" + j + this.objName+"','Date')\" "
					sHTML += "     SRC=\""+this.ImgURL+"/lookup.gif\"></td>";
					break;
				case "DateTime" :
					nw = this.CELLWIDTH[j]-21//100 => width:79;
					sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
					sHTML += "<INPUT id=inp" + j + this.objName+" name=inp" + j + this.objName + " readonly class=CellInp "
					sHTML += "       style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";background-color:whitesmoke;\" value=\"" + vVal + "\">"
					sHTML += "<IMG align=top style='cursor:hand' "
					sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!='')("+this.objName+".removeLookupFocus());"
					sHTML += "               if("+this.NumOfDisplayedRecords+"==1)"
					sHTML += "                 {"
					sHTML += "                 idActiveCell"+this.objName+".value='inp"+j+this.objName+"'"
					sHTML += "                 }"
					sHTML += "               else"
					sHTML += "                 {"
					sHTML += "                 idActiveCell"+this.objName+".value='inp"+j+this.objName+"["+i+"]'};"
					sHTML += "                 "+this.objName+".displayCalendar(this," + i + ",'inp" + j + this.objName+"','DateTime')\" "
					sHTML += "     SRC=\""+this.ImgURL+"/lookup.gif\"></td>";
					break;
				case "Number" ://110 => width:108;
					nw=this.CELLWIDTH[j]-2
					decplaces=this.INPUTTYPES[j][1]
					prefix=this.INPUTTYPES[j][2]
					suffix=this.INPUTTYPES[j][3]
					iseditable=this.INPUTTYPES[j][5]

					if(iseditable)
						{		
						sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
						sHTML += "<INPUT class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";text-align:right;\" type='text' "
						sHTML += "       id=inpDisp" + j + this.objName +" name=inpDisp" + j + this.objName +" "
						sHTML += "       value=\"" + formatNumber(vVal,decplaces,prefix,suffix) + "\"	"
						sHTML += "       onfocus=\"if("+this.NumOfDisplayedRecords+"==1)"
						sHTML += "                   {"
						sHTML += "                   inp"+j+this.objName+".style.display='block';"
						sHTML += "                   inp"+j+this.objName+".select();"
						sHTML += "                   }"
						sHTML += "                 else"
						sHTML += "                   {"
						sHTML += "                   inp"+j+this.objName+"["+i+"].style.display='block';"
						sHTML += "                   inp"+j+this.objName+"["+i+"].select();}\" >"									
						sHTML += "<INPUT type='text' onkeypress=\"forcenumber()\" class=CellInp "
						sHTML += "       style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";text-align:right;border:gray 1 solid;display:none\"  "
						sHTML += "       id=inp" + j + this.objName+" name=inp" + j + this.objName+" "
						sHTML += "       value=\"" + vVal + "\" "
						sHTML += "       onfocus=\"if("+this.NumOfDisplayedRecords+"==1)"
						sHTML += "                   {"
						sHTML += "                   inpDisp"+j+this.objName+".style.display='none'"
						sHTML += "                   }"
						sHTML += "                 else"
						sHTML += "                   {"
						sHTML += "                   inpDisp"+j+this.objName+"["+i+"].style.display='none'"
						sHTML += "                   };"
						sHTML += "                 "+this.objName+".removeLookupFocus();\" "
						sHTML += "       onblur=\"if("+this.NumOfDisplayedRecords+"==1)"
						sHTML += "                   {"
						sHTML += "                   inpDisp" + j + this.objName +".value=formatNumber(this.value,"+decplaces+",'"+prefix+"','"+suffix+"');"
						sHTML += "                   inpDisp" + j + this.objName +".style.display='block';"
						sHTML += "                   }"
						sHTML += "                else"
						sHTML += "                   {"
						sHTML += "                   inpDisp" + j + this.objName +"[" + i + "].value=formatNumber(this.value,"+decplaces+",'"+prefix+"','"+suffix+"');"
						sHTML += "                   inpDisp" + j + this.objName +"[" + i + "].style.display='block';"
						sHTML += "                   };"
						sHTML += "                this.style.display='none'; \">";
						//sHTML += "<INPUT class=CellInp style=\"text-align:right;display:none\" type='text' id=inp" + j + " name=inp" + j + " value=\"" + vVal + "\" onfocus=\"removeLookupFocus();this.style.cssText='border:gray 1 solid;text-align:right;'\" onblur=\"this.style.cssText='border:gray 0 solid;text-align:right;'\">";
						sHTML += "</td>";
						}
					else
						{
						sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
						sHTML += "<INPUT readonly class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";text-align:right;border:whitesmoke 1px solid;background-color:whitesmoke;font-size: x-small;\" type='text' "
						sHTML += "       value=\"" + formatNumber(vVal,decplaces,prefix,suffix) + "\">"	
														
						sHTML += "<INPUT type='text' class=CellInp style='display:none'  "
						sHTML += "       id=inp" + j + this.objName+" name=inp" + j + this.objName+" "
						sHTML += "       value=\"" + vVal + "\">";
						sHTML += "</td>";
						}
					break;	
				case "Text" ://110 => width:108; doEsc
					nw = this.CELLWIDTH[j]-2
					maxlength=this.INPUTTYPES[j][1]
					iseditable=this.INPUTTYPES[j][3]
					if(iseditable)
						{
						sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
						sHTML += "<TEXTAREA onkeypress=\"if(this.value.length>="+maxlength+")return false;\" class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";overflow:auto;width:"+nw+";font-family: Verdana;font-size: x-small;\" rows=5 cols=20 "
						sHTML += "          id=inp" + j + this.objName +" name=inp" + j + this.objName +"  "
						sHTML += "          onfocus=\""+this.objName+".removeLookupFocus();this.style.border='gray 1 solid'\" "
						sHTML += "          onblur=\"this.style.border='gray 0 solid'\">" + doEsc(vVal) + "</TEXTAREA></td>";
						//sHTML += "	<td class=Cell><INPUT class=CellInp maxlength="+maxlength+" style=\"width:"+nw+";\" type='text' id=inp" + j + " name=inp" + j + " value=\"" + doEsc(vVal) + "\" onfocus=\"removeLookupFocus();this.style.border='gray 1 solid'\" onblur=\"this.style.border='gray 0 solid'\"></td>";
						}
					else
						{
						sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
						sHTML += "<TEXTAREA readonly class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";overflow:auto;width:"+nw+";font-family: Verdana;font-size: x-small;border:whitesmoke 1px solid;background-color:whitesmoke;\" rows=5 cols=20 "
						sHTML += "          id=inp" + j + this.objName +" name=inp" + j + this.objName +">" + doEsc(vVal) + "</TEXTAREA></td>";
						}
					break;	
				default ://141 => width:120;
					nw = this.CELLWIDTH[j]-21
					if(this.INPUTTYPES[j][0].indexOf("LookupSmall")==0)
						{
						indx = this.INPUTTYPES[j][1]
						vValDisplayed = oOriginal.childNodes(i).childNodes(indx).text;
						sHTML += "<td class=Cell bgcolor=whitesmoke  style='height:"+this.CELLHEIGHT+";'>"
						sHTML += "<INPUT type='hidden' id=inp" + j + this.objName +" name=inp" + j + this.objName +" "
						sHTML += "       value='" + vVal + "'>"
						sHTML += "<INPUT readonly id=inp" + indx + this.objName + " name=inp" + indx + this.objName + " "
						sHTML += "       class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";BACKGROUND-COLOR:whitesmoke;\" "
						sHTML += "       value=\"" + vValDisplayed + "\">"
						sHTML += "<IMG style='cursor:hand' align=top SRC=\""+this.ImgURL+"/lookup.gif\"  align=bottom  "
						sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!=''){"+this.objName+".removeLookupFocus()};"
						sHTML += "               if("+this.NumOfDisplayedRecords+"==1)"
						sHTML += "                 {idActiveCell"+this.objName+".value='inp"+indx+this.objName+"'}"
						sHTML += "               else"
						sHTML += "                 {idActiveCell"+this.objName+".value='inp"+indx+this.objName+"["+i+"]'};"
						sHTML += "               "+this.objName+".displayLookup(this,eval('"+this.INPUTTYPES[j][2]+"')," + i + ",'inp" + j + this.objName +"','inp" + indx + this.objName +"','" + this.CAPTIONS[indx] + "');\">"
						sHTML += "</td>";
						}
					if(this.INPUTTYPES[j][0].indexOf("LookupLarge")==0)//this is lookup
						{
						indx = this.INPUTTYPES[j][1]
						lookwidth = this.INPUTTYPES[j][3]
						lookheight= this.INPUTTYPES[j][4]
						vValDisplayed = oOriginal.childNodes(i).childNodes(indx).text;
						sHTML += "<td class=Cell bgcolor=whitesmoke  style='height:"+this.CELLHEIGHT+";'>"
						sHTML += "<INPUT type='hidden' id=inp" + j + this.objName +" name=inp" + j + this.objName +" "
						sHTML += "       value='" + vVal + "'>"
						sHTML += "<INPUT readonly id=inp" + indx + this.objName + " name=inp" + indx + this.objName + " "
						sHTML += "       class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";BACKGROUND-COLOR:whitesmoke;\" "
						sHTML += "       value=\"" + vValDisplayed + "\">"
						sHTML += "<IMG style='cursor:hand' align=top SRC=\""+this.ImgURL+"/lookup.gif\"  align=bottom  "
						sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!=''){"+this.objName+".removeLookupFocus()};"
						sHTML += "               if("+this.NumOfDisplayedRecords+"==1)"
						sHTML += "                 {idActiveCell"+this.objName+".value='inp"+indx+this.objName+"'}"
						sHTML += "               else"
						sHTML += "                 {idActiveCell"+this.objName+".value='inp"+indx+this.objName+"["+i+"]'};"
						sHTML += "               "+this.objName+".displayLookupLarge('"+this.INPUTTYPES[j][2]+"'," + i + ",'inp" + j + this.objName +"','inp" + indx + this.objName +"',"+lookwidth+","+lookheight+");\">"
						sHTML += "</td>";
						}						
					break;				
					}
				}	
			sHTML += "</tr>";
			}

		
		
	/***********************************************************
		Add New Record
	************************************************************/

	sHTML += "<tr id=idNew"+this.objName+" style=\"display:none\">";
	
	if(this.useBtnDelete) sHTML += "	<td class=Cell>&nbsp;</td>";//use checkbox
		
	for (var j = 0 ; j < this.COLUMNS.length; j++)
		{
		switch(this.INPUTTYPES[j][0])
			{
			case "" :
				//do nothing
				break;
			case "Image" :
				nw = this.CELLWIDTH[j]-2
				iseditable=this.INPUTTYPES[j][2]
				sHTML += "<td class=Cell align=center style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;' valign=top>"
				sHTML += "<INPUT class=CellInp maxlength=255 style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";display:none;\" type='text' "
				sHTML += "       id=inpNew" + j + this.objName +" name=inpNew" + j + this.objName +" "
				sHTML += "       value='' onblur=\"this.style.border='gray 0 solid';this.style.display='none';"
				sHTML += "                         if(this.value=='')"
				sHTML += "                           {inpImgNew"+j+this.objName+".src='"+this.ImgURL+"/empty.jpg'}"
				sHTML += "                         else"
				sHTML += "                           {inpImgNew"+j+this.objName+".src=this.value;}\" >"
				sHTML += "<div style=\"width:"+nw+";height="+this.CELLHEIGHT+"\">"
				if(iseditable)
						{
						sHTML += "<span onclick=\""+this.objName+".removeLookupFocus();"
						sHTML += "      inpNew"+j+this.objName+".style.display='block';"
						sHTML += "      inpNew"+j+this.objName+".style.border='gray 1 solid';"
						sHTML += "      inpNew"+j+this.objName+".select()\" style=\"cursor:hand;height:20\" ><u>Edit</u></span><br>"
						}
				else
						{
						sHTML += "<span style='height:20'>&nbsp;</span>"
						sHTML += "<br>"
						}
				sHTML += "<image id=inpImgNew"+j+this.objName+" name=inpImgNew"+j+this.objName+" src='"+this.ImgURL+"/empty.jpg'>"
				sHTML += "</div></td>";	
				break;					
			case "Link" : //krn ini add new, diasumsikan editable
				nw = this.CELLWIDTH[j]-2
				sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
				sHTML += "<TEXTAREA class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";overflow:auto;width:"+nw+";font-family: Verdana;font-size: x-small;\" rows=5 cols=20 "
				sHTML += "          id=inpNew" + j + this.objName +" name=inpNew" + j + this.objName +"  "
				sHTML += "          onfocus=\""+this.objName+".removeLookupFocus();this.style.border='gray 1 solid'\" "
				sHTML += "          onblur=\"this.style.border='gray 0 solid'\"></TEXTAREA></td>";
				break;	 
			case "Boolean" :
				iseditable=this.INPUTTYPES[j][1]
				if(iseditable)
						{
						sHTML += "<td class=Cell align=center valign=top style='height:"+this.CELLHEIGHT+";'>"
						sHTML += "<INPUT id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+" type='checkbox' style='width:15;height:15;margin-top:4;'></td>";
						}
				else
						{
						sHTML += "<td class=Cell align=center valign=top style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
						sHTML += "<INPUT disabled id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+" type='checkbox' style='width:15;height:15;margin-top:4;'></td>";
						}
				break;
			case "Date" :
				nw = this.CELLWIDTH[j]-21
				sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
				sHTML += "<INPUT readonly id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+" class=CellInp "
				sHTML += "style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";background-color:whitesmoke;\">"
				sHTML += "<IMG align=top style='cursor:hand' "
				sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!='')("+this.objName+".removeLookupFocus());"
				sHTML += "               idActiveCell"+this.objName+".value='inpNew"+j+this.objName+"';"
				sHTML += "               "+this.objName+".displayCalendar(this,-1,'inpNew" + j + this.objName + "','Date')\" "
				sHTML += "     SRC=\""+this.ImgURL+"/lookup.gif\"></td>";
				break;
			case "DateTime" :
				nw = this.CELLWIDTH[j]-21
				sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
				sHTML += "<INPUT readonly id=inpNew" + j + this.objName +" name=inpNew" + j + this.objName +" "
				sHTML += "       class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";background-color:whitesmoke;\" >"
				sHTML += "<IMG align=top style='cursor:hand' "
				sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!='')("+this.objName+".removeLookupFocus());"
				sHTML += "               idActiveCell"+this.objName+".value='inpNew"+j+this.objName+"';"
				sHTML += "               "+this.objName+".displayCalendar(this,-1,'inpNew" + j + this.objName + "','DateTime')\" "
				sHTML += "     SRC=\""+this.ImgURL+"/lookup.gif\"></td>";
				break;				
			case "Number" :
				nw = this.CELLWIDTH[j]-2
				decplaces=this.INPUTTYPES[j][1]
				prefix=this.INPUTTYPES[j][2]
				suffix=this.INPUTTYPES[j][3]
				iseditable=this.INPUTTYPES[j][5]			

				if(iseditable)
					{	
					sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
					sHTML += "<INPUT class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";text-align:right;\" type='text' "
					sHTML += "       id=inpDispNew" + j + this.objName+" name=inpDispNew" + j + this.objName+" "
					sHTML += "       onfocus=\"inpNew"+j+this.objName+".style.display='block';inpNew"+j+this.objName+".select();\" >";
					sHTML += "<INPUT onkeypress=\"forcenumber()\" class=CellInp "
					sHTML += "       style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";text-align:right;border:gray 0 solid;display:none\" type='text' "
					sHTML += "       id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+"  "
					sHTML += "       onfocus=\"inpDispNew"+j+this.objName+".style.display='none';"+this.objName+".removeLookupFocus();"
					sHTML += "                 inpNew"+j+this.objName+".style.border='gray 1 solid';\" "
					sHTML += "       onblur=\"inpDispNew"+j+this.objName+".value=formatNumber(this.value,"+decplaces+",'"+prefix+"','"+suffix+"'); "
					sHTML += "                this.style.display='none';inpDispNew"+j+this.objName+".style.display='block';"
					sHTML += "                inpDispNew"+j+this.objName+".style.border='gray 0 solid';\">";
					sHTML += "</td>";	
					//sHTML += "	<td class=Cell><INPUT class=CellInp style=\"text-align:right;\" type='text' id=inpNew" + j + " name=inpNew" + j + " onfocus=\"removeLookupFocus();this.style.cssText='border:gray 1 solid;text-align:right;'\" onblur=\"this.style.cssText='border:gray 0 solid;text-align:right;'\"></td>";			
					}
				else
					{
					sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
					sHTML += "<INPUT readonly type='text' class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";text-align:right;border:whitesmoke 1px solid;background-color:whitesmoke;font-size: x-small;\"  "
					sHTML += "       id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+" "
					sHTML += "       value=''>";
					sHTML += "</td>";
					}			
				
				break;
			case "Text" ://doEsc
				nw = this.CELLWIDTH[j]-2
				maxlength=this.INPUTTYPES[j][1]
				iseditable=this.INPUTTYPES[j][3]
				if(iseditable)
					{
					sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";'>"
					sHTML += "<TEXTAREA class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";overflow:auto;width:"+nw+";font-family: Verdana;font-size: x-small;\"  cols=20 "
					sHTML += "          id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+"  "
					sHTML += "          onfocus=\""+this.objName+".removeLookupFocus();this.style.border='gray 1 solid'\" "
					sHTML += "          onblur=\"this.style.border='gray 0 solid'\"></TEXTAREA></td>";
					//sHTML += "	<td class=Cell><INPUT class=CellInp maxlength="+maxlength+" style=\"width:"+nw+";\" type='text' id=inpNew" + j + " name=inpNew" + j + " onfocus=\"removeLookupFocus();this.style.border='gray 1 solid'\" onblur=\"this.style.border='gray 0 solid'\"></td>";
					}
				else
					{
					sHTML += "<td class=Cell style='height:"+this.CELLHEIGHT+";background-color:whitesmoke;'>"
					sHTML += "<TEXTAREA readonly class=CellInp style=\"height:"+((this.CELLHEIGHT*1) - 3)+";overflow:auto;width:"+nw+";font-family: Verdana;font-size: x-small;border:whitesmoke 1px solid;background-color:whitesmoke;\" rows=5 cols=20 "
					sHTML += "          id=inpNew" + j + this.objName +" name=inpNew" + j + this.objName +"></TEXTAREA></td>";
					}
				break;	
			default :
				nw = this.CELLWIDTH[j]-21
				if(this.INPUTTYPES[j][0].indexOf("LookupSmall")==0)
					{
					indx = this.INPUTTYPES[j][1]
					sHTML += "<td class=Cell bgcolor=whitesmoke style='height:"+this.CELLHEIGHT+";'>"
					sHTML += "<INPUT type='hidden' id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+" >"
					sHTML += "<INPUT readonly id=inpNew" + indx + this.objName+" name=inpNew" + indx + this.objName+" class=CellInp "
					sHTML += "style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";background-color:whitesmoke;\" >"
					sHTML += "<IMG align=top style='cursor:hand' SRC=\""+this.ImgURL+"/lookup.gif\" align=bottom  "
					sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!='')("+this.objName+".removeLookupFocus());"
					sHTML += "     idActiveCell"+this.objName+".value='inpNew"+indx+this.objName+"';"+this.objName+".displayLookup(this,eval('"+this.INPUTTYPES[j][2]+"'),-1,'inpNew" + j + this.objName +"','inpNew" + indx + this.objName +"','" + this.CAPTIONS[indx] + "');\"></td>";
					}
				if(this.INPUTTYPES[j][0].indexOf("LookupLarge")==0)//this is lookup
					{
					indx = this.INPUTTYPES[j][1]
					lookwidth = this.INPUTTYPES[j][3]
					lookheight= this.INPUTTYPES[j][4]					
					sHTML += "<td class=Cell bgcolor=whitesmoke style='height:"+this.CELLHEIGHT+";'>"
					sHTML += "<INPUT type='hidden' id=inpNew" + j + this.objName+" name=inpNew" + j + this.objName+" >"
					sHTML += "<INPUT readonly id=inpNew" + indx + this.objName+" name=inpNew" + indx + this.objName+" class=CellInp "
					sHTML += "style=\"height:"+((this.CELLHEIGHT*1) - 3)+";width:"+nw+";background-color:whitesmoke;\" >"
					sHTML += "<IMG align=top style='cursor:hand' SRC=\""+this.ImgURL+"/lookup.gif\" align=bottom  "
					sHTML += "     onclick=\"if(idActiveCell"+this.objName+".value!='')("+this.objName+".removeLookupFocus());"
					sHTML += "     idActiveCell"+this.objName+".value='inpNew"+indx+this.objName+"';"+this.objName+".displayLookupLarge('"+this.INPUTTYPES[j][2]+"',-1,'inpNew" + j + this.objName +"','inpNew" + indx + this.objName +"',"+lookwidth+","+lookheight+");\"></td>";
					}						
				break;							
			}
		}
	sHTML += "</tr>";

	if(this.useBtnDelete)
		sHTML += "<tr><td height=5 colspan="+(nCol*1+1)+"></td></tr>";
	else
		sHTML += "<tr><td height=5 colspan="+nCol+"></td></tr>";


	sHTML += "<tr>";
		if(this.useBtnDelete)
			sHTML += "	<td colspan="+((nCol*1)+1)+">";	
		else
			sHTML += "	<td colspan="+nCol+">";	
	
	sHTML += "<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td align=left valign=top>"//sub table
	
	if(this.useBtnAddNew)
		sHTML += "  <INPUT type=button id=btnAddNew"+this.objName+" name=btnAddNew"+this.objName+" value=\"Add New\" onclick=\"if(idNew"+this.objName+".style.display=='none'){idNew"+this.objName+".style.display='block';this.value='Cancel Add New'}else{idNew"+this.objName+".style.display='none';this.value='Add New'}\">"
	if(this.useBtnDelete)
		sHTML += "	<INPUT type='button' onclick='"+this.objName+".Delete()' value='Delete selected'>";
	if(this.useBtnSave)
		sHTML += "	<INPUT type='button' onclick='"+this.objName+".Save()' value='S A V E'>";

	sHTML += "</td><td align=right valign=top>"//sub table
	
	/***********************************************************
		Number of Pages
	************************************************************/
	sHTML += "Page&nbsp;:&nbsp;"	
	for(j=1;j<=this.NumOfPages;j++)
		{
		if(j==this.ShowPage)
			sHTML += "<span>" + j + "</span>&nbsp; ";
		else
			sHTML += "<span onclick=\""+this.objName+".GoToPage('" + j + "')\" style='text-decoration:underline;cursor:hand'>" + j + "</span>&nbsp; ";
		}
		
	sHTML += "</td></tr></table>"//sub table
		
	sHTML += "	</td>";			
	sHTML += "</tr>";

	sHTML += "</table>";
	
	/***********************************************************
		Render HTML
	************************************************************/
	eval("grid"+this.objName).innerHTML = sHTML;	


	/***********************************************************
		Add Inserted error record for re-entry
	************************************************************/
	
	var oErr = this.dso.documentElement.selectSingleNode("ErrorReport")
	if(oErr!=null)
		{
		for(i=0;i<oErr.childNodes.length;i++)//for each row
			{
			eMod = oErr.childNodes(i).childNodes(1)
			eAct = oErr.childNodes(i).childNodes(3).text
			if(eAct=="INSERT")
				{
				for(j=0;j<this.dsoPersistNew.documentElement.childNodes.length;j++)
					{
					eval("inpNew"+j+this.objName).value = this.dsoPersistNew.documentElement.childNodes(j).text
					}
				eval("idNew"+this.objName).style.display = "block";
				eval("btnAddNew"+this.objName).value = "Cancel Add New"
				}
			}
		}
		
	/***********************************************************
		Resize Image
	************************************************************/
		for(var i=0;i<this.NumOfDisplayedRecords;i++) //for each rows
			{
			for (var j = 0 ; j < this.COLUMNS.length; j++) //for each fields in a row
				{			
				if(this.INPUTTYPES[j][0]=="Image")
					{
					
					vVal = oOriginal.childNodes(i).childNodes(j).text;
					nw = this.CELLWIDTH[j]-2

					//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					if(this.NumOfDisplayedRecords==1)
						{
						var width = eval("inpImg"+j+this.objName).width
						var height = eval("inpImg"+j+this.objName).height 
						var resizedWidth = nw;//
						var resizedHeight = this.CELLHEIGHT-30;//30 utk edit text

						var Ratio1 = resizedWidth/resizedHeight;
						var Ratio2 = width/height;

						if(Ratio2 > Ratio1)
							{
							if(width*1>resizedWidth*1)
								eval("inpImg"+j+this.objName).width=resizedWidth;
							else
								eval("inpImg"+j+this.objName).width=width;
							}
						else
							{
							if(height*1>resizedHeight*1)
								eval("inpImg"+j+this.objName).height=resizedHeight;
							else
								eval("inpImg"+j+this.objName).height=height;
							}
						}
					else
						{
						var width = eval("inpImg"+j+this.objName)[i].width
						var height = eval("inpImg"+j+this.objName)[i].height 
						var resizedWidth = nw;
						var resizedHeight = this.CELLHEIGHT-30;//30 utk edit text

						var Ratio1 = resizedWidth/resizedHeight;
						var Ratio2 = width/height;

						if(Ratio2 > Ratio1)
							{
							if(width*1>resizedWidth*1)
								eval("inpImg"+j+this.objName)[i].width=resizedWidth;
							else
								eval("inpImg"+j+this.objName)[i].width=width;
							}
						else
							{
							if(height*1>resizedHeight*1)
								eval("inpImg"+j+this.objName)[i].height=resizedHeight;
							else
								eval("inpImg"+j+this.objName)[i].height=height;
							}
						}
					//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					}
				}
			}
	eval(this.onLoadAction)
	}	
	
/************************************************************************************************
	G E T  E R R O R
*************************************************************************************************/
function getError()
	{
	var oErr = this.dso.documentElement.selectSingleNode("ErrorReport")
	NumOfErrRecords = oErr.childNodes.length
	if(NumOfErrRecords==0)
		{
		eval("idErr"+this.objName).innerHTML = ""
		//alert("Data updated")
		}
	else
		{
		alert("Warning : " + NumOfErrRecords + " records failed")

		var sHTML = ""
		sHTML += "<b><font size=2 color=orangered>Error Details :</font></b><br><br>"
		

		if(this.action=="Save")
			{
			sHTML += "<table border=0 cellpadding=1 cellspacing=0>"
			sHTML += "<tr bgcolor=Seashell><td class=fieldBar2><b>No.&nbsp;</b></td><td class=fieldBar2><b>Your modification :&nbsp;</b></td><td class=fieldBar2><b>Action :&nbsp;</b></td><td class=fieldBar2><b>Error Description :&nbsp;</b></td></tr>"
			for(i=0;i<oErr.childNodes.length;i++)//For each ROW
				{
				//eOrg = oErr.childNodes(i).childNodes(0)
				eMod = oErr.childNodes(i).childNodes(1)
				eSQL = oErr.childNodes(i).childNodes(2).text
				eAct = oErr.childNodes(i).childNodes(3).text
				//eSrc = oErr.childNodes(i).childNodes(4).text
				//eNum = oErr.childNodes(i).childNodes(5).text
				eDsc = oErr.childNodes(i).childNodes(6).text
								
				sHTML += "<tr>"
				sHTML += "<td align=center valign=top class=errMsg>"+((i*1)+1)+"</td>"

				sHTML += "<td valign=top class=errMsg>"

				for(j=0;j<eMod.childNodes.length;j++)//for each fields in a certain modified record (ROW)
					{
					sHTML += eMod.childNodes(j).nodeName + " : " + eMod.childNodes(j).text + "<br>"
					}

					
				sHTML += "&nbsp;</td>"			

				sHTML += "<td valign=top class=errMsg>"
				sHTML += eAct
				sHTML += "</td>"	
				sHTML += "<td valign=top class=errMsg>"
				sHTML += eDsc + "<BR>SQL : " + eSQL
				sHTML += "</td>"			
				sHTML += "</tr>"
				}
			sHTML += "</table>"
			}
		
		if(this.action=="Delete")
			{
			sHTML += "<table border=0 cellpadding=1 cellspacing=0>"
			sHTML += "<tr bgcolor=Seashell><td class=fieldBar2><b>No.&nbsp;</b></td><td class=fieldBar2><b>Your selections :&nbsp;</b></td><td class=fieldBar2><b>Action :&nbsp;</b></td><td class=fieldBar2><b>Error Description :&nbsp;</b></td></tr>"
			for(i=0;i<oErr.childNodes.length;i++)//For each ROW
				{
				eOrg = oErr.childNodes(i).childNodes(0)
				//eMod = oErr.childNodes(i).childNodes(1)
				eSQL = oErr.childNodes(i).childNodes(2).text
				eAct = oErr.childNodes(i).childNodes(3).text
				//eSrc = oErr.childNodes(i).childNodes(4).text
				//eNum = oErr.childNodes(i).childNodes(5).text
				eDsc = oErr.childNodes(i).childNodes(6).text
				
				sHTML += "<tr>"
				sHTML += "<td align=center valign=top class=errMsg>"+((i*1)+1)+"</td>"
				sHTML += "<td valign=top class=errMsg>"
				for(j=0;j<eOrg.childNodes.length;j++)//for each fields in a certain original record (ROW)
					{
					if(this.IsIdentitiy(eOrg.childNodes(j).nodeName))//If column is identity => OK
						{
						sHTML += eOrg.childNodes(j).nodeName + " : " + eOrg.childNodes(j).text + "<br>";
						}
					}
				sHTML += "&nbsp;</td>"			
				sHTML += "<td valign=top class=errMsg>"
				sHTML += eAct
				sHTML += "</td>"	
				sHTML += "<td valign=top class=errMsg>"
				sHTML += eDsc + "<BR>SQL : " + eSQL
				sHTML += "</td>"			
				sHTML += "</tr>"
				}
			sHTML += "</table>"			
			}
		
		eval("idErr"+this.objName).innerHTML = sHTML
		eval(this.divStatusBar).innerHTML = ""
		}
	}

/************************************************************************************************
	D E L E T E   O P E R A T I O N
*************************************************************************************************/
function IsIdentitiy(sField)
	{
	for(var i=0;i<this.IDENTITY.length;i++)
		{
		if(sField == this.IDENTITY[i]) return true;
		}
	return false
	}
function Delete()
	{
	var oOriginal = this.dso.documentElement.selectSingleNode("Original")
	if(oOriginal.childNodes.length==0)return;
	/***********************************************************
	
		Prepare XML Document that will contain records to be deleted :
		
		<YASP_SYNC>
			<YASP_Original/>
			<YASP_Modified/>
			<YASP_Deleted>
				<Row>
					... (contains identities only, for example : <ID>3</ID> )
				</Row>
				...
			</YASP_Deleted>
		</YASP_SYNC>

	************************************************************/
	
	var domObj = new ActiveXObject("Microsoft.XMLDOM");
	
	domObj.documentElement = domObj.createElement("YASP_SYNC")
	var root = domObj.documentElement
	
	var oNode;
	oNode = domObj.createElement("YASP_Original")
	var oNodeOriginal = root.appendChild(oNode)
	
	oNode = domObj.createElement("YASP_Modified")
	var oNodeModified = root.appendChild(oNode)//not used
	
	oNode = domObj.createElement("YASP_Deleted")
	var oNodeDeleted = root.appendChild(oNode)	

	oNode = domObj.createElement("YASP_New")
	var oNodeNew = root.appendChild(oNode)//not used
	
	/***********************************************************
		
		Check if there is more than 1 record. 
		If yes, perform Array operation.
	
	************************************************************/
	
	var chkRow = eval("chkRow"+this.objName)

	if(this.NumOfDisplayedRecords>1)
		{
		for(i=0;i<chkRow.length;i++)
			{
			if(chkRow[i].checked)//If found selected record
				{
				for (var j = 0 ; j < this.COLUMNS.length; j++)//For each columns/fields
					{
					if(this.IsIdentitiy(this.COLUMNS[j]))//If column is identity => OK
						{
						//alert(GRID["Columns"][j] + " : " + eval("inp"+j)[i].value)
						
						oNode = domObj.createElement("Row")
						oNodeDeleted.appendChild(oNode)	
						
						oNode = domObj.createElement(this.COLUMNS[j])
						//setelah dapat posisi j, kita bisa tahu elemen "inp"+j
						oNode.text = eval("inp"+j+this.objName)[i].value
						oNodeDeleted.lastChild.appendChild(oNode)												
						}
					}
					
				/***********************************************************
						
					If current Record (i) is deleted, then add Original Row to node <YASP_Original>.
					
				************************************************************/
				
				oNode = oOriginal.childNodes(i).cloneNode(true)
				oNodeOriginal.appendChild(oNode)					
				}
			}
		}
	else if(this.NumOfDisplayedRecords==1)
		{
		if(chkRow.checked)
			{
			for (var j = 0 ; j < this.COLUMNS.length; j++)
				{
				if(this.IsIdentitiy(this.COLUMNS[j]))//If column is identity => OK
					{
					oNode = domObj.createElement("Row")
					oNodeDeleted.appendChild(oNode)	
						
					oNode = domObj.createElement(this.COLUMNS[j])
					oNode.text = eval("inp"+j+this.objName).value
					oNodeDeleted.lastChild.appendChild(oNode)						
					}
				}
				
			/***********************************************************
						
				If current Record (i) is deleted, then add Original Row to node <YASP_Original>.
					
			************************************************************/
			
			oNode = oOriginal.childNodes(0).cloneNode(true)
			oNodeOriginal.appendChild(oNode)				
			}
		}
	else
		{
		//noop
		}
		
	
	/***********************************************************
		
		Confirm delete operation.
		To see XML that will be submitted to the server 
		(for delete operation) :
		
			alert(domObj.xml)
	
	************************************************************/
	
	if(domObj.documentElement.selectSingleNode("YASP_Deleted").childNodes.length==0)
	   {
	   alert("No selected records.")
	   return;
	   }	
	
	if (confirm("Are you sure you want to delete the data ?") == true) 
		{
		this.action = "Delete";
		this.send(domObj.xml,this.UrlPOST+ "?OrderBy=" + this.OrderBy + "&OrderType=" + this.OrderType + "&ShowPage=" + this.ShowPage + "&PageSize=" + this.PageSize + "&" + this.QueryString);
		}	
	}
	

/************************************************************************************************
	S A V E   O P E R A T I O N
*************************************************************************************************/
function IsRequired(j)//j=column index
	{
	switch(this.INPUTTYPES[j][0])
		{
		case "" :
			return false;
			break;
		case "ReadOnly" :
			return false;
			break;
		case "Boolean" :
			return false;
			break;
		case "Date" :
			return this.INPUTTYPES[j][1];
			break;
		case "Memo" :
			return this.INPUTTYPES[j][1];
			break;
		case "Number" :
			return this.INPUTTYPES[j][4];
			break;
		case "Text" :
			return this.INPUTTYPES[j][2];
			break;	
		case "Image" :
			return this.INPUTTYPES[j][1];
			break;				
		default :
			if(this.INPUTTYPES[j][0].indexOf("LookupSmall")==0)
				{
				return this.INPUTTYPES[j][3];
				}
			if(this.INPUTTYPES[j][0].indexOf("LookupLarge")==0)
				{
				return this.INPUTTYPES[j][5];
				}						
			break;							
		}
	}
	
function Save()
	{
	var bValidEdit=true;
	var bValidAdd=true;
	
	/***********************************************************
		Check if there is more than 1 record. 
		If yes, perform Array operation.
	************************************************************/
	if(this.NumOfDisplayedRecords>1)
		{
		for(i=0;i<this.NumOfDisplayedRecords;i++)//For each records
			{
			for (var j = 0 ; j < this.COLUMNS.length; j++)//For each columns/fields
				{
				if(this.IsRequired(j) && eval("inp"+j+this.objName)[i].value=="")//If is required & the cell value is still empty (=Not Valid)
					{
					bValidEdit = false;
					
					if(this.INPUTTYPES[j][0].indexOf("LookupSmall")==0 || this.INPUTTYPES[j][0].indexOf("LookupLarge")==0)
						{//If Input Type is LookupSmall/LookupLarge
						indx = this.INPUTTYPES[j][1]
						eval("inp"+indx+this.objName)[i].style.border = "red 1 solid";//highlight cell
						}
					else if(this.INPUTTYPES[j][0]=="Number")
						{//If Input Type is Number
						eval("inpDisp"+j+this.objName)[i].style.border = "red 1 solid";//highlight cell
						}
					else if(this.INPUTTYPES[j][0]=="Image")	
						{
						eval("inpImg"+j+this.objName)[i].style.border = "red 1 solid";//highlight cell
						}					
					else
						{
						eval("inp"+j+this.objName)[i].style.border = "red 1 solid";//highlight cell
						}					
					}
				}
			}
		}
	else if(this.NumOfDisplayedRecords==1)
		{
		for (var j = 0 ; j < this.COLUMNS.length; j++)
			{
			if(this.IsRequired(j) && eval("inp"+j+this.objName).value=="")
				{
				bValidEdit = false;
				
				if(this.INPUTTYPES[j][0].indexOf("LookupSmall")==0 || this.INPUTTYPES[j][0].indexOf("LookupLarge")==0)
					{
					indx = this.INPUTTYPES[j][1]
					eval("inp"+indx+this.objName).style.border = "red 1 solid";
					}
				else if(this.INPUTTYPES[j][0]=="Number")
					{
					eval("inpDisp"+j+this.objName).style.border = "red 1 solid";
					}
				else if(this.INPUTTYPES[j][0]=="Image")	
					{
					eval("inpImg"+j+this.objName).style.border = "red 1 solid";
					}											
				else
					{
					eval("inp"+j+this.objName).style.border = "red 1 solid";
					}					
				}
			}
		}
	else
		{
		//noop
		}

	/***********************************************************
		
		Check if New record is added.
		User can add only 1 record at a time 
		(1 new record at single "Save" operation),
		so we don't perform array operation.
	
	************************************************************/
	
	if(eval("idNew"+this.objName).style.display!="none")
		{
		for (var j = 0 ; j < this.COLUMNS.length; j++)//For each columns/fields
			{
			if(this.IsRequired(j) && eval("inpNew"+j+this.objName).value=="")//If is required & the cell value is still empty (=Not Valid)
				{
				bValidAdd = false;
				
				if(this.INPUTTYPES[j][0].indexOf("LookupSmall")==0 || this.INPUTTYPES[j][0].indexOf("LookupLarge")==0)
					{//If Input Type is LookupSmall/LookupLarge
					indx = this.INPUTTYPES[j][1]
					eval("inpNew"+indx+this.objName).style.border = "red 1 solid";//highlight cell
					}
				else if(this.INPUTTYPES[j][0]=="Number")
					{//If Input Type is Number
					eval("inpDispNew"+j+this.objName).style.border = "red 1 solid";//highlight cell
					}
				else if(this.INPUTTYPES[j][0]=="Image")	
					{
					eval("inpImgNew"+j+this.objName).style.border = "red 1 solid";//highlight cell
					}						
				else
					{	
					eval("inpNew"+j+this.objName).style.border = "red 1 solid";//highlight cell
					}
				}
			}		
		}
		
	
		
	if(bValidAdd==false || bValidEdit==false)//If Not Valid, then finish.
		{
		alert("Invalid Input. Please re-enter data.")
		return;
		}		

	/***********************************************************
	
		If Valid, then...
	
		Prepare XML Document that will contain records to be updated/added :
		
		<YASP_SYNC>
			<YASP_Original>
				<Row>
					... (contains original values of modified records only)
				</Row>
				...
			</YASP_Original>
			<YASP_Modified>
				<Row>
					... (contains modified fields only, for example : <ID>ABCD</ID><CompanyName>ABCF</CompanyName> )
					... (contains all identities, for example : <ID IsIdentity='true'>ABC</ID> )
				</Row>
				...
			</YASP_Modified>
			<YASP_Deleted/>
		</YASP_SYNC>

	************************************************************/
	
	var domObj = new ActiveXObject("Microsoft.XMLDOM");
	
	domObj.documentElement = domObj.createElement("YASP_SYNC")
	var root = domObj.documentElement		
	
	var oNode;
	oNode = domObj.createElement("YASP_Original")
	var oNodeOriginal = root.appendChild(oNode)	
	
	oNode = domObj.createElement("YASP_Modified")
	var oNodeModified = root.appendChild(oNode)	
	
	oNode = domObj.createElement("YASP_Deleted")
	var oNodeDeleted = root.appendChild(oNode)//Not used
	
	oNode=domObj.createElement("YASP_New")
	var oNodeNew = root.appendChild(oNode)
	

	/***********************************************************
		Find for each records if there are modified cells.
	************************************************************/
	iTmp = null
	for(var i=0;i<this.NumOfDisplayedRecords;i++) //For each records
		{
		isMod = false
		for (var j = 0 ; j < this.COLUMNS.length; j++) //For each columns/fields
			{
			/***********************************************************
				Check if there is more than 1 record. 
				If yes, perform Array operation.
			************************************************************/
			if(this.NumOfDisplayedRecords>1)
				{
				if(this.INPUTTYPES[j][0]=="Boolean")//If Input Type is Boolean
					{
					if(eval("inp"+j+this.objName)[i].checked)
						{vVal = "True"}
					else
						{vVal = "False"}
					}
				else //If Input Type is not Boolean
					{ 
					vVal = eval("inp"+j+this.objName)[i].value
					}
				}
			else
				{
				if(this.INPUTTYPES[j][0]=="Boolean")//If Input Type is Boolean
					{
					if(eval("inp"+j+this.objName).checked)
						{vVal = "True"}
					else
						{vVal = "False"}
					}
				else //If Input Type is not Boolean
					{ 				
					vVal = eval("inp"+j+this.objName).value
					}
				
				}
			
			/***********************************************************
				
				Then, we got each cells' value stored in variable vVal.
				Next, we'll compare vVal with it's original value.
			
			************************************************************/
				
			var oOriginal = this.dso.documentElement.selectSingleNode("Original")
			if(oOriginal.childNodes(i).childNodes(j).text!=cleanReturn(vVal))//If different (means modified) //cleanReturn
				{
				//note : cleanReturn remove %0D which is inserted when render the node value into textarea.
				//alert("Original : " + oOriginal.childNodes(i).childNodes(j).text + "\n" + "Modified : " + vVal + " | " + oOriginal.childNodes(i).childNodes(j).text.length + "  -  " + cleanReturn(vVal).length)

				/***********************************************************
					If current Record (i) is modified, then add Row to node <YASP_Modified>.
				************************************************************/
				if(iTmp!=i)
					{
					oNode = domObj.createElement("Row")
					var oNodeRow = oNodeModified.appendChild(oNode)	
					iTmp = i
					}
						
				oNode = domObj.createElement(this.COLUMNS[j])
				oNode.text = cleanReturn(vVal) //cleanReturn
				oNodeRow.appendChild(oNode)
				
				isMod = true
				}
			}
			
		if(isMod)
			{
			/***********************************************************
				If current Record (i) is modified, then add Identity Fields to the Row.
			************************************************************/
			for (var j = 0 ; j < this.IDENTITY.length; j++) // => OK
				{
				oNode = domObj.createElement(this.IDENTITY[j])
				for(var k=0;k<oOriginal.childNodes(i).childNodes.length;k++)//for each field
					{
					if(oOriginal.childNodes(i).childNodes(k).nodeName==this.IDENTITY[j])
					oNode.text = oOriginal.childNodes(i).childNodes(k).text
					oNode.setAttribute("isIdentity","true");
					oNodeModified.lastChild.appendChild(oNode)					
					}
				}


			/***********************************************************
					
				If current Record (i) is modified, then add Original Row to node <YASP_Original>.
				
			************************************************************/
			
			oNode = oOriginal.childNodes(i).cloneNode(true)
			oNodeOriginal.appendChild(oNode)
			}
		}
		
	/***********************************************************
		Find if there is added record.
	************************************************************/
	if(eval("idNew"+this.objName).style.display!="none")
		{
		/***********************************************************
			If there is added record, then add a Row to node <YASP_New>.
		************************************************************/	
		oNode = domObj.createElement("Row")
		oNodeNew.appendChild(oNode)		
		
		for (var j = 0 ; j < this.COLUMNS.length; j++) //For each fields in a row
			{
			if(this.INPUTTYPES[j][0]!="") //If Input Type is not empty (note: "empty" type means the field is just displayed value from lookup table)
				{
				//Construct
				oNode = domObj.createElement(this.COLUMNS[j])
				
				/***********************************************************
					No Array operation needed since the Add New is just one record
				************************************************************/
				if(this.INPUTTYPES[j][0]=="Boolean")//If Input Type is Boolean
					{
					if(eval("inpNew"+j+this.objName).checked)
						{oNode.text = "True"}
					else
						{oNode.text = "False"}
					}
				else //If Input Type is not Boolean
					{ 				
					oNode.text = cleanReturn(eval("inpNew"+j+this.objName).value) //cleanReturn
					}

				//if(this.IsIdentitiy(this.COLUMNS[j])) oNode.setAttribute("isIdentity","true"); // => tdk perlu
				oNodeNew.lastChild.appendChild(oNode)
				}
			}
		}
		
		
	/***********************************************************
		Persist Prepared New Record.
	************************************************************/
	if(eval("idNew"+this.objName).style.display!="none")
		{
		var domPersistNew = new ActiveXObject("Microsoft.XMLDOM");
		domPersistNew.documentElement = domPersistNew.createElement("PERSISTNEW")
		var nodePersistNew = domPersistNew.documentElement		

		for (var j = 0 ; j < this.COLUMNS.length; j++) //For each fields in a row
			{
			oNode = domObj.createElement(this.COLUMNS[j])
			/***********************************************************
				No Array operation needed since the Add New is just one record
			************************************************************/
			if(this.INPUTTYPES[j][0]=="Boolean")//If Input Type is Boolean
				{
				if(eval("inpNew"+j+this.objName).checked)
					{oNode.text = "True"}
				else
					{oNode.text = "False"}
				}
			else //If Input Type is not Boolean
				{ 				
				oNode.text = eval("inpNew"+j+this.objName).value
				}
			nodePersistNew.appendChild(oNode)
			}
		this.dsoPersistNew = domPersistNew;//persist
		}		
		
	/***********************************************************
		Confirm update/add operation.
		To see XML that will be submitted to the server 
		(for update/add operation) :
		
			alert(domObj.xml)
	************************************************************/
	//alert(domObj.xml)
	
	if(domObj.documentElement.selectSingleNode("YASP_Modified").childNodes.length==0 && 
	   domObj.documentElement.selectSingleNode("YASP_New").childNodes.length==0 )
	   {
	   alert("Data is not modified")
	   return;
	   }

	if (confirm("Are you sure you want to update the data ?") == true) 
		{
		this.action = "Save";
		this.send(domObj.xml,this.UrlPOST+ "?OrderBy=" + this.OrderBy + "&OrderType=" + this.OrderType + "&ShowPage=" + this.ShowPage + "&PageSize=" + this.PageSize + "&" + this.QueryString);
		}		
	}
	
	
/************************************************************************************************
	V A R I O U S   R E N D E R   F U N C T I O N
*************************************************************************************************/
function formatNumber(expr,decplaces,prefix,suffix)
	{
	var str = " " + Math.round(eval(expr)*Math.pow(10,decplaces))
	while (str.length <= decplaces)
		{
		str = "0" + str
		}
	var decpoint = str.length - decplaces;
	var ss = str.substring(1,decpoint);
	
	var ssTmp="";
	for(var i=ss.length;i>=0;i=i-3)
		{
		if(ss.substring(i-3,i)!="")
		ssTmp = ss.substring(i-3,i) + "," + ssTmp;
		}
		
	ssTmp = ssTmp.substring(0,ssTmp.length-1)
	if(str.substring(decpoint,str.length)=="")
		{
		return prefix + ssTmp + suffix;
		}
	else
		{
		if(ssTmp=="")
			{
			return prefix + "0." + str.substring(decpoint,str.length) + suffix;
			}
		else
			{
			return prefix + ssTmp + "." + str.substring(decpoint,str.length) + suffix;
			}
		}
	}
	
function doEsc(str)
	{
    var arrTmp = str.split("'");
    if (arrTmp.length > 1) str = arrTmp.join("&#39;");

    arrTmp = str.split('"'); 
    if (arrTmp.length > 1) str = arrTmp.join("&#34;");

    return str;
	}
	
function cleanReturn(str)
	{
    var arrTmp = escape(str).split("%0D");
    if (arrTmp.length > 1) str = arrTmp.join("");

    return unescape(str);
	}	
	
function forcenumber() 
	{
	var key = window.event.keyCode;
	if ((key >= 45 && key <= 46) || (key >= 48 && key <= 57)) 
		{
		return true;
		}
	else
		{
		window.event.keyCode=0;
		}
	}	
	

/************************************************************************************************
	G E N E R I C   C A L E N D A R   F U N C T I O N
*************************************************************************************************/
function drawCalendar(rowIndex,idTarget,currMonth,currYear,sType)
	{
	var dNow = new Date();
	dNowDate=dNow.getDate()
	dNowMonth=dNow.getMonth()+1
	dNowYear=dNow.getFullYear()
	
	if(currMonth==12) 
		{ 
		dTmp = new Date("1/1/"+currYear+1);	
		prevMonth=11
		nextMonth=1
		prevYear=currYear
		nextYear=currYear+1
		}
	else if(currMonth==1) 
		{
		dTmp = new Date(currMonth+1 + "/1/"+currYear+1);
		prevMonth=12
		nextMonth=2
		prevYear=currYear-1
		nextYear=currYear	
		}
	else 
		{ 
		dTmp = new Date(currMonth+1 + "/1/"+currYear+1);
		prevMonth=(currMonth-1)
		nextMonth=(currMonth+1)	
		prevYear=currYear
		nextYear=currYear					
		}
	var isFirst=true;

	var lastDate = getLastDateOfTheMonth(dTmp)
	 
	var sHTML ="<table bgcolor=whitesmoke border=0 width=100% cellpadding=0 cellspacing=0>";

	sHTML += "<tr><td style=\"cursor:'hand'\" align=center onclick=\""+this.objName+".drawCalendar("+rowIndex+",'"+idTarget+"',"+prevMonth+","+prevYear+")\"><b>&lt;</b></td><td colspan=5 align=center><b>"+monthName(currMonth)+", "+currYear+"</b></td><td onclick=\""+this.objName+".drawCalendar("+rowIndex+",'"+idTarget+"',"+nextMonth+","+nextYear+")\" align=center style=\"cursor:'hand'\"><b>&gt;</b></td></tr>"

	
	sHTML += "<tr><td align=center>Sun</td><td align=center>Mon</td><td align=center>Tue</td><td align=center>Wed</td><td align=center>Thu</td><td align=center>Fri</td><td align=center>Sat</td></tr>";

	for(var currDate=1; currDate<=lastDate.getDate();currDate++)
		{
		actDate = new Date(currMonth+"/"+currDate+"/"+currYear);
		if(isFirst==true)
			{
			sHTML+="<tr>"
			for(var i=0;i<actDate.getDay();i++)
				{
				sHTML+="<td bgcolor=Gainsboro style=\"border:'Gainsboro solid 1px'\">&nbsp;</td>"
				}
			isFirst=false
			}

		if(currDate==lastDate.getDate())
			{
			if(actDate.getDay()==0)
				{
				selDate = currMonth+","+currDate+","+currYear //unformated
				if(currDate==dNowDate && currMonth==dNowMonth && currYear==dNowYear)
					{
					
					sHTML+="<tr><td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" ><b>"+currDate+"</b></td>" //
					}
				else
					{
					sHTML+="<tr><td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" >"+currDate+"</td>" //
					}
				}
			else
				{
				selDate = currMonth+","+currDate+","+currYear //unformated
				if(currDate==dNowDate && currMonth==dNowMonth && currYear==dNowYear)
					{
					sHTML+="<td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" ><b>"+currDate+"</b></td>" //
					}
				else
					{				
					sHTML+="<td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" >"+currDate+"</td>" //
					}
				}		
			for(var i=actDate.getDay()+1;i<=6;i++)
				{
				sHTML+="<td bgcolor=Gainsboro>&nbsp;</td>"			
				}		
			}
		else
			{
			if(actDate.getDay()==6)
				{
				selDate = currMonth+","+currDate+","+currYear //unformated
				if(currDate==dNowDate && currMonth==dNowMonth && currYear==dNowYear)
					{
					sHTML+="<td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" ><b>"+currDate+"</b></td></tr>" //
					}
				else
					{				
					sHTML+="<td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" >"+currDate+"</td></tr>" //
					}
				}
			else if(actDate.getDay()==0)
				{
				selDate = currMonth+","+currDate+","+currYear //unformated
				if(currDate==dNowDate && currMonth==dNowMonth && currYear==dNowYear)
					{
					sHTML+="<tr><td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\"><b>"+currDate+"</b></td>" //
					}
				else
					{				
					sHTML+="<tr><td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\">"+currDate+"</td>" //
					}
				}
			else
				{
				selDate = currMonth+","+currDate+","+currYear //unformated
				if(currDate==dNowDate && currMonth==dNowMonth && currYear==dNowYear)
					{
					sHTML+="<td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" ><b>"+currDate+"</b></td>" //
					}
				else
					{				
					sHTML+="<td onclick=\""+this.objName+".selectDate("+rowIndex+","+idTarget+",Array("+selDate+"),"+(sType=="DateTime" ? "inpTime.value" : "''")+")\" align=center bgcolor=Gainsboro style=\"cursor:'hand';border:'Gainsboro solid 1px'\" onmouseover=\"this.style.border='red solid 1px'\" onmouseout=\"this.style.border='Gainsboro solid 1px'\" >"+currDate+"</td>" //
					}
				}
			}
		}
	
	if(sType=="DateTime")
		{
		sHTML += "<tr><td align=right colspan=7><input class=time type=text id='inpTime' name='inpTime' value='10:05 AM'></td></tr>";		
		}
	sHTML+="</table>"
	
	eval("calcontent"+this.objName).innerHTML=sHTML;
	}

function getLastDateOfTheMonth(dTmp)
	{
	lastDate = dTmp.getDate() -1 ;
	dTmp.setDate(lastDate);
	return dTmp;
	}	

function monthName(n)
	{
	switch(n)
		{
		case 1:
			return "January";
		case 2:
			return "February";	
		case 3:
			return "March";
		case 4:
			return "April";
		case 5:
			return "May";	
		case 6:
			return "June";	
		case 7:
			return "July";
		case 8:
			return "August";	
		case 9:
			return "September";	
		case 10:
			return "October";
		case 11:
			return "November";	
		case 12:
			return "December";															
		}
	}	
	
function AnimateWindowStatus(idStatusBar)
	{
	if(eval(idStatusBar).innerHTML.length <= 50)
		{
		if(eval(idStatusBar).innerHTML == "") eval(idStatusBar).innerHTML = "Loading ";
		eval(idStatusBar).innerHTML = eval(idStatusBar).innerHTML + "|"
		}
	else
		{
		eval(idStatusBar).innerHTML = ""
		}
	}
