//var apis_list = [$api_list];
//var tags_list = [$tag_list];
var apis_list = ["23","30 Boxes","411Sync","43Things","activeRenderer","Adobe on AIR Bus Tour","AIM Phoneline","Akismet","Alexa Site Thumbnail","Alexa Top Sites","Alexa Web Information Service","Alexa Web Search","Amazon A9 OpenSearch","Amazon EC2","Amazon eCommerce","Amazon Historical Pricing","Amazon Mechanical Turk","Amazon Queue Service","Amazon S3","Amnesty International","AmphetaRate","Answerbag","AOL Instant Messenger","AOL Music Now","AOL Pictures","AOL Presence","AOL Video","Aonaware Dictionary","Approver","aql","ArcWeb","Authorize.Net","Autodesk Freewheel","Backpack","Basecamp","BBC","Betfair","Bible Lookup","Big Contacts","BigTribe","bLaugh Comics","Blinksale","Blinkx","Blogger","Bloglines","Blogmarks","Blogwise","Blue Dot","Box.net","BT Web21C","Bunchball","buySAFE","BuzzGame","Buzznet","Cafe Press","CafeSpot","Cdyne","Cdyne Notify","Cicero","City and State by Zip Code","Civic Footprint","ClearForest Semantic Web Services1","Clearspring","Clickatell","CNET","Commission Junction","CommonTimes","Compete","Cordurl","cPath","Creative Commons","Criteo","Currency Rates","Cypress Golf","DabbleDB","Dapper","Data On Call","DataUnison eBay Research","Dave.TV","deCarta","del.icio.us","Democracy In Action","Digg","Digital Podcast","Direct Textbook","Domain Tools","Dominions Dice","Dropcash","Dun and Bradstreet Business Verification","Dun and Bradstreet Credit Check","Dun and Bradstreet WorldBase Marketing Plus","durl.us","EarthTools","EasyUtil","eBay","EchoSign","ecommstats","eCourier","EditGrid","Email Address Validator","Employease","eSideWalk","ESV Bible Lookup","EVE Online","Eventfinder","Eventful","ExactTarget","Facebook","Faces.com","FedEx","FedSpending.org","FeedBlitz","FeedBurner","Feedcache","FeedFlow","FeedMap","Findory","Flickr","Follow The Money","Food Candy","Fotolia","FraudLabs Credit Card Fraud Detection","Freedb / CDDB","FreshBooks","FUTEF Wikipedia API","Garmin MotionBased","geocoder","geocoder.ca","GeoIQ","GeoNames","Gigablast","Global IP Sound","GlobeXplorer","GoodStorm","Google AdSense","Google AdWords","Google Ajax Feeds","Google Ajax Search","Google Base","Google Calendar","Google Checkout","Google Client Authentication","Google Code Search","Google Custom Search","Google Desktop","Google Gears","Google Homepage","Google Maps","Google Mashup Editor","Google Notebook","Google Picasa","Google Provisioning","Google Safe Browsing","Google Search","Google Single SignOn","Google Spreadsheets","Google Talk","Google Web Authentication","Goplan","GovTracker","GraphMagic","Grouper Video","Gtalkr","gubb","Haystack Networking","Holidays Service","hon.jp","HopStop","hostip.info","HotOrNot","HTML2PDF","ImageLooop","IMified","indeed","InnerGears Weather by City","IntelliContact","Interfax","Internet Archive","iotum","IP Address Lookup","ISBNdb","iShareMaps On Demand","Jaduka","Jaiku","JangoMail","Jots","JotSpot","Kayak","Kegg","King County Buses","Kratia","Last.fm","Library of Congress SRW","Lingr","linkaGoGo","LiveJournal","LiveVideo","Living Stones","Lokad","LOUIS","Ma.gnolia","Macromedia News Aggregator","Mailbuild","Map24 AJAX API","Mappr","MapQuest","Mapstraction","MetaCarta","Microsoft adCenter","Microsoft MapPoint","Microsoft MSDN","Microsoft Silverlight Streaming","Microsoft start.com","Microsoft Virtual Earth","Mint","Mobivity","Mon.itor.us","Moneytrackin","Moreover","MoveDigital","Movil","MP3Tunes","MSN Messenger","Multimap","MuseStorm","MusicBrainz","MusicDNS.org","MusicMobs","MyNotify","NASA","Naver","Naver Maps","NCBI Entrez","Nearby.org.uk","Nenest","Nestoria","NetAccounts","NetDocuments","NetSuite","Netvibes","NewsCloud","NewsGator","NewsIsFree","Ning","NOAA Weather Service","Numbler","Omnidrive","OnlyWire","Ontok","Ontok Wikipedia","Open Patent Services","OpenDOAR","OpenLayers","Openomy","OpenStrands","OpenStreetMap","Orb","OReilly Safari","Outune","Pageflakes","Panoramio","PartySpark","PartySync","Pathfinder","PayPal","PaySimple","PBwiki","Performancing","Phanfare","PhishTank","PhoneDog","PhoneVal","Pingdom","Pixagogo","PlanningAlerts","Platial","Plaxo","Plazes","Poly9 FreeEarth","PriceRunner","Prodigem","Prosper","PubSub","Pushpin","Qurl","Rakuten","RapLeaf","Raw Sugar","RealEDA Reverse Phone Lookup","Remember the Milk","Revver","Rhapsody","Riya","Rrove","sabifoo","Salesforce.com","Scribble","SecondLife","SeeqPod","SeqHound","Serence Klip","Shadows","SharedBook","Shopping.com","ShutterPoint","Simpy","Skyhook Wireless","Skype","SlimTimer","SmartTravelDeals","SmashFly","smsBug","Smugmug","Snipshot","SNOCAP","SoftLayer","soundtoys","Sparklines","SplogSpot","Spongecell","Spraci","SpringWidgets","SRC Demographics","stikkit","Streamload","StrikeIron","StrikeIron Address Distance","StrikeIron Address Verfication","StrikeIron Do Not Call","StrikeIron Email Verification","StrikeIron Global SMS Pro","StrikeIron Historical Stock Quotes","StrikeIron Insider Trading","StrikeIron Mobile Email","StrikeIron Mutual Funds","StrikeIron Phone Number Enhancement","StrikeIron Residential Lookup","StrikeIron Reverse Phone Lookup","StrikeIron Sales Tax Basic","StrikeIron Stock Quotes Basic","StrikeIron Super Data Pack","StrikeIron Tax Service","StrikeIron US Addresses","StrikeIron US Census","StrikeIron Zacks Company Profile","Sunlight Labs","SwapThing","Sylantro","Syndic8","Tabblo","Tagalag","TagFinder","tagthe.net","TagTooga","TagWorld","Tagyu","Tailrank","Taleo","Talis","TeamDesk","Technorati","Textamerica","The Astrologer","TheyWorkForYou","Tiktrac","Toodledo","Topicalizer","TradeSports","Trekmail","Trulia","Trynt","Tunelog","Tutorials Garden","Twitter","Twittervision","TypeKey","TypePad","unAPI","UPC Database","Upcoming.org","UPS","Urban Mapping","UrbanDictionary","UrlTrends","US Postal Service","US Yellow Pages","Userplane","USGS Elevation Query Service","Vast","Vazu","Veoh","Vertical Response","ViaMichelin","Videodetective","Vodafone Betavine","voo2do","Voxbone","W3Counter","Wayfaring","WeatherBug","WebAIM","WebEx","WebJay","Weblogs","Webmail.us","WebPurify","Webride","WebShots","WebThumb","Wesabe","WhatCounts","WHERE GPS","Where Is Tim Web Service","Where2GetIt Geospatial","Where2GetIt SlippyMap","Whereis","Who is my Representative","Wigle","WikiMatrix","Winamp","Windows Live Contacts","Windows Live Contacts Control","Windows Live Custom Domains","Windows Live Data","Windows Live Expo","Windows Live Gadgets","Windows Live ID Client SDK","Windows Live Search","Windows Live Spaces","Windows Live Spaces Photo Control","Windows Sidebar Gadgets","Wink","Wordtracker","WSRelater","Wufoo","Yahoo Ads","Yahoo Answers","Yahoo Audio Search","Yahoo BBauth","Yahoo Geocoding","Yahoo Image Search","Yahoo Local Search","Yahoo Mail","Yahoo Map Image","Yahoo Maps","Yahoo Messenger","Yahoo Music Engine","Yahoo My Web Search","Yahoo Photos","Yahoo Related Suggestions","Yahoo Search","Yahoo Search Marketing","Yahoo Shopping","Yahoo Site Explorer","Yahoo Term Extraction","Yahoo Traffic","Yahoo Travel","Yahoo Video Search","Yahoo Widgets","yourminis","YouTube","Zazzle","ZeeMaps","Zillow","ZipCodes","Zixxo","Zoho","ZoomClouds","ZoomIn","Zoto","Zvents"];
var tags_list = ['3d','4D','ads','adult','advocacy','africa','aggregator','ai','ajax','albumart','alerts','alps','amazon','amsterdam','analytics','andorra','animals','animation','anime','answers','anthems','api','Arabic','argentina','art','article','Artistic','artists','asp','astronomy','atom','attractions','auction','auctions','audio','Australia','aviation','bands','Bangkok','barbados','bargains','bars','baseball','basketball','beauty','bebo','bedbreakfast','belgium','berlin','bi','bible','bicycle','bikes','biking','bikram','birding','bittorrent','blog','blogs','boating','bookmarking','bookmarklet','bookmarks','books','boston','brazil','bristol','broadcast','business','calculator','calendar','calgary','california','cambridge','camping','canada','carolina','cars','celebrities','celebrity','census','charity','chat','chemistry','chicago','childcare','china','chinese','classifieds','climbing','clipboard','clips','cms','code','code2D','coding','coffee','collaboration','collecting','college','comics','community','comparison','congress','contacts','contests','conversion','craigslist','cricket','crime','cruising','custom','cycling','czech','Dallas','dance','datamining','dating','dc','deadpool','deals','definition','demographics','denver','design','development','Dictionary','dieting','digg','dining','Directions','directories','diving','dj','domains','download','dublin','dvd','earthquakes','eBay','editing','education','electronica','email','emergency','emusic','energy','enterprise','environment','EPA','europe','events','facebook','family','Fashion','favrats','fiction','finance','finland','fire','firefox','fishing','flash','Flex','flickr','flight','florida','flying','food','football','forecast','forum','france','frisbee','fun','gadgets','galician','gambling','game','games','gender','geography','geonarrative','GeoRSS','geotag','germany','gifts','golf','google','government','gps','GPX','greasemonkey','greece','greenpeace','guide','guitar','hardware','hawaii','health','hiking','history','hockey','holidays','homes','horoscope','hosting','hotel','hotels','housing','houston','howto','humor','hungary','hurricanes','immobiliari','immobilier','india','Indianapolis','input','internet','iPhone','ipod','Iran','ireland','italy','Itinerary','itunes','IVR','japan','java','javascript','jesus','jimaku','job','jobs','junk','kansas','karaoke','kexp','keywords','korea','law','LBS','library','lightbox','live','loans','local','location','london','lookup','losangeles','lottery','lyrics','mac','Malta','map','mapping','mappping','maps','marathons','marketing','mashups','Massachusetts','Math','media','medical','messaging','mexico','michigan','microcontent','Microsoft','miles','military','mobiile','mobile','money','monitoring','Montreal','moon','motorcycle','motorcycles','motorcyles','movies','mp3','museums','music','MySpace','nascar','navigation','NBA','nc','NCAA','nestoria','net','netherlands','network','networking','networks','news','newyork','newzealand','nfl','nirvana','noaa','nokia','nonprofit','north','notams','nsfw','nutrition','nyc','office','olympics','Oodle','OpenID','opml','oregon','outlook','p2p','pandora','parenting','Paris','patents','payment','pearljam','personalization','personals','pets','philadelphia','philippines','phishing','phoenix','phone','photo','photos','php','picture','pim','ping-pong','pipes','playlists','plone','plugin','pm','podcast','poland','police','politics','pollution','Post','Prague','printing','programming','property','puertorico','python','quebec','racing','radio','rakuten','Random','rank','rating','ratings','rdf','realestate','realstate','realtime','recommendation','recruiting','recycle','recycling','reference','religion','reminders','reputation','research','restaurants','retail','review','reviews','rewards','rideshare','rpg','rss','ruby','running','salary','sandiego','sanfrancisco','sap','sardinia','school','science','screensaver','scuba','search','seattle','security','semantic','SEO','sex','sharing','shipping','shopping','Singapore','skateboarding','ski','skiing','skype','slang','slideshow','smart_browser','sms','soccer','social','songs','source','spain','spam','speech','sports','Spreadsheets','spy','starbucks','statistics','stocks','storage','streaming','subtitle','subtitles','subway','surfing','swap','switzerland','Sydney','tag','tagbulb','tagging','tags','Tehran','Telephone','telephony','television','tennis','terrorism','texas','tfrs','thailand','theatre','Theory','thumbnail','tickets','time','tinymce','tool','tools','top','Toronto','torrent','Toto','tracking','traffic','trails','transit','Translation','travel','trends','trivia','trucks','TTS','tutor','uae','ufo','ufos','uk','Ultima','user-generated','utility','vancouver','vc','video','videos','viewer','virginia','visualization','vizualization','Voice','WAP','war','weather','web20','webcam','webcams','websearch','wedding','whitepages','widget','widgets','wifi','wii','wiki','wikipedia','windfarms','windows','wine','wireless','wishlist','words','worldsbestapp','writing','Yahoo','yoga','youtube','yui'];

function findValue(li) {
	if( li == null ) return; //alert("No match!");
	
	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];
			
	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;
					
	//alert("The value you selected was: " + sValue);
}

function selectItem(li) {
	findValue(li);
}
function formatItem(row) {
	return row[0] + " (id: " + row[1] + ")";
}

function lookupLocal(i){
	var oSuggest = $("#apis"+i)[0].autocompleter;

	oSuggest.findValue();

	return false;
}

$(document).ready(function() {
	$("#apis1").autocompleteArray(
			apis_list,
	{
		delay:10,
		minChars:1,
		matchSubset:1,
		onItemSelect:selectItem,
		onFindValue:findValue,
		autoFill:true,
		maxItemsToShow:20
	}
	);
	$("#apis2").autocompleteArray(
			apis_list,
	{
		delay:10,
		minChars:1,
		matchSubset:1,
		onItemSelect:selectItem,
		onFindValue:findValue,
		autoFill:true,
		maxItemsToShow:20
	}
	);
	$("#apis3").autocompleteArray(
			apis_list,
	{
		delay:10,
		minChars:1,
		matchSubset:1,
		onItemSelect:selectItem,
		onFindValue:findValue,
		autoFill:true,
		maxItemsToShow:20
	}
	);
	if ($("#tags1")) {
		$("#tags1").autocompleteArray(
				tags_list,
		{
			delay:10,
			minChars:1,
			matchSubset:1,
			onItemSelect:selectItem,
			onFindValue:findValue,
			autoFill:true,
			maxItemsToShow:20
		}
		);
		$("#tags2").autocompleteArray(
				tags_list,
		{
			delay:10,
			minChars:1,
			matchSubset:1,
			onItemSelect:selectItem,
			onFindValue:findValue,
			autoFill:true,
			maxItemsToShow:20
		}
		);
		$("#tags3").autocompleteArray(
				tags_list,
		{
			delay:10,
			minChars:1,
			matchSubset:1,
			onItemSelect:selectItem,
			onFindValue:findValue,
			autoFill:true,
			maxItemsToShow:20
		}
		);
	}
	if ($("#ftags1")) {
		$("#ftags1").autocompleteArray(
				tags_list,
		{
			delay:10,
			minChars:1,
			matchSubset:1,
			onItemSelect:selectItem,
			onFindValue:findValue,
			autoFill:true,
			maxItemsToShow:20
		}
		);
	}
});

