// ajaxGrid.js v2

$(function() {
	$('#villaContent > ul').tabs({

		cache: true
	});

	$('#ajaxContainer').prepend('<p id="load">Searching for availability please wait...</p>');


	// Inner Functions
	$('#villaContent > ul').bind('tabsselect', function(event, ui) {
		$('#ajaxContainer div.ui-tabs-panel').hide();

	});
	$('#villaContent > ul').ajaxSend(function(evt, request, settings){

		$('#load').show();
		//
	 });
	$('#villaContent > ul').ajaxStop(function(evt, request, settings){
		$('#load').hide();
	 });


});

$('p#nextYearSearches a').livequery('click', function(event){
	var toLoad = $(this).attr('href');/[ ]/+' #ajaxGrid'
	toLoad = toLoad.replace(/ /g,"%20");
	$('#ajaxGridContainer').hide(loadContent(toLoad));
	return false;
});
$('div.monthSelector div a').livequery('click', function(event){
	var toLoad = $(this).attr('href');/[ ]/+' #ajaxGrid'
	toLoad = toLoad.replace(/ /g,"%20");
	$('#ajaxGridContainer').hide(loadContent(toLoad));
	return false;
});
function loadContent(toLoad) {
	$('#ajaxGridContainer').load(toLoad,'',showNewContent)
}
function showNewContent() {
	$('#ajaxGridContainer').show('normal',hideLoader);
}
function hideLoader(){
	$('#load').hide();
}

