var t = null;

// Handle the incoming spotlight results
function spotlightReqChange(response)
{
	var column0 = $('search-zone');
	var columnForm = $('search-zone-results-colform');
	var column1 = $('search-zone-results-col1');
	var column2 = $('search-zone-results-col2');
	
	var stringArray = response.split('<!-- BREAK -->');
	
	if (stringArray[0])
	  column1.innerHTML = stringArray[0];
	else
	  column1.innerHTML = '&nbsp;';
	
	if (stringArray[1])
	  column2.innerHTML = stringArray[1];
	else
	  column2.innerHTML = '&nbsp;';
	
	if ( (column1.offsetHeight > columnForm.offsetHeight) || (column2.offsetHeight > columnForm.offsetHeight) ) {
	if (column1.offsetHeight > column2.offsetHeight)
	  theNewSize = column1.offsetHeight;
	else
	  theNewSize = column2.offsetHeight;
	} else {
	  theNewSize = columnForm.offsetHeight;
	}
	
	myHeight.custom(column0.offsetHeight, theNewSize);
		
	// Stop spinning
	$('search-zone-spinner').style.display = 'none';
}


// Do the searching
function spotlightSearch()
{
	if((document.forms.searchform.keywords.value.length >= 3) && (spotlightIsOpen == true))
	{
		// Start spinning
		$('search-zone-spinner').style.display = 'block';
		
		new ajax('http://www.nextway.ch/spotlight.php?q=' + escape(document.forms.searchform.keywords.value), {method: 'get', onComplete: spotlightReqChange}).request();
	}
}


// Start the user interface timer
function spotlightStartTimer()
{
	if(t)
	{
		window.clearTimeout(t);
	}
	t = window.setTimeout("spotlightSearch()",500);
}

function spotlightCloseTimer()
{
	if(t)
	{
		window.clearTimeout(t);
	}
}