var sDebugSQL = '';
// 02/29/2008 Paul.  startHighlight is no longer used, so remove. 

var ChangeDate = null;

function CalendarPopup(ctlDate, clientX, clientY)
{
	clientX = window.screenLeft + parseInt(clientX);
	clientY = window.screenTop  + parseInt(clientY);
	if ( clientX < 0 )
		clientX = 0;
	if ( clientY < 0 )
		clientY = 0;
	return window.open('../Calendar/Popup.aspx?Date=' + ctlDate.value,'CalendarPopup','width=193,height=155,resizable=1,scrollbars=0,left=' + clientX + ',top=' + clientY);
	/*
	var sFeatures = 'dialogHeight:215px ;dialogWidth:253px;resizable:yes;center:yes;status:no;help:no;scroll:no;';
	var sUrl = '<%= Application["rootURL"] %>Calendar/CalendarPopup.aspx?Date=' + ctlDate.value;
	var lookupItems = window.showModalDialog(sUrl, null, sFeatures);
	if ( lookupItems != null )
	{
		ctlDate.value = lookupItems;
	}
	*/
}

// 03/04/2009 Paul.  In JavaScript, we need to check for undefined instead of null. 
function SelectOption(sID, sValue)
{
	var lst = document.forms[0][sID];
	if ( lst != undefined )
	{
		if ( lst.options != undefined )
		{
			for ( i=0; i < lst.options.length ; i++ )
			{
				if ( lst.options[i].value == sValue )
				{
					lst.options[i].selected = true;
					break;
				}
			}
		}
	}
}

// 03/04/2009 Paul.  In JavaScript, we need to check for undefined instead of null. 
// 03/04/2009 Paul.  If there is only one form field, then it will not have a length. 
function SelectedCount(sFieldID)
{
	var nCount = 0;
	var fld = document.forms[0][sFieldID];
	if ( fld != undefined )
	{
		if ( fld.length == undefined )
		{
			if ( fld.type == 'checkbox' )
			{
				if ( fld.checked )
					nCount++;
			}
		}
		else
		{
			for (i = 0; i < fld.length; i++)
			{
				if ( fld[i].type == 'checkbox' )
				{
					if ( fld[i].checked )
						nCount++;
				}
			}
		}
	}
	return nCount;
}

// 02/28/2008 Paul.  Replace the SugarCRM implementation with one that is more efficient. 
// There is simply no need to iterate through all elements. 
// 03/04/2009 Paul.  In JavaScript, we need to check for undefined instead of null. 
// 03/04/2009 Paul.  If there is only one form field, then it will not have a length. 
function checkAll(form, sFieldID, value)
{
	var fld = document.forms[0][sFieldID];
	if ( fld != undefined )
	{
		if ( fld.length == undefined )
		{
			if ( fld.type == 'checkbox' )
				fld.checked = value;
		}
		else
		{
			for (i = 0; i < fld.length; i++)
			{
				if ( fld[i].type == 'checkbox' )
					fld[i].checked = value;
			}
		}
	}
}

// 02/28/2008 Paul.  Simplify toggleDisplay() and move the linked toggling to AccessView. 
function toggleDisplay(sID)
{
	var fld = document.getElementById(sID);
	if ( fld != undefined )
		fld.style.display = (fld.style.display == 'none') ? 'inline' : 'none';
}

