$(function(){ 
    if(typeof(communityUrl)=="undefined")
        communityUrl = '';
	
	params = '';
	if(typeof(keyword)!="undefined")
        params += 'keyword:'+keyword+'/';
     
	if(typeof(filter_keyword)!="undefined")
        params += 'filterKeyword:'+filter_keyword+'/';
	

      		
     $('input#tagCompletion').autocomplete(communityUrl+'/tags/completeTags/'+params,
		                                      {delay: 50,
		                                       minChars: 2,
		                                       width: 200,
		                                       max: 10,
		                                       matchSubset: false,
		                                       scroll: false,
		                                       autoFill: true,
		                                       formatResult: function (row){
		                                           curString = $('#tagCompletion').val().substring(0,$('#tagCompletion').val().lastIndexOf(',')+1);
		                                           return curString+row;
		                                        }}
		                                      );
     
	 // toDo: set instances by parameter !!
	 if ($('input#tagCompletionAsk')) {
	 	$('input#tagCompletionAsk').autocomplete(communityUrl + '/tags/completeTags/' + params, {
	 		delay: 50,
	 		minChars: 2,
	 		width: 200,
	 		max: 10,
	 		matchSubset: false,
	 		scroll: false,
	 		autoFill: true,
	 		formatResult: function(row){
	 			curString = $('#tagCompletionAsk').val().substring(0, $('#tagCompletionAsk').val().lastIndexOf(',') + 1);
	 			return curString + row;
	 		}
	 	});
	 }				 
});
 
 
