//**************************************************************************
//		Copyright  Sybase, Inc. 2004-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.
//
//	 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!!!!		      **
//       ***************************************************************
//**************************************************************************

var PBDataWindow_ClickTimeout = 750;

var PBDataWindow_CurrentDW = null;

var PBDataWindow_Submitting = false;

function PBDataWindow_SetTextBoxClickEvent(dwName)
{
	var oTextBox = document.getElementById(dwName + "_toppageno");
	if (oTextBox)
	{
		oTextBox.onclick = PBDataWindow_TextBoxClickEvent;
		oTextBox.onfocus = PBDataWindow_TextBoxFocusEvent;
	}

	oTextBox = document.getElementById(dwName + "_bottompageno");
	if (oTextBox)
	{
		oTextBox.onclick = PBDataWindow_TextBoxClickEvent;
		oTextBox.onfocus = PBDataWindow_TextBoxFocusEvent;
	}
}

function PBDataWindow_TextBoxFocusEvent()
{
	goWindowManager.OnFocusOwn(event.srcElement.id);
}

function PBDataWindow_OnDropDownDDDW(sender)
{
	goWindowManager.OnFocusOwn(sender.dwControlId);
}

function PBDataWindow_TextBoxClickEvent()
{
	event.srcElement.focus();
}

function PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName)
{
	PBDataWindow_CurrentDW = sender;
	PBDataWindow_EraseRejectedText(sender);
	goWindowManager.OnFocusOwn(sender.dwControlId);
	PBDataWindow_CurrentDW = null;
}

var PBDataWindow_PendingDW = null;

function PBDataWindow_RecordRejectedText(sender, rowNumber, columnName, newValue)
{
	if(sender.rejectedRow.value != rowNumber || sender.rejectedColumn.value != sender.currCol)
	{
		sender.rejectedValue.value = newValue;
		sender.rejectedRow.value = rowNumber;
		sender.rejectedColumnName.value = columnName;
		sender.rejectedColumn.value = sender.currCol;
		PBDataWindow_PendingDW = sender;
	}
}

function PBDataWindow_EraseRejectedText(sender)
{
	PBDataWindow_PendingDW = null;
	sender.rejectedValue.value = "";
	sender.rejectedRow.value = -1;
	sender.rejectedColumnName.value = "";
	sender.rejectedColumn.value = -1;
}

function PBDataWindow_DelayedPendingDataPostback()
{
	if(PBDataWindow_CurrentDW != null)
	{
		PB_ShowMask();
		PBDataWindow_Submitting = true;
		if (!PBDataWindow_CurrentDW.submit())
		{
			PB_HideMask();
			PBDataWindow_Submitting = false;
		}
	}
	else 	
	{
		PB_ShowMask();
		if((PBDataWindow_PendingDW + "" != "undefined") && (PBDataWindow_PendingDW != null))
		{
			PBDataWindow_Submitting = true;
			if (!PBDataWindow_PendingDW.submit())
			{
				PB_HideMask();
				PBDataWindow_Submitting = false;
			}
		}
	}
}

var PBDataWindow_PendingSubmitTimeout;

function PBDataWindow_OnGlobalChangeFocus()
{
	if(PBDataWindow_PendingDW != null)
		if(PBDataWindow_PendingDW != PBDataWindow_CurrentDW)
		{
			clearTimeout(PBDataWindow_PendingSubmitTimeout);
			PBDataWindow_PendingSubmitTimeout=setTimeout("PBDataWindow_DelayedPendingDataPostback()",1500);
		}
}

function PBNETData_submit(sender)
{
	PB_ShowMask();
	PBDataWindow_EraseRejectedText(sender)
	sender.action = sender.oPBNETData.getAction();
	PBDataWindow_Submitting = true;
	this.bSubmitted = sender.submit();
	PBDataWindow_Submitting = this.bSubmitted;
	if (!this.bSubmitted)
		PB_HideMask();
}

function PBNETData_submit2(sender)
{
	PBDataWindow_EraseRejectedText(sender)
	sender.action = sender.oPBNETData.getAction();
	PBDataWindow_Submitting = true;
	this.bSubmitted = sender.submit();
	PBDataWindow_Submitting = this.bSubmitted;
}


function PBNETData_submitEmpty(sender)
{
	PB_ShowMask();	
	sender.action = "";
	PBDataWindow_Submitting = true;
	this.bSubmitted = sender.submit();
	PBDataWindow_Submitting = this.bSubmitted;
	if (!this.bSubmitted)
		PB_HideMask();
}


function PBNETData_getAction()
{
	var action = "genericpostback";
	action = action + "|" + this.nOutOfFocusRow;//-----------------1
	action = action + "|" + this.nOutOfFocusCol;//-----------------2
	action = action + "|" + this.strOutOfFocusObjName;//-----------3
	action = action + "|" + this.nInFocusRow;//--------------------4
	action = action + "|" + this.nInFocusCol;//--------------------5
	action = action + "|" + this.strInFocusObjName;//--------------6
	action = action + "|" + this.newValue;//-----------------------7
	if(this.bNewValueIsNull)//-------------------------------------8
		action = action + "|1";
	else
		action = action + "|0";
	action = action + "|" + this.nXpos;//--------------------------9
	action = action + "|" + this.nYpos;//-------------------------10
	if(this.bIsButton)//------------------------------------------11
		action = action + "|1";
	else
		action = action + "|0";
	if(!this.bIsButton&&this.bIsChangeFocus)//--------------------12
		action = action + "|1";
	else
		action = action + "|0";
	if(this.bIsItemError)//---------------------------------------13
		action = action + "|1";
	else
		action = action + "|0";	
	if(this.bIsItemChanged)//-------------------------------------14
		action = action + "|1";
	else
		action = action + "|0";

	if(this.bIncludesClick)//-------------------------------------15
		action = action + "|1";
	else
		action = action + "|0";
	action = action + "|" + this.strButtonAction;//---------------16

	action = action + "|" + this.secondNewValue;//----------------17

	if(this.bIsSecondItemChanged)//-------------------------------18
		action = action + "|1";
	else
		action = action + "|0";
	if(this.bIncludesDblClick)//----------------------------------19
		action = action + "|1";
	else
		action = action + "|0";
	action = action + "|" + this.nClickedRow;//-------------------20
	if(this.bIsRButtonDown)//-------------------------------------21
		action = action + "|1";
	else
		action = action + "|0";
	if(this.bIsSelect)//------------------------------------------22
		action = action + "|1";
	else
		action = action + "|0";
	action = action + "|" + this.nGraphXpos;//--------------------23
	action = action + "|" + this.nGraphYpos;//--------------------24
	action = action + "|" + this.nNonDetailRow;//-----------------25
	action = action + "|" + this.strRawNewValue;//----------------26
	action = action + "|" + this.strLastEvent;//------------------27


	action = action + "|" + this.strLog;

	return action;
}

function PBNETData()
{
	this.nOutOfFocusRow = -1;
	this.nOutOfFocusCol = -1;
	this.strOutOfFocusObjName = "";
	this.nInFocusRow = -1;
	this.nInFocusCol = -1;
	this.strInFocusObjName = "";
	this.newValue = "";
	this.bNewValueIsNull = false;
	this.nXpos = -1;
	this.nYpos = -1;
	this.bIsButton = false;
	this.bIsChangeFocus = false;
	this.bIsItemError = false;
	this.bIsItemChanged=false;
	this.bIncludesClick=false;
	this.strButtonAction="";
	this.secondNewValue = "";
	this.bIsSecondItemChanged = false;
	this.bIncludesDblClick = false;
	this.nClickedRow = -1;
	this.bIsRButtonDown = false;
	this.bIsSelect = false;
	this.nGraphXpos = -1;
	this.nGraphYpos = -1;
	this.nNonDetailRow = 0;
	this.strRawNewValue = "";
	this.strLastEvent = "";

	this.getAction = PBNETData_getAction;
	this.submit = PBNETData_submit;
	this.submit2 = PBNETData_submit2;
	this.submitEmpty = PBNETData_submitEmpty;

	this.strLog="";

	this.bSubmitted=false;
	this.bAfterFocusChanged=false;
	this.controlInFocus=null;

}

function PBDataWindow_ImmediateRButtonDownPostbackIfInDataWindow(element)
{
	if(element.pbtype == "datawindow" && element.pbenabled == "1")
	{
		var sender = eval(element.dwobj);
		var dwElement = document.getElementById(sender.name + "_datawindow");
		if (sender.eventImplemented("RButtonDown") && (dwElement == null || dwElement.onmousedown == null))
		{
			PBDataWindow_ImmediateRButtonDownPostback(sender, element);
			return true;
		}
		else
			return false;
	}
	if(element.parentElement == null)
		return false;
	return PBDataWindow_ImmediateRButtonDownPostbackIfInDataWindow(element.parentElement);
}

function PBDataWindow_ImmediateRButtonDownPostback(sender, element)
{
	PBDataWindow_EraseRejectedText(sender);
	sender.action = "rbuttondown|" + (event.clientX - element.offsetLeft) + "|" + (event.clientY - element.offsetTop);
	PBDataWindow_Submitting = true;
	this.bSubmitted = sender.submit();
	PBDataWindow_Submitting = this.bSubmitted;
}

function PBDataWindow_OnShareDataRefresh_Postback(sender)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	if(sender.oPBNETData.bSubmitted)
		return;
	sender.oPBNETData.submitEmpty(sender);
}


function PBDataWindow_ClickedDifferentRow(sender, rowNumber, objectName)
{
	var oSource = window.event.srcElement;
	var tagName = oSource.tagName.toUpperCase();

	var canContinue = false;
	if (oSource.readOnly + "" != "undefined")
	{					
		if (oSource.readOnly)
		{
			canContinue = true;
		}
	}
	if(tagName == "SPAN")
	{
		canContinue = true;
	}

	if(!canContinue)
		return;

	if(rowNumber==sender.currRow+1)
	{
		return;
	}

	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();


	if(sender.oPBNETData.bSubmitted)
		return;

	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_Clicked";

	sender.oPBNETData.nClickedRow = rowNumber;
	sender.oPBNETData.bIncludesClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.nGraphXpos = window.event.offsetX;
	sender.oPBNETData.nGraphYpos = window.event.offsetY;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.strInFocusObjName = objectName;
	sender.oPBNETData.nInFocusCol = sender.getColNum(objectName);
	sender.oPBNETData.bIsChangeFocus = true;
	sender.oPBNETData.nNonDetailRow = sender.nNonDetailRow;

	sender.oPBNETData.submit(sender);
}

function PBDataWindow_DelayedClickedDifferentRow(sender, rowNumber, objectName)
{
	var oSource = window.event.srcElement;
	var tagName = oSource.tagName.toUpperCase();

	var canContinue = false;
	if (oSource.readOnly + "" != "undefined")
	{					
		if (oSource.readOnly)
		{
			canContinue = true;
		}
	}
	if(tagName == "SPAN")
	{
		canContinue = true;
	}

	if(!canContinue)
		return;

	if(rowNumber==sender.currRow+1)
	{
		return;
	}

	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();


	if(sender.oPBNETData.bSubmitted)
		return;

	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_Clicked";

	sender.oPBNETData.nClickedRow = rowNumber;
	sender.oPBNETData.bIncludesClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.nGraphXpos = window.event.offsetX;
	sender.oPBNETData.nGraphYpos = window.event.offsetY;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.strInFocusObjName = objectName;
	sender.oPBNETData.nInFocusCol = sender.getColNum(objectName);
	sender.oPBNETData.bIsChangeFocus = true;

	PBDataWindow_ControlWithPendingPostback = sender;
	clearTimeout(PBDataWindow_DoubleClickedTimeout);
	PBDataWindow_DoubleClickedTimeout=setTimeout("PBDataWindow_DelayedClickedPostback()",PBDataWindow_ClickTimeout);
}


function PBDataWindow_Clicked(sender, rowNumber, objectName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();


	if(sender.oPBNETData.bSubmitted)
		return;


	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_Clicked";

	sender.oPBNETData.nClickedRow = rowNumber;
	sender.oPBNETData.bIncludesClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.nGraphXpos = window.event.offsetX;
	sender.oPBNETData.nGraphYpos = window.event.offsetY;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.strInFocusObjName = objectName;
	sender.oPBNETData.nInFocusCol = sender.getColNum(objectName);
	sender.oPBNETData.nNonDetailRow = sender.nNonDetailRow;

	if(sender.bSelectClicked != null)
		if(sender.bSelectClicked)
			sender.oPBNETData.bIsSelect = true;


	if (sender.eventImplemented("ItemFocusChanged"))
	{
		if(sender.oPBNETData.nOutOfFocusRow<=-1)
			sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
		if(sender.oPBNETData.nOutOfFocusCol<=-1)
			sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
			
	}

	var oSource = window.event.srcElement;
	var tagName = oSource.tagName.toUpperCase();
	var tagType = oSource.type;

	var bDontWaitForFocusChanged = false;
	if(sender.eventImplemented("ItemFocusChanged"))
	{
		var tmp = sender["ItemFocusChanged"] + "";
		var tmp2 = "function PBDataWindow_ItemFocusChangedClientProcess(";
		if(tmp.substring(0,tmp2.length)==tmp2)
			bDontWaitForFocusChanged = true;	
		if(!bDontWaitForFocusChanged && !sender.oPBNETData.bIsItemChanged)
		{
			tmp2 = "function PBDataWindow_ItemFocusChanged_AND_ItemChanged(" 
			if(tmp.substring(0,tmp2.length)==tmp2)
				bDontWaitForFocusChanged = true;	
		}		
	}

	if (!bDontWaitForFocusChanged&&sender.eventImplemented("ItemFocusChanged")&&!oSource.isDisabled && ((tagName == "INPUT")
		|| (tagName == "SELECT")
		|| (tagName == "TEXTAREA")))
	{
		var oType = oSource.type.toUpperCase();
		if (oType != "HIDDEN")
		{
			var backToServer = false;
			if (oSource.readOnly + "" != "undefined")
			{					
				if (oSource.readOnly)
				{
					backToServer = true;
				}
			}

			if (oSource.tabIndex + "" != "undefined")
			{
				if (oSource.tabIndex < 0)
				{
					backToServer = true;
				}
			}

			if (!backToServer)
			{
				return 0;
			}
		}
	}

	if(tagName == "SELECT")
		if(oSource.onmouseup == null )
			return 0;
	
	var bFullPostback = true;
	if (sender.eventImplemented("BrowserEventClicked"))
	{
		var result;
                if(sender.autoEventBind)			
			result = _evtDefault(sender.BrowserEventClicked(rowNumber, objectName));		
		else						
			result = _evtDefault(sender.BrowserEventClicked(sender, rowNumber, objectName));
		if(result == 0)
		{
			sender.oPBNETData = null; 
			return 0;			
		}
		if(result == 1)
		{
			sender.oPBNETData = null; 
			return 1;			
		}
		if(result == 2)
		{
			bFullPostback = false;
		}
	}

	if (sender.eventImplemented("ItemFocusChanged"))
	{
		if(sender.oPBNETData.nInFocusCol!=sender.oPBNETData.nOutOfFocusCol)
			sender.oPBNETData.bIsChangeFocus = true;
		if(sender.oPBNETData.nInFocusRow!=sender.oPBNETData.nOutOfFocusRow)
			sender.oPBNETData.bIsChangeFocus = true;
	}

	sender.oPBNETData.strLastEvent = "Clicked";	


	if(bFullPostback)
	{
		if(tagName == "BUTTON")
			return;
		
		if(tagName == "INPUT")
			if(tagType == "button" || tagType == "image")
				return;


		var bReadOnlyControl = false;
		var bNegativeTabIndexControl;
		if (sender.clickedControl + "" != "undefined")
		{
 			if (sender.clickedControl.readOnly + "" != "undefined")
			{
				bReadOnlyControl = sender.clickedControl.readOnly;
			}
			if (sender.clickedControl.tabIndex + "" != "undefined")
			{
				if(sender.clickedControl.tabIndex < 0 )
					bNegativeTabIndexControl = true;
			}

			if(sender.clickedControl.onfocus != null && !bNegativeTabIndexControl && !bReadOnlyControl )
			{
				sender.indicatorRow = rowNumber - 1;
			}
			else if(sender.allColumnsAreProtected+ "" != "undefined" && sender.allColumnsAreProtected == true )
			{
				sender.indicatorRow = rowNumber - 1;
			}
		}
		sender.oPBNETData.submit(sender);
	}
	else
	{
		sender.eventsCallback();
		sender.oPBNETData = null;
		return sender.eventCallbackResult;
	}
}

function PBDataWindow_RButtonDown(sender, rowNumber, objectName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_RButtonDown";

	if(sender.oPBNETData.nOutOfFocusRow<=-1)
		sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
	if(sender.oPBNETData.nOutOfFocusCol<=-1)
		sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;

	sender.oPBNETData.nClickedRow = rowNumber;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.nGraphXpos = window.event.offsetX;
	sender.oPBNETData.nGraphYpos = window.event.offsetY;
	sender.oPBNETData.bIsRButtonDown = true;
	sender.oPBNETData.nNonDetailRow = sender.nNonDetailRow;

	if(sender.oPBNETData.bSubmitted)
		return;

	if(objectName == "datawindow")
	{
		if(event.srcElement != null)
			if(event.srcElement.gobname != null)
				objectName = event.srcElement.gobname;
	}

	if(objectName == "datawindow")
	{
		if(event.srcElement != null)
			if(event.srcElement.children != null)
				if(event.srcElement.children.length >=1)
					if(event.srcElement.children[0].gobname != null)
						objectName = event.srcElement.children[0].gobname;
	}
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.strInFocusObjName = objectName;

	sender.oPBNETData.nInFocusCol = sender.getColNum(objectName);

	goWindowManager.SetPointer();
	sender.oPBNETData.submit2(sender);
}

var PBDataWindow_ControlWithPendingPostback = null;

var PBDataWindow_DoubleClickedTimeout;

function PBDataWindow_DelayedClickedPostback()
{
	if(PBDataWindow_ControlWithPendingPostback!=null)
	{
		PBDataWindow_ControlWithPendingPostback.oPBNETData.submit(PBDataWindow_ControlWithPendingPostback);	
		PBDataWindow_ControlWithPendingPostback = null;	
	}
}

function PBDataWindow_DelayedClicked(sender, rowNumber, objectName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();


	if(sender.oPBNETData.bSubmitted)
		return;


	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_DelayedClicked";

	sender.oPBNETData.nClickedRow = rowNumber;
	sender.oPBNETData.bIncludesClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.nGraphXpos = window.event.offsetX;
	sender.oPBNETData.nGraphYpos = window.event.offsetY;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.strInFocusObjName = objectName;
	sender.oPBNETData.nInFocusCol = sender.getColNum(objectName);
	if(sender.bSelectClicked != null)
		if(sender.bSelectClicked)
			sender.oPBNETData.bIsSelect = true;

	if (sender.eventImplemented("ItemFocusChanged"))
	{
		if(sender.oPBNETData.nOutOfFocusRow<=-1)
			sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
		if(sender.oPBNETData.nOutOfFocusCol<=-1)
			sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
			
	}


	var oSource = window.event.srcElement;
	var tagName = oSource.tagName.toUpperCase();

	var bItemFocusChangedClientProcess = false;
	if(sender.eventImplemented("ItemFocusChanged"))
	{
		var tmp = sender["ItemFocusChanged"] + "";
		var tmp2 = "function PBDataWindow_ItemFocusChangedClientProcess(";
		if(tmp.substring(0,tmp2.length)==tmp2)
			bItemFocusChangedClientProcess = true;			
	}

	if (!bItemFocusChangedClientProcess&&sender.eventImplemented("ItemFocusChanged")&&!oSource.isDisabled && ((tagName == "INPUT")
		|| (tagName == "SELECT")
		|| (tagName == "TEXTAREA")))
	{
		var oType = oSource.type.toUpperCase();
		if (oType != "HIDDEN")
		{
			var backToServer = false;
			if (oSource.readOnly + "" != "undefined")
			{					
				if (oSource.readOnly)
				{
					backToServer = true;
				}
			}

			if (oSource.tabIndex + "" != "undefined")
			{
				if (oSource.tabIndex < 0)
				{
					backToServer = true;
				}
			}

			if (!backToServer)
			{
				return 0;
			}
		}
	}

	if(tagName == "SELECT")
		if(oSource.onmouseup == null )
			return 0;

	if (sender.eventImplemented("ItemFocusChanged"))
	{
		if(sender.oPBNETData.nInFocusCol!=sender.oPBNETData.nOutOfFocusCol)
			sender.oPBNETData.bIsChangeFocus = true;
		if(sender.oPBNETData.nInFocusRow!=sender.oPBNETData.nOutOfFocusRow)
			sender.oPBNETData.bIsChangeFocus = true;
	}


	var bReadOnlyControl = false;
	var bNegativeTabIndexControl;
	if (sender.clickedControl + "" != "undefined")
	{
		if (sender.clickedControl.readOnly + "" != "undefined")
		{
			bReadOnlyControl = sender.clickedControl.readOnly;
		}
		if (sender.clickedControl.tabIndex + "" != "undefined")
		{
			if(sender.clickedControl.tabIndex < 0 )
				bNegativeTabIndexControl = true;
		}

		if(sender.clickedControl.onfocus != null && !bNegativeTabIndexControl && !bReadOnlyControl )
		{
			sender.indicatorRow = rowNumber - 1;
		}
		else if(sender.allColumnsAreProtected+ "" != "undefined" && sender.allColumnsAreProtected == true )
		{
			sender.indicatorRow = rowNumber - 1;
		}
	}
	PBDataWindow_ControlWithPendingPostback = sender;
	clearTimeout(PBDataWindow_DoubleClickedTimeout);
	PBDataWindow_DoubleClickedTimeout=setTimeout("PBDataWindow_DelayedClickedPostback()",PBDataWindow_ClickTimeout);
}



function PBDataWindow_DoubleClicked(sender, rowNumber, objectName)
{
	PBDataWindow_ControlWithPendingPostback = null;
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_DoubleClicked";
	if(sender.oPBNETData.bSubmitted)
		return;
	sender.oPBNETData.nClickedRow = rowNumber;
	sender.oPBNETData.bIncludesDblClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.nGraphXpos = window.event.offsetX;
	sender.oPBNETData.nGraphYpos = window.event.offsetY;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.strInFocusObjName = objectName;
	sender.oPBNETData.nInFocusCol = sender.getColNum(objectName);
	sender.oPBNETData.nNonDetailRow = sender.nNonDetailRow;

    if(!sender.oPBNETData.bIsChangeFocus)
    {
        if(sender.oPBNETData.nOutOfFocusCol <=0 || sender.oPBNETData.nOutOfFocusRow <=0 )
        {
            sender.oPBNETData.nOutOfFocusCol = sender.oPBNETData.nInFocusCol;
            sender.oPBNETData.nOutOfFocusRow = sender.oPBNETData.nInFocusRow;
        }
    }
    
	sender.oPBNETData.submit(sender);
}


function PBDataWindow_ButtonClicking(sender, rowNumber, buttonName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ButtonClicking";
	if(sender.oPBNETData.bSubmitted)
		return;
	sender.oPBNETData.bIncludesClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.bIsButton = true;
	sender.oPBNETData.strInFocusObjName = buttonName;
	sender.oPBNETData.nInFocusRow = rowNumber;
	if(sender.oPBNETData.nInFocusCol<=-1) 
		sender.oPBNETData.nInFocusCol = sender.currCol;
	sender.oPBNETData.bIsChangeFocus = false;
	if(sender.action!=null)
		if(sender.action!="") 
		{
			if (sender.AcceptText() != 1)         			
				return 1;			
			sender.oPBNETData.strButtonAction = sender.action;	
			sender.oPBNETData.submit(sender);
			return 1;
		}
}

function PBDataWindow_ButtonClicked(sender, rowNumber, buttonName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ButtonClicked";
	if(sender.oPBNETData.bSubmitted)
		return;
	sender.oPBNETData.bIncludesClick=true;
	sender.oPBNETData.nXpos = window.event.clientX;
	sender.oPBNETData.nYpos = window.event.clientY;
	sender.oPBNETData.bIsButton = true;
	sender.oPBNETData.strInFocusObjName = buttonName;
	sender.oPBNETData.nInFocusRow = rowNumber;
	if(sender.oPBNETData.nInFocusCol<=-1) 
		sender.oPBNETData.nInFocusCol = sender.currCol;
	sender.oPBNETData.bIsChangeFocus = false;
	sender.oPBNETData.submit(sender);
}


function PBDataWindow_ItemFocusChanged(sender,rowNumber,columnName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	if(sender.oPBNETData.controlInFocus==this.currentControl)
	{
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	sender.oPBNETData.controlInFocus=this.currentControl;
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemFocusChanged";
	sender.oPBNETData.bAfterFocusChanged=true;
	if(sender.oPBNETData.bSubmitted)
		return;
	if(sender.oPBNETData.nOutOfFocusRow<=-1)
		sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
	if(sender.oPBNETData.nOutOfFocusCol<=-1)
		sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.nInFocusCol = sender.currCol;
	sender.oPBNETData.strInFocusObjName = columnName;
	sender.oPBNETData.bIsChangeFocus = true;

	if(sender.currentControl.type == "checkbox" ||	sender.currentControl.type == "radio" )
		if(sender.eventImplemented("ItemChanged"))		
		{
			PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
			return;
		}

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
	{
		if(sender.currentControl.options.length<1)
			sender.setDDDWVisible(columnName,false);
	}
    
	PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
    
	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
	{
		if(sender.oPBNETData.nOutOfFocusRow == sender.oPBNETData.nInFocusRow && sender.oPBNETData.nOutOfFocusCol == sender.oPBNETData.nInFocusCol)
		{
			PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
			return; 
		}
	}

	var bFullPostback = true;
	if (sender.eventImplemented("BrowserEventItemFocusChanged"))
	{
		var result;
		if(sender.autoEventBind)			
			result = _evtDefault(sender.BrowserEventItemFocusChanged(rowNumber, columnName));		
		else			
			result = _evtDefault(sender.BrowserEventItemFocusChanged(sender, rowNumber, columnName));
		if(result == 0)
		{
			sender.oPBNETData = null; 
			return 0;			
		}
		if(result == 1)
		{
			bFullPostback = false;
		}
	}
	sender.oPBNETData.strLastEvent = "ItemFocusChanged";	
	if(bFullPostback)
	{
		if (sender.eventImplemented("Clicked"))
		{
			PBDataWindow_ControlWithPendingPostback = sender;
			clearTimeout(PBDataWindow_DoubleClickedTimeout);
			PBDataWindow_DoubleClickedTimeout=setTimeout("PBDataWindow_DelayedClickedPostback()",PBDataWindow_ClickTimeout);
		}
		else if(sender.eventImplemented("DoubleClicked")) 
		{
			PBDataWindow_ControlWithPendingPostback = sender;
			clearTimeout(PBDataWindow_DoubleClickedTimeout);
			PBDataWindow_DoubleClickedTimeout=setTimeout("PBDataWindow_DelayedClickedPostback()",PBDataWindow_ClickTimeout);
		}
		else
		{
			sender.oPBNETData.submit(sender);
		}
	}
	else
	{
		sender.eventsCallback();
		sender.oPBNETData = null;
		return sender.eventCallbackResult;
	}
}

function PBDataWindow_ItemFocusChanged_AND_ItemError(sender,rowNumber,columnName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	if(sender.oPBNETData.controlInFocus==this.currentControl)
	{
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	sender.oPBNETData.controlInFocus=this.currentControl;
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemFocusChanged_AND_ItemError";
	sender.oPBNETData.bAfterFocusChanged=true;
	if(sender.oPBNETData.bSubmitted)
		return;
	if(!sender.oPBNETData.bIsItemError)
	{
		if(PBDataWindow_ControlWithPendingPostback==null)
			sender.oPBNETData = null;
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	if(sender.oPBNETData.nOutOfFocusRow<=-1)
		sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
	if(sender.oPBNETData.nOutOfFocusCol<=-1)
		sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.nInFocusCol = sender.currCol;
	sender.oPBNETData.strInOfFocusObjName = columnName;
	sender.oPBNETData.bIsChangeFocus = true;

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
		if(sender.currentControl.options.length<1)
			sender.setDDDWVisible(columnName,false);

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
		sender.oPBNETData.bIsSelect = true;
	if(sender.currentControl.isdddw + "" == "1")
		sender.oPBNETData.bIsSelect = true;
	if(sender.currentControl.gob.bDDCalendar)
		sender.oPBNETData.bIsSelect = true;


	PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
    
	sender.oPBNETData.submit(sender);
}

function PBDataWindow_ItemFocusChanged_AND_ItemChanged(sender,rowNumber,columnName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	if(sender.oPBNETData.controlInFocus==this.currentControl)
	{
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	sender.oPBNETData.controlInFocus=this.currentControl;
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemFocusChanged_AND_ItemChanged";
	sender.oPBNETData.bAfterFocusChanged=true;
	if(sender.oPBNETData.bSubmitted)
		return;
	if(!sender.oPBNETData.bIsItemChanged)
	{
		if(PBDataWindow_ControlWithPendingPostback==null)
			sender.oPBNETData = null;
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	if(sender.oPBNETData.nOutOfFocusRow<=-1)
		sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
	if(sender.oPBNETData.nOutOfFocusCol<=-1)
		sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.nInFocusCol = sender.currCol;
	sender.oPBNETData.strInFocusObjName = columnName;
	sender.oPBNETData.bIsChangeFocus = true;
	if(sender.currentControl.type == "checkbox" ||sender.currentControl.type == "radio")
	{
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
		if(sender.currentControl.options.length<1)
			sender.setDDDWVisible(columnName,false);

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
		sender.oPBNETData.bIsSelect = true;

	if(sender.currentControl.isdddw + "" == "1")
		sender.oPBNETData.bIsSelect = true;

	if(sender.currentControl.gob.bDDCalendar)
		sender.oPBNETData.bIsSelect = true;

	PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
    
	sender.oPBNETData.submit(sender);
}

function PBDataWindow_ItemFocusChanged_AND_ItemChanged_OR_ItemError(sender,rowNumber,columnName)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	if(sender.oPBNETData.controlInFocus==this.currentControl)
	{
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	sender.oPBNETData.controlInFocus=this.currentControl;
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemFocusChanged_AND_ItemChanged_OR_ItemError";
	sender.oPBNETData.bAfterFocusChanged=true;
	if(sender.oPBNETData.bSubmitted)
		return;
	if(!sender.oPBNETData.bIsItemChanged&&!sender.oPBNETData.bIsItemError)
	{
		if(PBDataWindow_ControlWithPendingPostback==null)
			sender.oPBNETData = null;
		PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
		return;
	}
	if(sender.oPBNETData.nOutOfFocusRow<=-1)
		sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
	if(sender.oPBNETData.nOutOfFocusCol<=-1)
		sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.nInFocusCol = sender.currCol;
	sender.oPBNETData.strInFocusObjName = columnName;
	sender.oPBNETData.bIsChangeFocus = true;

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
		if(sender.currentControl.options.length<1)
			sender.setDDDWVisible(columnName,false);

	if(sender.currentControl.tagName.toUpperCase() == "SELECT")
		sender.oPBNETData.bIsSelect = true;

	if(sender.currentControl.isdddw + "" == "1")
		sender.oPBNETData.bIsSelect = true;

	if(sender.currentControl.gob.bDDCalendar)
		sender.oPBNETData.bIsSelect = true;

	PBDataWindow_ItemFocusChangedClientProcess(sender,rowNumber,columnName);
    
	sender.oPBNETData.submit(sender);
}


function PBDataWindow_RowFocusChanged(sender,rowNumber)
{
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_RowFocusChanged";
	if(sender.oPBNETData.bSubmitted)
		return;
	if(sender.oPBNETData.nOutOfFocusRow<=-1)
		sender.oPBNETData.nOutOfFocusRow = sender.nOutOfFocusRow+1;
	if(sender.oPBNETData.nOutOfFocusCol<=-1)
		sender.oPBNETData.nOutOfFocusCol = sender.nOutOfFocusCol;
	sender.oPBNETData.nInFocusRow = rowNumber;
	sender.oPBNETData.nInFocusCol = sender.currCol;
	if (sender.cols[sender.currCol] != undefined)
		sender.oPBNETData.strInFocusObjName = sender.cols[sender.currCol].name
	sender.oPBNETData.bIsChangeFocus = true;

	if (sender.eventImplemented("Clicked"))
	{
		PBDataWindow_ControlWithPendingPostback = sender;
		clearTimeout(PBDataWindow_DoubleClickedTimeout);
		PBDataWindow_DoubleClickedTimeout=setTimeout("PBDataWindow_DelayedClickedPostback()",PBDataWindow_ClickTimeout);
	}
	else if(sender.eventImplemented("DoubleClicked")) 
	{
		PBDataWindow_ControlWithPendingPostback = sender;
		clearTimeout(PBDataWindow_DoubleClickedTimeout);
		PBDataWindow_DoubleClickedTimeout=setTimeout("PBDataWindow_DelayedClickedPostback()",PBDataWindow_ClickTimeout);
	}
	else
	{
		sender.oPBNETData.submit(sender);
	}
}


function PBDataWindow_ItemChangedReject(sender, rowNumber, columnName, newValue)
{
	PBDataWindow_RecordRejectedText(sender, rowNumber, columnName, newValue);
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemChangedReject";
	if(sender.oPBNETData.bSubmitted)
		return 2;

	if(!sender.oPBNETData.bAfterFocusChanged)
	{
		sender.oPBNETData.bIsItemChanged = true;
		sender.oPBNETData.nOutOfFocusRow = rowNumber;
		sender.oPBNETData.nOutOfFocusCol = sender.currCol;
		sender.oPBNETData.strOutOfFocusObjName = columnName;
		sender.oPBNETData.newValue = newValue;
		sender.oPBNETData.strRawNewValue = sender.strRawNewValue;
		//if(sender.currentControl.type == "radio")
		//{
		//	if(sender.rows[rowNumber][sender.currCol]==newValue)
		//	{
		//		sender.oPBNETData.bIsItemChanged = false;
		//		sender.oPBNETData.newValue = "";
		//		return 0;
		//	}
		//}
	}
	else
	{
		sender.oPBNETData.bIsSecondItemChanged = true;
		sender.oPBNETData.secondNewValue = newValue;
	}

	var control = sender.currentControl;
	if (control != null && control.gob != null && control.gob.bNilIsNull && newValue == "")
		sender.oPBNETData.bNewValueIsNull = true;
	if(sender.currentControl!=null)
		if(
			sender.currentControl.type == "checkbox" ||
			sender.currentControl.type == "radio" ||
			sender.currentControl.tagName.toUpperCase() == "SELECT" ||
			sender.currentControl.isdddw + "" == "1" ||
			sender.currentControl.gob.bDDCalendar ||
			(  (sender.currentControl.bTabPressed + "" != "undefined") && (sender.currentControl.bTabPressed) )                 
		)
		{
			if(sender.currentControl.tagName.toUpperCase() == "SELECT")
				sender.oPBNETData.bIsSelect = true;
			if(sender.currentControl.isdddw + "" == "1")
				sender.oPBNETData.bIsSelect = true;
			if(sender.currentControl.gob.bDDCalendar)
				sender.oPBNETData.bIsSelect = true;

			if(sender.oPBNETData.nInFocusCol<=-1) 
			{
				sender.oPBNETData.nInFocusCol = sender.currCol;
				sender.oPBNETData.strInFocusObjName = columnName;
			}
			if(sender.oPBNETData.nInFocusRow<=-1) 
				sender.oPBNETData.nInFocusRow = sender.currRow+1;
			if(sender.currentControl.type == "checkbox")
			{
				sender.oPBNETData.bIncludesClick = true;
				sender.oPBNETData.nXpos = window.event.clientX;
				sender.oPBNETData.nYpos = window.event.clientY;
			}
			if(sender.currentControl.type == "radio")
			{
				sender.oPBNETData.bIncludesClick = true;
				sender.oPBNETData.nXpos = window.event.clientX;
				sender.oPBNETData.nYpos = window.event.clientY;
			}
			sender.oPBNETData.submit(sender);
		}
	return 2;
}

function PBDataWindow_ItemError(sender, rowNumber, columnName, newValue)
{
	//PBDataWindow_RecordPendingText(sender, rowNumber, columnName, newValue);
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemError";
	if(sender.oPBNETData.bSubmitted)
		return 3;
	if(sender.oPBNETData.bIsItemChanged)
		return 3;
	if(sender.oPBNETData.bIsSecondItemChanged)
		return 3;
	sender.oPBNETData.nOutOfFocusRow = rowNumber;
	sender.oPBNETData.nOutOfFocusCol = sender.currCol;
	sender.oPBNETData.strOutOfFocusObjName = columnName;
	sender.oPBNETData.newValue = newValue;
	sender.oPBNETData.bIsItemError = true;
	var control = sender.currentControl;
	if (control != null && control.gob != null && control.gob.bNilIsNull && newValue == "")
		sender.oPBNETData.bNewValueIsNull = true;
	if(sender.currentControl!=null)
		if(
			sender.currentControl.type == "checkbox" ||
			sender.currentControl.type == "radio" ||
			sender.currentControl.tagName.toUpperCase() == "SELECT"
		)
		{
			if(sender.oPBNETData.nInFocusCol<=-1) 
				sender.oPBNETData.nInFocusCol = sender.currCol;
			if(sender.oPBNETData.nInFocusRow<=-1) 
				sender.oPBNETData.nInFocusRow = sender.currRow+1;
			sender.oPBNETData.submit(sender);
		}
	return 3;
}

function PBDataWindow_ItemErrorNoPostback(sender, rowNumber, columnName, newValue)
{
	//PBDataWindow_RecordPendingText(sender, rowNumber, columnName, newValue);
	if(sender.oPBNETData==null)
		sender.oPBNETData = new PBNETData();
	sender.oPBNETData.strLog = sender.oPBNETData.strLog + ",PBDataWindow_ItemError";
	if(sender.oPBNETData.bSubmitted)
		return 3;
	if(sender.oPBNETData.bIsItemChanged)
		return 3;
	if(sender.oPBNETData.bIsSecondItemChanged)
		return 3;
}

function PBDataWindow_Collapsed(sender, rowNumber, groupLevel)
{
	if (event != null && event.type == "click")
	{
		sender.action = "collapsed|" + rowNumber + "|" + groupLevel + "|" + sender.xmlRenderer.treeBandAffected;
		PBDataWindow_Submitting = true;
		this.bSubmitted = sender.submit();
		PBDataWindow_Submitting = this.bSubmitted;
	}
}

function PBDataWindow_Expanded(sender, rowNumber, groupLevel)
{
	if (event != null && event.type == "click")
	{
		sender.action = "expanded|" + rowNumber + "|" + groupLevel + "|" + sender.xmlRenderer.treeBandAffected;
		PBDataWindow_Submitting = true;
		this.bSubmitted = sender.submit();
		PBDataWindow_Submitting = this.bSubmitted;
	}
}

function PBDataWindow_TreeNodeSelected(sender, rowNumber, groupLevel)
{
	if (event != null && event.type == "click")
	{
		sender.action = "treenodeselected|" + rowNumber + "|" + groupLevel;
		PBDataWindow_Submitting = true;
		this.bSubmitted = sender.submit();
		PBDataWindow_Submitting = this.bSubmitted;
	}
}

var PBDataWindow_ControlWithProgrammaticFocus = null;

var PBDataWindow_ResetControlWithProgrammaticFocusTimeout;

function PBDataWindow_DelayedResetControlWithProgrammaticFocus()
{
	if(PBDataWindow_ControlWithProgrammaticFocus!=null)
		PBDataWindow_ControlWithProgrammaticFocus.bSuppressItemGainFocusCallback = false;		
}


function PBDataWindowFocusAndDropDown(dw_name,row,col)
{
	var dw = null;
	var isObject = eval('typeof ' + dw_name);
	if(isObject != "object")
		return;
	dw = eval(dw_name);
	if(dw == null)
		return;
	if(row<=-1)
		return;
	dw.currRow = row;
	dw.nOutOfFocusRow = row;
	dw.nOutOfFocusCol = col;
	if(col<=-1)
		return;
	var control = null; 	
	var controlId = 'dw.dataForm.' + dw.name + '_' + row + '_' + col;
	var controlExists = eval('typeof ' + controlId);
	if (controlExists == "object") 	{
		control = eval(controlId);	          
		dw.bSuppressItemGainFocusCallback = true;
        if(dw.oPBNETData==null)
            dw.oPBNETData=new PBNETData();
		if(control.length!=null && control.length >= 1)
		{
			if(control[0].type=="radio")
			{
                		var i;
				for(i=0; i<control.length; ++i)
					if(control[i].type=="radio")
						if(control[i].checked)
						{
							control[i].focus();
                            			dw.oPBNETData.controlInFocus=control[i];							  
	                                    goWindowManager.OnFocusOwn(dw.dwControlId);
						}
			}
			else
			{
				control[0].focus();
                		dw.oPBNETData.controlInFocus=control[0];							  
                        goWindowManager.OnFocusOwn(dw.dwControlId);
			}
		}
		else
		{
			control.focus();
            	dw.oPBNETData.controlInFocus=control;							  
                  goWindowManager.OnFocusOwn(dw.dwControlId);
		}
		dw.currRow = row;
		if(control.onmouseup != null )
			control.onmouseup();
	}
	dw.nOutOfFocusRow = row;
	dw.nOutOfFocusCol = col;
	PBDataWindow_ControlWithProgrammaticFocus = dw;
	clearTimeout(PBDataWindow_ResetControlWithProgrammaticFocusTimeout);
	PBDataWindow_ResetControlWithProgrammaticFocusTimeout=setTimeout("PBDataWindow_DelayedResetControlWithProgrammaticFocus()",300);
}

function PBDataWindowFocusAndDropDownNoMouseUp(dw_name,row,col)
{
	var dw = null;
	var isObject = eval('typeof ' + dw_name);
	if(isObject != "object")
		return;
	dw = eval(dw_name);
	if(dw == null)
		return;
	if(row<=-1)
		return;
	dw.currRow = row;
	dw.nOutOfFocusRow = row;
	dw.nOutOfFocusCol = col;
	if(col<=-1)
		return;
	var control = null; 	
	var controlId = 'dw.dataForm.' + dw.name + '_' + row + '_' + col;
	var controlExists = eval('typeof ' + controlId);
	if (controlExists == "object") 	{
		control = eval(controlId);	          
		dw.bSuppressItemGainFocusCallback = true;
        if(dw.oPBNETData==null)
            dw.oPBNETData=new PBNETData();
		if(control.length!=null && control.length >= 1)
		{
			if(control[0].type=="radio")
			{
                		var i;
				for(i=0; i<control.length; ++i)
					if(control[i].type=="radio")
						if(control[i].checked)
						{
							control[i].focus();
                            			dw.oPBNETData.controlInFocus=control[i];							  
	                                    goWindowManager.OnFocusOwn(dw.dwControlId);
						}
			}
			else
			{
				control[0].focus();
                		dw.oPBNETData.controlInFocus=control[0];							  
                        goWindowManager.OnFocusOwn(dw.dwControlId);
			}
		}
		else
		{
			if(control.isdddw + "" == "undefined" && control.iscalendar + "" == "undefined")
			{
				control.focus();
			}			
			else
			{
				if(control.onfocus != null )
				{
					dw.bSuppressItemGainFocusCallback = true;
					if(control.iscalendar + "" == "1")
						control.bSetByCal = true;
					control.onfocus();
					if(control.iscalendar + "" == "1")
						control.bSetByCal = true;
				}
			}	
	            dw.oPBNETData.controlInFocus=control;							  
      	      goWindowManager.OnFocusOwn(dw.dwControlId);
			if(control.iscalendar + "" == "1")
				control.blur();							
		}
		dw.currRow = row;
	}
	dw.nOutOfFocusRow = row;
	dw.nOutOfFocusCol = col;
	PBDataWindow_ControlWithProgrammaticFocus = dw;
	clearTimeout(PBDataWindow_ResetControlWithProgrammaticFocusTimeout);
	PBDataWindow_ResetControlWithProgrammaticFocusTimeout=setTimeout("PBDataWindow_DelayedResetControlWithProgrammaticFocus()",300);
}


function PBDataWindowFocus(dw_name,row,col)
{
	var dw = null;
	var isObject = eval('typeof ' + dw_name);
	if(isObject != "object")
		return;
	dw = eval(dw_name);
	if(dw == null)
		return;
	if(row<=-1)
		return;
	dw.currRow = row;
	dw.nOutOfFocusRow = row;
	dw.nOutOfFocusCol = col;
	if(col<=-1)
		return;
	var control = null; 	
	var controlId = 'dw.dataForm.' + dw.name + '_' + row + '_' + col;
	var controlExists = eval('typeof ' + controlId);
	if (controlExists == "object") 	{
		control = eval(controlId);	          
        if(dw.oPBNETData==null)
            dw.oPBNETData=new PBNETData();
		if(control.length!=null && control.length >= 1)
		{
			if(control[0].type=="radio")
			{
                		var i;
				for(i=0; i<control.length; ++i)
					if(control[i].type=="radio")
						if(control[i].checked)
						{
							control[i].focus();
                            			dw.oPBNETData.controlInFocus=control[i];							  
						}
			}
			else
			{
				control[0].focus();
                		dw.oPBNETData.controlInFocus=control[0];							  
			}
		}
		else
		{
			if(control.isdddw + "" == "undefined")
			{
				control.focus();
			}
			else
			{
				if(control.onfocus != null )
				{
					dw.bSuppressItemGainFocusCallback = true;
					control.onfocus();
				}
			}	
            	dw.oPBNETData.controlInFocus=control;							  
		}
		dw.currRow = row;
	}
}

function PBDataWindowFocusNoRowChange(dw_name,row,col)
{
	var dw = null;
	var isObject = eval('typeof ' + dw_name);
	if(isObject != "object")
		return;
	dw = eval(dw_name);
	if(dw == null)
		return;
	if(row<=-1)
		return;
	dw.nOutOfFocusRow = row;
	dw.nOutOfFocusCol = col;
	if(col<=-1)
		return;
	var control = null; 	
	var controlId = 'dw.dataForm.' + dw.name + '_' + row + '_' + col;
	var controlExists = eval('typeof ' + controlId);
	if (controlExists == "object") 	{
		control = eval(controlId);	          
        if(dw.oPBNETData==null)
            dw.oPBNETData=new PBNETData();
		if(control.length!=null && control.length >= 1)
		{
			if(control[0].type=="radio")
			{
                		var i;
				for(i=0; i<control.length; ++i)
					if(control[i].type=="radio")
						if(control[i].checked)
						{
							control[i].focus();
                            			dw.oPBNETData.controlInFocus=control[i];							  
						}
			}
			else
			{
				control[0].focus();
                		dw.oPBNETData.controlInFocus=control[0];							  
			}
		}
		else
		{
			control.focus();
            	dw.oPBNETData.controlInFocus=control;							  
		}
	}
}

function PBDataWindowSetFocus(dw_name)
{
	var dw = null;
	var isObject = eval('typeof ' + dw_name);
	if(isObject != "object")
		return;
	var dw = eval(dw_name);
	if(dw == null)
		return;
	var row = dw.currRow;
	if(row<=-1)
		row = 0;
	var col = 1;
	var focusCol = 1;
	var focusTabIndex = 65536;
	if(dw.dataForm + "" == "undefined")
		return;
	if(dw.dataForm == null)
		return;
	while (true)
	{
		var control = null; 	
		var controlId = 'dw.dataForm.' + dw.name + '_' + row + '_' + col;
		var controlExists = eval('typeof ' + controlId);
		if ( (controlExists + "" != "undefined") && (controlExists == "object") )
		{
			control = eval(controlId);
			if(control.length!=null && control.length >= 1)
				tabIndex = control[0].tabIndex;
			else
				tabIndex = control.tabIndex;
			
			if (tabIndex>0 && tabIndex<focusTabIndex)
			{
				focusTabIndex = tabIndex;
				focusCol = col;
			}
		}
		else
		{
			break;
		}
		col++;
	}
	PBDataWindowFocus(dw_name,row,focusCol);
}