function _doNavPost(link) {
	document.navForm.action = link;
	document.navForm.submit();
	return false;
}

$().ready(function() {
		$("#searchBox").autocomplete("getautocomplete.php", {
			width: 370,
			cacheLength: 0,
			selectFirst: false,
			scroll: false,
			max:10,
			formatItem : autoSuggestionFormatItem,
			highlight: function(value){return value;}
		});
		$("input#searchBox").result(function(event, data, formatted) {
			$("#searchbt").click();
		});
		
	});
	function autoSuggestionFormatItem(data, index, max, value, term) {
		// if the first item, add the "Suggestions" text
		if (index == 1) {
			value = '<span style="float:left">'+value+'</span><span style="float:right;font-size:10px;color:#9F9F85">Suggestions</span>';
		}

		return value;
	}
	var provider_arr_link = new Array(
										'wsearch.php',
										'http://images.search.yahoo.com/search/images;_ylt=A0WTefMcsCFJOlgAJjCLuLkF',
										'http://video.search.yahoo.com/search/video;_ylt=',
										'http://news.search.yahoo.com/search/news;_ylt='
										);

	function changeSearchType() {	
		
	// find and set the searchTypeId
	var index = 0;
	if ($(this).attr("id") == "web") index = 0;
	else if ($(this).attr("id") == "images") index = 1;
	else if ($(this).attr("id") == "video") index = 2;	
	else if ($(this).attr("id") == "news") index = 3;
	
	$("input[name='searchTypeId']").val(index);
	
	// change form url
	
	var url = provider_arr_link[index];
	$("form#searchForm").attr("action", url);	
	// we don't want to reload the page ...
	return false;
}

function resetSearchTypeColor(stype) {
	var link_url = document.getElementById(stype).value;
	document.searchForm.action = link_url;
	var searchTypeArray = new Array("web", "video", "images", "news");
	for (i = 0; i < searchTypeArray.length; i++) {
		if (searchTypeArray[i] != stype)
			document.getElementById(searchTypeArray[i]).className = 'unSelectedSearchType';
		else
			document.getElementById(searchTypeArray[i]).className = 'selectedSearchType';
	}
}

