$(document).ready(function() {
	var general_search = new Bloodhound({
		datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
		queryTokenizer: Bloodhound.tokenizers.whitespace,
		prefetch: 'remote.php?op=general/search/%QUERY&encode=json',
		remote: {
			url: 'remote.php?op=general/search/%QUERY&encode=json',
			wildcard: '%QUERY'
		}
	});
$('#input-search').typeahead(null, {
	name: 'general-search',
	display: 'value',
	source: general_search
	}).bind("typeahead:selected", function(obj, result, name) {
		if (typeof result.pid !== 'undefined'){
			window.location.href = 'visit.php?vid=&pid=' + result.pid;
		}
		
		if (typeof result.oid !== 'undefined'){
			window.location.href = 'owner.php?op=f&oid=' + result.oid;
		}
		
		if (typeof result.vid !== 'undefined'){
			window.location.href = 'visit.php?vid=' + result.vid;
		}
		
	});
});
