function rate(score, link) {
			c = 0;
			var rating_what = $(link).parents("ul").attr("id");
			var val_field = "#"+rating_what+"_v";
			$(val_field).val(score);
			
			$("#"+rating_what+" a").each(function(i){
				if (c < score) {
					$(this).addClass("on");

					c++;
				} else {
					$(this).removeClass("on");
				}
			});
			$("#"+rating_what).siblings("span").html( $(link).attr("title") );
}

function formatItem(row) {
	//var row = row.split("|");
	return row[0] + " (id: " + row[1] + ")";
}
function formatItemSimple(row) {
	return row[0];
}
function formatResult(row) {
	return row[0];
}
function load_normal_autocomplete() {
	$("#normal").autocomplete('/events/helpers/aj_normal.php', {
		delay: 150,
		width: 260,
		formatItem: formatItem,
		formatResult: formatResult,
		minChars: 0,
		selectFirst: false
	}).result(function(event, data, formatted){
	//alert('result');
		if (data) {
		} else {
		}
	}).show();
}

function load_location_autocomplete() {
	$("#locationentry").autocomplete('/events/helpers/aj_search2.php', {
		delay: 150,
		width: 260,
		formatItem: formatItem,
		formatResult: formatResult,
		selectFirst: false,
		mustMatch: true
	}).result(function(event, data, formatted){
		if (data) {
			$("#locationentry").val(data[0]);
			$("#locationentryid").val(data[1]);
			$("a.editlocation").attr("rel", data[1]);
			$("#altphonebox").hide();
			$("#locationcontainer div.details").empty();
			if (data[1] > 1) {
			$("#locationcontainer div.details").html("Name: "+data[0]+"<br>Phone: "+data[2]+"<br>Address: "+data[3]).append("<br><a class='altphone' href='#'>Use alternate phone number</a>");
			//$("#locationcontainer div.details").html("Name: "+data[0]+"<br>Phone: "+data[2]+"<br>Address: "+data[3]).append("<br><a rel='"+data[1]+"' class='editlocation' href='v3.php?act=location&location_id="+data[1]+"&ts="+new Date().getTime()+"'>Edit This Location</a><br><a class='altphone' href='#'>Use alternate phone number</a>");
			} else {
				//alert("No data..");
			}
			$(".editlocation").show();
		} else {
			$("#altphonebox").hide();
			$("#locationcontainer div.details").html('');
			//$("#locationentryid").val(1);
			$(".editlocation").hide();
		}
	}).show().search();
	
//	$("#locationcontainer .loc_links").html("&nbsp;<a class=addlocation href='v3.php?act=location&location_id=new&ts="+new Date().getTime()+"'>Add a location</a> | <a class='nolocation' href='#'>No location</a>");
	//		.append('<input id="locationentryid" name="location_id" type="hidden">');
	

}