﻿// JavaScript Document
//$(function() {   
//  
//  $("#rate").autocomplete('Feetip.aspx', {matchContains: true});       

//});  
$().ready(function() {
	function formatItem(row) {
		

		if (row.length>=2)
		{
		  return "<table width='90%'  align='left' > <tr align='left'  height='3'> "+
         		 "<td width='65%' align='left' >"+ row[1]+"</td> "+
				 "<td width='35%' align='left' >区号："+row[0]+"</td>"+
				 "</tr></table>";
		}
		if (row.length==1)
		{
		  return "<table width='90%'  align='left' > <tr align='left'  height='3'>"+
		       "<td >"+row[0]+"</td>"+
		       "</tr>"+
		       "</table>";
		}
	}
	function formatResult(row) {
		//return row[0].replace(/(<.+?>)/gi, '');
		
		if (row.length>=2)
		{
		       
		       return row[1].replace(/(<.+?>)/gi, '');
		}
		if (row.length==1)
		{

		       return row[0].replace(/(<.+?>)/gi, '');
		}
		//alert(row.length)
		//return row[0].replace(/(<.+?>)/gi, '');
	}
	function selectItem(li) {
		makeSearchUrl(document.formkeyword);
	}
	$("#rate").autocomplete("/Feetip.aspx",
	{
		delay:10,
		matchSubset:true,
		cacheLength:10,
		matchContains:1,
		onItemSelect:selectItem,
		formatItem: formatItem,
		formatResult: formatResult,
		autoFill:true,
		width:400,
		scroll:false
	}
	);

});
var makeSearchUrl = function(o){
	
	
	var keys = encodeURIComponent(o.keyword.value);
	var url = "/article-search-keyword-"+ keys+".html";
	window.open(url,'_self');
	return false; 
	}