

//**************************************************************************

//		Copyright  Sybase, Inc. 1998-2006

//						 All Rights reserved.

//

//	Sybase, Inc. ("Sybase") claims copyright in this

//	program and documentation as an unpublished work, versions of

//	which were first licensed on the date indicated in the foregoing

//	notice.  Claim of copyright does not imply waiver of Sybase's

//	other rights.

//

//	 This code is generated by the PowerBuilder HTML DataWindow generator.

//	 It is provided subject to the terms of the Sybase License Agreement

//	 for use as is, without alteration or modification.  

//	 Sybase shall have no obligation to provide support or error correction 

//	 services with respect to any altered or modified versions of this code.  

//

//       ***********************************************************

//       **     DO NOT MODIFY OR ALTER THIS CODE IN ANY WAY       **

//       ***********************************************************

//

//       ***************************************************************

//       ** IMPLEMENTATION DETAILS SUBJECT TO CHANGE WITHOUT NOTICE.  **

//       **            DO NOT RELY ON IMPLEMENTATION!!!!		      **

//       ***************************************************************

//

// Use the public interface only.

//**************************************************************************



// these arrays will be filled with internationalized strings based on the server

var DW_shortDayNames = new Array("Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat");

var DW_longDayNames = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

var DW_shortMonthNames = new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC");

var DW_longMonthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");



// this is dependent on the control panel setting on the server

// it indicates the order of days (this is mm/dd/yyyy)

var DW_PARSEDT_monseq = 0;

var DW_PARSEDT_dayseq = 1;

var DW_PARSEDT_yearseq = 2;



// DWItemStatus

var DW_ITEMSTATUS_NOCHANGE = 0;

var DW_ITEMSTATUS_MODIFIED = 1;

var DW_ITEMSTATUS_NEW = 2;

var DW_ITEMSTATUS_NEW_MODIFIED = 3;



// DWPagingMethod

var DW_PAGING_POSTBACK = 0;

var DW_PAGING_CALLBACK = 1;

var DW_PAGING_XMLCLIENTSIDE = 2;



// Added to determine if dates are being processed in client side JavaScript.

var bDateTimeProcessingEnabled = false;



var gMask = "";



// common utility functions



function escapeString( inString )

{

    var index;

    var outString = "";

    var tempChar;



    // force to string type or charAt will fail!

    if (typeof inString != "string")

    	inString = inString.toString();



    var strLength = inString.length;

    for ( index=0; index < strLength; index++ )

        {

        tempChar = inString.charAt( index );

        if (tempChar == "\"" || tempChar == "'") 

            outString += "~" + tempChar;

        else if (tempChar == "\r")

            outString += "~r";

        else if (tempChar == "\n")

            outString += "~n";

        else

            outString += tempChar;

        }

    return outString;

}



function convertToRGB( color )

{

	var hexValue = "000000" + eval( color ).toString(16);

	hexValue = hexValue.substr( hexValue.length - 6, 6 );

	hexValue = hexValue.substr( 4, 2 ) + hexValue.substr( 2, 2 ) + hexValue.substr( 0, 2 );

	return hexValue;

}



// default event returns to 0

function _evtDefault (value)

{

    if (value + "" == "undefined")

        return 0;

    return value;

}



// need to double up because of template expander!

function DW_parseIsSpace(theChar)

{

    return /^\s$/.test(theChar);

}



function DW_parseIsDigit(theChar)

{

    return /^\d$/.test(theChar);

}



function DW_parseIsAlpha(theChar)

{

    return /^\w$/.test(theChar) && ! /^\d$/.test(theChar);

}



// auto binding of events expect <controlName>_<eventName>

function HTDW_eventImplemented(sEventName)

{

    // check if we already have one scripted

    if (this[sEventName] == null && this.autoEventBind == true)

        {

        // check for function with default name

        var testName = this.name + '_' + sEventName;

        if (eval ('typeof ' + testName) == 'function')

            this[sEventName] = eval(testName);

        }



    return this[sEventName] != null;

}

// bind the event with the givent function name instead of above <controlName>_<eventName>

function HTDW_AddEventImplementation(sEventName, sEventFunctionName)

{

    if (eval ('typeof ' + sEventFunctionName) == 'function')

        this[sEventName] = eval(sEventFunctionName);

}



// utility functions

function allowInString (inString, refString)

{

    var index, tempChar;

    var strLength = inString.length;

    for (index=0; index < strLength; index++)

        {

        tempChar= inString.charAt (index);

        if (refString.indexOf (tempChar)==-1)  

            return false;

        }

    return true;

}



function DW_Trim(inString)

{

    var indexStart, indexEnd, tempChar, outString;

    var strLength = inString.length;

    // skip leading blanks

    for (indexStart=0; indexStart < strLength; indexStart++)

        {

        tempChar= inString.charAt (indexStart);

        if (tempChar != " ")

            break;

        }

    if (indexStart != strLength)

        {

        // skip trailing blanks

        for (indexEnd=strLength-1; indexEnd > 0; indexEnd--)

            {

            tempChar= inString.charAt (indexEnd);

            if (tempChar != " ")

                break;

            }

        // get all chars in between

        outString = inString.substring(indexStart, indexEnd+1);

        }

    else

        outString = "";

    return outString;

}

function DW_ChangeDecimalCharAndGroupCharToStd(inString)

{

   if(DW_decimalChar != ',')

   {

   	return inString;

   }

   	

   var outString = "";

   var index;

   for(index = 0;index < inString.length;index++)

   {

   	if(inString.charAt (index) == DW_decimalChar)

   	{

   	      outString += ".";

   	}

   	else if(inString.charAt (index) == DW_thousandsChar)

   	{

   		outString += ",";

   	}

   	else

   	{

	   	outString += inString.charAt (index);

	}

   }

   return outString;

}

function DW_ChangeDecimalCharAndGroupCharToStd2(inString)

{

   var outString = "";

   var index;

   for(index = 0;index < inString.length;index++)

   {

   	if(inString.charAt (index) == DW_decimalChar)

   	{

   	      outString += ".";

   	}

   	else if(inString.charAt (index) == DW_thousandsChar)

   	{

   		outString += "";

   	}

   	else

   	{

	   	outString += inString.charAt (index);

	}

   }

   return outString;

}

function DW_ChangeDecimalCharAndGroupCharToCurrent(inString)

{

   if(DW_decimalChar != ',')

   {

   	return inString;

   }

   	

   var outString = "";

   var index;

   for(index = 0;index < inString.length;index++)

   {

   	if(inString.charAt (index) == '.')

   	{

   	      outString += DW_decimalChar;

   	}

   	else if(inString.charAt (index) == ',')

   	{

   		outString += DW_thousandsChar;

   	}

   	else

   	{

	   	outString += inString.charAt (index);

	}

   }

   return outString;

}

function DW_Round(num, decPlaces)

{

	var powTen = Math.pow(10.0,decPlaces);

	num *= powTen;

	if (num >= 0)

	    num = Math.floor(num + 0.5);

	else

	    num = Math.ceil(num - 0.5);



    return num / powTen;

}



function DW_IsNonNegativeNumber(inString, bNilIsNull)

{

	if (arguments.length < 2)

			bNilIsNull = false;

		if (inString == "")

			return bNilIsNull;

		else

		{

			var newString = DW_Trim(inString);		

			if (newString == "")								

				return false; 										

			else														

			{														

				var result = new DW_NumberClass();	

				var newString = DW_ChangeDecimalCharAndGroupCharToStd(inString);

				if(DW_parseNumberStringAgainstMask(newString, result, false)) 	

				{													

					if (result.number >= 0) 							

						return true; 								

				}													

				

				return false; 									

			}														

		}

}



function DW_IsValidDisplayOrDataValue(inString, bNilIsNull)

{

    if (arguments.length < 2)

        bNilIsNull = false;

    if (inString == "")

        return bNilIsNull;

    else

        {

        var i;

        for(i = 0; i < this.displayValue.length; i++)

            {

            if (inString == this.displayValue[i])

                return true;		    

            if (inString == this.dataValue[i])

                return true;		    

            }

        return false;

        }

}



function DW_IsNumber(inString, bNilIsNull)

{

	if (arguments.length < 2)

			bNilIsNull = false;

		if (inString == "")

		{

	        if (typeof(goEditMaskManager) == "object")

	            return true;

	        else

			    return bNilIsNull;

		}

		else

		{

			var newString = DW_Trim(inString);		

			if (newString == "")		

				return false;		

			else			

			{

				newString = DW_ChangeDecimalCharAndGroupCharToStd(newString)

				return DW_parseNumberStringAgainstMask(newString, null, true); 

			}

		}

}



// exprContext class

function HTDW_exprContextClass(dataWindow)

{

    this.dw = dataWindow;

    this.row = -1;

    this.currentText = "";

}



// Col0 class

function HTDW_Col0Class(rowId, dwItemStatus)

{

    this.colModified = new Array();

    this.rowId = rowId;

    this.itemStatus = dwItemStatus;

}



// Row class

function HTDW_RowClass(rowId)

{

    var col;



    // column 0 holds special data

    this[0] = new HTDW_Col0Class(rowId, arguments[1]);

    

    // get data values

    for (col = 1; col < arguments.length - 1; col++)

        {

        this[0].colModified[col] = false;

        this[col] = arguments[col + 1];

        }



    this.numCols = arguments.length - 1;

}



function HTDW_Row_generateChange (rowNum, rowObj, pagingMode)

{

    var col;

    var result;



    if (pagingMode == DW_PAGING_XMLCLIENTSIDE &&

        (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW ||

         rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED))

        {

        result = "(InsertRow " + rowNum + " (";

        for (col = 1; col < rowObj.numCols; col++)

            {

            if (rowObj[col] == null)

                result += "(" + col + " 1)";

            else

                result += "(" + col + " 0 '" + escapeString(rowObj[col]) + "')";

            }

        result += "))";

        }

    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_MODIFIED ||

        rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED)

        {

        result = "(ModifyRow " + rowNum + " " + rowObj[0].rowId + " (";

        for (col = 1; col < rowObj.numCols; col++)

            {

            if (rowObj[0].colModified[col])

                {

                if (rowObj[col] == null)

                    result += "(" + col + " 1)";

                else

                    result += "(" + col + " 0 '" + escapeString(rowObj[col]) + "')";

                }

            }

        result += "))";

        }

    else

        result = "";



    return result;

}





function HTDW_Row_generateQuery (rowNum, rowObj)

{

    var col;

    var result;



    if (rowObj[0].itemStatus == DW_ITEMSTATUS_MODIFIED ||

        rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED)

        {

        result = "(Query " + rowNum + " " + rowObj[0].rowId + " (";

        for (col = 1; col < rowObj.numCols; col++)

            {

            if (rowObj[0].colModified[col])

                {

                if (rowObj[col] == null)

                    result += "(" + col + " 1)";

                else

                    result += "(" + col + " 0 '" + escapeString(rowObj[col]) + "')";

                }

            }

        result += "))";

        }

    else

        result = "";



    return result;

}

function HTDW_Row_generateQuerySort (rowNum, rowObj)

{

    var col;

    var result;



    if (rowObj[0].itemStatus == DW_ITEMSTATUS_MODIFIED ||

        rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED)

        {

        result = "(QuerySort " + rowNum + " " + rowObj[0].rowId + " (";

        for (col = 1; col < rowObj.numCols; col++)

            {

            if (rowObj[0].colModified[col])

                {

                if (rowObj[col] == null)

                    result += "(" + col + " 1)";

                else

                    result += "(" + col + " 0 '" + escapeString(rowObj[col]) + "')";

                }

            }

        result += "))";

        }

    else

        result = "";



    return result;

}





function HTDW_Row_dumpRow (rowNum, rowObj)

{

    var col;

    var result;



    result = "Row " + rowNum + "\n" + 

             "Modified:" + rowObj[0].itemStatus + "\n" +

             "RowId:" + rowObj[0].rowId + "\n" + 

             "NumCols:" + (rowObj.numCols - 1) + "\n";

             

    for (col = 1; col < rowObj.numCols; col++)

        {

        result += "   Col " + col + " modified:" + rowObj[0].colModified[col] + " '" + rowObj[col] + "'\n";

        }



    // alert (result);

    

    return result;

}



// set up class functions

HTDW_RowClass.generateChange = HTDW_Row_generateChange;



HTDW_RowClass.generateQuery = HTDW_Row_generateQuery;

HTDW_RowClass.generateQuerySort = HTDW_Row_generateQuerySort;



HTDW_RowClass.dumpRow = HTDW_Row_dumpRow;



function HTDW_ColumnGob(name, colNum, rowInDetail, region, bRequired, bNilIsNull, bFocusRect, bDDCalendar,

						formatFunc, getDisplayFormatFunc, getEditFormatFunc, column)

{

    this.name = name;

    this.colNum = colNum;

    this.rowInDetail = rowInDetail;

    this.region = region;

    this.bRequired = bRequired;

    this.bNilIsNull = bNilIsNull;

    this.bFocusRect = bFocusRect;

    this.bDDCalendar = bDDCalendar;

	this.bUseCodeTable = false;



    this.getDisplayFormat = getDisplayFormatFunc;

    this.getEditFormat = getEditFormatFunc;

    this.format = formatFunc;

    this.column = column;



    this.bEditStyleIsEditMask = false;

}



function HTDW_ComputeGob(name, region, computeFunc, formatFunc, getDisplayFormatFunc)

{

    this.name = name;

    this.region = region;



    this.compute = computeFunc;

    this.getDisplayFormat = getDisplayFormatFunc;

    this.format = formatFunc;

}



// Depend classes common function

// DependCompute class

function HTDW_DependComputeUpdate(htmlDw, row, bSkipCurrent)

{

    var gob = this.gob;

    var control = htmlDw.findControl(gob.name, row, gob.region == 0);



    if (control != null && typeof gob.compute == "function")

        {

        // body

        if (gob.region == 0)

            row = row;

        // header

        else if (gob.region == 1)

            row = htmlDw.firstRow;

        // footer or summary

        else if (gob.region == 2 || gob.region == 3)

            row = htmlDw.lastRow;



        var exprCtx = htmlDw.exprCtx;

        exprCtx.row = row;

        exprCtx.currentText = "";



        var value = gob.compute(exprCtx);



        if (control.type == "hidden" || control.type == "password" || 

            control.type == "text" || control.type == "textarea")

            {

            var displayValue;

            if (gob.format != null && gob.getDisplayFormat != null)

                {

                var formatString;

                if (typeof gob.getDisplayFormat == "string")

                    formatString = gob.getDisplayFormat;

                else

                    formatString = gob.getDisplayFormat (exprCtx);

                displayValue = gob.format (formatString, value, control);

                }

            else if (value != null)

                displayValue = value.toString();

            else

                displayValue = "";

            control.value = displayValue;

            }

        }

}



function HTDW_DependCompute(gob)

{

    this.gob = gob;

    

    this.update = HTDW_DependComputeUpdate;

}



// DependColumn class

function HTDW_DependColumnUpdate(htmlDw, row, bSkipCurrent)

{

    var gob = this.gob;

    var control = htmlDw.findControl(gob.name, row, gob.region == 0);



    // don't mess with the current control if asked not to

    if (control != null && 

            ! (bSkipCurrent && control == htmlDw.currentControl))

        {

        // body

        if (gob.region == 0)

	{

            //row = row + gob.rowInDetail;

	}

        // header

        else if (gob.region == 1)

            row = htmlDw.firstRow;

        // footer or summary

        else if (gob.region == 2 || gob.region == 3)

            row = htmlDw.lastRow;



        var value = htmlDw.rows[row][gob.colNum];



        if (control.type == "hidden" || control.type == "password" || 

            control.type == "text" || control.type == "textarea" ||

            control.type == "select-one")

            {

            var displayValue;

            if (gob.format != null && gob.getDisplayFormat != null)

                {

                var exprCtx = htmlDw.exprCtx;

                exprCtx.row = row;

                exprCtx.currentText = "";

                if (typeof gob.getDisplayFormat == "string")

                    formatString = gob.getDisplayFormat;

                else

                    formatString = gob.getDisplayFormat (exprCtx);

                displayValue = gob.format (formatString, value, control);

                }

            else if (value != null)

                displayValue = value.toString();

            else

                displayValue = "";

            control.value = displayValue;

            }

      else if(control.type == "checkbox")

         {

		 if (value != null)

             {  

				var displayValue;

				displayValue = value.toString();

				if ( (control.checked==true) &&  (displayValue!=control.value.toString()))

						control.checked=false;

				else if  ((control.checked==false) && (displayValue!=control.value.toString()))

						control.checked=true;



				control.value = displayValue;		

		     }	

         }



      else if(control.length>1)

     		if(control[0].type=="radio")		

		     {	

				var r;

				for (r=0;r<control.length;r++)

				{

					 displayValue = value.toString();

         				 if(control[r].value==displayValue && !(bSkipCurrent && control[r] == htmlDw.currentControl))

         			 	{

         					control[r].checked=true;

						}

					 

				 }

			

			}

         

        }

}



function HTDW_DependColumn(gob)

{

    this.gob = gob;



    this.update = HTDW_DependColumnUpdate;

}



// Column class

function HTDW_Column_addDepend(depend)

{

    if (this.dependents == null)

        this.dependents = new Array();



    this.dependents[this.dependents.length] = depend;

}



function HTDW_Column_updateDependents(htmlDw, row, bSkipCurrent)

{

    if (this.dependents != null)

        {

        for (var i=0; i < this.dependents.length; ++i)

            this.dependents[i].update (htmlDw, row, bSkipCurrent);

        }

}



function HTDW_ColumnClass(colId, name, convertFromStringFunc, typeValidationFunc, itemValidateFunc, validationMessageFunc, computeFunc, displayGobName)

{

    this.colId = colId;

    this.name = name;

    this.dependents = null;

    

    this.convertFromString = convertFromStringFunc;

    this.validateByType = typeValidationFunc;

    this.validateItem = itemValidateFunc;

    this.validationError = validationMessageFunc;

    this.compute = computeFunc;

    this.displayGobName = displayGobName;

    

    // interface functions

    this.addDepend = HTDW_Column_addDepend;

    this.updateDependents = HTDW_Column_updateDependents;



    this.displayValue = new Array();

    this.dataValue = new Array()

}



// DataWindow class

function HTDW_findControl(gobName, row, bInBody)

{

    var control = null;

    var controlExists;

    var controlName = gobName;

    var controlObject;



    if (bInBody)

        controlName += "_" + row;



    if (this.dataForm + "" != "undefined")

        {

        controlObject = 'this.dataForm.' + controlName;

        controlExists = eval('typeof ' + controlObject);

        if (controlExists == "object")

            control = eval(controlObject);

        else if(controlExists + "" == "undefined")

            {

            controlName = this.name + "_" + controlName;

            controlObject = 'this.dataForm.' + controlName;

            controlExists = eval('typeof ' + controlObject);

            if (controlExists == "object")

                control = eval(controlObject);

            }

        }

    else if (this.navLayerForms[0] + "" != "undefined") // try array of Netscape layered forms

        {

        var rowObj = this.rows[row];

        var index = 0;

        if (bInBody)

            index = row * (rowObj.numCols - 1); // skip over for search

        for( ; index < this.navLayerForms.length; index++)

             {

             if (this.navLayerForms[index].elements[0].name == controlName)

                 {

                 control = this.navLayerForms[index].elements[0];

                 break;

                 }

             }

        }

    else

        control = null;

        

    return control;

}



function HTDW_itemGainFocus(newRow,newCol,control,gob)

{

    var bRowChanged = false;

    var bNoFocusChange;

	var bReadOnlyControl = false;

	var bNegativeTabIndexControl = false;



    var nRTL = "";

    

    if ( "SELECT" != control.tagName && null != gob.bEditStyleIsEditMask && gob.bEditStyleIsEditMask )

    {

        nRTL = control.dir;

        

        if ( "" != nRTL )

        {

          control.setAttribute("DIR_SAVE", nRTL );

          control.dir = "LTR";

        }

    }



    // default arguments

    control.row = newRow;

    control.col = newCol;

    control.gob = gob;



    bNoFocusChange = this.bDisallowFocusChange;

    this.bDisallowFocusChange = false;

    // if in the middle of trying to force focus back

    // to a control, ignore all other focus stuff

	if (this.forcingBackFocusTo != null)

	    {

	    // check if we have made it back yet

	    if (this.forcingBackFocusTo == control)

	    {

    		this.forcingBackFocusTo = null;

    		this.currentControl = control;

	    	// can only programatically change border on IE4

	    	if (control.gob.bFocusRect && HTDW_DataWindowClass.isIE4)

	    	{

	    		this.currentControlBorder = control.style.borderStyle;

	    		control.style.borderStyle = "dotted";

	    	}

	    }

    	// don't do any other focus related stuff

    	return;

    	}



    // bail if we think that the current control already has focus

    // (Could happen if a button is pressed)

    if (this.currentControl == control &&

		!(this.currentControl.type == "hidden" || this.currentControl.type == "password" ||

		this.currentControl.type == "text" || this.currentControl.type == "textarea"))

        return;

	// check control attri

	if (control.readOnly + "" != "undefined")

		{

		bReadOnlyControl = control.readOnly;

		}

	if (control.tabIndex + "" != "undefined")

		{

		if(control.tabIndex < 0 )

			bNegativeTabIndexControl = true;

		}



	if (bNegativeTabIndexControl)

		{

		control.blur(); //don't allow focus.

		return;

		}



    // if the control is different from the current one and bNoFocusChange,

    if (this.currentControl != control && bNoFocusChange)

    {

        this.currentControl = control; //set currentcontrol so that later's losefocus can pass.

        // don't do any other focus related stuff

        return;

    }



    if (bReadOnlyControl && ( (control == null) || (control!=null && control.isdddw + "" != "1" ) ) )

    {

        this.currentControl = control; 

        // can only programatically change border on IE4

        if (control.gob.bFocusRect && HTDW_DataWindowClass.isIE4)

        {

            this.currentControlBorder = control.style.borderStyle;

        }

        return;

    }



    if (newRow != -1)

        {

        if (newRow != this.currRow)

            {

            bRowChanged = true;



			

            // row focus changing event

		this.nOutOfFocusRow = this.currRow;

            if (this.eventImplemented("RowFocusChanging") && !this.bSuppressItemGainFocusCallback)

                {

                var result ;

                if(this.autoEventBind)

                    result = _evtDefault(this.RowFocusChanging (this.currRow+1, newRow+1));

               else

                    result = _evtDefault(this.RowFocusChanging (this, this.currRow+1, newRow+1));

                // if 1 returned, don't allow focus to change (leave focus in last control to have gained focus

                if (result == 1)

                    {

                    this.restoreFocus();

                    // bail out early

                    return;

                    }

                }

			

            }

            

        this.currRow = newRow;

        this.actionRow = newRow;

        }

    if (newCol != -1)

        this.currCol = newCol;



    this.currentControl = control;



    // update the displayed value to be in editible form

    if (newRow != -1 && newCol != -1 && (this.currentControl.isdddw + "" == "undefined") &&

	    (this.currentControl.type == "hidden" || this.currentControl.type == "password" ||

		 this.currentControl.type == "text" ||this.currentControl.type == "textarea"))

        {

        var value = this.rows[newRow][newCol];

        var formatString = null;

        var displayValue;

        if (gob.format != null)

        {

            if (gob.getEditFormat != null)

                {

                if (typeof gob.getEditFormat == "string")

                    formatString = gob.getEditFormat;

                else

                    {

                    var exprCtx = this.exprCtx;

                    exprCtx.row = control.row;

                    exprCtx.currentText = "";

                    formatString = gob.getEditFormat (exprCtx);

                    }

                displayValue = gob.format (formatString, value, this.currentControl);

                if (typeof(goEditMaskManager) == "object" && gob.bEditStyleIsEditMask)

                    {

                    goEditMaskManager.OnClick(control, false);

                    if (value == null

                        && !(typeof(DW_FormatDate) == "function" && gob.format == DW_FormatDate)

                        && !(typeof(DW_FormatNumber) == "function" && gob.format == DW_FormatNumber))

                        displayValue = goEditMaskManager.oControl.value;

                    }

                }

            else if (value != null)

            {

               if((typeof value == "date" || typeof value == "number" ) 

               && gob.getDisplayFormat != null)

              {

				if (eval ('typeof ' + 'DW_FormatNumber' ) == 'function')

				{

					if (gob.format == DW_FormatNumber && (typeof gob.getDisplayFormat == "string" ) )

						displayValue = gob.format (gob.getDisplayFormat, value, this.currentControl);

					else

						displayValue = value.toString();

				}

				else

					displayValue = value.toString();

              }

              else

              {

                displayValue = value.toString();

              }

                

            }

            else

                displayValue = "";



            if (this.currentControl.value != displayValue)

            {

                this.currentControl.value = displayValue;

                this.currentControl.bChanged = true;

            }

        }

        else if ( value != null )

			{

            // Do not compare against Date/Time if no date fields have been defined

            if (!bDateTimeProcessingEnabled ||

               (value.toString != DW_DatetimeToString &&

                value.toString != DW_DateToString &&

                value.toString != DW_TimeToString))

                {

                displayValue = value.toString();

                if (this.currentControl.value != displayValue)

                    this.currentControl.value = displayValue;

                }

            }

        else

            {

                if (!(typeof(goEditMaskManager) == "object" && gob.bEditStyleIsEditMask && gob.getDisplayFormat == gob.getEditFormat))

                    this.currentControl.value = "";

            }



        // if Date or Datetime field, render dropdown calendar

        if (gob.bDDCalendar && document.getElementById(this.name + '_calFrame') != null)

            DW_NewCalendar(this, value, formatString);

        }



    // can only programatically change border on IE4

    if (control.gob.bFocusRect && HTDW_DataWindowClass.isIE4)

        {

        this.currentControlBorder = control.style.borderStyle;

        control.style.borderStyle = "dotted";

        }

        

    // show row focus indicator

	this.showRowFocusIndicator(this.currRow, true);



	



	if(this.bSuppressItemGainFocusCallback)

	{

		this.bSuppressItemGainFocusCallback = false;

		return;

	} 

    // row focus changed event

    if (bRowChanged && this.eventImplemented("RowFocusChanged"))

        {

        if(this.autoEventBind)

            this.RowFocusChanged (newRow+1)

        else

            this.RowFocusChanged (this, newRow+1)

        }

    // item focus changed event

    if (newCol != -1 && this.eventImplemented("ItemFocusChanged"))

        {

        if(this.autoEventBind)

           this.ItemFocusChanged (newRow+1, this.cols[newCol].name)

        else

            this.ItemFocusChanged (this, newRow+1, this.cols[newCol].name)

        }

	

}



function HTDW_itemLoseFocus(control)

{

	var bReadOnlyControl = false;

	var bNegativeTabIndexControl = false;

        var nRTL = "";

    

        nRTL = control.getAttribute("DIR_SAVE", nRTL );

	

        if ( "" != nRTL && null != nRTL )

        {      

          control.dir = nRTL;

        }

	

	this.bDisallowFocusChange = false;

	// check control attri

	if (control.readOnly + "" != "undefined")

		{

		bReadOnlyControl = control.readOnly;

		}

	if (control.tabIndex + "" != "undefined")

		{

		if( control.tabIndex < 0 )

			bNegativeTabIndexControl = true;

		}



	if (bNegativeTabIndexControl)

		{

		return 2;

		}



    // restore border

    // can only programatically change border on IE4

    if (control.gob.bFocusRect && HTDW_DataWindowClass.isIE4 && this.currentControl == control)

        control.style.borderStyle = this.currentControlBorder;



    // don't do validation if in the middle of forcing focus

    // due to validation error (endless loop could happen)

    if (this.forcingBackFocusTo != null)

        return 2;

    // to avoid repeated acceptText. For example, calling acceptText diretly might cause itemerror and

    // itemerror might cause alert msg box. then current control will lose focus asynchronously, where

    // acceptText will be called again.

    if (this.acceptControl == control)

        return 2;



    if (this.currentControl != control)

        {

       // alert("Focus problem! Control losing focus is not current control!");

        // fake it out

        this.currentControl = control;

        }

    this.bProcessingLoseFocus = true;

	var gob = control.gob;

	if (gob.getEditFormat != null)

	{

		if (typeof gob.getEditFormat == "string")

		gMask = gob.getEditFormat;

		else

		{

			var exprCtx = this.exprCtx;

			exprCtx.row = control.row;

			exprCtx.currentText = "";

			gMask = gob.getEditFormat (exprCtx);

		}

		

		// code table's edit format is a dummy "CodeTable" format for info.

		if (gob.bUseCodeTable)

			gMask = "";

	}





	this.nOutOfFocusRow = control.row;

	this.nOutOfFocusCol = control.col;

 // CLIENTEVENTS



    if (!control.bChanged && !bReadOnlyControl)  // check if Change misfired (losing focus beyond frame?)

        {

        var newValue;

        var row = control.row;

        var col = control.col;

        var rowObj = this.rows[row];

        var colObj = this.cols[col];



        if (control.type == "select-one")

            newValue = control.options[control.selectedIndex].value;

        else

            newValue = control.value;



        if (newValue == "")

            {

            if (control.gob.bNilIsNull)

				{

				if (rowObj[col] != null)

					control.bChanged = true;

				}

			else if (rowObj[col] != null && rowObj[col] != "")  // for inserts

				control.bChanged = true;

            }

        else if (colObj.convertFromString != null)

            {

            var convertedValue = null;

		    if (colObj.convertFromString == parseInt)

			{

				var reg = /,/g;

				var noComma = newValue.replace(reg, "");

				convertedValue = colObj.convertFromString (noComma, 10);

			}

			else

			{

				convertedValue = colObj.convertFromString (newValue);

                if (typeof(goEditMaskManager) == "object" && gob.bEditStyleIsEditMask && gob.getEditFormat)

                {

					if (typeof(DW_IsString)=="function" && colObj.validateByType==DW_IsString 

						&& typeof(convertedValue) == "string"

						&& convertedValue.replace(/^\s+/g, '') == "")

						convertedValue = null;

                }

			}



            if (convertedValue != null)

                {



                if (bDateTimeProcessingEnabled &&

                    (colObj.convertFromString == DW_DateParse ||

                     colObj.convertFromString == DW_DatetimeParse ||

                     colObj.convertFromString == DW_TimeParse))

                       {// it is datetime, use equals instead of ==

                       if(rowObj[col] == null || !rowObj[col].equals(convertedValue))

                         control.bChanged = true;

                       }

		    else if (

 				(rowObj[col] != null) &&

				(rowObj[col].equals + "" != "undefined") &&

				(typeof rowObj[col].equals == "function") &&

				(convertedValue.equals + "" != "undefined") &&

				(typeof convertedValue.equals == "function") &&

				(rowObj[col].equals + "" == convertedValue.equals + "") 

				)

			  control.bChanged = !convertedValue.equals(rowObj[col]);

                else if (rowObj[col] != convertedValue)

                    control.bChanged = true;

                }

            }

        else

            {

            if (rowObj[col] != newValue)

                control.bChanged = true;

            }

        }



    var result = this.AcceptText();



	gMask = "";



    if (result == 1)

        {

        // reformat the data

        var gob = control.gob;

        

        if(this.rows.length <= 0)

            return result;



        if(control.isdddw + "" == "1")

            return result;



        var value = this.rows[control.row][gob.colNum];

		

        if (control.type == "hidden" || control.type == "password" || 

            control.type == "text" || control.type == "textarea")

            {

            if (gob.format != null && value != null)

                {

                var displayValue;



                if (gob.getDisplayFormat != null)

                    {

                    var formatString;

                    if (typeof gob.getDisplayFormat == "string")

                        formatString = gob.getDisplayFormat;

                    else

                        {

                        var exprCtx = this.exprCtx;

                        exprCtx.row = control.row;

                        exprCtx.currentText = "";

                        formatString = gob.getDisplayFormat (exprCtx);

                        }

                    displayValue = gob.format (formatString, value, this.currentControl);

                    }

                else if (value != null)

                {

                    displayValue = value.toString( );

                }

                else

                    displayValue = "";

                this.currentControl.value = displayValue;

                }

            else if ( value != null )

                {

                // Do not compare against Date/Time if no date fields have been defined

                if (!bDateTimeProcessingEnabled ||

                    (value.toString != DW_DatetimeToString &&

                     value.toString != DW_DateToString &&

                     value.toString != DW_TimeToString))

                     this.currentControl.value = value.toString( );

                }

            else

                if (!(typeof(goEditMaskManager) == "object" && gob.bEditStyleIsEditMask && gob.getDisplayFormat == gob.getEditFormat))

                    this.currentControl.value = "";

            }

			

		if (this.pagingMode == DW_PAGING_XMLCLIENTSIDE)

			{

			var xmlRenderer = this.xmlRenderer;

			if ((xmlRenderer) && (xmlRenderer.bMozilla))

				{

				var detailList = xmlRenderer.dwXML.getElementsByTagName("detail");

				var cellNode = detailList[control.row].firstChild;                    

				while (cellNode)

					{

					if (cellNode.nodeName == xmlRenderer.divName + "_" + gob.name)

						{

						cellNode.textContent = this.currentControl.value;

						break;

						}

					cellNode = cellNode.nextSibling;

					}

				}

			}

        }

    this.bProcessingLoseFocus = false;

    return result;

}



function HTDW_selectControlContent(control)

{

	var bNegativeTabIndexControl = false;

	if(control != null)

		{

		if (control.tabIndex + "" != "undefined")

			{

			if( control.tabIndex < 0 )

				bNegativeTabIndexControl = true;

			}



		if(!bNegativeTabIndexControl)

			{

			control.select();

			}

		}

}



function HTDW_getChanges()

{

    var changes = "";



	if( this.bIsSlaveSharedDataWindow )

		return changes;



    var index, rowObj;

    for (index=0; index < this.rows.length; ++index)

        {

        rowObj = this.rows[index];

        if (rowObj != null)

            {

            if(this.dumpRow + "" != "undefined" && this.dumpRow == true)

                HTDW_RowClass.dumpRow (index, rowObj);



		if(this.bIsQueryMode==false)



	            changes += HTDW_RowClass.generateChange (index, rowObj, this.pagingMode);



		else if(this.bIsQuerySort && index==0 )

	            changes += HTDW_RowClass.generateQuerySort (index, rowObj);

		else

	            changes += HTDW_RowClass.generateQuery (index, rowObj);



            }

        }

    return changes;

}



function HTDW_itemError(row, col, exprCtx, bIsRequired)

{

    var colObj = this.cols[col];

    var result = 0;



    if(colObj + "" == "undefined")

        return;



	

    // item error event

    if (this.eventImplemented("ItemError"))

        {   

        if(this.autoEventBind)

            result = _evtDefault(this.ItemError (row+1, colObj.name, exprCtx.currentText));

        else

             result = _evtDefault(this.ItemError (this, row+1, colObj.name, exprCtx.currentText));

        }

	



    // map unknown results to 0

    if (result != 1 && result != 2 && result != 3)

        result = 0;

    if (result== 0 || result == 1)

        this.bDisallowFocusChange = true;

    if (result == 0)

        {

        var sMessage;

        if (colObj.validationError != null)

            sMessage = colObj.validationError (exprCtx);

        else if (bIsRequired)

            sMessage = "Value required for item '" + colObj.name + "'.";

        else

            sMessage = "Item '" + exprCtx.currentText + "' does not pass validation test.";



        alert (sMessage);

        }



    return result;

}



function HTDW_restoreFocus()

{

    if (this.currentControl != null)

        {

        var bDocHasFocus = true;

        var bIsDefined = false;

		

        if ( (document.hasFocus + "" != "undefined") && (this.currentControl.setActive + "" != "undefined") )

            bIsDefined = true;



        if ( bIsDefined )

            {

            bDocHasFocus = document.hasFocus();

            }



        if(bDocHasFocus == false)

            this.currentControl.setActive(); // CR323659

        else

            this.currentControl.focus();

        }

}



function HTDW_forceBackFocus(control, bDelay)

{

    if (control == null)

        return;

    this.forcingBackFocusTo = control;

    if (bDelay && window && window.setTimeout + "" != "undefined") // use timeout instead of calling focus in onblur, which might cause problem.

    {

        window.setTimeout(this.name + ".forceBackFocusTimeout()", 50);

    }

    else

        control.focus();

}





function HTDW_forceBackFocusTimeout()

{

    if (this.forcingBackFocusTo != null)

    {

        this.forcingBackFocusTo.focus();

    }

}





function HTDW_setCheckboxValue(control, chkValue, unchkValue)

{

    if (control.checked)

        control.value = chkValue;

    else

        control.value = unchkValue;

}



function HTDW_positionComboBox(control, cB)

{

	var cP = cB.offsetParent;

	var eL = 0;

	var eT = 0;



	for(var obj = control; obj && obj != cP; obj = obj.offsetParent)

	{

	    eL += obj.offsetLeft;

	    eT += obj.offsetTop;

	    if (obj.offsetParent && obj.offsetParent != cP)

		{

			eL -= obj.offsetParent.scrollLeft;

			eT -= obj.offsetParent.scrollTop;

		}

	}



	var eW = control.offsetWidth;

	var dW = cB.style.pixelWidth;

	var sL = cP.scrollLeft;



	if (eL + dW > cP.clientWidth + sL)

	    eL -= (dW - eW);



	var eH = control.offsetHeight;

	if(control.type == "text")

		eH += 2;

	var dH = cB.style.pixelHeight;

	var sT = cP.scrollTop;

	if (eT - dH >= sT && eT + eH + dH > cP.clientHeight + sT)

	    eT -= dH;

	else

	    eT += eH;

	cB.style.left = eL;

	cB.style.top = eT;

}



// Dropdown DataWindow

// Configurable parameters

var DDDW_SelectRowColor = "blue"; // background color of selected row

var DDDW_SelectTextColor = "white"; // text color of selected row

// end Configurable parameters



function HTDW_addDDDWOptions(dddw, aOptions)

{

	var i;

	if (dddw.options.length < aOptions.length)

	{

		var selection = dddw.options[0];

		for (i = 0; i < aOptions.length; i++)

		{

			if (aOptions[i][0] != selection.text)

			{

				var oOption = document.createElement("option");

				dddw.options.add(oOption, i);

				oOption.innerText = aOptions[i][0];

				oOption.value = aOptions[i][1];

			}

		}

	}

}



function HTDW_removeDDDWOptions(dddw)

{

	if (dddw.selectedIndex < 0)

		dddw.selectedIndex = 0;

	var selection = dddw.options[dddw.selectedIndex];

	dddw.options.length = 0;

	dddw.options[0] = selection;

}



function HTDW_overrideDDDWSelect(dddwSelect, newCol, dddwName)

{

	var dddw = document.getElementById(this.name + "_" + dddwName + "_dddw");



	if(dddw == null)

		return true;



	if (dddwSelect == document.elementFromPoint(window.event.clientX, window.event.clientY))

	{

		if (this.currentControl != null)

		{

			if (newCol == this.currentControl.col)

				dddw.blur();

		}

		return false;

	}

	return true;

}



function HTDW_setDDDWVisible(dddwName, bVisible, newRow, newCol, control, aOptions)

{

	var dddw = document.getElementById(this.name + "_" + dddwName + "_dddw");

	var dddwF = document.getElementById(this.name + "_" + dddwName + "_frame");

	if (dddw==null||dddwF==null) return;

	

	var dddwRows = document.getElementById(this.name + "_" + dddwName + "_dddw_rows");

	if ( (dddwRows!=null) &&(dddwRows.children.length<=0) )

	{

		this.currentDDDW_control = control;

		this.currentDDDW_newRow = newRow;

		this.currentDDDW_newCol = newCol;

		this.currentDDDW_aOptions = aOptions;

		this.performAction("DDDWCB|" + dddwName + "|");

		return;

	}



	var i;

	if (bVisible)

	{

		// display DDDW

		dddw.style.display = "block";

		this.positionComboBox(control, dddw);

		// display frame

		dddwF.style.width = dddw.offsetWidth;

		dddwF.style.height = dddw.offsetHeight;

		dddwF.style.top = dddw.style.top;

		dddwF.style.left = dddw.style.left;

		dddwF.style.zIndex = dddw.style.zIndex - 1;

		dddwF.style.display = "block";

		dddw.row = newRow;

		dddw.col = newCol;

		dddw.textbox = control;

		dddw.selectedRow = -1;

            if( control.options + "" == "undefined")

            {

    		    if (control.value != "")

		    {

			for (i = 0; i < aOptions.length; i++)

			{

				if (aOptions[i][0] == control.value)

				{

					dddw.selectedRow = i;

					break;

				}

			}

		    }

            }

            else

            {

		    var selection = control.options[0];

    		    if (selection.text != "")

		    {

			for (i = 0; i < aOptions.length; i++)

			{

				if (aOptions[i][0] == selection.text)

				{

					dddw.selectedRow = i;

					break;

				}

			}

		    }

            }

		dddw.focus();

	}

	else

	{

		// hide

		dddw.style.display = "none";

		dddwF.style.display = "none";



		// deselect row after hiding

		var gob = dddw.textbox.gob;

		var rowElement = gob.dddw_selectedRowElement;

		if (rowElement != null)

		{

			rowElement.style.backgroundColor = gob.dddw_bgColors[0];

			rowElement.style.color = gob.dddw_txtColors[0];

			for(i = 0; i < rowElement.all.length; i++)

			{

				rowElement.all(i).style.backgroundColor = gob.dddw_bgColors[i+1];

				rowElement.all(i).style.color = gob.dddw_txtColors[i+1];

			}

			gob.dddw_selectedRowElement = null;

		}

	}

}



function HTDW_scrollDDDW(dddwControl, dddwObj)

{

	var row = dddwControl.selectedRow;

	var i;



	if (row < 0)

	{

		// scroll to top

		dddwControl.scrollTop = 0;

		return;

	}

	var rowElementId = dddwObj + "_detail_" + row.toString();

	var rowElement = dddwControl.all[rowElementId];

	var oneRowElement = null;

	if (rowElement.length + "" != "undefined")

		oneRowElement = rowElement[0];

	else

		oneRowElement = rowElement;



	// scroll

	dddwControl.scrollTop = oneRowElement.offsetTop;



	// save row element

	var gob = dddwControl.textbox.gob;

	gob.dddw_selectedRowElement = oneRowElement;



	// select row

	gob.dddw_bgColors[0] = oneRowElement.style.backgroundColor;

	gob.dddw_txtColors[0] = oneRowElement.style.color;

	oneRowElement.style.backgroundColor = DDDW_SelectRowColor;

	oneRowElement.style.color = DDDW_SelectTextColor;

	for(i = 0; i < oneRowElement.all.length; i++)

	{

		gob.dddw_bgColors[i+1] = oneRowElement.all(i).style.backgroundColor;

		gob.dddw_txtColors[i+1] = oneRowElement.all(i).style.color;

		oneRowElement.all(i).style.backgroundColor = DDDW_SelectRowColor;

		oneRowElement.all(i).style.color = DDDW_SelectTextColor;

	}

}



function HTDW_setDDDWItem(dddwGobName, dddwObjName, row, aOptions)

{

	var dddw = document.getElementById(this.name + "_" + dddwGobName + "_dddw");

	var gob = dddw.textbox.gob;

	var rowElement = gob.dddw_selectedRowElement;

	var i;



	// deselect old row

	if (rowElement != null)

	{

		rowElement.style.backgroundColor = gob.dddw_bgColors[0];

		rowElement.style.color = gob.dddw_txtColors[0];

		for(i = 0; i < rowElement.all.length; i++)

		{

			rowElement.all(i).style.backgroundColor = gob.dddw_bgColors[i+1];

			rowElement.all(i).style.color = gob.dddw_txtColors[i+1];

		}

	}



	// get new selection

	var rowElementId = dddwObjName + "_detail_" + row.toString();

	rowElement = dddw.all[rowElementId];

	var oneRowElement = null;

	if (rowElement.length + "" != "undefined")

		oneRowElement = rowElement[0];

	else

		oneRowElement = rowElement;



	// save row

	gob.dddw_selectedRowElement = oneRowElement;



	// select row

	gob.dddw_bgColors[0] = oneRowElement.style.backgroundColor;

	gob.dddw_txtColors[0] = oneRowElement.style.color;

	oneRowElement.style.backgroundColor = DDDW_SelectRowColor;

	oneRowElement.style.color = DDDW_SelectTextColor;

	for(i = 0; i < oneRowElement.all.length; i++)

	{

		gob.dddw_bgColors[i+1] = oneRowElement.all(i).style.backgroundColor;

		gob.dddw_txtColors[i+1] = oneRowElement.all(i).style.color;

		oneRowElement.all(i).style.backgroundColor = DDDW_SelectRowColor;

		oneRowElement.all(i).style.color = DDDW_SelectTextColor;

	}



	// set item

      var selectedValue = aOptions[row];



      if( dddw.textbox.options + "" == "undefined")

      {

	    dddw.textbox.value = selectedValue[0];

	    dddw.textbox.dwdatavalue = selectedValue[1];

      }

      else

      {

	    dddw.textbox.options.length = 0;

	    var oOption = document.createElement("option");

	    dddw.textbox.options.add(oOption);

	    oOption.innerText = selectedValue[0];

	    oOption.value = selectedValue[1];

      }



	if(dddw.selectedRow != row)

	{

		dddw.textbox.bChanged = true;

		this.AcceptText();

	}

	// wait a moment so new SelectRow can be seen

	window.setTimeout(this.name + ".setDDDWVisible('" + dddwGobName + "',false)", 200);

}



alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

digits = "0123456789";



function isalpha(c) 

{ 

	return alphas.indexOf(c) >= 0; 

}



function isdigit(c) 

{ 

	return digits.indexOf(c) != -1;

} 



function isalnum(c)

{

	return isalpha(c)||isdigit(c);

}



function DWQRY_isropkey(text)

{

	var temp=text.toLocaleUpperCase();

	if(temp=="AND" || temp=="OR")

		return true;

	else 

		return false;

}



function DWQRY_isopkey(text)

{

	if(text=="=" || text=="<" || text==">" || text=="<>" || text=="<=" || text == ">=" )

		return true;

	else 

		return false;

}



function DWQRY_FindFirstNonNumericalPos(inString)

{

    var index, tempChar="", tempPrevChar="";

    var strLength = inString.length;

    var foundExpForm = false;

    var foundDecimalForm = false;

    

    for (index=0; index < strLength; index++)

    {

		tempPrevChar=tempChar;

        tempChar= inString.charAt (index);

        if(tempChar=="E" || tempChar=="e")

        {

			if(foundExpForm)

				return index;

			else if(tempPrevChar=="")

				return index;

			else if(!isdigit(tempPrevChar))

				return index;

			else 

				foundExpForm = true;

		}

		else if(tempChar==".")

		{

			if(foundDecimalForm||foundExpForm)

				return index;

			else

				foundDecimalForm = true;

		}

		else if(tempChar=="+" || tempChar=="-")

		{

			if(tempPrevChar!="")

				if(tempPrevChar!="E" && tempPrevChar!="e")

					return index;

		}

		else if(!isdigit(tempChar))

		{

			return index;

		}

		

	}

	return index;

}



function DWQRY_FindFirstNonStringPos(inString)

{

    var index, tempChar="";

    var strLength = inString.length;

    

    for (index=0; index < strLength; index++)

    {

        tempChar= inString.charAt (index);

        if(!isalnum(tempChar) && tempChar!="_" && tempChar!="#" && tempChar!="$")

			return index;

	}

	return index;

}



function DWQRYTokenizer_gettoken()

{

	this.buffer = DW_LeftTrim(this.buffer);

	

	if(this.buffer=="")

	{

		this.curtoktype="END";

		this.curtok="";	

		this.buffer="";	

	}

	else if(this.buffer.substr(0,1)=="(" )

	{

		this.curtoktype="OPAREN";

		this.curtok="(";

		this.buffer=this.buffer.substr(1);

	}

	else if(this.buffer.substr(0,1)==")" )

	{

		this.curtoktype="CPAREN";

		this.curtok=")";

		this.buffer=this.buffer.substr(1);

	}

	else if(this.buffer.substr(0,2)=="<="  )

	{

		this.curtoktype="SPECIAL";

		this.curtok="<=";

		this.buffer=this.buffer.substr(2);

	}

	else if(this.buffer.substr(0,2)==">="  )

	{

		this.curtoktype="SPECIAL";

		this.curtok=">=";

		this.buffer=this.buffer.substr(2);

	}

	else if(this.buffer.substr(0,2)=="<>"  )

	{

		this.curtoktype="SPECIAL";

		this.curtok="<>";

		this.buffer=this.buffer.substr(2);

	}

	else if(this.buffer.substr(0,1)=="<"  )

	{

		this.curtoktype="SPECIAL";

		this.curtok="<";

		this.buffer=this.buffer.substr(1);

	}

	else if(this.buffer.substr(0,1)==">"  )

	{

		this.curtoktype="SPECIAL";

		this.curtok=">";

		this.buffer=this.buffer.substr(1);

	}

	else if(this.buffer.substr(0,1)=="="  )

	{

		this.curtoktype="SPECIAL";

		this.curtok="=";

		this.buffer=this.buffer.substr(1);

	}

	else if(this.buffer.substr(0,1)=="\"" && (this.buffer.indexOf("\"",1)>=1) )

	{

		var newpos=this.buffer.indexOf("\"",1);

		this.curtoktype="DQUOTE";

		this.curtok=this.buffer.substring(1,newpos);

		this.buffer=this.buffer.substr(newpos+1);	

	}

	else if(isdigit(this.buffer.substr(0,1)))

	{

		var newpos=DWQRY_FindFirstNonNumericalPos(this.buffer);

		this.curtoktype="NUMBER";

		this.curtok=this.buffer.substring(0,newpos);	

		this.buffer=this.buffer.substr(newpos);	

	}

	else if(this.buffer.substr(0,1)==".")

	{

		var newpos=DWQRY_FindFirstNonNumericalPos(this.buffer);

		this.curtoktype="NUMBER";

		this.curtok=this.buffer.substring(0,newpos);	

		this.buffer=this.buffer.substr(newpos);	

	}

	else if(this.buffer.substr(0,1)=="+")

	{

		var newpos=DWQRY_FindFirstNonNumericalPos(this.buffer);

		this.curtoktype="NUMBER";

		this.curtok=this.buffer.substring(0,newpos);	

		this.buffer=this.buffer.substr(newpos);	

	}

	else if(this.buffer.substr(0,1)=="-")

	{

		var newpos=DWQRY_FindFirstNonNumericalPos(this.buffer);

		this.curtoktype="NUMBER";

		this.curtok=this.buffer.substring(0,newpos);	

		this.buffer=this.buffer.substr(newpos);	

	}

	else if(this.buffer.substr(0,1)==",")

	{

		this.curtoktype="SPECIAL";

		this.curtok=",";

		this.buffer=this.buffer.substr(1);

	}

	else if(isalpha(this.buffer.substr(0,1)))

	{

		var newpos=DWQRY_FindFirstNonStringPos(this.buffer);

		this.curtoktype="NAME";

		this.curtok=this.buffer.substring(0,newpos);	

		this.buffer=this.buffer.substr(newpos);	

	}

	else

	{

		this.curtoktype = "SPECIAL";

		this.curtok=this.buffer.substring(0,1);	

		this.buffer=this.buffer.substr(1);			

	}

}



function DWQRYTokenizer_token(tokentype)

{

	if(this.curtok=="")

	{

		this.gettoken();

	}

	if(this.curtoktype==tokentype)

	{

		var temp = this.curtok;

		this.curtok = "";

		return temp;

	}

	else

	{

		return "";

	}

}



function DWQRYTokenizer_checktoken(tokentype)

{

	if(this.curtok=="")

	{

		this.gettoken();

	}

	if(this.curtoktype==tokentype)

	{

		this.curtok = "";

		return true;

	}

	else

	{

		return false;

	}

}



function DWQRYTokenizer(text)

{

	this.buffer=text.toLocaleUpperCase();

	this.curtok="";

	this.curtoktype="";

	

	this.checktoken=DWQRYTokenizer_checktoken;

	this.token=DWQRYTokenizer_token;

	this.gettoken=DWQRYTokenizer_gettoken;

}



function HTDW_validateQueryCriterion(text,columnType,curRow,curCol)

{

	var tokenizer=new DWQRYTokenizer(text);

	var word = tokenizer.token("NAME");

	var word1 = "";

	var bOp = false;

	var bHavePart = false;

	var bIn = false;

	

	if(word!="")

	{

		if(DWQRY_isropkey(word))

		{

			var index, index2, rowObj;

			var bFoundNonEmptyCell=false;



			rowObj = this.rows[curRow];

			for(index=curCol-1;index>=1;--index)

				if(rowObj[index]!=null&&rowObj[index]!="")

				{

					bFoundNonEmptyCell=true;					

					break;

				}

					

			if(!bFoundNonEmptyCell)

			{

				var topCheckedRow = 0;

				if(this.bIsQuerySort)

					topCheckedRow = 1;					

				for (index=curRow-1; index>=topCheckedRow ; --index)

				{

					rowObj = this.rows[index];

					for(index2=1; index2<rowObj.numCols;++index2)

					{

						if(rowObj[index2]!=null&&rowObj[index2]!="")

						{

							bFoundNonEmptyCell=true;					

							break;

						}

					}

				}

			}



			if(!bFoundNonEmptyCell)

				return false;



			word = tokenizer.token("NAME");		

			word = word.toLocaleUpperCase();	

			

			if(word!="")

			{

				if(word == "LIKE")

				{

					bOp = true;

				}

				

				if(word == "NOT")

				{

					word1 = tokenizer.token("NAME");		

					word1 = word.toLocaleUpperCase();	

					

					if(word1=="LIKE")

					{

						bOp = true;

					}

					else

					{

						bHavePart = true;

					}

				}

				else

				if(word=="IN")

				{

					bOp=true;

					bIn=true;

				}

				else

				{

					bHavePart=true;

				}	

			}

		}

		else

		if(word == "LIKE")

		{

			bOp = true;

		}

		else

		if(word == "NOT")

		{

			word1 = tokenizer.token("NAME");		

			word1 = word.toLocaleUpperCase();	

					

			if(word1=="LIKE")

			{

				bOp = true;

			}

			else

			{

				bHavePart = true;

			}

		}

		else

		if(word=="IN")

		{

			bOp=true;

			bIn=true;

		}

		else

		{

			bHavePart=true;

		}	

	}

	if(word=="" && !bOp)

	{

		word = tokenizer.token("SPECIAL");

		if(word!="")

		{

			if(DWQRY_isopkey(word))

			{

				bOp=true;

			}

			else if(word=="+" || word=="-")

			{

				++this.curpos;

			}

			else

			{

				return false;

			}

		}

	}

	//if(!bOp)

	//{

	//}

	if(bIn)

	{

		if(!tokenizer.checktoken("OPAREN"))

		{

			return false;

		}

		while(1)

		{

			if(columnType=="NUMBER")

			{

				word = tokenizer.token("NUMBER");

				if(word=="")

					return false;

			}

			else

			{

				word = tokenizer.token("NAME");

				if(word=="")

					word = tokenizer.token("DQUOTE");

				if(word=="")

					return false;

					

			}

			word = tokenizer.token("SPECIAL");

			if(word!="")

			{

				if(word!=",")

				{

					return false;

				}

			}

			else

			{

				if(!tokenizer.checktoken("CPAREN"))

					return false;

				break;

				

			}

		}

		if(tokenizer.checktoken("END"))

		{

			return true;

		} 

		else

		{

			return false;

		}

	}

	if(bHavePart)

	{

		if(columnType=="NUMBER")

		{

			return false;

		}

		else

		{

			return true;

		}

	}

	if(columnType=="NUMBER")

	{

		word = tokenizer.token("NUMBER");

		if(word!="")

		{

			if(tokenizer.checktoken("END"))

			{

				return true;

			} 

			else

			{

				return false;

			}

		}

	}

	word = tokenizer.token("DQUOTE");

	if(word!="")

	{

		if(tokenizer.checktoken("END"))

		{

			return true;

		} 

		else

		{

			return false;

		}

	}

	return true;

}







function HTDW_acceptText()

{

    // nothing to do if no current control

    if (this.currentControl == null)

        return 1;

        

    if(this.rows + "" == undefined)

        return 1;



    if(this.rows == null)

        return 1;



    if(this.rows.length == 0)

        return 1;



    var control = this.currentControl;

    var row = control.row;

    var col = control.col;

    var bRequired = control.gob.bRequired;

    var colObj = this.cols[col];

    var bIsValid = true;

    var exprCtx = this.exprCtx;

    var validAction = 2;  // default to accept

    var newValue;

    var oldValue=exprCtx.currentText;

	var bDataValueChanged = control.bChanged;



    var gob = control.gob;

    if (gob.getEditFormat != null)

    {

      if (typeof gob.getEditFormat == "string")

        gMask = gob.getEditFormat;

      else

      {

        exprCtx.row = control.row;

        exprCtx.currentText = "";

        gMask = gob.getEditFormat (exprCtx);

      }

      // code table's edit format is a dummy "CodeTable" format for info.

      if (gob.bUseCodeTable)

        gMask = "";

    }

    else  

      gMask = "";

    if (control.type == "select-one")

    {

	if(control.selectedIndex<=-1)

		return 1;

        newValue = control.options[control.selectedIndex].value;

        if(oldValue==newValue)

			return 1;

    }

    else if(control.isdddw + "" != "undefined")

    {

        if(control.dwdatavalue + "" == "undefined")

            return 1;

        if(control.dwdatavalue == null)

            return 1;

        if(control.dwdatavalue == "")

            return 1;

        newValue = control.dwdatavalue;

        if(oldValue==newValue)

			return 1;

    }

    else

    {

        newValue = control.value;

    }



    // to avoid accepttext is called recursively since we might fire event below and there accepttext might be called again in dw .net and pb .net

    if (this.acceptControl == control)

        return 1;

    this.acceptControl = control;		

    exprCtx.row = row;

    exprCtx.currentText = newValue;

	

    if (this.pagingMode == DW_PAGING_XMLCLIENTSIDE)

		{

        var xmlRenderer = this.xmlRenderer;

        if ((xmlRenderer) && (!xmlRenderer.bMozilla))

			{	

            var detailList = xmlRenderer.dwXML.getElementsByTagName("detail");

            var cellNode = detailList.item(control.row).firstChild;

            while (cellNode)

				{

                if (cellNode.nodeName == xmlRenderer.divName + "_" + gob.name)

					{

                    var currentValue = DW_Trim(this.currentControl.value);

                    var nodeText = DW_Trim(cellNode.text);

                    if (nodeText != currentValue)

						{

                        cellNode.text = this.currentControl.value;

                        

                        if ((control.bChanged != false) && (control.bChanged != true))

                            control.bChanged = true;

						}

                    break;

					}

                cellNode = cellNode.nextSibling;

				}

			}

		}     // check if value required

    if (bRequired && ! control.bChanged)

        {

        if (this.rows[row][col] == null)

            validAction = this.itemError (row, col, exprCtx, true);

        }

    else if (bRequired && control.gob.bNilIsNull && newValue == "")

        validAction = this.itemError (row, col, exprCtx, true);



    if (control.bChanged)

        {

        var dataValue  = newValue;

        if (bIsValid && colObj.validateByType != null)



		

		if(this.bIsQueryMode && !this.bIsQuerySort)

		{

			var colType="";

			if(colObj.validateByType==DW_IsNumber)

				colType=="NUMBER"

			if(colObj.validateByType==DW_IsNonNegativeNumber)

				colType=="NUMBER"

			bIsValid = this.ValidateQueryCriterion(newValue,colType,row,col);

		}

		else if(this.bIsQueryMode && this.bIsQuerySort && row>= 1)

		{

			var colType="";

			if(colObj.validateByType==DW_IsNumber)

				colType=="NUMBER"

			if(colObj.validateByType==DW_IsNonNegativeNumber)

				colType=="NUMBER"

			bIsValid = this.ValidateQueryCriterion(newValue,colType,row,col);

		}

		else if(this.bIsQueryMode && this.bIsQuerySort )

			bIsValid = true;

		else



	            bIsValid = colObj.validateByType(newValue, control.gob.bNilIsNull);



       if (!(control.gob.bNilIsNull && newValue == "") && colObj.convertFromString != null)

           {// get the data value instead of value with format.

           var tempDataValue;

           if (colObj.convertFromString == parseInt)

               tempDataValue = colObj.convertFromString (newValue, 10);

           else

               tempDataValue = colObj.convertFromString (newValue);

           if (tempDataValue != null)

               dataValue = tempDataValue.toString();

               

			var colType="";

			if (typeof(DW_FloatParse)=="function" && (colObj.convertFromString==DW_FloatParse || colObj.convertFromString==DW_IntParse))

				colType = "NUMBER";

			else if (typeof(DW_StringParse)=="function" && colObj.convertFromString==DW_StringParse)

				colType = "STRING";

			else if (typeof(DW_DateParse)=="function" && (colObj.convertFromString==DW_DatetimeParse || colObj.convertFromString==DW_DateParse || colObj.convertFromString==DW_TimeParse))

				colType = "DATETIME";

				

			if (tempDataValue == null && this.rows[row][col] == null)

				bDataValueChanged = false;

			else if (tempDataValue != null && this.rows[row][col] != null)

				{

				if ((colType == "NUMBER" || colType == "STRING") && tempDataValue == this.rows[row][col])

					bDataValueChanged = false;

				else if (colType == "DATETIME" 

					&& (typeof(tempDataValue) == "object" && typeof(this.rows[row][col]) == "object")

					&& dataValue == this.rows[row][col].toString())

					bDataValueChanged = false;

				}

			else if (tempDataValue != null && this.rows[row][col] == null

			    && typeof(goEditMaskManager) == "object" && control.gob.bEditStyleIsEditMask)

				{

				if (colType == "NUMBER" && tempDataValue == 0)

					bDataValueChanged = false;

				if (colType == "DATETIME" && tempDataValue.year==0 && tempDataValue.month==0 && tempDataValue.day==0 && tempDataValue.hour==0 && tempDataValue.min==0 && tempDataValue.sec == 0 && tempDataValue.msec==0)

					bDataValueChanged = false;

				}

           }



        if (bIsValid && colObj.validateItem != null)



		if(!this.bIsQueryMode)



			{//in validatation expression, gettext() use unformatted text to do the validation

			    exprCtx.currentText = dataValue;

	            bIsValid = colObj.validateItem (exprCtx);

			    exprCtx.currentText = newValue;

	        }



		

        // item changed event

        if (bIsValid && bDataValueChanged && this.eventImplemented("ItemChanged"))

            {

		if(this.bDwDotNet  && gob.bEditStyleIsEditMask) 

			this.strRawNewValue = dataValue;

		else

			this.strRawNewValue = newValue;

            if(this.autoEventBind)

                validAction = _evtDefault(this.ItemChanged (row+1, colObj.name, this.bDwDotNet ? dataValue : newValue));

            else

                validAction = _evtDefault(this.ItemChanged (this, row+1, colObj.name, this.bDwDotNet ? dataValue : newValue));

            // map unknown results to 0

            if (validAction != 1 && validAction != 2)

                validAction = 0;

            // map itemChanged action codes to itemError action codes

            if (validAction == 0) // accept value

                validAction = 2;

            else

                {

                bIsValid = false;

                if (validAction == 1) // reject value, no focus change

                    validAction = 1;

                else // reject value, allow focus change

                    validAction = 3;

                }

            }

		



        if (!bIsValid && bDataValueChanged)

            validAction = this.itemError (row, col, exprCtx, false);



        if (validAction == 2)

            {

            var rowObj = this.rows[row];



		if(this.bIsQueryMode)

		{

			if (rowObj[col] != newValue)

                 	{

				rowObj[col] = newValue;

				if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED && rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

					this.modifiedCount++;	    

				rowObj[0].colModified[col] = true;		    

				if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

					rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

				else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

					rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

			}

		}

		else



            if (control.gob.bNilIsNull && newValue == "")

                {

                if (rowObj[col] != null)

                    { 

                    rowObj[col] = null;

                    if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                        rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

                        this.modifiedCount++;

                    rowObj[0].colModified[col] = true;		    

                    if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

                    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

                    }

                }

            else if (colObj.convertFromString != null)

                {

				var convertedValue;

				if (colObj.convertFromString == parseInt)

					convertedValue = colObj.convertFromString (newValue, 10);

				else

					convertedValue = colObj.convertFromString (newValue);



                if (rowObj[col] != convertedValue && bDataValueChanged)

                    {

                    rowObj[col] = convertedValue;

                    if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                        rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

                        this.modifiedCount++;	    

                    rowObj[0].colModified[col] = true;		    

                    if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

                    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

                    }

                }

            else

                {

                if (rowObj[col] != newValue  && bDataValueChanged)

                    {

                    rowObj[col] = newValue;

                    if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                        rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

                        this.modifiedCount++;	    

                    rowObj[0].colModified[col] = true;		    

                    if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

                    else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                        rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

                    }

                }

            control.bChanged = false;

            // skip current control

            colObj.updateDependents(this, row, true);           

            

            this.refreshSharedDataWindows(row,col);

            

            }

        }



    // force focus back if an error (focus change will happen after we return!)

    if (validAction < 2)

        {

        this.forceBackFocus(control, this.bProcessingLoseFocus ? true : false);

        }



    var result = (validAction < 2) ? -1 : 1;

    this.acceptControl = null; // clear the acceptControl before return.

    return result;

    // this return will only be used if we are not an input form

    return 1;

}



// if false returned, don't allow focus to change or action to happen (leave focus in last control to have gained focus

function HTDW_itemClicked(row, col, objName, bandID, group)

{

    var evtResult = 0;



    // CR228156 - click on DDDW column fires a validation error in IE5.x - Partha

    if (this.currentControl != null)

    {

	if ( this.currentControl.type == "select-one" )

	{

	    if ( HTDW_DataWindowClass.isIE4 

		&& this.currentControl.gob.bRequired == true 

		&& this.currentControl.value == "" )

            	return false ;

	    else 

		if (this.AcceptText() != 1)

			return false;



	}

    	else if (this.currentControl.type == "checkbox" 

		|| this.currentControl.type == "radio" 

		|| this.currentControl.type == "select-multiple" )

	{

        	if (this.AcceptText() != 1)

			return false;

	}

    }



	if ((this.processing == 8 || this.processing == 9) && (bandID == 4 || bandID == 0) && this.bSelectNodeByMouse)

		this.SelectTreeNode(row + 1, group + 1, true);



    this.nNonDetailRow = 0;     

    if(this.bDwDotNet && (bandID != 0))

    {

        if(bandID >= 4)

            this.nNonDetailRow = row + 1;

        row = -1;

        col = 0;

    }

    

    this.clickedRow = row;

    this.clickedCol = col;



    if (this.eventImplemented("Clicked"))

        {

        if(this.autoEventBind)

            evtResult = _evtDefault(this.Clicked (row+1, objName));

        else

             evtResult = _evtDefault(this.Clicked (this, row+1, objName));

        }



    // prevent clicked event from bubbling up in IE4 or higher

    if (HTDW_DataWindowClass.isIE4)

        window.event.cancelBubble = true;



    if (row > -1)

	    if(this.allColumnsAreProtected+ "" != "undefined" && this.allColumnsAreProtected == true )

	    {

            if (this.eventImplemented("RowFocusChanging"))

            {

                if(this.currRow != row)

                {

                    var result ;

                    result = 0;                

                    if(this.autoEventBind)

                        result = _evtDefault(this.RowFocusChanging (this.currRow+1, row+1));

                    else

                        result = _evtDefault(this.RowFocusChanging (this, this.currRow+1, row+1));

                        // if 1 returned, don't allow focus to change (leave focus in last control to have gained focus

                        

                    if (result == 1)

                        return false;

                }

            }

	    

	        this.showRowFocusIndicator(row, true);

	        this.currRow = row;

	        

            if (this.eventImplemented("RowFocusChanged"))

            {

                if(this.autoEventBind)

                    this.RowFocusChanged (row+1)

                else

                    this.RowFocusChanged (this, row+1)

            }       

        }

    

    return evtResult != 1;

}



function HTDW_itemDoubleClicked(row, col, objName, bandID)

{

    var evtResult = 0;



    if(row < 0 && this.clickedRow >= 0)

    {

        row = this.clickedRow;         

    }



    if (this.eventImplemented("DoubleClicked"))

        {

        if(this.autoEventBind)

            evtResult = _evtDefault(this.DoubleClicked (row+1, objName));

        else

             evtResult = _evtDefault(this.DoubleClicked (this, row+1, objName));

        }



    // prevent clicked event from bubbling up in IE4 or higher

    if (HTDW_DataWindowClass.isIE4)

        window.event.cancelBubble = true;



    return evtResult != 1;

}



function HTDW_itemRButtonDown(row, col, objName, bandID)

{

	if(window.event.button!=2)

		return;

		

    var evtResult = 0;

         

    if(this.bDwDotNet && (bandID == 1 || bandID == 2 || bandID == 3))

        row = -1;

    if (this.eventImplemented("RButtonDown"))

        {

        if(this.autoEventBind)

            evtResult = _evtDefault(this.RButtonDown (row+1, objName));

        else

             evtResult = _evtDefault(this.RButtonDown (this, row+1, objName));

        }



    // prevent clicked event from bubbling up in IE4 or higher

    if (HTDW_DataWindowClass.isIE4)

        window.event.cancelBubble = true;



    this.clickedRow = row;

    this.clickedCol = col;

    

    return evtResult != 1;

}







function dotNetAjaxCSSHandler(sStyle, objName)

{

    for(var i = 0; i < document.styleSheets.length; i++)

    {

        styleSheet = document.styleSheets[i];	

        if(styleSheet.owningElement.id == objName + "_stylesheet")

        {

            styleSheet.cssText = sStyle;// refresh the stylesheet.	    

	    document.getElementsByTagName("head")[0].appendChild(styleSheet.owningElement);

            break;

        }	

    }

}



function dotNetAjaxScptHandler(sScpt)

{

    var scpt = document.createElement('script');

    scpt.type = 'text/javascript';

    scpt.src = sScpt;

	document.getElementsByTagName("head")[0].appendChild(scpt);



}





function HTDW_htmlCallbackHandler(eventResult, dwObj)

{

    var sindex, eindex, htmlindex, i;

    var stylestr, htmlstr, tempstr, beginscripts, endscripts, rslt;

    var divSTag, divETag, styleSTag, styleETag, scriptSTag, scriptETag;

    var scriptEle, dwContainerEle;

    

    rslt = eventResult;

    divSTag = "<" + "DIV";

    divETag = "<" + "/DIV>";

    styleSTag = "<" + "STYLE";

    styleETag = "<" + "/STYLE>";

    scriptSTag = "<" + "SCRIPT";

    scriptETag = "<" + "/SCRIPT>";

    // extract the style sheet from rslt;

    sindex = rslt.indexOf(styleSTag + " ID=\"" + dwObj.name + "_stylesheet" + "\"");

    if(sindex < 0)

        sindex = rslt.indexOf(styleSTag.toLowerCase() + " id=\"" + dwObj.name + "_stylesheet" + "\"");

    sindex = rslt.indexOf(">", sindex) + 1;

    eindex = rslt.indexOf(styleETag, sindex);

    if(eindex < 0)

        eindex = rslt.indexOf(styleETag.toLowerCase(), sindex);

    stylestr = rslt.substring(sindex, eindex);

    

    htmlindex = rslt.indexOf(divSTag + " ID=\"" + dwObj.name + "\"", eindex);

    if(htmlindex < 0)

        htmlindex = rslt.indexOf(divSTag.toLowerCase() + " id=\"" + dwObj.name + "\"", eindex);

    // extract the begin javascript from rslt;

    sindex = rslt.indexOf(scriptSTag, eindex);

    if(sindex < 0)

        sindex = rslt.indexOf(scriptSTag.toLowerCase(), eindex);

    beginscripts = new Array();

    i = 0;

    while(sindex > 0 && sindex < htmlindex)

    {

        sindex = rslt.indexOf(">", sindex) + 1;

        // can not use complete script end tag here, which might cause error.

        eindex = rslt.indexOf(scriptETag, sindex);

        if(eindex < 0)

            eindex = rslt.indexOf(scriptETag.toLowerCase(), sindex);

        tempstr = rslt.substring(sindex, eindex);

        beginscripts[i] = tempstr;

        i++;

        sindex = rslt.indexOf(scriptSTag, eindex);

        if(sindex < 0)

            sindex = rslt.indexOf(scriptSTag.toLowerCase(), eindex);

    }

    // extract the datawindow display contents from rslt;

    sindex = rslt.indexOf(">", htmlindex) + 1;

    eindex = rslt.lastIndexOf(divETag);

    if(eindex < 0)

        eindex = rslt.lastIndexOf(divETag.toLowerCase());

    htmlstr = rslt.substring(sindex, eindex);

    

    // extract the end javascript from rslt;

    sindex = rslt.indexOf(scriptSTag, eindex);

    if(sindex < 0)

        sindex = rslt.indexOf(scriptSTag.toLowerCase(), eindex);

    endscripts = new Array();

    i = 0;

    while(sindex > 0)

    {

        sindex = rslt.indexOf(">", sindex) + 1;

        // can not use complete script end tag here, which might cause error.

        eindex = rslt.indexOf(scriptETag, sindex);

        if(eindex < 0)

            eindex = rslt.indexOf(scriptETag.toLowerCase(), sindex);

        tempstr = rslt.substring(sindex, eindex);

        endscripts[i] = tempstr;

        i++;

        sindex = rslt.indexOf(scriptSTag, eindex);

        if(sindex < 0)

            sindex = rslt.indexOf(scriptSTag.toLowerCase(), eindex);

    }

    

    // start the update result to dom

    // update styleshee

    if(HTDW_DataWindowClass.isIE4) // for IE

    {

        // in IE, styleElement.innerHTML is readonly

        var styleSheet, styleSheeId;

        styleSheeId = dwObj.name + "_stylesheet";

        for(var i = 0; i < document.styleSheets.length; i++)

        {

            styleSheet = document.styleSheets[i];

            if(styleSheet.owningElement.id == styleSheeId)

            {

                styleSheet.cssText = stylestr;// refresh the stylesheet.

                break;

            }

        }

    }

    else

    {

        var styleEle = document.getElementById(dwObj.name + "_stylesheet");        

        styleEle.innerHTML = stylestr;// refresh the stylesheet.

    }

    // update begin script    

    dwContainerEle = document.getElementById(dwObj.name);

    

    for(i=0; i<beginscripts.length; i++)

    {

        temp = beginscripts[i];

        scriptEle = document.getElementById(dwObj.name + "_bscript" + i.toString());

        if(scriptEle)

        {

            if(HTDW_DataWindowClass.isIE4) // for IE

            {

                scriptEle.text = temp;

                continue;

            }            

            scriptEle.parentNode.removeChild(scriptEle);// need to remove and readd

        }

        scriptEle = document.createElement("script");

        scriptEle.id = dwObj.name + "_bscript" + i.toString();

        scriptEle.type = "text/javascript";

        scriptEle.defer = true;

        if(HTDW_DataWindowClass.isIE4) // for IE

            scriptEle.text = temp;

        else

            scriptEle.innerHTML = temp;

        dwContainerEle.parentNode.insertBefore(scriptEle, dwContainerEle);

    }

    // update html content

    dwContainerEle.innerHTML = htmlstr;

    // update end script

    for(i=0; i<endscripts.length; i++)

    {

        temp = endscripts[i];

        scriptEle = document.getElementById(dwObj.name + "_escript" + i.toString());

        if(scriptEle)

        {

            if(HTDW_DataWindowClass.isIE4) // for IE

            {

                scriptEle.text = temp;

                continue;

            }            

            scriptEle.parentNode.removeChild(scriptEle);// need to remove and readd

        }

        scriptEle = document.createElement("script");

        scriptEle.id = dwObj.name + "_escript" + i.toString();

        scriptEle.type = "text/javascript";

        scriptEle.defer = true;

        if(HTDW_DataWindowClass.isIE4) // for IE

            scriptEle.text = temp;

        else

            scriptEle.innerHTML = temp;

        dwContainerEle.parentNode.appendChild(scriptEle);

    }

}

function HTDW_xhtmlCallbackHandler(eventResult, dwObj)

{

    var sindex, eindex, temp, rslt, bDelay;

    var dwContainerEle, scriptEle, scriptParent, linkEle, newLinkEle;

    var linkhref, linkhref1, htmlstr, rowscripts;    

    var linkSTag, divSTag, divETag, scriptSTag, scriptETag;    

    

    rslt = eventResult;

    dwContainerEle = document.getElementById(dwObj.name);

    linkSTag = "<" + "link";

    divSTag = "<" + "div";

    divETag = "<" + "/div" + ">";

    scriptSTag = "<" + "script";

    scriptETag = "<" + "/script" + ">";

    

    // stylesheet

    sindex = rslt.indexOf(linkSTag + " id=\"" + dwObj.name + "_stylesheet\"");

    sindex = rslt.indexOf("href=\"", sindex) + 6;

    eindex = rslt.indexOf("\"", sindex);

    linkhref = rslt.substring(sindex, eindex);

    

    // styleshee1 not always there

    sindex = rslt.indexOf(divSTag + " id=\"" + dwObj.name + "\"", eindex);

    temp = sindex;

    linkhref1 = rslt.substring(0, sindex);

    sindex = linkhref1.indexOf(linkSTag + " id=\"" + dwObj.name + "_stylesheet1\"");

    if (sindex >= 0)

    {

        sindex = linkhref1.indexOf("href=\"", sindex) + 6;

        eindex = linkhref1.indexOf("\"", sindex);

        linkhref1 = linkhref1.substring(sindex, eindex);    

    }

    else

        linkhref1 = null;

    

    // html

    sindex = temp;

    sindex = rslt.indexOf(">", sindex) + 1;   

    eindex = rslt.lastIndexOf(divETag); //skip the xhtml doc's div end tag

    eindex = rslt.lastIndexOf(divETag, eindex); // this our container div tag

    htmlstr = rslt.substring(sindex, eindex);

    

    // rowscript

    sindex = rslt.lastIndexOf(scriptSTag + " id=\"" + dwObj.name + "_rowscript\"");

    sindex = rslt.indexOf(">", sindex) + 1;

    eindex = rslt.indexOf(scriptETag, sindex);

    rowscripts = rslt.substring(sindex, eindex);

    

    // update stylesheet

    bDelay = false;

    dwObj.linkReadyStateChangeCount = 0;

    linkEle = document.getElementById(dwObj.name + "_stylesheet");

    newLinkEle = document.getElementById(linkEle.id + "_new"); //new link for buffer so that old style can be kept temporarily.

    if(newLinkEle == null)

    {

        newLinkEle = linkEle.cloneNode(true);

        newLinkEle.id = linkEle.id + "_new";

        linkEle.parentNode.insertBefore(newLinkEle, linkEle);

    }

    newLinkEle.href = linkhref; //set the new stylesheet

    if(newLinkEle.readyState + "" != "undefined" &&  newLinkEle.readyState != "complete")

    {

        newLinkEle.dwObj = dwObj;

        newLinkEle.dwObjHtml = htmlstr;

        newLinkEle.onreadystatechange = HTDW_xhtmlLinkReadyStateChange;

        bDelay = true;

        dwObj.linkReadyStateChangeCount++;

    }

    else

    {

        linkEle.href = linkhref; //set the new stylesheet

        newLinkEle.dwObj = null;

        newLinkEle.dwObjHtml = null;

        newLinkEle.onreadystatechange = null;

    }

    if(linkhref1)

    {

        var linkEle1 = document.getElementById(dwObj.name + "_stylesheet1");

        if(linkEle1 == null)

        {

            linkEle1 = document.getElementById(dwObj.name + "_stylesheet").cloneNode(true);

            linkEle1.id = dwObj.name + "_stylesheet1";

            linkEle1.href = linkhref1;

            linkEle.parentNode.insertBefore(linkEle1, linkEle);

            if(linkEle1.readyState + "" != "undefined" &&  linkEle1.readyState != "complete")

            {

                linkEle1.dwObj = dwObj;

                linkEle1.dwObjHtml = htmlstr;

                linkEle1.onreadystatechange = HTDW_xhtmlLinkReadyStateChange;

                bDelay = true;

                dwObj.linkReadyStateChangeCount++;

            }

        }

        else

        {

            newLinkEle = document.getElementById(linkEle1.id + "_new"); //new link for buffer

            if(newLinkEle == null)

            {

                newLinkEle = linkEle1.cloneNode(true);

                newLinkEle.id = linkEle1.id + "_new";

                linkEle1.parentNode.insertBefore(newLinkEle, linkEle1);

            }

            newLinkEle.href = linkhref1;//set the new stylesheet

            if(newLinkEle.readyState + "" != "undefined" &&  newLinkEle.readyState != "complete")

            {

                newLinkEle.dwObj = dwObj;

                newLinkEle.dwObjHtml = htmlstr;

                newLinkEle.onreadystatechange = HTDW_xhtmlLinkReadyStateChange;

                bDelay = true;

                dwObj.linkReadyStateChangeCount++;

            }

            else

            {

                linkEle1.href = linkhref1; //set the new stylesheet

                newLinkEle.dwObj = null;

                newLinkEle.dwObjHtml = null;

                newLinkEle.onreadystatechange = null;

            }           

        }

    }



    // update html content

    if(!bDelay)

        dwContainerEle.innerHTML = htmlstr;



    // update rows script

    eval(rowscripts);

}



function HTDW_xhtmlLinkReadyStateChange()

{

    if(this.readyState == "complete")

    {

        this.dwObj.linkReadyStateChangeCount--;

        var timerId = window.setTimeout("HTDW_xhtmlLinkTimerCallback('" + this.id + "')", 5);

        this.timerId = timerId;

    }

}

function HTDW_xhtmlLinkTimerCallback(linkId)

{

    var linkEle, mainLinkEle, dwObj;

    linkEle = document.getElementById(linkId);

    dwObj = linkEle.dwObj;

    mainLinkEle = document.getElementById(linkId.substring(0, linkId.length - 4)); // remove "_new"

    window.clearTimeout(linkEle.timerId);

    mainLinkEle.href = linkEle.href; // set the main link href to the buffer one.

    if(dwObj.linkReadyStateChangeCount <= 0)

    { // update continer's innerHtml after stylsheet is ready.

        var savedIndicatorRow = -1;

        if(dwObj.bHasRowFocusIndicator && dwObj.indicatorRow != -1)

        {

            savedIndicatorRow = dwObj.indicatorRow;

            dwObj.showRowFocusIndicator(dwObj.indicatorRow, false);

        }



        var dwContainerEle = document.getElementById(dwObj.name);

        dwContainerEle.innerHTML = linkEle.dwObjHtml;



        if(dwObj.bHasRowFocusIndicator && savedIndicatorRow != -1)

           dwObj.showRowFocusIndicator(savedIndicatorRow, true);

    }

    linkEle.dwObjHtml = null;

}



function HTDW_PreCallbackArgClass(eventResult)

{

    this.eventResult = eventResult;

    this.resultModified = false;

}

function HTDW_callbackHandler(eventResult, context)

{

    var dwObj = context;

    var savedIndicatorRow = -1;

    var fRow, controlEle;

    if(dwObj == null)

        return;



    if(dwObj.onprecallback)

    {// give a chance for inheritor or wrapper (like .net dw) to check or modify its customized 

     // eventResult before passing it into our dw.

        var arg = new HTDW_PreCallbackArgClass(eventResult);

        dwObj.onprecallback(dwObj, arg);

        if(arg.resultModified) // check whether onprecallback returns the modified eventResult

            eventResult = arg.eventResult;

    }

    dwObj.currRow = -1;

    if(dwObj.rows)

        dwObj.rows.length = 0; //reset the rows.

    if(dwObj.rowInfos)

        dwObj.rowInfos.length = 0; //reset the rowInfos.

    if(dwObj.bHasRowFocusIndicator && dwObj.indicatorRow != -1)

    {

        savedIndicatorRow = dwObj.indicatorRow;

        dwObj.showRowFocusIndicator(dwObj.indicatorRow, false);

    }

    fRow = dwObj.firstRow;

    if(dwObj.renderFormat == 0) // html

        HTDW_htmlCallbackHandler(eventResult, dwObj);

    else if(dwObj.renderFormat == 1) // xhtml

        HTDW_xhtmlCallbackHandler(eventResult, dwObj);

    else // xml

        XMLDW_TransformCallbackPage(eventResult, dwObj);



    if(dwObj.currentControl)

        dwObj.currentControl = null; // clear the current control.

    if(dwObj.bHasRowFocusIndicator && savedIndicatorRow != -1)

        dwObj.showRowFocusIndicator(savedIndicatorRow, true);

    if(fRow != dwObj.firstRow && dwObj.action && (dwObj.action == "PageNext" || dwObj.action == "PagePrior" || 

       dwObj.action == "PageFirst" || dwObj.action == "PageLast" || dwObj.action.toUpperCase().indexOf("PAGETO") == 0))

    {

        controlEle = null;

        if(document.getElementById + "" != "undefined")

            controlEle = document.getElementById(dwObj.dwControlId);

        if(controlEle != null && controlEle.scrollTop + "" != "undefined")

            controlEle.scrollTop = 0;

    }

}

function HTDW_dddwCallbackHandler(eventResult, context)

{

	var dwctr = 0;

	var dwObj = context;

	var startOfDiv = eventResult.indexOf(',');

	var dddwName = eventResult.substr(0,startOfDiv);

	var dddw = document.getElementById(dwObj .name + "_" + dddwName + "_dddw");

	var dddwF = document.getElementById(dwObj .name + "_" + dddwName + "_frame");

	if (dddw==null||dddwF==null) return;

	var rslt = eventResult.substring(startOfDiv+1);



	var sindex;

	var eindex;



	var styleSTag;

	var styleETag; 

	styleSTag = "<" + "STYLE";

	styleETag = "<" + "/STYLE>";

	

	var stylestr;



	sindex = rslt.indexOf(styleSTag);

	if(sindex < 0)

      	sindex = rslt.indexOf(styleSTag.toLowerCase());

	sindex = rslt.indexOf(">", sindex) + 1;

	eindex = rslt.indexOf(styleETag, sindex);

	if(eindex < 0)

		eindex = rslt.indexOf(styleETag.toLowerCase(), sindex);

	stylestr = rslt.substring(sindex, eindex);



	var styleSheet, styleSheeId;

	styleSheeId = "htmldw_stylesheet";

	for(var i = 0; i < document.styleSheets.length; i++)

	{

		styleSheet = document.styleSheets[i];

		if(styleSheet.owningElement.id == styleSheeId)

		{

			styleSheet.cssText = styleSheet.cssText + stylestr;// refresh the stylesheet.

			break;

		}

	}	



	var dddwR = document.getElementById(dwObj.name + "_" + dddwName + "_dddw_rows");



	dddwR.innerHTML = rslt;



	var dddwObj = eval(dwObj.name + '_' + dddwName);

	dddwObj.hookElementsEvent();	



	dddw.style.display = "block";

	dwObj .positionComboBox(dwObj.currentDDDW_control, dddw);

	// display frame

	dddwF.style.width = dddw.offsetWidth;

	dddwF.style.height = dddw.offsetHeight;

	dddwF.style.top = dddw.style.top;

	dddwF.style.left = dddw.style.left;

	dddwF.style.zIndex = dddw.style.zIndex - 1;

	dddwF.style.display = "block";

	dddw.row = dwObj.currentDDDW_newRow;

	dddw.col = dwObj.currentDDDW_newCol;

	dddw.textbox = dwObj.currentDDDW_control;

	dddw.selectedRow = -1;



      if( dwObj.currentDDDW_control.options + "" == "undefined")

      {

	    if (dwObj.currentDDDW_control.value != "")

          {

	        for (i = 0; i < dwObj.currentDDDW_aOptions.length; i++)

	        {

	            if (dwObj.currentDDDW_aOptions[i][0] == dwObj.currentDDDW_control.value)

	            {

                      dddw.selectedRow = i;

		          break;

	            }

              }

          }

      }

      else

      {

	    var selection = dwObj.currentDDDW_control.options[0];

	    if (selection.text != "")

	    {

		  for (dwctr = 0; dwctr  < dwObj.currentDDDW_aOptions.length; dwctr ++)

		  {

		      if (dwObj.currentDDDW_aOptions[dwctr][0] == selection.text)

			{

				dddw.selectedRow = dwctr;

				break;

			}

		  }

	    }

      }

	dddw.focus();

}



function HTDW_performAction(action)

{

    this.action = action;

	if(action.substr(0,7) == "DDDWCB|")

	{

		this.dddwcallback( HTDW_dddwCallbackHandler, action );	

		return;

	}

	if ((this.pagingMode == DW_PAGING_XMLCLIENTSIDE) &&

		(action == "PageNext" ||

		 action == "PagePrior" ||

		 action == "PageFirst" ||

		 action == "PageLast"))

	{

		this.xmlRenderer.transformClientSidePage( action );

	}

	else if (this.pagingMode == DW_PAGING_XMLCLIENTSIDE &&

		action == "InsertRow")

	{

		this.xmlRenderer.insertClientSide( );

	}

	else if (this.pagingMode == DW_PAGING_XMLCLIENTSIDE &&

		action == "AppendRow")

	{

		this.actionRow = this.rows.length;

		this.xmlRenderer.insertClientSide( );

	}

	else if (this.pagingMode == DW_PAGING_XMLCLIENTSIDE &&

		action == "DeleteRow")

	{

		this.xmlRenderer.deleteClientSide( );

	}

	else if (this.b4GLWeb)

    {

		var tempType;

		tempType = eval('typeof goWindowManager');

		if(tempType == "object")

		{

			if((this.bIsButtonPress + "" != "undefined") && this.bIsButtonPress )

			{

				this.submit();	

				return;

			}				

		}

		if ((this.pagingMode == DW_PAGING_CALLBACK) && (this.callback + "" != "undefined") )

			this.callback( HTDW_callbackHandler, action );

		else

        // cause the surrounding page to be submitted

		if (this.submit + "" != "undefined") //Asp.Net

			this.submit();

		else

        	psPage.Submit(); //Jsp Target

	}

	else // deal with it like in 7.0

    {

	   	    var rc = 0;

   	    // OnSubmit can prevent the page from being submitted by returning 1

   	    if (this.eventImplemented("OnSubmit"))

   	        {

   	        if(this.autoEventBind)

                               rc = _evtDefault(this.OnSubmit ());

   	        else

   	            rc = _evtDefault(this.OnSubmit (this));

                           }

        if (rc == 0)

            {

       	    this.actionField.value = this.action;

   	        this.contextField.value = this.GetFullContext();

            this.submitForm.submit();

            }

	    }

}



function HTDW_GetFullContext()

{

    var     result = this.context;



	result = this.getTreeContext(result);

    if (result.indexOf("((DeleteRow") < 0)

	    result += "(";

    result += this.getChanges();

    if (this.actionRow != -1)

    {

        result += "(row " + this.actionRow;

        if (this.action == "DeleteRow" && this.rows)

            result += " (" + this.rows[this.actionRow][0].rowId + ")";

        result += ")";

    }

    if (this.currRow != -1 && this.bDwDotNet)

        result += "(currentrow " + this.currRow + ")";

    if (this.currCol != -1 && this.bDwDotNet)

        result += "(currentcol " + this.currCol + ")";

    if (this.sortString != null)

        result += "(sortString '" + escapeString (this.sortString) + "')";

    var rowSelectedChanges = this.getRowSelectedChanges();

    if (rowSelectedChanges != null && rowSelectedChanges != "")

        result += rowSelectedChanges;

    result += ")";



    return result ;

}



function HTDW_getTreeContext(oldContext)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVGetContext(oldContext);

	else

		return oldContext;

}



function HTDW_getRowHtmlElement(row)

{

    if (row < 1)

        return null;

    var dwElement, rowElement, oneElement;

    var rowElementId;

    var count = 0;

    if (document.getElementById + "" != "undefined")

        {

        dwElement = document.getElementById(this.name + "_datawindow");

        if (dwElement == null)

            return null;

        rowElementId = this.name + "_detail_" + (row-1).toString();

        rowElement = null;

        if (HTDW_DataWindowClass.isIE4)

            rowElement = dwElement.all[rowElementId];

        else

            {

            var temp = document.getElementById(rowElementId);

            var tempArray = new Array();

            if (temp == null)

                return null;

            tempArray[0] = temp;

            count++;

            while (temp.nextSibling != null)

                {// find out all the following row elements. This cound happen in our tabular render.

                if (temp.nextSibling.id + "" != "undefined" && temp.nextSibling.id  != null && temp.nextSibling.id == rowElementId)

                    {                      

                    tempArray[count] = temp.nextSibling;

                    count++;

                    temp = temp.nextSibling;

                    }

                else

                    break;

                }

            if (tempArray.length > 1)

                rowElement = tempArray;

            else

                rowElement = temp;

            }       

        return rowElement;

        }

    return null;

}



function HTDW_showRowFocusIndicator(row, bShow)

{

    // show row focus indicator

    if (!this.bHasRowFocusIndicator || row < 0)

        return;

    if(this.indicatorRow == row && bShow)

        return;

    if(bShow)

         this.indicatorRow = row;

    else

         this.indicatorRow = -1;



    var rowElement, oneRowElement;

    rowElement = this.getRowHtmlElement(row + 1);

    if (rowElement != null)

        {

        oneRowElement = null;

        if (rowElement.length + "" != "undefined")

            oneRowElement = rowElement[0];

        else

            oneRowElement = rowElement;



        var imgElement, divRectElementLeft, divRectElementTop, divRectElementRight, divRectElementBottom;

        if (this.bRowFocusRect) // row focus indicator is rectangle

            {               

            divRectElementLeft = document.getElementById(this.name + "_" + "rowfocusindicator_left");

            divRectElementTop = document.getElementById(this.name + "_" + "rowfocusindicator_top");

            divRectElementRight = document.getElementById(this.name + "_" + "rowfocusindicator_right");

            divRectElementBottom = document.getElementById(this.name + "_" + "rowfocusindicator_bottom");

            if (divRectElementLeft == null  || divRectElementTop == null  || divRectElementRight == null  || divRectElementBottom == null)

                    return;

            }

        else

            {

             imgElement = document.getElementById(this.name + "_" + "rowfocusindicator_wrapper");

             if (imgElement == null)

                 return;

            }

        if (bShow)

            {

            var offsetLeft, offsetTop;

            offsetLeft = 0;

            offsetTop = 0;

            if (oneRowElement.tagName.toUpperCase() == "TR")

                { // for grid, divRectElement is at the same level of dwElement <TABLE>. for others, divRectElement is inside the dwElement.

                 var dwElement = document.getElementById(this.name + "_datawindow");  

                 if (dwElement != null)

                    {

                    offsetLeft = dwElement.offsetLeft;

                    offsetTop = dwElement.offsetTop;

                    }          

                }

            if (this.bRowFocusRect) // row focus indicator is rectangle

                {                

                divRectElementLeft.style.left = (offsetLeft + oneRowElement.offsetLeft).toString() + "px";

                divRectElementLeft.style.top = (offsetTop + oneRowElement.offsetTop).toString() + "px";

                divRectElementLeft.style.width = "1px";



                divRectElementTop.style.left = (offsetLeft + oneRowElement.offsetLeft).toString() + "px";

                divRectElementTop.style.top = (offsetTop + oneRowElement.offsetTop).toString() + "px";

                divRectElementTop.style.width = oneRowElement.offsetWidth.toString() + "px";

                divRectElementTop.style.height = "1px";



                divRectElementRight.style.left = (offsetLeft + oneRowElement.offsetWidth).toString() + "px";

                divRectElementRight.style.top = (offsetTop + oneRowElement.offsetTop).toString() + "px";

                divRectElementRight.style.width = "1px";



                divRectElementBottom.style.left = (offsetLeft + oneRowElement.offsetLeft).toString() + "px";

                divRectElementBottom.style.height= "1px";

                divRectElementBottom.style.width = oneRowElement.offsetWidth.toString() + "px";



                if (oneRowElement != rowElement)

                    {

                    var totalHeight, i;

                    var tempElement;

                    totalHeight = 0;

                    for(i = 0; i < rowElement.length; i++)

                        {

                        tempElement = rowElement[i];

                        totalHeight += tempElement.offsetHeight;

                        }

                    divRectElementLeft.style.height = totalHeight.toString() + "px";

                    divRectElementRight.style.height = totalHeight.toString() + "px";

                    divRectElementBottom.style.top = (offsetTop + oneRowElement.offsetTop + totalHeight).toString() + "px";

                    }

                else

                    {

                    divRectElementLeft.style.height = oneRowElement.offsetHeight.toString() + "px";

                    divRectElementRight.style.height = oneRowElement.offsetHeight.toString() + "px";

                    divRectElementBottom.style.top = (offsetTop + oneRowElement.offsetTop + oneRowElement.offsetHeight).toString() + "px";                    

                    }

                

                divRectElementLeft.style.visibility = "visible";

                divRectElementTop.style.visibility = "visible";

                divRectElementRight.style.visibility = "visible";

                divRectElementBottom.style.visibility = "visible";

                // set the zIndex of divRectElement to a positive value so that it can overlap the row element since row element has not zIndex.

                divRectElementLeft.style.zIndex = 1;

                divRectElementTop.style.zIndex = 2;

                divRectElementRight.style.zIndex = 3;

                divRectElementBottom.style.zIndex = 4;        

                }

            else // bitmap row focus indicator

                { // for grid, imgElement is at the same level of dwElement <TABLE>. for others, imgElement is inside the dwElement.

                imgElement.style.left = (this.rowFocusIndicatorX + offsetLeft + oneRowElement.offsetLeft).toString() + "px";

                imgElement.style.top = (this.rowFocusIndicatorY + offsetTop + oneRowElement.offsetTop).toString() + "px";

                imgElement.style.height = (oneRowElement.offsetHeight).toString() + "px";

                imgElement.style.visibility = "visible";              

                // set the zIndex of imgElementto a positive value so that it can overlap the row element since row element has not zIndex.

                imgElement.style.zIndex = 1;        

                }

            } // show

        else // hide

            {

            if (this.bRowFocusRect) // row focus indicator is rectangel

                {

                divRectElementLeft.style.visibility = "hidden";

                divRectElementTop.style.visibility = "hidden";

                divRectElementRight.style.visibility = "hidden";

                divRectElementBottom.style.visibility = "hidden";

                }

            else // bitmap row focus indicator

                {

                imgElement.style.left = "0px";

                imgElement.style.top = "0px";

                imgElement.style.visibility = "hidden";

                }

            }// hide

        } // element is not null

}



function HTDW_buttonPress(action, row, buttonName, bandID, group)

{

    var evtResult;



    if(this.bDwDotNet && (bandID == 1 || bandID == 2 || bandID == 3))

    {

        row = -1;

        this.currCol = -1;

    }



    // false from clicked will cancel processing

    if (!this.itemClicked(row, -1, buttonName, bandID, group))

        return;



    // button clicking event

    if (this.eventImplemented("ButtonClicking"))

        {

        var old_action = this.action;

        this.action = action;

        if(this.autoEventBind)

            evtResult = _evtDefault(this.ButtonClicking (row+1, buttonName));

        else

            evtResult = _evtDefault(this.ButtonClicking (this, row+1, buttonName));

        this.action = old_action;

        // non-zero return will cancel processing

        if (evtResult != 0)

            return;

        }



    // make sure all changes have been recorded

    if (action != "" && this.AcceptText() != 1)

        // cancel processing if AcceptText fails

        return;



    // update start event 

    if (action == "Update" && this.eventImplemented("UpdateStart"))

        {

        if(this.autoEventBind)

            evtResult = _evtDefault(this.UpdateStart ());

        else

            evtResult = _evtDefault(this.UpdateStart (this));

        // a return of 1 will cancel action

        if (evtResult == 1)

            return;

        }



    if (action == "Print")

	    {

        window.print();

        return;

        }

    // an action of "" is a user defined button which doesn't cause a page reload

    if (action != "")

        {

        if((action == "DeleteRow" || action == "InsertRow") && (bandID == 0))

            this.actionRow = row;

        else

            this.actionRow =  this.currRow;

        this.performAction(action);

        }

    else

        {

        // button clicked event

        if (this.eventImplemented("ButtonClicked"))

           {

           if(this.autoEventBind)

               this.ButtonClicked (row+1, buttonName)

           else

               this.ButtonClicked (this, row+1, buttonName)

           }            

        }

}





function HTDW_initElement(element)

{

    if(!element.bIsInit)

    {

        element.bIsInit = true;

        

        element.parentDW = eval(element.dwname);

        if(element.rowno != null)

            element.iRowNo = parseInt(element.rowno);

        else

            element.iRowNo = -1;

        if(element.colno != null)

            element.iColNo = parseInt(element.colno);

        else

            element.iColNo = -1;

        if(element.bandid != null)

            element.iBandId = parseInt(element.bandid);

        else

            element.iBandId = -1;

        if(element.grouplevel != null)

            element.iGroup = parseInt(element.grouplevel);

        else

            element.iGroup = -1;

        if(element.autoselect != null)

            element.iAutoSelect = parseInt(element.autoselect);

        else

            element.iAutoSelect = 0;

        if(element.gobname != null)

        {

            try

            {

                element.gobobj = eval(element.dwname + ".gobs." + element.gobname);

            }

            catch(e)

            {

                element.gobobj = null;

            }

        }

        else

            element.gobname = "datawindow";

    }    

}

function HTDW_elementDoubleClick()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    var ret;

    ret = obj.parentDW.itemDoubleClicked(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId);

    window.event.returnValue = ret;

}

function HTDW_elementRButtonDown()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    if (typeof(goEditMaskManager) == "object" 

		&& obj.gobobj && obj.gobobj.bEditStyleIsEditMask && obj.gobobj.getEditFormat

		&& this.tagName == "INPUT" && this.type == "text")

         goEditMaskManager.OnMouseDown(this);



    var ret;

    ret = obj.parentDW.itemRButtonDown(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId);

    window.event.returnValue = ret;

}

function HTDW_elementMouseUp()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    if (typeof(goEditMaskManager) == "object" 

		&& obj.gobobj && obj.gobobj.bEditStyleIsEditMask && obj.gobobj.getEditFormat

		&& this.tagName == "INPUT" && this.type == "text")

        goEditMaskManager.OnClick(this,true);

}

function HTDW_elementClick(element)

{

    var obj = element;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.parentDW.clickedControl = obj;

    var ret;

    ret = obj.parentDW.itemClicked(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId, obj.iGroup);

    return ret;

}

//1. For InputEvents, InputEventsEdit and InputEventsCalendar

function HTDW_inputEditFocus()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.parentDW.itemGainFocus(obj.iRowNo, obj.iColNo, obj, obj.gobobj);

    if(obj.parentDW == null)

        return;



    if (!(typeof(goEditMaskManager) == "object" && obj.gobobj && obj.gobobj.bEditStyleIsEditMask && obj.gobobj.getEditFormat))

       {

           if(obj.iAutoSelect == 1)

               obj.parentDW.selectControlContent(obj);

       }

}

function HTDW_inputEditClick()

{

    if(this.isdddw + "" == "1")

        this.parentDW.bSelectClicked = true;

    window.event.returnValue = HTDW_elementClick(this);

    if(this.isdddw + "" == "1" && this.parentDW != null)

        this.parentDW.bSelectClicked = false;

}



function HTDW_inputEditChange()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

        

    obj.bChanged = true;

}

function HTDW_inputEditBlur()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

     obj.parentDW.itemLoseFocus(obj);

     if(obj.iscalendar + "" != "undefined")

         DW_HideCalendar(obj.dwname + "_calFrame");

}

function HTDW_inputEditKeyPress()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);



    if (typeof(goEditMaskManager) == "object" && obj.gobobj && obj.gobobj.bEditStyleIsEditMask && obj.gobobj.getEditFormat)

    {

		if (obj.gobobj.column.validateByType==DW_IsNonNegativeNumber||obj.gobobj.column.validateByType==DW_IsNumber)

		{

			if ((this.value.indexOf("-")<0)&&(this.value.length>obj.gobobj.getEditFormat.length))

				return;

			if ((this.value.indexOf("-")>=0)&&(this.value.length>(obj.gobobj.getEditFormat.length+1)))

				return;

		}



        var oldvalue = this.value;

        goEditMaskManager.KeyPress(this);

        if (this.value != oldvalue)

            obj.bChanged = true;

        return;

    }

    

    if(obj.casetype == "1")

        ret = DW_EditKeyPressed(window.event, obj, 1);

    else if(obj.casetype == "2")

        ret = DW_EditKeyPressed(window.event, obj, 2);

    else

        ret = DW_EditKeyPressed(window.event, obj, 0);

    window.event.returnValue = ret;

}



function HTDW_inputKeyDown()

{

    var obj = this;

    if(obj.dwname == null)

        return;     if(!obj.bIsInit)

        HTDW_initElement(obj);



    if (event.keyCode == 9 && !event.ctrlKey && !event.altKey && !event.shiftKey)

        ProcessTab(obj);

    else if (event.keyCode == 9 && !event.ctrlKey && !event.altKey && event.shiftKey)

        ProcessShiftTab(obj);

    else if (event.keyCode == 38 && obj.isdddw == "1")

        ProcessDDDWArrowKey(obj,1);

    else if (event.keyCode == 40 && obj.isdddw == "1")

        ProcessDDDWArrowKey(obj,2);

    else if (typeof(goEditMaskManager) == "object" && obj.gobobj && obj.gobobj.bEditStyleIsEditMask && obj.gobobj.getEditFormat)

    {

		if (obj.gobobj.column.validateByType==DW_IsNonNegativeNumber||obj.gobobj.column.validateByType==DW_IsNumber)

		{

			if ((this.value.indexOf("-")<0)&&(this.value.length>obj.gobobj.getEditFormat.length))

				return;

			if ((this.value.indexOf("-")>=0)&&(this.value.length>(obj.gobobj.getEditFormat.length+1)))

				return;

		}



        var oldvalue = this.value;

        goEditMaskManager.KeyDown(this);

        if (this.value != oldvalue)

            obj.bChanged = true;

    }

}



function ProcessDDDWArrowKey(obj,direction)

{

    event.cancelBubble = true;

    event.returnValue = false;



    var aOptions = eval(obj.dwname + "." + obj.gobname + "_options");

    var selectedRow = -1;

    if (obj.value != "")

    {

        for (i = 0; i < aOptions.length; i++)

	  {

		if (aOptions[i][0] == obj.value)

		{

			selectedRow = i;

			break;

		}

        }

    }

    if(selectedRow <= 0 && direction == 1)

        return;

    if(selectedRow >= (aOptions.length -1) &&direction ==2)

        return;

    

    if(direction == 1)

        selectedRow -= 1;

    if(direction == 2)

        selectedRow += 1;



    var selectedValue = aOptions[selectedRow];



    obj.value = selectedValue[0];

    obj.dwdatavalue = selectedValue[1];

    obj.bChanged = true;

    obj.parentDW.AcceptText();

    obj.select();

}



function ProcessTab(obj)

{

    var dwElement = document.getElementById(obj.dwname + "_datawindow");

    if(dwElement == null)

        return;



    var currTabIndex = obj.tabIndex;

    if (currTabIndex == null)

        currTabIndex = 0;



    var nextTabIndex = 65536;

    var nextElement = null;

    var currElementFound = false;

    var nextElementFound = false;

    var inputs = dwElement.getElementsByTagName("INPUT");

    i = 0;

    while (objElement = inputs.item(i++))

    {

        tabIndex = objElement.tabIndex;

		if (tabIndex == null || tabIndex <= 0)

			continue;

		else if (tabIndex > currTabIndex && tabIndex < nextTabIndex)

		{

			nextTabIndex = tabIndex;

			nextElement = objElement;

		}

		else if (tabIndex == currTabIndex)

		{

			if (objElement.id == obj.id)

			{

				currElementFound = true;

				continue;

			}

			else if (currElementFound)

			{

				nextElement = objElement;

				nextElementFound = true;

				break;

			}

		}

    } 	if (!nextElementFound)

	{

		var selects = dwElement.getElementsByTagName("SELECT");

		i = 0;

		while (objElement = selects.item(i++))

		{

			tabIndex = objElement.tabIndex;

			if (tabIndex == null || tabIndex <= 0)

				continue;

			else if (tabIndex > currTabIndex && tabIndex < nextTabIndex)

			{

				nextTabIndex = tabIndex;

				nextElement = objElement;

			}

			else if (tabIndex == currTabIndex)

			{

				if (objElement.id == obj.id)

				{

					currElementFound = true;

					continue;

				}

				else if (currElementFound)

				{

					nextElement = objElement;

					nextElementFound = true;

					break;

				}

			}

		}

	}



	if (!nextElementFound)

	{

		var textareas = dwElement.getElementsByTagName("TEXTAREA");

		i = 0;

		while (objElement = textareas.item(i++))

		{

			tabIndex = objElement.tabIndex;

			if (tabIndex == null || tabIndex <= 0)

				continue;

			else if (tabIndex > currTabIndex && tabIndex < nextTabIndex)

			{

				nextTabIndex = tabIndex;

				nextElement = objElement;

			}

			else if (tabIndex == currTabIndex)

			{

				if (objElement.id == obj.id)

				{

					currElementFound = true;

					continue;

				}

				else if (currElementFound)

				{

					nextElement = objElement;

					nextElementFound = true;

					break;

				}

			}

		}

	}



    if (nextElement != null)

    {

        if(nextElement.isdddw + "" == "1")

        {

            nextElement.suppressDDDW = true;

        }

        nextElement.focus();

        event.cancelBubble = true;

        event.returnValue = false;

        if(nextElement.isdddw + "" == "1")

        {

            nextElement.suppressDDDW = false;

        }



    }

    else

    {

        obj.bTabPressed = true;

        if(obj.parentDW != null)

            obj.parentDW.itemLoseFocus(obj);

        obj.bTabPressed = false;

    }

}



function ProcessShiftTab(obj)

{

    var dwElement = document.getElementById(obj.dwname + "_datawindow");

    if(dwElement == null)

	    return;



    var currTabIndex = obj.tabIndex;

    if (currTabIndex == null)

	    currTabIndex = 65536;



    var nextTabIndex = 0;

    var nextElement = null;

    var currElementFound = false;

    var nextElementFound = false;

    var inputs = dwElement.getElementsByTagName("INPUT");

    i = 0;

    while (objElement = inputs.item(i++))

    {

        tabIndex = objElement.tabIndex;

		if (tabIndex == null || tabIndex <= 0)

			continue;

		else if (tabIndex < currTabIndex && tabIndex > nextTabIndex)

		{

			nextTabIndex = tabIndex;

			nextElement = objElement;

		}

		else if (tabIndex == currTabIndex)

		{

			if (objElement.id == obj.id)

			{

				currElementFound = true;

				continue;

			}

			else if (currElementFound)

			{

				nextElement = objElement;

				nextElementFound = true;

				break;

			}

		}

    } 	if (!nextElementFound)

	{

		var selects = dwElement.getElementsByTagName("SELECT");

		i = 0;

		while (objElement = selects.item(i++))

		{

			tabIndex = objElement.tabIndex;

			if (tabIndex == null || tabIndex <= 0)

				continue;

			else if (tabIndex < currTabIndex && tabIndex > nextTabIndex)

			{

				nextTabIndex = tabIndex;

				nextElement = objElement;

			}

			else if (tabIndex == currTabIndex)

			{

				if (objElement.id == obj.id)

				{

					currElementFound = true;

					continue;

				}

				else if (currElementFound)

				{

					nextElement = objElement;

					nextElementFound = true;

					break;

				}

			}

		}

	}



	if (!nextElementFound)

	{

		var textareas = dwElement.getElementsByTagName("TEXTAREA");

		i = 0;

		while (objElement = textareas.item(i++))

		{

			tabIndex = objElement.tabIndex;

			if (tabIndex == null || tabIndex <= 0)

				continue;

			else if (tabIndex < currTabIndex && tabIndex > nextTabIndex)

			{

				nextTabIndex = tabIndex;

				nextElement = objElement;

			}

			else if (tabIndex == currTabIndex)

			{

				if (objElement.id == obj.id)

				{

					currElementFound = true;

					continue;

				}

				else if (currElementFound)

				{

					nextElement = objElement;

					nextElementFound = true;

					break;

				}

			}

		}

	}



    if (nextElement != null)

    {

        if(nextElement.isdddw + "" == "1")

        {

            nextElement.suppressDDDW = true;

        }

        nextElement.focus();

        event.cancelBubble = true;

        event.returnValue = false;

        if(nextElement.isdddw + "" == "1")

        {

            nextElement.suppressDDDW = false;

        }

    }

    else

    {

        obj.bTabPressed = true;

        if(obj.parentDW != null)

            obj.parentDW.itemLoseFocus(obj);

        obj.bTabPressed = false;

    }

}

//2. For InputEventsWithAcceptText and InputEventsDDDWText

function HTDW_selectFocus()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    if(obj.isdddw + "" != "undefined")

    {

        var options = eval(obj.dwname + "." + obj.gobname + "_options");

        obj.parentDW.addDDDWOptions(obj,options); 

    }

    obj.parentDW.itemGainFocus(obj.iRowNo, obj.iColNo, obj, obj.gobobj);



    if(obj.parentDW == null)

        return;



    if(obj.iAutoSelect == 1)

       obj.parentDW.selectControlContent(obj);

}

function HTDW_selectClick()

{   

    this.parentDW.bSelectClicked = true;

    window.event.returnValue = HTDW_elementClick(this);

    this.parentDW.bSelectClicked = false;

}

function HTDW_selectChange()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.bChanged = true;

    obj.parentDW.AcceptText();

}

function HTDW_selectBlur()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

        

    if(obj.isdddw + "" != "undefined")

    {        

        obj.parentDW.removeDDDWOptions(obj);

    }

    obj.parentDW.itemLoseFocus(obj);

}

function HTDW_selectBeforeActive()

{

    var obj = this;

    if(obj.isdddw + "" == "1" && obj.suppressDDDW + "" != "undefined" && obj.suppressDDDW == true)

        return;



    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    if (obj.parentDW.eventImplemented("OnDropDownDDDW"))

        {

        if(obj.parentDW.autoEventBind)

            _evtDefault(obj.parentDW.OnDropDownDDDW());

        else

             _evtDefault(obj.parentDW.OnDropDownDDDW(obj.parentDW));

        }



    var ret;

    ret = obj.parentDW.overrideDDDWSelect(obj, obj.iColNo, obj.gobname);

    window.event.returnValue = ret;

}

function HTDW_selectMouseUp()

{

    if( (window.event != null) && (window.event.button == 2) )

        return;



    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    var options = eval(obj.dwname + "." + obj.gobname + "_options");



    if(obj.DDDWID + "" != "undefined")

    {

        obj = document.getElementById(obj.DDDWID);

        if(obj.dwname == null)

            return;

        if(!obj.bIsInit)

            HTDW_initElement(obj);

        if(obj.onfocus != null)

            obj.onfocus();

    }



    if(obj.parentDW != null)

        obj.parentDW.setDDDWVisible(obj.gobname, true, obj.iRowNo, obj.iColNo, obj, options);

}



//4. For InputEventsRadio

function HTDW_inputRadioFocus()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.parentDW.itemGainFocus(obj.iRowNo, obj.iColNo, obj, obj.gobobj);



    if(obj.parentDW == null)

        return;



    if(obj.iAutoSelect == 1)

       obj.parentDW.selectControlContent(obj);

}



function HTDW_inputRadioBeforeClick()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    if(obj.checked == false)

        obj.bChanged = true;	  

    

}



function HTDW_inputRadioClick()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    if(obj.bChanged);

    	  obj.parentDW.AcceptText();

    

    if(obj.parentDW == null)

        return;



    var ret;

    obj.parentDW.clickedControl = obj;

    ret = obj.parentDW.itemClicked(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId, obj.iGroup);

    window.event.returnValue = ret;

}



function HTDW_inputReadOnlyRadioClick()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

      

    obj.parentDW.clickedControl = obj;

    obj.parentDW.itemClicked(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId, obj.iGroup);

    window.event.returnValue = false;

}



function HTDW_inputRadioBlur()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.parentDW.itemLoseFocus(obj);

}

//5. For InputEventsCheckbox

function HTDW_inputCheckBoxFocus()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);



    obj.parentDW.itemGainFocus(obj.iRowNo, obj.iColNo, obj, obj.gobobj);



    if(obj.parentDW == null)

        return;



    if(obj.iAutoSelect == 1)

       obj.parentDW.selectControlContent(obj);

}

function HTDW_inputCheckBoxClick()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.bChanged = true;

    obj.parentDW.setCheckboxValue(obj, obj.checkvalue, obj.uncheckvalue);

    obj.parentDW.AcceptText();

    

    if(obj.parentDW == null)

        return;



    var ret;

    obj.parentDW.clickedControl = obj;

    ret = obj.parentDW.itemClicked(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId, obj.iGroup);

    window.event.returnValue = ret;

}



function HTDW_inputReadOnlyCheckBoxClick()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

      

    obj.parentDW.clickedControl = obj;

    obj.parentDW.itemClicked(obj.iRowNo, obj.iColNo, obj.gobname, obj.iBandId, obj.iGroup);

    window.event.returnValue = false;

}



function HTDW_inputCheckBoxBlur()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

        

    obj.parentDW.itemLoseFocus(obj);

}

//6. For TextEvents

function HTDW_textClick()

{   

    window.event.returnValue = HTDW_elementClick(this);

}



//7. For AnchorEvents

function HTDW_anchorClick()

{   

    window.event.returnValue = HTDW_elementClick(this);

}

//8. For ImgEvents

function HTDW_imgClick()

{   

    if(this.isdddw + "" == "1")

        this.parentDW.bSelectClicked = true;

    window.event.returnValue = HTDW_elementClick(this);

    if(this.isdddw + "" == "1" && this.parentDW != null)

        this.parentDW.bSelectClicked = false;

}

//9. For ButtonEvents and UneventfulButtonEvents

//private func

function HTDW_buttonElementClick(element)

{

    var obj = element;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

    

    obj.parentDW.bIsButtonPress = true;

    obj.parentDW.buttonPress(obj.dwaction, obj.iRowNo, obj.gobname, obj.iBandId, obj.iGroup);



    if(obj.parentDW == null)

        return;



    obj.parentDW.bIsButtonPress = false;

    if(obj.parentDW.restoreFocus)

        obj.parentDW.restoreFocus();

}

//public func

function HTDW_buttonClick()

{

    HTDW_buttonElementClick(this);

}

//10. For ImageButtonEvents and UneventfulImageButtonEvents

function HTDW_imgButtonClick()

{

     HTDW_buttonElementClick(this);

    window.event.returnValue = false;

}

//11. For ComputeEvents

function HTDW_computeClick()

{

    HTDW_elementClick(this);

}

function HTDW_computeFocus()

{

    var obj = this;

    if(obj.dwname == null)

        return;

    if(!obj.bIsInit)

        HTDW_initElement(obj);

        

    obj.blur();

}

//12. For RegionEvents

function HTDW_regionClick()

{

    HTDW_elementClick(this);

}



function HTDW_hookElementsEvent()

{

    var dwElement = document.getElementById(this.name + "_datawindow");

	if(dwElement == null)

		return;

    if(dwElement.parentElement != null && dwElement.parentElement.tagName + "" == "DIV")

    {

        dwElement.parentElement.bIsInit = false;

        dwElement.parentElement.dwname = this.name;

        dwElement.parentElement.onclick = eval("HTDW_textClick");

        dwElement.parentElement.ondblclick = eval("HTDW_elementDoubleClick");

        dwElement.parentElement.onmousedown = eval("HTDW_elementRButtonDown");

        if(dwElement.parentElement.parentElement != null && dwElement.parentElement.parentElement.tagName + "" == "DIV" && dwElement.parentElement.parentElement.pbtype + "" == "datawindow")

        {

            dwElement.parentElement.parentElement.bIsInit = false;

            dwElement.parentElement.parentElement.dwname = this.name;

            dwElement.parentElement.parentElement.onclick = eval("HTDW_textClick");

            dwElement.parentElement.parentElement.ondblclick = eval("HTDW_elementDoubleClick");

        	dwElement.parentElement.parentElement.onmousedown = eval("HTDW_elementRButtonDown");

        }

    }

    this.hookBandElementsEvent("_datawindow");

    if(dwElement.tagName=="TABLE")

    {

        var dwElement2 = document.getElementById(this.name + "_footer");

        if(dwElement2 != null)

            this.hookBandElementsEvent("_footer");

    }

}



function HTDW_onContextMenu()

{

    window.event.cancelBubble = true;

    return false;

}



function HTDW_hookBandElementsEvent(bandsuffix)

{

    var dwElement = document.getElementById(this.name + bandsuffix);

	if(dwElement == null)

		return;

    var i = 0;

    var objElement, objElements;

    var pDoubleClick, pRButtonDown, pMouseUp;

    var pIEFocus, pIEClick, pIEBlur, pIEChange, pIEKeyPress;

    var pCBFocus, pCBClick, pCBBlur;

    var pRBFocus, pRBClick, pRBBlur;

    var pBTClick, pIBTClick;

    var pSelectFocus, pSelectClick, pSelectBlur, pSelectChange, pSelectBeforeActive, pSelectMouseUp;

    var pAClick, pIMGClick, pTEXTClick, pRegionClick;

    var pComputeClick, pComputeFocus;

   

    pDoubleClick = eval("HTDW_elementDoubleClick");

    pRButtonDown = eval("HTDW_elementRButtonDown");

    pMouseUp = eval("HTDW_elementMouseUp");



    pIEFocus = eval("HTDW_inputEditFocus");

    pIEClick = eval("HTDW_inputEditClick");

    pIEBlur = eval("HTDW_inputEditBlur");

    pIEChange = eval("HTDW_inputEditChange");

    pIEKeyPress = eval("HTDW_inputEditKeyPress");

    pIEKeyDown = eval("HTDW_inputKeyDown");     pCBFocus = eval("HTDW_inputCheckBoxFocus");

    pCBClick = eval("HTDW_inputCheckBoxClick");

    pCBReadOnlyClick = eval("HTDW_inputReadOnlyCheckBoxClick");

    pCBBlur = eval("HTDW_inputCheckBoxBlur");



    pRBFocus = eval("HTDW_inputRadioFocus");

    pRBBeforeClick = eval("HTDW_inputRadioBeforeClick");

    pRBClick = eval("HTDW_inputRadioClick");

    pRBReadOnlyClick = eval("HTDW_inputReadOnlyRadioClick");

    pRBBlur = eval("HTDW_inputRadioBlur");



    pBTClick = eval("HTDW_buttonClick");

    pIBTClick = eval("HTDW_imgButtonClick");

    

    pSelectFocus = eval("HTDW_selectFocus");

    pSelectClick = eval("HTDW_selectClick");

    pSelectBlur = eval("HTDW_selectBlur");

    pSelectChange = eval("HTDW_selectChange");

    pSelectBeforeActive = eval("HTDW_selectBeforeActive");

    pSelectMouseUp = eval("HTDW_selectMouseUp");



    pAClick = eval("HTDW_anchorClick");

    pIMGClick = eval("HTDW_imgClick");

    pTEXTClick = eval("HTDW_textClick");

    pRegionClick = eval("HTDW_regionClick");



    pComputeClick = eval("HTDW_computeClick");

    pComputeFocus = eval("HTDW_computeFocus");

   

    if(dwElement.tagName == "DIV")

    {

        dwElement.bIsInit = false;

        dwElement.dwname = this.name;

        dwElement.onclick = pTEXTClick;

        dwElement.ondblclick = pDoubleClick;

        dwElement.onmousedown = pRButtonDown;

    }



    // hook all input 

    objElements = dwElement.getElementsByTagName("input");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;

        objElement.bIsInit = false;

        objElement.dwname = this.name;

        if(objElement.type == "text" || objElement.type == "password")

        {

            if (objElement.iscomp == null)

            {

                objElement.onfocus = pIEFocus;

                objElement.onclick = pIEClick;

                objElement.onblur =  pIEBlur;

                objElement.onchange = pIEChange;

                objElement.onkeypress = pIEKeyPress;

                if(objElement.isdddw != null)

                {

                    objElement.onbeforeactivate = pSelectBeforeActive;

                    objElement.onmouseup = pSelectMouseUp;

                }

                else

                {

                    objElement.onmouseup = pMouseUp;

                }

            }

            else

            {

                objElement.onfocus = pComputeFocus;

                objElement.onclick = pComputeClick;

            }

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;

            objElement.oncontextmenu = HTDW_onContextMenu;

        }

        else if(objElement.type == "checkbox")

        {

	      if(objElement.pbnetreadonly == null)

            {

                objElement.onfocus = pCBFocus;

                objElement.onclick = pCBClick;

                objElement.onblur =  pCBBlur;

            }

            else

            {

                objElement.onclick = pCBReadOnlyClick;

            }

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;

            objElement.oncontextmenu = HTDW_onContextMenu;

        }

        else if(objElement.type == "radio")

        {

	      if(objElement.pbnetreadonly == null)

            {

                objElement.onfocus = pRBFocus;

                objElement.onclick = pRBClick;

                objElement.onbeforeactivate = pRBBeforeClick;

                objElement.onblur =  pRBBlur;

            }

            else

            {

                objElement.onclick = pRBReadOnlyClick;

            }

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;

            objElement.oncontextmenu = HTDW_onContextMenu;

        }

        else if(objElement.type == "button")            

            objElement.onclick = pBTClick;

        else if(objElement.type == "image")            

            objElement.onclick = pIBTClick;

        objElement.onkeydown = pIEKeyDown;

        objElement = null;

    }

    objElements = null;

    // hook all textarea

    objElements = dwElement.getElementsByTagName("textarea");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;

        

        objElement.bIsInit = false;

        objElement.dwname = this.name;

        objElement.onfocus = pIEFocus;

        objElement.onclick = pIEClick;

        objElement.onblur =  pIEBlur;

        objElement.onchange = pIEChange;

        if(objElement.casetype != null)

            objElement.onkeypress = pIEKeyPress;  

        objElement.ondblclick =  pDoubleClick;

        objElement.onmousedown = pRButtonDown;

        objElement.oncontextmenu = HTDW_onContextMenu;

        objElement.onkeydown = pIEKeyDown;

        objElement = null;

    }

    objElements = null;

    

    // hook all select

    objElements = dwElement.getElementsByTagName("select");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;

        

        objElement.bIsInit = false;

        objElement.dwname = this.name;

        objElement.onfocus = pSelectFocus;

        objElement.onclick = pSelectClick;

        objElement.onblur =  pSelectBlur;

        objElement.onchange = pSelectChange;

        objElement.ondblclick = pDoubleClick;

        objElement.onmousedown = pRButtonDown;

        objElement.oncontextmenu = HTDW_onContextMenu;

        if(objElement.isdddw != null)

        {

            objElement.onbeforeactivate = pSelectBeforeActive;

            objElement.onmouseup = pSelectMouseUp;

        }

        objElement.onkeydown = pIEKeyDown;

        objElement = null;

    }

    objElements = null;

    

    // hook all button

    objElements = dwElement.getElementsByTagName("button");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;

        

        objElement.bIsInit = false;

        objElement.dwname = this.name;

        objElement.onclick = pBTClick;

        objElement = null;

    }

    objElements = null;

    // hook div

    objElements = dwElement.getElementsByTagName("div");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.gobname == null)

            continue;



        objElement.bIsInit = false;

        objElement.dwname = this.name;

        objElement.onclick = pTEXTClick;

        objElement = null;

    }

    objElements = null;

    // hook all anchor

    objElements = dwElement.getElementsByTagName("a");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.bIsInit = false;

        objElement.dwname = this.name; 

        objElement.onclick = pAClick;

        objElement = null;

    }

    objElements = null;

    // hook all img

    objElements = dwElement.getElementsByTagName("img");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.bIsInit = false;

        objElement.dwname = this.name;

        objElement.onclick = pIMGClick;

        objElement.ondblclick = pDoubleClick;

        objElement.onmousedown = pRButtonDown;  

        objElement.oncontextmenu = HTDW_onContextMenu;



        if(objElement.isdddw != null)

        {

            objElement.onmouseup = pSelectMouseUp;

        }

        objElement = null;



    }

    objElements = null;

    

    if (dwElement.tagName.toLowerCase() == "table")

    {

        // hook all tr

        for (i = 0; i < dwElement.rows.length; i++)

        {

            objElement = dwElement.rows(i);

            if(objElement.rowno == null)

                continue;



            objElement.bIsInit = false;

            objElement.dwname = this.name;

            objElement.onclick = pRegionClick;

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;  

            objElement.oncontextmenu = HTDW_onContextMenu;

			objElement = null;

        }

        objElements = dwElement.getElementsByTagName("td");

        for (i = 0; i < objElements.length; i++)

        {

            objElement = objElements[i];

            if(objElement.rowno == null)

                continue;

            

            objElement.bIsInit = false;

            objElement.dwname = this.name;

            objElement.onclick = pTEXTClick 

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;  

            objElement.oncontextmenu = HTDW_onContextMenu;

			objElement = null;

        }

		objElements = null;

        objElements = dwElement.getElementsByTagName("th");

        for (i = 0; i < objElements.length; i++)

        {

            objElement = objElements[i];

            if(objElement.rowno == null)

                continue;



            objElement.bIsInit = false;

            objElement.dwname = this.name;

            objElement.onclick = pTEXTClick;

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;

            objElement.oncontextmenu = HTDW_onContextMenu;

			objElement = null;

        }

		objElements = null;

        

    }

    else

    {

        // hook all span

        objElements = dwElement.getElementsByTagName("span");

        for (i = 0; i < objElements.length; i++)

        {

            objElement = objElements[i];

            if(objElement.rowno == null)

                continue;



            objElement.bIsInit = false;

            objElement.dwname = this.name;

            if(objElement.gobname == null)

                objElement.onclick =  pRegionClick;

            else

                objElement.onclick = pTEXTClick;

            objElement.ondblclick = pDoubleClick;

            objElement.onmousedown = pRButtonDown;  

            objElement.oncontextmenu = HTDW_onContextMenu;

			objElement = null;

        }

		objElements = null;

    }   



}



function HTDW_unhookElementsEvent()

{

    var dwElement = document.getElementById(this.name + "_datawindow");

	if(dwElement == null)

		return;

    if(dwElement.parentElement != null && dwElement.parentElement.tagName + "" == "DIV")

    {

        dwElement.parentElement.dwname = null;

        dwElement.parentElement.onclick = null;

        dwElement.parentElement.ondblclick = null;

        dwElement.parentElement.onmousedown = null;

        if(dwElement.parentElement.parentElement != null && dwElement.parentElement.parentElement.tagName + "" == "DIV" && dwElement.parentElement.parentElement.pbtype + "" == "datawindow")

        {

            dwElement.parentElement.parentElement.dwname = null;

            dwElement.parentElement.parentElement.onclick = null;

            dwElement.parentElement.parentElement.ondblclick = null;

            dwElement.parentElement.parentElement.onmousedown = null;

        }

    }



	this.unhookBandElementsEvent("_datawindow");

    if(dwElement.tagName=="TABLE")

    {

        var dwElement2 = document.getElementById(this.name + "_footer");

        if(dwElement2 != null)

            this.unhookBandElementsEvent("_footer");

    }

	this.gobs = null;

	this.cols.length = 0;

	this.rows.length = 0;

	this.dataForm = null;

	this["Clicked"] = null;

	this["ItemFocusChanged"] = null;

	this["RowFocusChanged"] = null;

	this["OnDropDownDDDW"] = null;

}



function HTDW_unhookBandElementsEvent(bandsuffix)

{

    var dwElement = document.getElementById(this.name + bandsuffix);

	if(dwElement == null)

		return;

    var i = 0;

    var objElement, objElements;



    // unhook all input 

    objElements = dwElement.getElementsByTagName("input");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        if(objElement.type == "text" || objElement.type == "password")

        {

			objElement.onfocus = null;

			objElement.onclick = null;

            if (objElement.iscomp == null)

            {

                objElement.onblur =  null;

                objElement.onchange = null;

                objElement.onkeypress = null;

                objElement.onmouseup = null;

                if(objElement.isdddw != null)

                {

                    objElement.onbeforeactivate = null;

                }

            }

            objElement.ondblclick = null;

            objElement.onmousedown = null;

            objElement.oncontextmenu = null;

        }

        else if(objElement.type == "checkbox")

        {

			objElement.onclick = null;

			if(objElement.pbnetreadonly == null)

            {

                objElement.onfocus = null;

                objElement.onblur =  null;

            }

            objElement.ondblclick = null;

            objElement.onmousedown = null;

            objElement.oncontextmenu = null;

        }

        else if(objElement.type == "radio")

        {

			objElement.onclick = null;

			if(objElement.pbnetreadonly == null)

            {

                objElement.onfocus = null;

                objElement.onbeforeactivate = null;

                objElement.onblur =  null;

            }

            objElement.ondblclick = null;

            objElement.onmousedown = null;

            objElement.oncontextmenu = null;

        }

        else if(objElement.type == "button")            

            objElement.onclick = null;

        else if(objElement.type == "image")            

            objElement.onclick = null;

        objElement.onkeydown = null;

        objElement = null;

    }

    objElements = null;

    // unhook all textarea

    objElements = dwElement.getElementsByTagName("textarea");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        objElement.onfocus = null;

        objElement.onclick = null;

        objElement.onblur =  null;

        objElement.onchange = null;

        if(objElement.casetype != null)

            objElement.onkeypress = null;  

        objElement.ondblclick =  null;

        objElement.onmousedown = null;

        objElement.oncontextmenu = null;

        objElement.onkeydown = null;

        objElement = null;

    }

    objElements = null;



    // unhook all select

    objElements = dwElement.getElementsByTagName("select");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        objElement.onfocus = null;

        objElement.onclick = null;

        objElement.onblur =  null;

        objElement.onchange = null;

        objElement.ondblclick = null;

        objElement.onmousedown = null;

        objElement.oncontextmenu = null;

        if(objElement.isdddw != null)

        {

            objElement.onbeforeactivate = null;

            objElement.onmouseup = null;

        }

        objElement.onkeydown = null;

        objElement = null;

    }

    objElements = null;



    // unhook all button

    objElements = dwElement.getElementsByTagName("button");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        objElement.onclick = null;

        objElement = null;

    }

    objElements = null;

    // unhook div

    objElements = dwElement.getElementsByTagName("div");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.gobname == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        objElement.onclick = null;

        objElement = null;

    }

    objElements = null;

    // unhook all anchor

    objElements = dwElement.getElementsByTagName("a");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        objElement.onclick = null;

        objElement = null;

    }

    objElements = null;

    // unhook all img

    objElements = dwElement.getElementsByTagName("img");

    for (i = 0; i < objElements.length; i++)

    {

        objElement = objElements[i];

        if(objElement.rowno == null)

            continue;



        objElement.dwname = null;

		objElement.parentDW = null;

		objElement.gobobj = null;



        objElement.onclick = null;

        objElement.ondblclick = null;

        objElement.onmousedown = null;  

        objElement.oncontextmenu = null;

        if(objElement.isdddw != null)

        {

            objElement.onmouseup = null;

        }

        objElement = null;



    }

    objElements = null;

    

    if (dwElement.tagName.toLowerCase() == "table")

    {

        // unhook all tr

        for (i = 0; i < dwElement.rows.length; i++)

        {

            objElement = dwElement.rows(i);

            if(objElement.rowno == null)

                continue;



            objElement.dwname = null;

			objElement.parentDW = null;

			objElement.gobobj = null;



            objElement.onclick = null;

            objElement.ondblclick = null;

            objElement.onmousedown = null;  

            objElement.oncontextmenu = null;

			objElement = null;

        }

        objElements = dwElement.getElementsByTagName("td");

        for (i = 0; i < objElements.length; i++)

        {

            objElement = objElements[i];

            if(objElement.rowno == null)

                continue;



            objElement.dwname = null;

			objElement.parentDW = null;

			objElement.gobobj = null;



            objElement.onclick = null 

            objElement.ondblclick = null;

            objElement.onmousedown = null;  

            objElement.oncontextmenu = null;

			objElement = null;

        }

		objElements = null;

        objElements = dwElement.getElementsByTagName("th");

        for (i = 0; i < objElements.length; i++)

        {

            objElement = objElements[i];

            if(objElement.rowno == null)

                continue;



            objElement.dwname = null;

			objElement.parentDW = null;

			objElement.gobobj = null;



            objElement.onclick = null;

            objElement.ondblclick = null;

            objElement.onmousedown = null;

            objElement.oncontextmenu = null;

			objElement = null;

        }

		objElements = null;

        

    }

    else

    {

        // unhook all span

        objElements = dwElement.getElementsByTagName("span");

        for (i = 0; i < objElements.length; i++)

        {

            objElement = objElements[i];

            if(objElement.rowno == null)

                continue;



            objElement.dwname = null;

			objElement.parentDW = null;

			objElement.gobobj = null;



            objElement.onclick = null;

            objElement.ondblclick = null;

            objElement.onmousedown = null;  

            objElement.oncontextmenu = null;

			objElement = null;

        }

		objElements = null;

    }  

    if(dwElement.tagName == "DIV")

    {

        dwElement.dwname = null;

        dwElement.onclick = null;

        dwElement.ondblclick = null;

        dwElement.onmousedown = null;

    }

	 

}



// RowInfo class for client SelectRow.

function HTDW_RowInfoClass(rowKey, rowIdNo)

{

    this.key = rowKey;

    this.idNo = rowIdNo;

    this.origBkColor = null;

    this.origSelected = 0;

    if (arguments.length > 2)

        this.origBkColor = arguments[2];

    if (arguments.length > 3)

        this.origSelected = arguments[3];

     this.selected =  this.origSelected;

}



function HTDW_getColNum(col)

{

    if (typeof col == "string")

        {

        for (var i=1; i< this.cols.length; ++i)

            {

            var colObj = this.cols[i];

            if (colObj.name == col)

                return i;

            }

        }

    else

        return col;



    // if we get here, then we couldn't find it

    return -1;

}



function HTDW_getRowSelectedChanges()

{

    var changes = "";

    if (this.rowInfos.length <= 0)

        return changes;



    for (index=this.firstRow; index <= this.lastRow; ++index)

        {

        if (this.rowInfos[index] != null && this.rowInfos[index].selected != this.rowInfos[index].origSelected)

           changes += ("(SelectRow " + this.rowInfos[index].key + " " + index.toString() + " " + this.rowInfos[index].idNo.toString() + " " + this.rowInfos[index].selected.toString() + ")");

        }

    return changes;

}



function HTDW_DeletedCount()

{

	return this.deletedCount;

}



function HTDW_DeleteRow(row)

{

	if(this.AcceptText() == 1)

		{

		if (row > 0)

    		    this.actionRow = row-1;

		else if(row == 0 && (this.currRow + "" != "undefined"))

    		     this.actionRow = this.currRow;

		else

		    return -1;

		this.performAction ("DeleteRow");

		return 1;

		}

	else

		return -1;

}



function HTDW_GetClickedColumn()

{

	return this.clickedCol;

}



function HTDW_GetClickedRow()

{

	return this.clickedRow + 1;

}



function HTDW_GetColumn()

{

	return this.currCol;

}



function HTDW_GetNextModified(startRow)

{

    var nextModified = 0;

    var index, rowObj;

 

    if (startRow == null)

        return null;



    for (index=startRow-1; index < this.rows.length; ++index)

        {

        rowObj = this.rows[index];

        if (rowObj != null)

            {

            if (rowObj[0].itemStatus == DW_ITEMSTATUS_MODIFIED ||

                rowObj[0].itemStatus == DW_ITEMSTATUS_NEW_MODIFIED)

                {

                nextModified = index+1;

                break;

                }

            }

        }

    return nextModified;

}



function HTDW_GetRow()

{

	return this.currRow + 1;

}



function HTDW_GetItem(row, col)

{

	var result;

	var colNum = this.getColNum(col);

    var rowObj = this.rows[row-1];



	if (colNum == -1 ||

	        (rowObj + "" == "undefined") || 

			rowObj[colNum] + "" == "undefined")

		result = -1;

	else

		result = rowObj[colNum];



	return result;

}



function HTDW_GetItemStatus(row, col)

{

    if (row == null || col == null)

        return null;



    var dwItemStatus = DW_ITEMSTATUS_NOCHANGE;

    var colNum = this.getColNum(col);

    var rowObj = this.rows[row-1];



    if (colNum == -1 ||

            (rowObj + "" == "undefined") || 

            (colNum > 0 && rowObj[colNum] + "" == "undefined"))

        dwItemStatus = -1;

    else if (colNum == 0)

            dwItemStatus = rowObj[0].itemStatus;

    else

        {

        if (rowObj[0].colModified[colNum])

            dwItemStatus = DW_ITEMSTATUS_MODIFIED;

        }



	return dwItemStatus;

}



function HTDW_InsertRow(row)

{

	if(this.AcceptText() == 1)

		{

		if(row > 0)

		    this.actionRow = row-1;

		else if(row == 0)

		    this.actionRow = -1;

		else

		    return -1;

		this.performAction ("InsertRow");

		return 1;

		}

	else

		return -1;

}



function HTDW_ModifiedCount()

{

    return this.modifiedCount;

}



function HTDW_Retrieve()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("Retrieve");

		return 1;

		}

	else

		return -1;

}



function HTDW_RowCount()

{

	return this.rowCount;

}



function HTDW_ScrollFirstPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PageFirst");

		return 1;

		}

	else

		return -1;

}



function HTDW_ScrollLastPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PageLast");

		return 1;

		}

	else

		return -1;

}



function HTDW_ScrollNextPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PageNext");

		return 1;

		}

	else

		return -1;

}



function HTDW_ScrollPriorPage()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("PagePrior");

		return 1;

		}

	else

		return -1;

}



function HTDW_SetScroll(scrollAction, data)

{ //scrollAction: 1-scrolltorow(data is the row); 2-scroll page (data 0-prior page, 1-next page)



	var controlElement, rowElement, oneRowElement;

	controlElement = null;

	if (document.getElementById + "" != "undefined")

		controlElement = document.getElementById(this.dwControlId);

	if (controlElement == null)

		return -1;



	if (scrollAction == 1)

		{

		var row = data;

		if (row < 1)

			return -1;

		if ((row % this.rowsPerDetail) == 0)

			row = row / this.rowsPerDetail;

		else

			row = row / this.rowsPerDetail + 1;

		 rowElement = this.getRowHtmlElement(row);

		if (rowElement != null)

			{

			oneRowElement = null;

			 if (rowElement.length + "" != "undefined")

				 oneRowElement = rowElement[0];

			else

				oneRowElement = rowElement;

			}

		 if (oneRowElement == null )

			return -1;

		// do scroll

		if ((oneRowElement.offsetTop + oneRowElement.offsetHeight) > (controlElement.scrollTop + controlElement.clientHeight))

			{

			var temp = oneRowElement.offsetHeight - controlElement.clientHeight;

			controlElement.scrollTop = oneRowElement.offsetTop + (temp > 0 ? 0 : temp);//make sure begining of row is visible.			

			}

		else if (oneRowElement.offsetTop < controlElement.scrollTop)

			controlElement.scrollTop = oneRowElement.offsetTop;

		}

	else if (scrollAction == 2)

		{

		if (data)

			{

			controlElement.scrollTop = controlElement.scrollTop + controlElement.clientHeight;

			}

		else

			{

			controlElement.scrollTop = controlElement.scrollTop - controlElement.clientHeight;

			}

		}

	return 1;

}



function HTDW_SelectRow(row, select)

{

	if (this.rowInfos.length <= 0)

		return;

	if(row < (this.firstRow + 1) || row > (this.lastRow + 1) )

		return;

	if(this.IsRowSelected(row) && select)

		return;

	if(!this.IsRowSelected(row) && !select)

		return;



	var rowElement, i, oneRowElement;

	rowElement = this.getRowHtmlElement(row);

	if(rowElement != null)

		{

		if(select)

			{

			if(rowElement.length != null)

				{

				for(i = 0; i < rowElement.length; i++)

					{

					oneRowElement = rowElement(i);

					if(this.rowInfos[row-1].origBkColor == null)

						this.rowInfos[row-1].origBkColor = oneRowElement.style.backgroundColor;

					oneRowElement.style.backgroundColor = this.selectedRowColor;

					}

				}

			else

				{

				if(this.rowInfos[row-1].origBkColor == null)

					this.rowInfos[row-1].origBkColor = rowElement.style.backgroundColor;

				rowElement.style.backgroundColor = this.selectedRowColor;				

				}

			this.rowInfos[row-1].selected = 1;

			}

		else 

			{

			if(rowElement.length != null)

				{

				for(i = 0; i < rowElement.length; i++)

					{					

					oneRowElement = rowElement(i);					

					oneRowElement.style.backgroundColor = this.rowInfos[row-1].origBkColor;

					}

				}

			else

				{				

				rowElement.style.backgroundColor = this.rowInfos[row-1].origBkColor;

				}

			this.rowInfos[row-1].selected = 0;

			}

		}

}



function HTDW_IsRowSelected(row)

{

	if (this.rowInfos.length <= 0)

		return false;

	if(row < (this.firstRow + 1) || row > (this.lastRow + 1) )

		return false;

	if(this.rowInfos[row-1] != null && this.rowInfos[row-1].selected != 0)

		return true;

	return false;

}



function HTDW_SetItem(row,col,value)

{

	var result;

	var colNum = this.getColNum(col);

    var rowObj = this.rows[row-1];



	if (colNum == -1 ||

	        (rowObj + "" == "undefined") || 

			rowObj[colNum] + "" == "undefined")

		result = -1;

	else

		{

        if (rowObj[colNum] != value)

			{

			rowObj[colNum] = value;

            if (rowObj[0].itemStatus != DW_ITEMSTATUS_MODIFIED &&

                rowObj[0].itemStatus != DW_ITEMSTATUS_NEW_MODIFIED)

				this.modifiedCount++;	    

			rowObj[0].colModified[colNum] = true;

            if (rowObj[0].itemStatus == DW_ITEMSTATUS_NOCHANGE)

                rowObj[0].itemStatus = DW_ITEMSTATUS_MODIFIED;

            else if (rowObj[0].itemStatus == DW_ITEMSTATUS_NEW)

                rowObj[0].itemStatus = DW_ITEMSTATUS_NEW_MODIFIED;

			}



		// update them all

		this.cols[colNum].updateDependents(this, row-1, false);		

		

		this.refreshSharedDataWindows(row,col);

		

		result = 1;

		}



	return result;

}



function HTDW_SetColumn(col)

{

    var result = -1;

	var colNum = this.getColNum(col);



    if (colNum != -1)

        {

        var colObj = this.cols[colNum];

        if (typeof colObj != "undefined" && colObj.displayGobName != null)

            {

            var control = this.findControl(colObj.displayGobName, this.currRow, true);

            // if we can't find a control, then we can't set the column

            if (control != null)

                {

                // force focus onto the found control

                // the onFocus event will change the currency variables

                control.focus();

                result = 1;

                }

            }

        }

	return result;

}



function HTDW_SetRow(row)

{

    var result = -1;

    row -= 1;

	var colNum = this.currCol;



    if (colNum != -1)

        {

        var colObj = this.cols[colNum];

        if (typeof colObj != "undefined" && colObj.displayGobName != null)

            {

            var control = this.findControl(colObj.displayGobName, row, true);

            // if we can't find a control, then we can't set the row

            if (control != null)

                {

                // force focus onto the found control, 

                // the onFocus event will change the currency variables

                control.focus();

                result = 1;

                }

            }

        }

	return result;

}



function HTDW_SetSort(sortString)

{

	this.sortString = sortString;	

	return 1;

}



function HTDW_Sort()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("Sort");

		return 1;

		}

	else

		return -1;

}



function HTDW_Update()

{

	if(this.AcceptText() == 1)

		{

		this.performAction ("Update");

		return 1;

		}

	else

		return -1;

}



function HTDW_Collapse(row, groupLevel)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVCollapse(row, groupLevel);

	else

		return -16;

}



function HTDW_Expand(row, groupLevel)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVExpand(row, groupLevel);

	else

		return -16;

}



function HTDW_ExpandAll()

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVExpandAll();

	else

		return -16;

}



function HTDW_CollapseAll()

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVCollapseAll();

	else

		return -16;

}



function HTDW_ExpandAllChildren(row, groupLevel)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVExpandAllChildren(row, groupLevel);

	else

		return -16;

}



function HTDW_CollapseAllChildren(row, groupLevel)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVCollapseAllChildren(row, groupLevel);

	else

		return -16;

}



function HTDW_ExpandLevel(groupLevel)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVExpandLevel(groupLevel);

	else

		return -16;

}



function HTDW_CollapseLevel(groupLevel)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.TVCollapseLevel(groupLevel);

	else

		return -16;

}



function HTDW_SelectTreeNode(row, groupLevel, select)

{

	if (this.xmlRenderer + "" != "undefined")

		return this.xmlRenderer.selectTreeNode(row, groupLevel, select);

	else

		return -16;

}



function DW_EditKeyPressed(e, control, nCase)

{

	if(nCase == 1)

	{

		if(window.event)

		{ //IE

			var str = String.fromCharCode(window.event.keyCode).toUpperCase();

			if(str.charCodeAt(0) != window.event.keyCode)

				window.event.keyCode = str.charCodeAt(0);

		}

		else if(e && (e.which || e.charCode))

		{

			var charCode, str;

			if(e.which)

				charCode = e.which;

			else

				charCode = e.charCode;

			str = String.fromCharCode(charCode).toUpperCase();

			if(str.charCodeAt(0) != charCode && (control.setSelectionRange + "") != "undefined")

			{

				var oldSelectionStart = control.selectionStart;

				var oldSelectionEnd = control.selectionEnd;

				if(control.value != null)

					control.value = control.value.substring(0, oldSelectionStart) + str + control.value.substring(oldSelectionEnd);

				else

					control.value = str;

				control.setSelectionRange(oldSelectionStart + str.length, oldSelectionStart + str.length);

				return false;

			}

		}

	}

	else if (nCase == 2)

	{

		if(window.event)

		{ //IE

			var str = String.fromCharCode(window.event.keyCode).toLowerCase();

			if(str.charCodeAt(0) != window.event.keyCode)

				window.event.keyCode = str.charCodeAt(0);

		}

		else if(e && (e.which || e.charCode))

		{

			var charCode, str;

			if(e.which)

				charCode = e.which;

			else

				charCode = e.charCode;

			str = String.fromCharCode(charCode).toLowerCase();

			if(str.charCodeAt(0) !=charCode && (control.setSelectionRange + "") != "undefined")

			{

				var oldSelectionStart = control.selectionStart;

				var oldSelectionEnd = control.selectionEnd;

				if(control.value != null)

					control.value = control.value.substring(0, oldSelectionStart) + str + control.value.substring(oldSelectionEnd);

				else

					control.value = str;

				control.setSelectionRange(oldSelectionStart + str.length, oldSelectionStart + str.length);

				return false;

			}

		}

	}

return true;

}



function DW_HideCalendar(calFrameName)

{

	var calFrame = document.getElementById(calFrameName);

	var nextFocus = document.elementFromPoint(window.event.clientX, window.event.clientY);



	if (nextFocus != calFrame && calFrame != null)

		calFrame.style.display = 'none';

}



function SetCellControlValue(dw,control,gob,value)

{

	if (control.type == "hidden" || control.type == "password" || control.type == "text" || control.type == "textarea" || control.type == "select-one")

	{

		var displayValue;

        if (gob.format != null && gob.getDisplayFormat != null)

        {

            if (typeof gob.getDisplayFormat == "string")

				formatString = gob.getDisplayFormat;

			else

				formatString = gob.getDisplayFormat (exprCtx);

			displayValue = gob.format (formatString, value, control);

		}

		else if (value != null)

			displayValue = value.toString();

		else

			displayValue = "";

		control.value = displayValue;

	}

    else if(control.type == "checkbox")

    {

		if (value != null)

        {  

			var displayValue;

			displayValue = value.toString();

			if ( (control.checked==true) &&  (displayValue!=control.value.toString()))

				control.checked=false;

			else if  ((control.checked==false) && (displayValue!=control.value.toString()))

				control.checked=true;



			control.value = displayValue;		

		}	

	}

	else if(control.length>1)

	{

		if(control[0].type=="radio")		

		{	

			var r;

			for (r=0;r<control.length;r++)

			{

				displayValue = value.toString();

        		if(control[r].value==displayValue)

				{

         			control[r].checked=true;

				}

				else

				{

         			control[r].checked=false;

				}

			}

		}

	}

	else if(control.tagName == "SPAN")

	{

		PBDataWindow_OnShareDataRefresh_Postback(dw);	

	}

}

 

function HTDW_refreshControl(row,col)

{

	var control = null;

	var controlId = 'this.dataForm.' + this.name + '_' + row + '_' + col;

	var controlExists = eval('typeof ' + controlId);

	if(controlExists == "undefined")

	{

		controlId = this.name + '_' + row + '_' + col;				

		controlExists = eval('typeof ' + controlId);

	}

	if (controlExists == "object")

	{

		control = eval(controlId);	          

		var value = this.rows[row][col];

		var gobName = this.cols[col].displayGobName;

		var gob = eval('this.gobs.'+gobName);

		SetCellControlValue(this,control,gob,value);

	}

}



function HTDW_share(masterDW)

{

	this.linkedDataWindows[this.linkedDataWindows.length]=masterDW;

	masterDW.linkedDataWindows[masterDW.linkedDataWindows.length]=this;

	this.rows = masterDW.rows;

	this.bIsSlaveSharedDataWindow=true;

}



function HTDW_refreshSharedDataWindows(row,col)

{

	if (this.eventImplemented("OnShareDataRefresh"))

	{

		var result ;

		if(this.autoEventBind)

			result = _evtDefault(this.OnShareDataRefresh());

		else

			result = _evtDefault(this.OnShareDataRefresh(this));

	}

	for (var i=0; i< this.linkedDataWindows.length; ++i)

	{

		var dw = this.linkedDataWindows[i];

		dw.refreshControl(row,col);

	}

}



function HTDW_DDDWClass_share(masterDW)

{

	masterDW.linkedDataWindows[masterDW.linkedDataWindows.length]=this;

	this.rows = masterDW.rows;

}



function HTDW_DDDWClass_refreshAffected(row,col)

{

	var control = null;

	var controlId = null;

	var controlExists = null;

	var len = this.dw.rows.length;

	var i;

	for(i=0; i<len; ++i)

	{

		control = null;

		controlId = 'this.dw.dataForm.' + this.dw.name + '_' + i + '_' + this.dwCol;

		controlExists = eval('typeof ' + controlId);

		if (controlExists == "object")

		{

			control = eval(controlId);

			if(control.options[0].value == this.options[row][1])

				control.options[0].text = this.options[row][0];	          

		}

	}

}



function HTDW_DDDWClass_refreshControl(row,col)

{

	var controlName = this.dw.name + "_" + this.gob + "_detail_" + row;

	var control = eval(controlName);

	if(col==this.displayCol)

	{

		this.options[row][0] = this.rows[row][col];

		control.children[1].innerText = this.rows[row][col];

		this.refreshAffected(row,col);

	}

	else if(col==this.dataCol)

	{

		this.options[row][1] = this.rows[row][col];

		control.children[0].innerText = this.rows[row][col];

	}

}



function HTDW_DDDWClass(dw,options,dataCol,displayCol,gob,dwCol)

{

	this.rows = null;

	this.dw = dw;

	this.gob = gob;

	this.dwCol = dwCol;

	this.options = options;

	this.dataCol = dataCol;

	this.displayCol = displayCol;

	this.refreshControl = HTDW_DDDWClass_refreshControl;

	this.refreshAffected = HTDW_DDDWClass_refreshAffected;

	this.share = HTDW_DDDWClass_share;

}





function XMLDW_CreateDOM() {

	var dom = null;

	for (var i=0; i < this.arrDOMProgID.length && dom == null; i++) {

		try {

			dom = new ActiveXObject(this.arrDOMProgID[i]);

		} catch (exception) {

		}

	}

	return dom;

}



function XMLDW_CreateXSLT() {

	var xslt = null;

	for (var i=0; i < this.arrXSLTProgID.length && xslt == null; i++) {

		try {

			xslt = new ActiveXObject(this.arrXSLTProgID[i]);

		} catch (exception) {

		}

	}

	return xslt;

}



function XMLDW_LoadDocument(filename) {

	var xmlDoc = this.createDOM();

	xmlDoc.async = false;

	xmlDoc.load(filename);

	return xmlDoc;

}



function XMLDW_LoadDocument_Msxml25(filename) {

	var xmlDoc = new ActiveXObject("MSXML.FreeThreadedDOMDocument");

	xmlDoc.async = false;

	xmlDoc.load(filename);

	return xmlDoc;

}



function XMLDW_LoadDocument_Mozilla(filename) {

	var dwXMLRequest = new XMLHttpRequest();

	dwXMLRequest.open("GET", filename, false);

	dwXMLRequest.send(null);

	return dwXMLRequest.responseXML;

}



function XMLDW_LoadDocumentString(xml) {

	var xmlDoc = this.createDOM();

	xmlDoc.async = false;

	xmlDoc.loadXML(xml);

	return xmlDoc;

}



function XMLDW_LoadDocumentString_Mozilla(xml) {

	var dwXMLParser = new DOMParser();

	return dwXMLParser.parseFromString(xml, "text/xml");

}



function XMLDW_LoadStylesheet_Mozilla(filename) {

	var dwXSLTRequest = new XMLHttpRequest();

	dwXSLTRequest.open("GET", filename, false);

	dwXSLTRequest.overrideMimeType("text/xml");

	dwXSLTRequest.send(null);



	return dwXSLTRequest.responseXML;

}



function XMLDW_DoTransform() {

	this.dwXSLT.stylesheet = this.dwXSL;

	var processor = this.dwXSLT.createProcessor();

	processor.input = this.dwXML;

	processor.transform();

	document.getElementById(this.divName).innerHTML = processor.output;

}



function XMLDW_DoTransform_Msxml25() {

	document.getElementById(this.divName).innerHTML = this.dwXML.transformNode(this.dwXSL);

}



function XMLDW_DoTransform_Mozilla() {

	var dwXSLTProcessor = new XSLTProcessor();

	dwXSLTProcessor.importStylesheet(this.dwXSL);

	var dwXHTML = dwXSLTProcessor.transformToFragment(this.dwXML, document);

	document.getElementById(this.divName).innerHTML = "";

	document.getElementById(this.divName).appendChild(dwXHTML);

}



function XMLDW_OrderBy(select, dataType) {

	this.dwXSL = this.loadDocument(this.dwXSLfile);

	var sortItem = this.dwXSL.getElementsByTagName("xsl:sort")[0];

	sortItem.setAttribute("select", select + "/text()");

	sortItem.setAttribute("data-type", dataType);

	if (this.dw != null) {

		if (this.dw.sortCol != select || !this.dw.sortAscending) {

			sortItem.setAttribute("order", "ascending");

			this.dw.sortAscending = true;

			this.dw.sortCol = select; }

		else {

			sortItem.setAttribute("order", "descending");

			this.dw.sortAscending = false; }

	}

	this.doTransform();

}



function XMLDW_OrderBy_Mozilla(select, dataType) {

	this.dwXSL = this.loadStylesheet(this.dwXSLfile);

	var sortItems,  sortItem;

	sortItems = null;

	if(this.dwXSL.getElementsByTagNameNS + "" != "undefined")

		sortItems = this.dwXSL.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "sort");

	if(sortItems == null || sortItems.length == 0)

		sortItems = this.dwXSL.getElementsByTagName("sort");

	sortItem = sortItems[0];

	sortItem.setAttribute("select", select + "/text()");

	sortItem.setAttribute("data-type", dataType);

	if (this.dw != null) {

		if (this.dw.sortCol != select || !this.dw.sortAscending) {

			sortItem.setAttribute("order", "ascending");

			this.dw.sortAscending = true;

			this.dw.sortCol = select; }

		else {

			sortItem.setAttribute("order", "descending");

			this.dw.sortAscending = false; }

	}

	this.doTransform();

}



function XMLDW_TransformCallbackPage(nextPage, dwObj) {

	var xmlRen = dwObj.xmlRenderer;

	if (xmlRen.bMozilla)

		xmlRen.dwXML = xmlRen.loadDocumentString(nextPage);

	else

		xmlRen.dwXML.loadXML(nextPage);

	var root = xmlRen.dwXML.documentElement;

	if (root.nodeName == "XSL-Required")

	{

		dwObj.pagingMode = DW_PAGING_POSTBACK;

		dwObj.performAction(dwObj.action);

	}

	else

	{

		var scriptNode = root.removeChild(root.lastChild);

		eval(scriptNode.text);

		xmlRen.doTransform();

	}

}



function XMLDW_TransformClientSidePage(action) {

	if (this.dw == null)

		return;

	var pageSize = this.dw.lastRow - this.dw.firstRow + 1;

	if (action == "PageNext")

	{

		if (this.dw.lastRow >= (this.dw.rows.length - 1))

			return;

		this.dw.firstRow = this.dw.lastRow + 1;

		this.dw.lastRow += pageSize;

	}

	else if (action == "PagePrior")

	{

		if (this.dw.firstRow == 0)

			return;

		this.dw.lastRow = this.dw.firstRow - 1;

		this.dw.firstRow -= pageSize;

		if (this.dw.firstRow < 0)

		{

			this.dw.firstRow = 0;

			this.dw.lastRow = pageSize - 1;

		}

	}

	else if (action == "PageFirst")

	{

		this.dw.firstRow = 0;

		this.dw.lastRow = pageSize - 1;

	}

	else if (action == "PageLast")

	{

		var lastPageSize = this.dw.rows.length % pageSize;

		if (lastPageSize == 0)

			lastPageSize = pageSize;

		this.dw.firstRow = this.dw.rows.length - lastPageSize;

		this.dw.lastRow = this.dw.firstRow + pageSize - 1;

	}



	var detailItem;

	if (this.bMozilla)

	{

		this.dwXSL = this.loadStylesheet(this.dwXSLfile);

		var detailItems = null;

		if (this.dwXSL.getElementsByTagNameNS + "" != "undefined")

			detailItems = this.dwXSL.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "apply-templates");

		if (detailItems == null || detailItems.length == 0)

			detailItems = this.dwXSL.getElementsByTagName("apply-templates");

		detailItem = detailItems[1];

	}

	else

	{

		this.dwXSL = this.loadDocument(this.dwXSLfile);

		detailItem = this.dwXSL.getElementsByTagName("xsl:apply-templates")[1];

	}

	detailItem.setAttribute("select", "*[not(self::band_header or self::band_footer)][@row >= " +

							this.dw.firstRow + " and @row <= " + this.dw.lastRow +"]");

	this.dw.currentControl = null;

	this.doTransform();

}



function XMLDW_InsertClientSide( ) {

  if (this.dw == null)

      return;

  var detailList = this.dwXML.getElementsByTagName("detail");

  var insertRow = (this.dw.actionRow >= 0) ? this.dw.actionRow : 0;

  var iInsert = (insertRow / this.dw.rowsPerDetail) | 0;

  var rowShift = String(iInsert * this.dw.rowsPerDetail); // init for Append

  var iInsertRowOff = insertRow % this.dw.rowsPerDetail + 1;

  var iRowOff = 0;

  var iColOff = 0;

  var column;

  var colName;

  var insertDetail;

  var insertColumn = null;

  var detail;

  var attrNode;

  var i, j;

  var bIncLastDetail = (this.dw.rows.length % this.dw.rowsPerDetail == 0);

  if (this.dw.rowsPerDetail > 1 && detailList.length > 1 && iInsert < (detailList.length - 1))

  {

      var gobType = null;

      if (this.bMozilla)

          insertDetail = detailList[iInsert];

      else

          insertDetail = detailList.item(iInsert);

      while (iRowOff != iInsertRowOff && iColOff < insertDetail.childNodes.length) {

          if (this.bMozilla)

              column = insertDetail.childNodes[iColOff++];

          else

              column = insertDetail.childNodes.item(iColOff++);

          gobType = column.getAttribute("gob");

          if (gobType != null && gobType == "text")

              continue;

          colName = column.nodeName;

          iRowOff = parseInt(colName.charAt(colName.length - 1));

      }

      if (iColOff < insertDetail.childNodes.length ||

          (gobType != null && gobType == "text"))

      {

          iColOff--;

          if (iRowOff < this.dw.rowsPerDetail)

              insertColumn = column;

      }

  }

  for (i=iInsert; i < (detailList.length - 1); i++) 

  {

      if (this.bMozilla)

          detail = detailList[i];

      else

          detail = detailList.item(i);

      if (bIncLastDetail)

          rowShift = String((i + 1) * this.dw.rowsPerDetail);

      else

          rowShift = String(i * this.dw.rowsPerDetail);

      if (this.dw.rowsPerDetail > 1)

      {

          column = null;



          var iNextColOff = 0;



          var nextDetail;

          var nextColumn = null;

          if ((i + 1) < (detailList.length - 1))

          {

              if (this.bMozilla)

              {

                  nextDetail = detailList[i + 1];

                  nextColumn = nextDetail.childNodes[0];

              }

              else

              {

                  nextDetail = detailList.item(i + 1);

                  nextColumn = nextDetail.childNodes.item(0);

              }

          }

          else if(bIncLastDetail)

          {

              var newDetail = this.dwXML.createElement("detail");

              newDetail.setAttribute("row", rowShift);

              if (this.bMozilla)

                  nextDetail = this.dwXML.documentElement.insertBefore(newDetail, detailList[i + 1]);

              else

                  nextDetail = this.dwXML.documentElement.insertBefore(newDetail, detailList.item(i + 1));

          }

          while (iNextColOff < detail.childNodes.length) {

              if (this.bMozilla)

                  column = detail.childNodes[iNextColOff];

              else

                  column = detail.childNodes.item(iNextColOff);

              var gobType = column.getAttribute("gob");

              if (gobType != null && gobType == "text")

              {

                  iNextColOff++;

                  continue;

              }

              colName = column.nodeName;

              iRowOff = parseInt(colName.charAt(colName.length - 1));

              if (iRowOff == this.dw.rowsPerDetail)

              {

                  if(nextColumn != null)

                  {

                    colName = colName.substr(0, colName.length - 1) + "0";

                  }

                  else

                  {

                    colName = colName.substr(0, colName.length - 1) + "1";

                  }

                  var newElem = this.dwXML.createElement(colName);

                  while (column.attributes.length > 0) {

                      if (this.bMozilla)

                          attrNode = column.removeAttributeNode(column.attributes[0]);

                      else

                          attrNode = column.removeAttributeNode(column.attributes.item(0));

                      newElem.setAttributeNode(attrNode);

                  }

                  newElem.text = column.text;

                  if (nextColumn != null)

                      nextDetail.insertBefore(newElem, nextColumn);

                  else

                      nextDetail.appendChild(newElem);

                  

                  detail.removeChild(column);

               }

               else

               {

                  iNextColOff++;

               }

           }



          iRowOff = 0;

          iColOff = 0

          while (iRowOff < this.dw.rowsPerDetail && iColOff < detail.childNodes.length) 

          {

              if (this.bMozilla)

                  column = detail.childNodes[iColOff++];

              else

                  column = detail.childNodes.item(iColOff++);

              var gobType = column.getAttribute("gob");

              if (gobType != null && gobType == "text")

                  continue;

              colName = column.nodeName;

              iRowOff = parseInt(colName.charAt(colName.length - 1));

              if (iRowOff < this.dw.rowsPerDetail && (iRowOff >= iInsertRowOff || i !=iInsert))

              {

                  colName = colName.substr(0, colName.length - 1) + String(iRowOff + 1);

                  var newElem = this.dwXML.createElement(colName);

                  while (column.attributes.length > 0) {

                      if (this.bMozilla)

                          attrNode = column.removeAttributeNode(column.attributes[0]);

                      else

                          attrNode = column.removeAttributeNode(column.attributes.item(0));

                      newElem.setAttributeNode(attrNode);

                  }

                  newElem.text = column.text;

                  if(insertColumn == column)

                  {

                    insertColumn = newElem;

                  }

                  detail.replaceChild(newElem, column);

              }

          }

      }

      else

      {

          detail.setAttribute("row", rowShift);

      }

  }

  for(j=0; j < 2; j++) {

      var bandFoot = null;

      if (j == 0)

          bandFoot = this.dwXML.getElementsByTagName("band_summary");

      else

          bandFoot = this.dwXML.getElementsByTagName("band_footer");

      if (bandFoot != null && bandFoot.length > 0)

      {

          if (this.bMozilla)

              bandFoot[0].setAttribute("row", rowShift);

          else

              bandFoot.item(0).setAttribute("row", rowShift);

      }

  }

  var emptyRow;

  if (this.bMozilla)

      emptyRow = detailList[i];

  else

      emptyRow = detailList.item(i);

  if (this.dw.rowsPerDetail > 1 && iInsert < (detailList.length - 1))

  {

      for (j=0; j < emptyRow.childNodes.length; j++) {

          var emptyCol;

          if (this.bMozilla)

              emptyCol = emptyRow.childNodes[j];

          else

              emptyCol = emptyRow.childNodes.item(j);

          colName = emptyCol.nodeName;

          colName = colName.substr(0, colName.length - 1) + String(iInsertRowOff);

          var newCol = this.dwXML.createElement(colName);

          newCol.text = emptyCol.text;

          if (insertColumn != null)

              insertDetail.insertBefore(newCol, insertColumn);

          else

              insertDetail.appendChild(newCol);

      }

  }

  else

  {

      var newRow = emptyRow.cloneNode(true);

      newRow.setAttribute("row", String(iInsert * this.dw.rowsPerDetail));

      if (this.bMozilla)

          this.dwXML.documentElement.insertBefore(newRow, detailList[iInsert]);

      else

          this.dwXML.documentElement.insertBefore(newRow, detailList.item(iInsert));

  }

  for (j=this.dw.rows.length; j > insertRow; j--) {

      this.dw.rows[j] = this.dw.rows[j - 1];

  }

  var reParens = /\[\]/g;

  var newRowIndex = "[" + String(insertRow) + "]";

  var newRowScript = this.dw.rowCreation.replace(reParens, newRowIndex);

  eval(newRowScript);

  this.dw.currentControl = null;

  if (this.dw.action == "AppendRow")

      this.transformClientSidePage("PageLast");

  else

      this.doTransform();

}



function XMLDW_DeleteClientSide( ) {

	if (this.dw == null)

		return;

	var detailList = this.dwXML.getElementsByTagName("detail");

	if (detailList.length < 2)

		return;

	var deleteRow = (this.dw.actionRow >= 0) ? this.dw.actionRow : 0;

	var iDelete = (deleteRow / this.dw.rowsPerDetail) | 0;

	var rowShift = "0";

	var iDeleteRowOff = deleteRow % this.dw.rowsPerDetail + 1;

	var iRowOff = 0;

	var iColOff = 0;

	var column;

	var colName;

	var deleteDetail;

	var iDeleteColOff = null;

	var iDeleteCount = 0;

	var detail;

	var attrNode;

	var i, j;

	var bDecLastDetail = (this.dw.rows.length % this.dw.rowsPerDetail == 1);

	// init rowShift for last row

	if (iDelete > 0)

	{

		if (this.dw.rowsPerDetail == 1 || bDecLastDetail)

			rowShift = String((iDelete - 1) * this.dw.rowsPerDetail);

		else

			rowShift = String(iDelete * this.dw.rowsPerDetail);

	}

	if (this.dw.rowsPerDetail > 1)

	{

		var gobType = null;

		if (this.bMozilla)

			deleteDetail = detailList[iDelete];

		else

			deleteDetail = detailList.item(iDelete);

      while (iColOff < deleteDetail.childNodes.length) {

          if (this.bMozilla)

              column = deleteDetail.childNodes[iColOff];

          else

              column = deleteDetail.childNodes.item(iColOff);

          gobType = column.getAttribute("gob");

          if (gobType != null && gobType == "text")

          {

              iColOff++;

              continue;

          }

          colName = column.nodeName;

          iRowOff = parseInt(colName.charAt(colName.length - 1));

          if (iRowOff == iDeleteRowOff)

          {

                deleteDetail.removeChild(column);          

          }

          else

          {

             iColOff++;

          }

      }

      if (iColOff < deleteDetail.childNodes.length ||

          (gobType != null && gobType == "text"))

          iColOff--;

  }

  for (var i=iDelete; i < (detailList.length - 1); i++) {

      if (this.bMozilla)

          detail = detailList[i];

      else

          detail = detailList.item(i);

      if (i > iDelete)

      {

          if (this.dw.rowsPerDetail == 1 || bDecLastDetail)

              rowShift = String((i - 1) * this.dw.rowsPerDetail);

          else

              rowShift = String(i * this.dw.rowsPerDetail);

      }

      iColOff = 0;

      if (this.dw.rowsPerDetail > 1)

      {

          var lastGob = null;

          while (iColOff < detail.childNodes.length) {

              if (this.bMozilla)

                  column = detail.childNodes[iColOff++];

              else

                  column = detail.childNodes.item(iColOff++);

              var gobType = column.getAttribute("gob");

              if (gobType != null && gobType == "text")

              {

                  if (lastGob == null)

                      lastGob = column;

                  continue;

              }

              colName = column.nodeName;

              iRowOff = parseInt(colName.charAt(colName.length - 1));

               if (i != iDelete || iRowOff > iDeleteRowOff)

               {

                  colName = colName.substr(0, colName.length - 1) + String(iRowOff - 1);

                  var newElem = this.dwXML.createElement(colName);

                  while (column.attributes.length > 0)

                  {

                      if (this.bMozilla)

                          attrNode = column.removeAttributeNode(column.attributes[0]);

                      else

                          attrNode = column.removeAttributeNode(column.attributes.item(0));

                      newElem.setAttributeNode(attrNode);

                  }

                  newElem.text = column.text;

                  detail.replaceChild(newElem, column);

               }

          }

          iRowOff = 0;

          if ((i + 1) < (detailList.length - 1))

          {

              var nextDetail;

              if (this.bMozilla)

                  nextDetail = detailList[i + 1];

              else

                  nextDetail = detailList.item(i + 1);

              var nextCol = 0;

              while (nextCol < nextDetail.childNodes.length) 

              {

                  if (this.bMozilla)

                      column = nextDetail.childNodes[nextCol];

                  else

                      column = nextDetail.childNodes.item(nextCol);

                  gobType = column.getAttribute("gob");

                  if (gobType != null && gobType == "text")

                  { 

                    nextCol ++;

                    continue;

                  }

                  colName = column.nodeName;

                  iRowOff = parseInt(colName.charAt(colName.length - 1));

                  if (iRowOff < 2)

                  {

                      colName = colName.substr(0, colName.length - 1) +

                                String(this.dw.rowsPerDetail);

                      var newElem = this.dwXML.createElement(colName);

                      while (column.attributes.length > 0) {

                          if (this.bMozilla)

                              attrNode = column.removeAttributeNode(column.attributes[0]);

                          else

                              attrNode = column.removeAttributeNode(column.attributes.item(0));

                          newElem.setAttributeNode(attrNode);

                      }

                      newElem.text = column.text;

                      if (lastGob != null)

                          detail.insertBefore(newElem, lastGob);

                      else

                          detail.appendChild(newElem);

                      nextDetail.removeChild(column);

                  }

                  else

                  {

                    nextCol++;

                  }

              }

              var bLastGobIsText = true;

              var iCol = 0;

              while( iCol < nextDetail.childNodes.length)

              {

                  if (this.bMozilla)

                      column = nextDetail.childNodes[iCol];

                  else

                      column = nextDetail.childNodes.item(iCol);

                  var gobType = column.getAttribute("gob");

                  if (gobType != null && gobType == "text")

                  {

                    iCol ++;

                  }

                  else

                  {

                    bLastGobIsText = false;

                    break;

                  }

              }

              if (nextDetail.childNodes.length == 0 || bLastGobIsText)

                  this.dwXML.documentElement.removeChild(nextDetail);

          }

          iColOff = 0;

      }

      else if (i > iDelete)

      {

          detail.setAttribute("row", rowShift);

      }

  }

  for(j=0; j < 2; j++) {

      var bandFoot = null;

      if (j == 0)

          bandFoot = this.dwXML.getElementsByTagName("band_summary");

      else

          bandFoot = this.dwXML.getElementsByTagName("band_footer");

      if (bandFoot != null && bandFoot.length > 0)

      {

          if (this.bMozilla)

              bandFoot[0].setAttribute("row", rowShift);

          else

              bandFoot.item(0).setAttribute("row", rowShift);

      }

  }

  if (this.dw.rowsPerDetail > 1 &&

      !(iDelete == (detailList.length - 2) && bDecLastDetail))

  {

   

  }

  else

  {

      if (this.bMozilla)

          this.dwXML.documentElement.removeChild(detailList[iDelete]);

      else

          this.dwXML.documentElement.removeChild(detailList.item(iDelete));

  }

  if (this.dw.context.indexOf("((DeleteRow") < 0) 

      this.dw.context += "("; 

  this.dw.context += "(DeleteRow " + this.dw.rows[deleteRow][0].rowId + ")";

  for (var k=deleteRow; k < this.dw.rows.length - 1; k++) {

      this.dw.rows[k] = this.dw.rows[k + 1];

  }

  this.dw.rows.length--;

  this.dw.currentControl = null;

  this.doTransform();

}



function XMLDW_TransformTreeView()

{

	if (this.dw.bSubmitted + "" != "undefined" && this.dw.bSubmitted)

		return;



	//re-transform

	this.doTransform();



	if (this.treeNodeSelected != null)

		this.highlightTreeNode();



	if (this.treeRowsSelected.length > 0)

		this.highlightTreeRows();



	this.TVAdjustHeight();

}



function XMLDW_RenderTreeView()

{

	var templateList = null;

	var i;

	var template = null;

	var matchName = null;

	var bandId = null;

	var bandNum = 0;

	var applyNode = null;



	if (this.dw.bSubmitted + "" != "undefined" && this.dw.bSubmitted)

		return;



	// lookup template by bandName in XSLT

	if (this.bMozilla)

	{

		this.dwXSL = this.loadStylesheet(this.dwXSLfile);

		if (this.dwXSL.getElementsByTagNameNS + "" != "undefined")

			templateList = this.dwXSL.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "template");

		if (templateList == null || templateList.length == 0)

			templateList = this.dwXSL.getElementsByTagName("template");

	}

	else

	{

		this.dwXSL = this.loadDocument(this.dwXSLfile);

		templateList = this.dwXSL.getElementsByTagName("xsl:template");

	}



	for (i=0; i < templateList.length; i++) {

		if (this.bMozilla)

			template = templateList[i];

		else

			template = templateList.item(i);



		matchName = template.getAttribute("match");

		if (matchName != null && matchName.substring(0, 5) == "band_")

		{

			bandId = parseInt(matchName.substr(5));

			if (!isNaN(bandId))

			{

				bandNum = bandId;

				if (this.Expanded[bandNum] + "" != "undefined" && this.Expanded[bandNum])

				{

					this.dwXSL.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");

					var bandIcons = template.selectSingleNode(".//xsl:call-template");

					if (bandIcons != null)

					{

						var clpsdName = bandIcons.getAttribute("name");

						var expdName = "minu" + clpsdName.substr(4);

						bandIcons.setAttribute("name", expdName);

					}



					// add apply-templates for detail children

					applyNode = this.dwXSL.createNode(1, "xsl:apply-templates", "http://www.w3.org/1999/XSL/Transform");

					applyNode.setAttribute("select", "*[starts-with(name(),'band') or self::detail]");

					template.appendChild(applyNode);

				}

			}

		}

	}



	if (this.Expanded.length > bandNum + 1)

		this.Expanded.length = bandNum + 1;



	this.transformTreeView();

}



function XMLDW_TVCollapseByBandName(bandName)

{

	var bandNum = parseInt(bandName.substr(5));

	if (!isNaN(bandNum))

	{

		this.Expanded[bandNum] = false;

		this.treeBandAffected = bandNum;

	}

}



function XMLDW_TVExpandByBandName(bandName)

{

	var bandNum = parseInt(bandName.substr(5));

	if (!isNaN(bandNum))

	{

		this.Expanded[bandNum] = true;

		this.treeBandAffected = bandNum;

	}

}



function XMLDW_TVCollapseByClick(hideIcon)

{

	var bandClass = hideIcon.parentNode.className;

	var bandName = bandClass.substr(this.cssName.length + 1);

	var evtResult = 0;

	var bCollapsingEvent = this.dw.eventImplemented("Collapsing");

	var bCollapsedEvent = this.dw.eventImplemented("Collapsed");

	var row;

	var groupLevel;

	if (bCollapsingEvent || bCollapsedEvent)

	{

		row = -2;

		groupLevel = -1;

		var bandId = hideIcon.parentNode.id;

		var sArgs = bandId.substr(this.dw.name.length + "_groupheader".length).split("_");

		if (sArgs.length > 0)

		{

			groupLevel = parseInt(sArgs[0]);

			if (isNaN(groupLevel))

				groupLevel = -1;

		}

		if (sArgs.length > 1)

		{

			row = parseInt(sArgs[1]);

			if (isNaN(row))

				row = -2;

		}

	}

	if (bCollapsingEvent)

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.Collapsing (row+1, groupLevel));

		else

			evtResult = _evtDefault(this.dw.Collapsing (this.dw, row+1, groupLevel));

		if (evtResult != 0)

			return;

	}



	this.TVCollapseByBandName(bandName);



	if (bCollapsedEvent)

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.Collapsed (row+1, groupLevel));

		else

			_evtDefault(this.dw.Collapsed (this.dw, row+1, groupLevel));

	}



	this.renderTreeView();

}



function XMLDW_TVExpandByClick(hideIcon)

{

	var bandClass = hideIcon.parentNode.className;

	var bandName = bandClass.substr(this.cssName.length + 1);

	var evtResult = 0;

	var bExpandingEvent = this.dw.eventImplemented("Expanding");

	var bExpandedEvent = this.dw.eventImplemented("Expanded");

	var row;

	var groupLevel;

	if (bExpandingEvent || bExpandedEvent)

	{

		row = -2;

		groupLevel = -1;

		var bandId = hideIcon.parentNode.id;

		var sArgs = bandId.substr(this.dw.name.length + "_groupheader".length).split("_");

		if (sArgs.length > 0)

		{

			groupLevel = parseInt(sArgs[0]);

			if (isNaN(groupLevel))

				groupLevel = -1;

		}

		if (sArgs.length > 1)

		{

			row = parseInt(sArgs[1]);

			if (isNaN(row))

				row = -2;

		}

	}

	if (bExpandingEvent)

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.Expanding (row+1, groupLevel));

		else

			evtResult = _evtDefault(this.dw.Expanding (this.dw, row+1, groupLevel));

		if (evtResult != 0)

			return;

	}



	this.TVExpandByBandName(bandName);



	if (bExpandedEvent)

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.Expanded (row+1, groupLevel));

		else

			_evtDefault(this.dw.Expanded (this.dw, row+1, groupLevel));

	}



	this.renderTreeView();

}



function XMLDW_TVCollapse(row, groupLevel)

{

	if (this.dw == null)

		return -1;

	var evtResult = 0;

	var detail = this.dwXML.selectSingleNode("//detail[@row = \"" + (row - 1) + "\"]");

	if (detail != null)

	{

		var band = detail.parentNode;

		var groups = new Array();

		var i = 0;

		while (band != this.dwXML.documentElement) {

			groups[i++] = band;

			band = band.parentNode;

		}

		if (groupLevel > 0 && groupLevel <= i)

		{

			var bandName = groups[i - groupLevel].nodeName;

			if (this.dw.eventImplemented("Collapsing"))

			{

				if (this.dw.autoEventBind)

					evtResult = _evtDefault(this.dw.Collapsing (row, groupLevel));

				else

					evtResult = _evtDefault(this.dw.Collapsing (this.dw, row, groupLevel));

				if (evtResult != 0)

					return 1;

			}



			this.TVCollapseByBandName(bandName);



			if (this.dw.eventImplemented("Collapsed"))

			{

				if (this.dw.autoEventBind)

					_evtDefault(this.dw.Collapsed (row, groupLevel));

				else

					_evtDefault(this.dw.Collapsed (this.dw, row, groupLevel));

			}



			this.renderTreeView();

		}

		else

			return -5;

	}

	else

		return -5;

	return 1;

}



function XMLDW_TVExpand(row, groupLevel)

{

	if (this.dw == null)

		return -1;

	var evtResult = 0;

	var detail = this.dwXML.selectSingleNode("//detail[@row = \"" + (row - 1) + "\"]");

	if (detail != null)

	{

		var band = detail.parentNode;

		var groups = new Array();

		var i = 0;

		while (band != this.dwXML.documentElement) {

			groups[i++] = band;

			band = band.parentNode;

		}

		if (groupLevel > 0 && groupLevel <= i)

		{

			if (this.dw.eventImplemented("Expanding"))

			{

				if (this.dw.autoEventBind)

					evtResult = _evtDefault(this.dw.Expanding (row, groupLevel));

				else

					evtResult = _evtDefault(this.dw.Expanding (this.dw, row, groupLevel));

				if (evtResult != 0)

					return 1;

			}



			var j = i - groupLevel;

			// for (j = i - 1; j >= i - groupLevel; j--) {

				var bandName = groups[j].nodeName;

				this.TVExpandByBandName(bandName);

			// }



			if (this.dw.eventImplemented("Expanded"))

			{

				if (this.dw.autoEventBind)

					_evtDefault(this.dw.Expanded (row, groupLevel));

				else

					_evtDefault(this.dw.Expanded (this.dw, row, groupLevel));

			}



			this.renderTreeView();

		}

		else

			return -5;

	}

	else

		return -5;

	return 1;

}



function XMLDW_TVFilterByGroupLevel(groupLevel, bCollapse)

{

	var templateList = null;

	var i;

	var template = null;

	var matchName = null;

	var bandNum = 0;

	var bandId = null;

	var bandType = null;

	var level = null;

	var applyNode = null;



	// lookup template by bandId in XSLT

	if (this.bMozilla)

	{

		this.dwXSL = this.loadStylesheet(this.dwXSLfile);

		if (this.dwXSL.getElementsByTagNameNS + "" != "undefined")

			templateList = this.dwXSL.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "template");

		if (templateList == null || templateList.length == 0)

			templateList = this.dwXSL.getElementsByTagName("template");

	}

	else

	{

		this.dwXSL = this.loadDocument(this.dwXSLfile);

		templateList = this.dwXSL.getElementsByTagName("xsl:template");

	}



	for (i=0; i < templateList.length; i++) {

		if (this.bMozilla)

			template = templateList[i];

		else

			template = templateList.item(i);



		matchName = template.getAttribute("match");

		if (matchName != null && matchName.substring(0, 5) == "band_")

		{

			bandId = parseInt(matchName.substr(5));

			if (!isNaN(bandId))

			{

				bandNum = bandId;

				bandId = template.firstChild.getAttribute("id");

				if (bandId != null)

				{

					bandType = bandId.substr(this.dw.name.length + 1, 11);

					if (bandType != null && bandType == "groupheader")

					{

						level = bandId.substr(this.dw.name.length + 12, groupLevel.length);

						if (level != null && level == groupLevel &&

							(!groupLevel.length ||

							 bandId.charAt(this.dw.name.length + 12 + groupLevel.length) == '_'))

						{

							if (bCollapse)

							{

								if (this.Expanded[bandNum] + "" != "undefined")

									this.Expanded[bandNum] = false;

							}

							else

							{

								this.Expanded[bandNum] = true;

							}

						}

						if (this.Expanded[bandNum] + "" != "undefined" && this.Expanded[bandNum])

						{

							this.dwXSL.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");

							var bandIcons = template.selectSingleNode(".//xsl:call-template");

							if (bandIcons != null)

							{

								var clpsdName = bandIcons.getAttribute("name");

								var expdName = "minu" + clpsdName.substr(4);

								bandIcons.setAttribute("name", expdName);

							}



							// add apply-templates for detail children

							applyNode = this.dwXSL.createNode(1, "xsl:apply-templates", "http://www.w3.org/1999/XSL/Transform");

							applyNode.setAttribute("select", "*[starts-with(name(),'band') or self::detail]");

							template.appendChild(applyNode);

						}

					}

				}

			}

		}

	}



	if (this.Expanded.length > bandNum + 1)

		this.Expanded.length = bandNum + 1;

}



function XMLDW_TVExpandAll()

{

	var evtResult = 0;

	if (this.dw.eventImplemented("Expanding"))

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.Expanding (-1, -1));

		else

			evtResult = _evtDefault(this.dw.Expanding (this.dw, -1, -1));

		if (evtResult != 0)

			return 1;

	}



	this.TVFilterByGroupLevel("", false);



	if (this.dw.eventImplemented("Expanded"))

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.Expanded (-1, -1));

		else

			_evtDefault(this.dw.Expanded (this.dw, -1, -1));

	}



	this.transformTreeView();



	return 1;

}



function XMLDW_TVCollapseAll()

{

	var evtResult = 0;

	var i;

	if (this.dw.eventImplemented("Collapsing"))

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.Collapsing (-1, -1));

		else

			evtResult = _evtDefault(this.dw.Collapsing (this.dw, -1, -1));

		if (evtResult != 0)

			return 1;

	}



	for (i=0; i <= this.Expanded.length; i++) {

		if (this.Expanded[i] + "" != "undefined")

			this.Expanded[i] = false;

	}



	if (this.dw.eventImplemented("Collapsed"))

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.Collapsed (-1, -1));

		else

			_evtDefault(this.dw.Collapsed (this.dw, -1, -1));

	}



	this.renderTreeView();



	return 1;

}



function XMLDW_TVExpandAllChildren(row, groupLevel)

{

	if (this.dw == null)

		return -1;

	var evtResult = 0;

	var detail = this.dwXML.selectSingleNode("//detail[@row = \"" + (row - 1) + "\"]");

	if (detail != null)

	{

		var band = detail.parentNode;

		var groups = new Array();

		var i = 0;

		while (band != this.dwXML.documentElement) {

			groups[i++] = band;

			band = band.parentNode;

		}

		if (groupLevel > 0 && groupLevel <= i)

		{

			if (this.dw.eventImplemented("Expanding"))

			{

				if (this.dw.autoEventBind)

					evtResult = _evtDefault(this.dw.Expanding (row, groupLevel));

				else

					evtResult = _evtDefault(this.dw.Expanding (this.dw, row, groupLevel));

				if (evtResult != 0)

					return 1;

			}



			var j = i - groupLevel;

			var bandName;

			// for (j = i - 1; j >= i - groupLevel; j--) {

				bandName = groups[j].nodeName;

				this.TVExpandByBandName(bandName);

			// }



			var lastBandNum = bandNum = parseInt(bandName.substr(5));

			if (!isNaN(bandNum))

			{

				var lastBand = groups[j]; //++j

				var lastChild = null;

				do {

					lastChild = lastBand.lastChild;

					if (lastChild && lastChild.nodeName.substr(0, 5) == "band_")

					{

						var suffix = parseInt(lastChild.nodeName.substr(5));

						if (!isNaN(suffix))

						{

							lastBand = lastChild;

							lastBandNum = suffix;

						}

					}

				} while (lastBand == lastChild);



				var k;

				for (k = bandNum + 1; k <= lastBandNum; k++) {

					this.Expanded[k] = true;

				}

			}



			if (this.dw.eventImplemented("Expanded"))

			{

				if (this.dw.autoEventBind)

					_evtDefault(this.dw.Expanded (row, groupLevel));

				else

					_evtDefault(this.dw.Expanded (this.dw, row, groupLevel));

			}



			this.renderTreeView();

		}

		else

			return -5;

	}

	else

		return -5;

	return 1;

}



function XMLDW_TVCollapseAllChildren(row, groupLevel)

{

	if (this.dw == null)

		return -1;

	var evtResult = 0;

	var detail = this.dwXML.selectSingleNode("//detail[@row = \"" + (row - 1) + "\"]");

	if (detail != null)

	{

		var band = detail.parentNode;

		var groups = new Array();

		var i = 0;

		while (band != this.dwXML.documentElement) {

			groups[i++] = band;

			band = band.parentNode;

		}

		if (groupLevel > 0 && groupLevel <= i)

		{

			var bandName = groups[i - groupLevel].nodeName;

			if (this.dw.eventImplemented("Collapsing"))

			{

				if (this.dw.autoEventBind)

					evtResult = _evtDefault(this.dw.Collapsing (row, groupLevel));

				else

					evtResult = _evtDefault(this.dw.Collapsing (this.dw, row, groupLevel));

				if (evtResult != 0)

					return 1;

			}



			this.TVCollapseByBandName(bandName);



			var lastBandNum = bandNum = parseInt(bandName.substr(5));

			if (!isNaN(bandNum))

			{

				var lastBand = groups[i - groupLevel];

				var lastChild = null;

				do {

					lastChild = lastBand.lastChild;

					if (lastChild && lastChild.nodeName.substr(0, 5) == "band_")

					{

						var suffix = parseInt(lastChild.nodeName.substr(5));

						if (!isNaN(suffix))

						{

							lastBand = lastChild;

							lastBandNum = suffix;

						}

					}

				} while (lastBand == lastChild);



				var j;

				for (j = bandNum + 1; j <= lastBandNum; j++) {

					if (this.Expanded[j] + "" != "undefined")

						this.Expanded[j] = false;

				}

			}



			if (this.dw.eventImplemented("Collapsed"))

			{

				if (this.dw.autoEventBind)

					_evtDefault(this.dw.Collapsed (row, groupLevel));

				else

					_evtDefault(this.dw.Collapsed (this.dw, row, groupLevel));

			}



			this.renderTreeView();

		}

		else

			return -5;

	}

	else

		return -5;

	return 1;

}



function XMLDW_TVExpandLevel(groupLevel)

{

	var evtResult = 0;



	if (this.dw.eventImplemented("Expanding"))

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.Expanding (-1, groupLevel));

		else

			evtResult = _evtDefault(this.dw.Expanding (this.dw, -1, groupLevel));

		if (evtResult != 0)

			return 1;

	}



	var i = groupLevel;

	// for (i = 1; i <= groupLevel; i++) {

		this.TVFilterByGroupLevel(i + "", false);

	// }



	if (this.dw.eventImplemented("Expanded"))

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.Expanded (-1, groupLevel));

		else

			_evtDefault(this.dw.Expanded (this.dw, -1, groupLevel));

	}



	this.transformTreeView();



	return 1;

}



function XMLDW_TVCollapseLevel(groupLevel)

{

	var evtResult = 0;

	if (this.dw.eventImplemented("Collapsing"))

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.Collapsing (-1, groupLevel));

		else

			evtResult = _evtDefault(this.dw.Collapsing (this.dw, -1, groupLevel));

		if (evtResult != 0)

			return 1;

	}



	this.TVFilterByGroupLevel(groupLevel + "", true);



	if (this.dw.eventImplemented("Collapsed"))

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.Collapsed (-1, groupLevel));

		else

			_evtDefault(this.dw.Collapsed (this.dw, -1, groupLevel));

	}



	this.transformTreeView();



	return 1;

}



function XMLDW_TVGetContext(oldContext)

{

	var treeContext = "";

	var treeCtxStart;

	var treeCtxEnd;

	var i;

	var nodeSelected;

	var nodeContext = "";

	var newContext;



	treeCtxStart = oldContext.indexOf("(tree");

	if (treeCtxStart < 0)

		return oldContext;



	treeCtxEnd = oldContext.indexOf(")", treeCtxStart);



	if (oldContext.substr(treeCtxEnd + 1, 11) == "(SelectNode")

		treeCtxEnd = oldContext.indexOf(")", treeCtxEnd + 1);



	for (i=0; i <= this.Expanded.length; i++)

		if (this.Expanded[i] + "" != "undefined" && this.Expanded[i])

			treeContext += " " + i;



	if (this.treeNodeSelected != null)

	{

		if (this.treeNodeSelected.substr(this.dw.name.length, 12) == "_groupheader")

			nodeSelected = this.treeNodeSelected.substr(this.dw.name.length + "_groupheade".length);

		else

			nodeSelected = this.treeNodeSelected.substr(this.dw.name.length + "_detai".length);



		nodeContext = ")(SelectNode " + nodeSelected;

	}



	newContext = oldContext.substring(0, treeCtxStart + 5) + treeContext + nodeContext +

				 oldContext.substr(treeCtxEnd);



	return newContext;

}



function XMLDW_RestoreTreeContext()

{

	var treeContext;

	var treeCtxStart;

	var treeCtxEnd;

	var arrBandNums;

	var i;

	var bandNum;

	var nodeContext;

	var nodeCtxStart;

	var nodeCtxEnd;

	var rowCtxStart;

	var rowContext;



	treeCtxStart = this.dw.context.indexOf("(tree");

	if (treeCtxStart < 0)

		return;



	treeCtxEnd = this.dw.context.indexOf(")", treeCtxStart);



	if (treeCtxEnd > treeCtxStart + 5)

	{

		treeContext = this.dw.context.substring(treeCtxStart + 5, treeCtxEnd);

		arrBandNums = treeContext.split(" ");



		for (i = 0; i < arrBandNums.length; i++) {

			bandNum = parseInt(arrBandNums[i]);

			if (isNaN(bandNum))

				continue;

			this.Expanded[bandNum] = true;

		}

	}



	if (this.dw.context.substr(treeCtxEnd + 1, 11) == "(SelectNode")

	{

		nodeCtxStart = treeCtxEnd + 13;

		treeCtxEnd = nodeCtxEnd = this.dw.context.indexOf(")", nodeCtxStart);

		nodeContext = this.dw.context.substring(nodeCtxStart, nodeCtxEnd);

		if (nodeContext.charAt(0) == 'r')

			this.treeNodeSelected = this.dw.name + "_groupheade" + nodeContext;

		else

			this.treeNodeSelected = this.dw.name + "_detai" + nodeContext;

	}



	rowCtxStart = this.dw.context.indexOf("(SelectRow (", treeCtxEnd);

	for (i = 0; rowCtxStart >= 0; i++)

	{

		rowCtxStart = this.dw.context.indexOf(") ", rowCtxStart + 12);

		rowContext = this.dw.context.substr(rowCtxStart + 2);

		this.treeRowsSelected[i] = parseInt(rowContext);

		rowCtxStart = this.dw.context.indexOf("(SelectRow (", rowCtxStart + 2);

	}

}



function XMLDW_HighlightTreeNode()

{

	var nodeElementId = this.treeNodeSelected;

	var dwElement = document.getElementById(this.dw.name + "_datawindow");

	var nodeElement = null;

	var oneNodeElement;

	var i;



	if (this.dw.bSubmitted + "" != "undefined" && this.dw.bSubmitted)

		return;



	if (nodeElementId == null)

		return;



	nodeElement = dwElement.all[nodeElementId];

	if (nodeElement != null)

	{

		if (nodeElement.length + "" != "undefined")

			oneNodeElement = nodeElement[0];

		else

			oneNodeElement = nodeElement;



		// highlight selected node

		this.treeNodeBgColors[0] = oneNodeElement.style.backgroundColor;

		this.treeNodeTxtColors[0] = oneNodeElement.style.color;

		oneNodeElement.style.backgroundColor = this.dw.selectedRowColor;

		oneNodeElement.style.color = "white";

		for(i = 0; i < oneNodeElement.all.length; i++)

		{

			this.treeNodeBgColors[i+1] = oneNodeElement.all(i).style.backgroundColor;

			this.treeNodeTxtColors[i+1] = oneNodeElement.all(i).style.color;

			oneNodeElement.all(i).style.backgroundColor = this.dw.selectedRowColor;

			oneNodeElement.all(i).style.color = "white";

		}

	}

}



function XMLDW_HighlightTreeRows()

{

	var nodeElementId = null;

	var dwElement = document.getElementById(this.dw.name + "_datawindow");

	var nodeElement = null;

	var oneNodeElement;

	var i;

	var j;



	for (i = 0; i < this.treeRowsSelected.length; i++)

	{

		nodeElementId = this.dw.name + "_detail_" + this.treeRowsSelected[i];

		nodeElement = dwElement.all[nodeElementId];

		if (nodeElement != null)

		{

			if (nodeElement.length + "" != "undefined")

				oneNodeElement = nodeElement[0];

			else

				oneNodeElement = nodeElement;



			// highlight selected row

			oneNodeElement.style.backgroundColor = this.dw.selectedRowColor;

			oneNodeElement.style.color = "white";

			for(j = 0; j < oneNodeElement.all.length; j++)

			{

				oneNodeElement.all(j).style.backgroundColor = this.dw.selectedRowColor;

				oneNodeElement.all(j).style.color = "white";

			}

		}

	}

}



function XMLDW_SelectTreeNode(row, groupLevel, select)

{

	var evtResult = 0;

	var dwElement = document.getElementById(this.dw.name + "_datawindow");

	var i = 0;

	var nodeElement = null;

	var nodeElementId = null;

	var newNodeElement = null;

	var oldNodeElement = null;

	var arrNodeNums;

	var oldGroupLevel;

	var oldRow;

	var bCurrentlySelected = false;



	if (groupLevel > this.maxGroup)

		return -5;



	if (groupLevel < 1)

		groupLevel = this.maxGroup;



	// get new selection

	do {

		i++;

		if (groupLevel != this.maxGroup)

			nodeElementId = this.dw.name + "_groupheader" + groupLevel + "_" + (row - i);

		else

			nodeElementId = this.dw.name + "_detail_" + (row - i);

		nodeElement = null;

		nodeElement = dwElement.all[nodeElementId];

	} while (nodeElement == null && i < row);



	if (nodeElement == null)

		return -5;



	if (select && this.dw.eventImplemented("TreeNodeSelecting"))

	{

		if (this.dw.autoEventBind)

			evtResult = _evtDefault(this.dw.TreeNodeSelecting (row, groupLevel));

		else

			evtResult = _evtDefault(this.dw.TreeNodeSelecting (this.dw, row, groupLevel));

		if (evtResult != 0)

			return 1;

	}



	if (nodeElement.length + "" != "undefined")

		newNodeElement = nodeElement[0];

	else

		newNodeElement = nodeElement;



	// deselect old node

	nodeElement = dwElement.all[this.treeNodeSelected];

	if (nodeElement != null)

	{

		if (this.treeNodeSelected.substr(this.dw.name.length, 12) == "_groupheader")

		{

			nodeElementId = this.treeNodeSelected.substr(this.dw.name.length + 12);

			arrNodeNums = nodeElementId.split("_");

			oldGroupLevel = parseInt(arrNodeNums[0]);

			oldRow = parseInt(arrNodeNums[1]);

		}

		else

		{

			nodeElementId = this.treeNodeSelected.substr(this.dw.name.length + 8);

			oldRow = parseInt(nodeElementId);

			oldGroupLevel = this.maxGroup;

		}

		bCurrentlySelected = (row - i == oldRow && groupLevel == oldGroupLevel);



		if (select || bCurrentlySelected)

		{

			if (nodeElement.length + "" != "undefined")

				oldNodeElement = nodeElement[0];

			else

				oldNodeElement = nodeElement;

			oldNodeElement.style.backgroundColor = this.treeNodeBgColors[0];

			oldNodeElement.style.color = this.treeNodeTxtColors[0];

			for(i = 0; i < oldNodeElement.all.length; i++)

			{

				oldNodeElement.all(i).style.backgroundColor = this.treeNodeBgColors[i+1];

				oldNodeElement.all(i).style.color = this.treeNodeTxtColors[i+1];

			}

		}

	}



	// save node

	if (select)

		this.treeNodeSelected = newNodeElement.id;

	else if (bCurrentlySelected)

		this.treeNodeSelected = null;



	if (select && this.dw.eventImplemented("TreeNodeSelected"))

	{

		if (this.dw.autoEventBind)

			_evtDefault(this.dw.TreeNodeSelected (row, groupLevel));

		else

			_evtDefault(this.dw.TreeNodeSelected (this.dw, row, groupLevel));

	}



	if (select)

		this.highlightTreeNode();



	return 1;

}



function XMLDW_TVAdjustHeight()

{

	var dwElement = document.getElementById(this.dw.name + "_datawindow");

	var treeChild = dwElement.lastChild;

	var aGridlines = new Array();

	var i = 0;

	var j = 0;



	// first adjust gridline heights

	if (this.dw.processing == 9)

	{

		while (treeChild.offsetTop == 0)

		{

			aGridlines[i++] = treeChild;

			treeChild = treeChild.previousSibling;

		}



		for (j = 0; j < i; j++)

		{

			aGridlines[j].style.pixelHeight = treeChild.offsetTop + treeChild.offsetHeight;

		}

	}

	dwElement.style.pixelHeight = treeChild.offsetTop + treeChild.offsetHeight;

}



function XMLDW_RendererClass(parentDW, dwName, cssName, maxGroup, bMsxml25, bMozilla)

{

	this.arrDOMProgID = ["Msxml2.FreeThreadedDOMDocument.6.0",

						 "Msxml2.FreeThreadedDOMDocument.4.0",

						 "Msxml2.FreeThreadedDOMDocument.3.0",

						 "Msxml2.FreeThreadedDOMDocument.2.6",

						 "Msxml2.FreeThreadedDOMDocument",

						 "MSXML.FreeThreadedDOMDocument"];



	this.arrXSLTProgID = ["Msxml2.XSLTemplate.6.0",

						  "Msxml2.XSLTemplate.4.0",

						  "Msxml2.XSLTemplate.3.0",

						  "Msxml2.XSLTemplate.2.6",

						  "Msxml2.XSLTemplate"];

	this.dw = parentDW;

	this.divName = dwName;

	this.cssName = cssName;

	this.maxGroup = maxGroup;

	this.bMozilla = bMozilla;

	this.Expanded = new Array();

	this.treeBandAffected = 0;

	this.treeNodeSelected = null;

	this.treeNodeBgColors = new Array(); // original background color of each gob in selected treenode

	this.treeNodeTxtColors = new Array(); // original text color of each gob in selected treenode

	this.treeRowsSelected = new Array();



	this.createDOM = XMLDW_CreateDOM;

	this.createXSLT = XMLDW_CreateXSLT;

	if (bMsxml25)

	{

		this.loadDocument = XMLDW_LoadDocument_Msxml25;

		this.doTransform = XMLDW_DoTransform_Msxml25;

	}

	else if (bMozilla)

	{

		this.loadDocument = XMLDW_LoadDocument_Mozilla;

		this.loadStylesheet = XMLDW_LoadStylesheet_Mozilla;

		this.doTransform = XMLDW_DoTransform_Mozilla;

		this.orderBy = XMLDW_OrderBy_Mozilla;

		this.loadDocumentString = XMLDW_LoadDocumentString_Mozilla;

	}

	else

	{

		this.loadDocument = XMLDW_LoadDocument;

		this.doTransform = XMLDW_DoTransform;

		this.orderBy = XMLDW_OrderBy;

		this.loadDocumentString = XMLDW_LoadDocumentString;

	}

	this.transformClientSidePage = XMLDW_TransformClientSidePage;

	this.insertClientSide = XMLDW_InsertClientSide;

	this.deleteClientSide = XMLDW_DeleteClientSide;

	this.transformTreeView = XMLDW_TransformTreeView;

	this.renderTreeView = XMLDW_RenderTreeView;

	this.restoreTreeContext = XMLDW_RestoreTreeContext;

	this.highlightTreeNode = XMLDW_HighlightTreeNode;

	this.highlightTreeRows = XMLDW_HighlightTreeRows;

	this.selectTreeNode = XMLDW_SelectTreeNode;

	this.TVAdjustHeight = XMLDW_TVAdjustHeight;

	this.TVCollapseByBandName = XMLDW_TVCollapseByBandName;

	this.TVExpandByBandName = XMLDW_TVExpandByBandName;

	this.TVCollapseByClick = XMLDW_TVCollapseByClick;

	this.TVExpandByClick = XMLDW_TVExpandByClick;

	this.TVFilterByGroupLevel = XMLDW_TVFilterByGroupLevel;

	this.TVCollapse = XMLDW_TVCollapse;

	this.TVCollapseAll = XMLDW_TVCollapseAll;

	this.TVCollapseAllChildren = XMLDW_TVCollapseAllChildren;

	this.TVCollapseLevel = XMLDW_TVCollapseLevel;

	this.TVExpand = XMLDW_TVExpand;

	this.TVExpandAll = XMLDW_TVExpandAll;

	this.TVExpandAllChildren = XMLDW_TVExpandAllChildren;

	this.TVExpandLevel = XMLDW_TVExpandLevel;

	this.TVGetContext = XMLDW_TVGetContext;

}

function HTDW_RegisterEditMask(ColName, MaskType, EditMask)

{

	if (typeof(goEditMaskManager) == "object")

	{

		var nMaskType = parseInt(MaskType.charAt(0));

		var sCurrencyChar = "$";

		var sTailChar = "%";

		if ((nMaskType == 2 || nMaskType == 6) && (MaskType.length > 1))

		{

			if (MaskType.charAt(1) == 'C')

			{

				sCurrencyChar = MaskType.substring(3).replace(/^\s+/g, '');

				if (MaskType.charAt(2) == 'T')

					sTailChar = MaskType.substring(3);

			}

		}

		if ((nMaskType == 2 || nMaskType == 6) && (DW_decimalChar == ','))

		{

			EditMask = DW_ChangeDecimalCharAndGroupCharToCurrent(EditMask);

		}

		goEditMaskManager.Register(ColName,EditMask,nMaskType,ColName,false,ColName,ColName,false,false,

			DW_decimalChar,DW_thousandsChar,sCurrencyChar,sTailChar);

	}

}

function HTDW_DataWindowClass(name)

{

    this.name = name;

    this.submitForm = null;

    this.actionField = null;

    this.contextField = null;

    this.sortString = null;

    this.sortCol = "";

    this.sortAscending = false;

    this.action = "";

    this.bDwDotNet = false;

    this.dwControlId = name + "_datawindow";

    this.indicatorRow = -1;

    

    // private functions

    this.buttonPress = HTDW_buttonPress;

	this.performAction = HTDW_performAction;

    this.getRowHtmlElement = HTDW_getRowHtmlElement;

    this.showRowFocusIndicator =  HTDW_showRowFocusIndicator;

    this.getTreeContext = HTDW_getTreeContext;

    this.hookElementsEvent = HTDW_hookElementsEvent;

    this.hookBandElementsEvent = HTDW_hookBandElementsEvent;

    this.unhookElementsEvent = HTDW_unhookElementsEvent;

    this.unhookBandElementsEvent = HTDW_unhookBandElementsEvent;



    this.eventImplemented = HTDW_eventImplemented;

    this.itemClicked = HTDW_itemClicked;

    this.itemDoubleClicked = HTDW_itemDoubleClicked;

    this.itemRButtonDown = HTDW_itemRButtonDown;

    this.addEventImplementation = HTDW_AddEventImplementation;

    this.autoEventBind = true;

	this.bSuppressItemGainFocusCallback=false;

	this.oPBNETData = null;

	this.nOutOfFocusRow = -1;

	this.nOutOfFocusCol = -1;

	this.nNonDetailRow = 0;

	this.strRawNewValue = ""



    // public function

    this.GetFullContext = HTDW_GetFullContext;   

    

    this.currRow = -1;

    this.currCol = -1;

    this.actionRow = -1;

    this.forcingBackFocusTo = null;

    this.currentControl = null;

    this.bSingleRow = false;

    this.acceptControl = null;

    this.bDisallowFocusChange = false;

    this.bProcessingLoseFocus = false;

    

    this.gobs = new Object();

    this.rows = new Array();

    this.cols = new Array();

    this.navLayerForms = new Array();

    this.exprCtx = new HTDW_exprContextClass(this);



    // private functions

    this.getChanges = HTDW_getChanges;

    this.itemLoseFocus = HTDW_itemLoseFocus;

    this.selectControlContent = HTDW_selectControlContent;

    this.itemError = HTDW_itemError;

    this.itemGainFocus = HTDW_itemGainFocus;

    this.restoreFocus = HTDW_restoreFocus;

    this.forceBackFocus = HTDW_forceBackFocus;

    this.forceBackFocusTimeout = HTDW_forceBackFocusTimeout;

    this.findControl = HTDW_findControl;

    this.setCheckboxValue = HTDW_setCheckboxValue;

    this.positionComboBox = HTDW_positionComboBox;

    this.addDDDWOptions = HTDW_addDDDWOptions;

    this.removeDDDWOptions = HTDW_removeDDDWOptions;

    this.overrideDDDWSelect = HTDW_overrideDDDWSelect;

    this.setDDDWVisible = HTDW_setDDDWVisible;

    this.scrollDDDW = HTDW_scrollDDDW;

    this.setDDDWItem = HTDW_setDDDWItem;



    // public functions

    this.AcceptText = HTDW_acceptText;



	this.linkedDataWindows = new Array();

	this.share = HTDW_share;

	this.refreshSharedDataWindows = HTDW_refreshSharedDataWindows;

	this.refreshControl = HTDW_refreshControl;

	this.bIsSlaveSharedDataWindow = false;



	this.bIsQueryMode = false;

	this.bIsQuerySort = false;

	this.ValidateQueryCriterion = HTDW_validateQueryCriterion; 



    // private functions

    this.rowInfos = new Array();

    this.getColNum = HTDW_getColNum;

    this.getRowSelectedChanges = HTDW_getRowSelectedChanges;

    

    // public functions

    this.AcceptText = HTDW_acceptText;

	this.DeletedCount = HTDW_DeletedCount;

	this.DeleteRow = HTDW_DeleteRow;

	this.GetClickedColumn = HTDW_GetClickedColumn;

	this.GetClickedRow = HTDW_GetClickedRow;

	this.GetColumn = HTDW_GetColumn;

	this.GetNextModified = HTDW_GetNextModified;

	this.GetRow = HTDW_GetRow;

	this.GetItem = HTDW_GetItem;

	this.GetItemStatus = HTDW_GetItemStatus;

	this.InsertRow = HTDW_InsertRow;

	this.IsRowSelected = HTDW_IsRowSelected;

	this.ModifiedCount = HTDW_ModifiedCount;

	this.Retrieve = HTDW_Retrieve;

	this.RowCount = HTDW_RowCount;

	this.ScrollFirstPage = HTDW_ScrollFirstPage;

	this.ScrollLastPage = HTDW_ScrollLastPage;

	this.ScrollNextPage = HTDW_ScrollNextPage;

	this.ScrollPriorPage = HTDW_ScrollPriorPage;

	this.SelectRow = HTDW_SelectRow;

	this.SetScroll = HTDW_SetScroll;

	this.SetItem = HTDW_SetItem;

	this.SetColumn = HTDW_SetColumn;

	this.SetRow = HTDW_SetRow;

	this.SetSort = HTDW_SetSort;

	this.Sort = HTDW_Sort;

	this.Update = HTDW_Update;



	// treeview functions

	this.Collapse = HTDW_Collapse;

	this.CollapseAll = HTDW_CollapseAll;

	this.CollapseAllChildren = HTDW_CollapseAllChildren;

	this.CollapseLevel = HTDW_CollapseLevel;

	this.Expand = HTDW_Expand;

	this.ExpandAll = HTDW_ExpandAll;

	this.ExpandAllChildren = HTDW_ExpandAllChildren;

	this.ExpandLevel = HTDW_ExpandLevel;

//	this.IsExpanded = HTDW_IsExpanded;

	this.SelectTreeNode = HTDW_SelectTreeNode;

}



// determine the client browser

// this should be used only where ABSOLUTELY necessary

// Generic JavaScript should be used where ever possible

HTDW_DataWindowClass.isNav4 = false;

HTDW_DataWindowClass.isIE4 = false;

if (parseInt(navigator.appVersion) >= 4)

    {

    HTDW_DataWindowClass.isNav4 = (navigator.appName == "Netscape");

    HTDW_DataWindowClass.isIE4 = (navigator.appName.indexOf("Microsoft") != -1);

    }



function DW_ShowCodeTableDisplayValue(formatString, value)

{

    if (value == null)

        return "";

    var result = value.toString();

    var i;

    for (i = 0; i < this.column.displayValue.length; i++)

        if (value.toString() == this.column.dataValue[i])

            {

            result = this.column.displayValue[i];

            i = this.column.displayValue.length; 

            }

    

   return result;

}



// between is inclusive

function DW_Between(val, test1, test2)

{

    if (val == null || test1 == null || test2 == null)

        return false;

        

    if (test1 <= val && val <= test2)

        return true;

    else

        return false;

}



function DW_BetweenByFunc(val, test1, test2, func)

{

    return func(test1, val) >= 0 && func(val, test2) <= 0;

}



function DW_In(testValue)

{

    var bResult = false;



    for (var i=1; i < arguments.length; i++)

        {

        if (arguments[i] == testValue)

            {

            bResult = true;

            break;

            }

        }

    return bResult;

}



function DW_InByFunc(testValue, func)

{

    var bResult = false;



    for (var i=2; i < arguments.length; i++)

        {

        if (func(arguments[i],testValue) == 0)

            {

            bResult = true;

            break;

            }

        }

    return bResult;

}


