	var canChangeBtn = false;

function checkAvailableApartment(){
	var iApartmentId = document.getElementById('iReservationApartmentId').value;
	postString = "&iReservationApartmentId=" + iApartmentId;
	var iDay = document.getElementsByName('sStartDateDay')[0].value;
	postString += "&sStartDateDay=" + iDay;
	var iMonth = document.getElementsByName('sStartDateMonth')[0].value;
	postString += "&sStartDateMonth=" + iMonth;
	var iYear = document.getElementsByName('sStartDateYear')[0].value;
	postString += "&sStartDateYear=" + iYear;
	var iEDay = document.getElementsByName('sEndDateDay')[0].value;
	postString += "&sEndDateDay=" + iEDay;
	var iEMonth = document.getElementsByName('sEndDateMonth')[0].value;
	postString += "&sEndDateMonth=" + iEMonth;
	var iEYear = document.getElementsByName('sEndDateYear')[0].value;
	postString += "&sEndDateYear=" + iEYear;
	var iReservationPersonsCount = document.getElementsByName('iReservationPersonsCount')[0].value;
	var iReservationCurrency = document.getElementsByName('iReservationCurrency')[0].value;
	postString += "&iReservationPersonsCount="+iReservationPersonsCount+"&iReservationCurrency="+iReservationCurrency;
	var sReservationLanguage = document.getElementsByName('sReservationLanguage')[0].value;
	postString += "&lang="+sReservationLanguage;
	var passtru = false;
	jQuery.ajax({
		beforeSend: function() {
			/* deactivating the "continue" button */
			//jQuery('#continue_button').attr('disabled','disabled');
			jQuery('#check_loader').html('<img src="logic_frontend/templates/site/images/ajax-loader3.gif" />');
		},
		type: "POST",
		url: "ajaxindex.php?lang="+sReservationLanguage,
		data: "mod=apart&sec=_ajax_apartment_available"+postString,
		success: function(data, status){
			canChangeBtn = true;
			jQuery('#check_loader').html('');
			jQuery('#iSearchCurrency').val(iReservationCurrency);
			jQuery('#iSearchPersonsCount').val(iReservationPersonsCount);
			jQuery('#iSearchStartDay').val(iDay);
			jQuery('#iSearchStartMonth').val(iMonth);
			jQuery('#iSearchStartYear').val(iYear);
			jQuery('#iSearchEndDay').val(iEDay);
			jQuery('#iSearchEndMonth').val(iEMonth);
			jQuery('#iSearchEndYear').val(iEYear);
			
			if(data.search('ok')==0){
				var aRespondMsg = data.split(",")
				jQuery('#price_box').css('display','block');
				jQuery('#price-box-container').html('<span>'+aRespondMsg[1]+'</span>');
				jQuery('#btn_next').css('display','block');
				jQuery('#btn_check').css('display','none');
				passtru = true;
			}
			else{
				passtru = false;
				jQuery('#btn_next').css('display','none');
				jQuery('#btn_check').css('display','none');
				jQuery('#price_box').css('display','none');
				jQuery('#error_available').remove();
				$('#tb_step1 tr:last').before(data);
				jQuery('#continue_button').attr('disabled','');
			}
		}
	});
	
	return passtru;
}
function clearToCheck(){
	if(jQuery('#error_available')){
		jQuery('#error_available').remove();
		jQuery('#available_apartments').remove();
		jQuery('#list_apartments').remove();
		
	}
	if(canChangeBtn){
		
		//jQuery('buttons_b').attr('class','');
		//jQuery('.step_a').attr('href','#');
		
		jQuery('#btn_check').css('display','block');
		jQuery('#price_box').css('display','none');
		jQuery('#btn_next').css('display','none');
		canChangeBtn=false;
	}

		
}
function disableSteps(){

	jQuery('.step_a').attr('class','buttons_b');
	jQuery('#step_2').css('display','none');
	jQuery('#step_3').css('display','none');
	jQuery('#step_4').css('display','none');
	jQuery('.steps_block').css('display','block');
}
