function update_venue_form()
{
	$('#venue-search-button').attr('src', "/images/bo-ajax-loader.gif");
	$('#venue-search-button').attr('alt', "Loading...");
	$('#venue-search-button').attr('disabled', "disabled");

	$('#go-to-site img').attr('src', "/images/go-to-site-disabled.gif");
	$('#go-to-site').attr('title', "Select A Venue");
	$('#go-to-site img').attr('alt', "Select A Venue");
	$('#go-to-site').unbind('click');
	$('#go-to-site').click(function(){
		return false;
	});

	$('#book-online img').attr('src', "/images/book-online-disabled.gif");
	$('#book-online').attr('title', "Select A Venue");
	$('#book-online img').attr('alt', "Select A Venue");
	$('#book-online').unbind('click');
	$('#book-online').click(function(){
		return false;
	});

	var location_id = $('#search_location').val();
	var channel = $('#channel').val();
	if (location_id == '') location_id = 'all';
	if (channel == 'home') channel = 'all';

	$.getJSON("/ajax/get.venues.php?location_id=" + location_id + "&channel=" + channel, function(json){
		if (json != null)
		{
			$('#venue_search_venues').empty();
			$('#venue_search_venues').append('<select name="search_venue" id="search_venue" onchange="check_venue_functions()"></select>');
			$('#venue_search_venues select').append('<option value="">Select Venue</option>');

			for (var i = 0; i < json.length; i++)
			{
				$('#venue_search_venues select').append('<option value="'+json[i]['id']+'">'+json[i]['name']+'</option>');
			}

			$('#venue-search-button').attr('src', "/images/search-venues.gif");
			$('#venue-search-button').attr('alt', "Search All Venues");
			$('#venue-search-button').removeAttr("disabled")
		}
		else
		{
			$('#venue_search_venues').html("<p>Sorry, no venues to display.</p>");
			$('#venue-search-button').attr('src', "/images/search-venues-disabled.gif");
			$('#venue-search-button').attr('alt', "Search All Venues");
			$('#venue-search-button').attr('disabled', "disabled");
		}
	});
}

function check_venue_functions(){
	$('#go-to-site img').attr('src', "/images/go-to-site-disabled.gif");
	$('#go-to-site').attr('title', "Select A Venue");
	$('#go-to-site img').attr('alt', "Select A Venue");
	$('#go-to-site').unbind('click');
	$('#go-to-site').click(function(){
		return false;
	});

	$('#book-online img').attr('src', "/images/book-online-disabled.gif");
	$('#book-online').attr('title', "Select A Venue");
	$('#book-online img').attr('alt', "Select A Venue");
	$('#book-online').unbind('click');
	$('#book-online').click(function(){
		return false;
	});

	var venue = $('#search_venue').val();
	if (venue){
		if (search_venues[venue]['book'] > 0){
			$('#book-online img').attr('src', "/images/book-online.gif");
			$('#book-online').attr('title', "Book a Table at this venue");
			$('#book-online img').attr('alt', "Book Online");
			$('#book-online').unbind('click');
			$('#book-online').click(function(){
				Shadowbox.open({
					content: 'http://app.restaurantdiary.com/ts/find.asp?id_prov=' + search_venues[venue]['book'],
					player: 'iframe',
					title: 'Book a Table',
					width: 680,
					height: 474
				});
				return false;
			});
		}

		$('#go-to-site img').attr('src', "/images/go-to-site.gif");
		$('#go-to-site').attr('title', "Go to the venue's website");
		$('#go-to-site img').attr('alt', "Go To Site");
		$('#go-to-site').unbind('click');
		$('#go-to-site').click(function(){
			window.location.href = search_venues[venue]['url'];
			return false;
		});
	}
}
