﻿var HitCount = 0;
var EnterCount = 0;
var ItemsRequestingCount = 0;
var ItemsRequestedCount = 0;


function printStatus()
{
	//window.status = 'HitCount = ' + HitCount + ', EnterCount = ' + EnterCount + ', ItemsRequestingCount = ' + ItemsRequestingCount + ', ItemsRequestedCount = ' + ItemsRequestedCount;
}

function MultiLiveSearch_OnDropDownOpening(combobox)
{
	var inputbox = document.getElementById(combobox.InputID)
	if(typeof(inputbox) != 'undefined')
	{
		if(inputbox.value=='')
			return false;
	}
	return true;
}

function MultiLiveSearch_OnClientItemsRequesting(combobox)
{
	if( typeof(MultiLiveSearch_FilterBoxes) != 'undefined' )
	{
		combobox.ClientDataString = MultiLiveSearch_GetSearchFilter()+"";
	}
	
	ItemsRequestingCount++;
	printStatus();
}

function MultiLiveSearch_OnClientItemsRequested(combobox)
{
	if(combobox.Items.length==0)
		combobox.HideDropDown() 
		
	ItemsRequestedCount++;
	printStatus();
}

function MultiLiveSearch_GetSearchFilter()
{
	var bitflagFilter = 0;
	for(i = 0; i < MultiLiveSearch_FilterBoxes.length; i++)
	{
		var elm = document.getElementById(MultiLiveSearch_FilterBoxes[i]);
		if(elm.checked)
			bitflagFilter += parseInt(elm.searchTypeValue);
	}
	return bitflagFilter;
}

function MultiLiveSearch_HandleKeyPress(combobox, e)
{
	HitCount++;

	if (e.keyCode == 13 && typeof(MultiLiveSearch_TargetButtonID) != 'undefined')
	{
		EnterCount++;
	
		var targetButton = document.getElementById(MultiLiveSearch_TargetButtonID);
		if( typeof(targetButton) != 'undefined' )
		{
			targetButton.click();
		}
	}
	printStatus();
}
