
function FChkSrchTxt(wz)
{
	var ws=/^[\s]*$/;
	return wz&&!ws.test(wz);
}

function FocSrchTxt(o)
{
	if (o && o.value)
	{
		if (strNonSearchString != null && strNonSearchString != 'undefined' && o.value == strNonSearchString && !fEnteredText)
		{
			o.value = '';
		}
		else
		{
			o.select();
		}
		setSearchOnColor(o);
		fEnteredText=true;
	}
}

function FTrySearch(e, strFormName, index)
{
	fSearchFocus = false;
	searchclose();

	var oSrchFrm = document.getElementById(strFormName);

	if ('undefined' != typeof(oSrchFrm) && null != oSrchFrm && SelectAction(oSrchFrm, index))
		{

		try {external.AutoCompleteSaveForm(oSrchFrm);} catch (err) {}
		oSrchFrm.submit();
		}
      else
      {
      document.getElementById(strFormName).focus();
      }

	if (e && e.stopPropagation)
		e.stopPropagation(); 

	//return false;
}

function FEntTextbox(e, strFormName, index)
{
	if (e && 13 == e.keyCode)
		return FTrySearch(e, strFormName, index);

	return true;
}

function offset(object, alignment) {
	var nOffset = 0;

	if (object == null)
		return nOffset;

	while (object.offsetParent) 
   {
		nOffset += ((alignment == 'x') ? 25 : 2);
		object = object.offsetParent;
	}

	return nOffset;
}

function setNonSearchString(searchBox)
{
	if (searchBox != null && searchBox != 'undefined' && searchBox.value == '')
	{
		searchBox.value = strNonSearchString;
		setSearchOffColor(searchBox);
		fEnteredText = false;
	}
}

function setSearchOffColor(searchBox)
{
	searchBox.className = 'cdsearchbox cdSearchBoxOffColor';
}

function setSearchOnColor(searchBox)
{
	searchBox.className = 'cdsearchbox cdSearchBoxOnColor';
}

function delayedclose()
{
	fSearchFocus = false;
	window.setTimeout('searchclose()', 400);
}

function setSearchFocus()
{
	fSearchFocus = true;
}

function searchclose()
{
	var searchdrop = document.getElementById('cdsearchoutcdsdrop');
	if (searchdrop != null && searchdrop != 'undefined')
	{
		if (fSearchFocus == false)
		{
			searchdrop.style.display = 'none';
			fSearchOn = false;
		}
	}
}

function searchout()
{
	var searchdrop = document.getElementById('cdsearchoutcdsdrop');
	if (searchdrop != null && searchdrop != 'undefined' && fSearchOn == true)
	{
		searchdrop.style.display = 'none';
		fSearchOn = false;
	}
	else
	{
		var buttonleft = document.getElementById('cdsdropleft');
		var buttonmiddle = document.getElementById('cdsdrop');

		if (buttonleft != null && buttonleft != 'undefined' &&
			buttonmiddle != null && buttonmiddle != 'undefined' && 
			searchdrop != null && searchdrop != 'undefined')

		{
			var newleft = offset(buttonleft, 'x');
			var newtop = offset(buttonleft, 'y');

			searchdrop.style.display = 'none';
			searchdrop.style.position = 'absolute';

			if (fIsRTL)
			{				
				newleft = offset(buttonmiddle, 'x');
				searchdrop.style.left = newleft + 'px';
			}
			else
			{			
				searchdrop.style.left = newleft + 'px';
			}
			searchdrop.style.top = newtop + buttonmiddle.offsetHeight + 'px';

			searchdrop.style.display = 'block';

			fSearchOn = true;
		}
	}
}

