jQuery.noConflict();
var pricesUpdatedTimer;

var firstDatesAndRatesLoad = true;

function loadDatesAndRates(select_mvcodes, bookable_online, name) {
		
		if ((select_mvcodes == false) || (select_mvcodes == "false")) {
			var	mvcodes = jQuery("#default_mvcodes").val();
		}
		else {
			var	mvcodes = select_mvcodes;
		}
		
		if (mvcodes.substr(0, 1) == ",") {
			mvcodes = mvcodes.substr(1);
		}
		var ajax_url = '/content/dates-and-rates.php?mvcodes=' + mvcodes + '&bookable-online=' + bookable_online + '&name=' + name;
		//var ajax_url = 'http://milestones/content/dates-and-rates.php?mvcodes=DACOMS04,DBCLAS04';
		
/*		if (jQuery("#prices_extensions_fs").html()) {*/
			
			var height = jQuery("#prices_content").height();
			var width = jQuery("#prices_content").width() + (10*1);
			
			jQuery(".prices_updating").css("height", height);
			jQuery(".prices_updating").css("width", width);
			
			if (height > 120) {
				jQuery(".prices_updating span").css("margin-top", "60px");
			}
			else {
				jQuery(".prices_updating span").css("margin-top", "0");
			}
			
			jQuery(".prices_updated").slideUp("normal", function() {
				//jQuery(".prices_updating").show("normal");
				jQuery(".prices_updating").show();
				jQuery("#prices_content").load(ajax_url, function () {	
/*					jQuery(".prices_updating").slideUp("normal", function() {
						displayPricesUpdated();
					});
*/
					jQuery(".prices_updating").hide();
					displayPricesUpdated();
					bindOnlineBookingButtons();
				});
			});
/*		}
		else {
			jQuery("#prices_content").load(ajax_url);
		}*/
		
}

function displayPricesUpdated() {
	if (firstDatesAndRatesLoad) {
		firstDatesAndRatesLoad = false;
	} else {
		jQuery(".prices_updated").slideDown("normal");
		pricesUpdatedTimer = window.setTimeout(hidePricesUpdated, 5*1000); // show for 2 seconds	
	}
}

function hidePricesUpdated(event) {
	//jQuery(".prices_updated").slideUp("normal");
	jQuery(".prices_updated").slideUp("normal");
	clearTimeout(pricesUpdatedTimer);
	//return false;
}

function bindOnlineBookingButtons() {
	jQuery(".book-now").bind("click", onOnlineBookingClick);
	//jQuery(".btn_request").bind("click", onOnlineBookingClick);
}

function onOnlineBookingClick() {
	pageTracker._trackPageview('/goals/online-booking');
}

