// *********************************************************************************************************************************************
// AJAX - LOCATIONS
// *********************************************************************************************************************************************

// prepopularea casutei de location info la initializare
function prepopulateLocationInfo(id_location, target) {
	
	$(target + " .locatie-info-holder").hide(); // ascundem initial holderul ca sa putem face fadeIn
	
	if (id_location>0) {
		$.ajax({ 
			method: "get",
			url: "inc_pag/rezervari/ajax-step1-location-info.php",
			data: "id_location="+id_location+"&lang="+selected_lang, 
			
			success: function(html){ //so, if data is retrieved, store it in html 
				//alert(html);
				$(target + " .locatie-info-holder").html(html); //show the html inside .content div 
				$(target + " .locatie-info-holder").fadeIn(300); //animation 
			} //
		}); //end $.ajax
	} // end IF (id_location is valid)
	else {
		$(target + " .locatie-info-holder").slideUp(200);
	}
}


// popularea casutei de location info la modificarea optiunii
function changeLocationInfo(id_location, target) {
	
	if (id_location>0) {
		$.ajax({ 
			method: "get",
			url: "inc_pag/rezervari/ajax-step1-location-info.php",
			data: "id_location="+id_location+"&lang="+selected_lang, 
			
			//beforeSend: function(){ $(target + " .ajax-loader").show(200); $(target + " .locatie-info-holder").hide(); }, //show loading just when event triggered
			//complete: function(){ $(target + " .ajax-loader").hide(200); }, //stop showing loading when the process is complete 
			success: function(html){ //so, if data is retrieved, store it in html 
				$(target + " .locatie-info-holder").html(html); //show the html inside .content div 
				$(target + " .locatie-info-holder").fadeIn(300); //animation 
			} //
		}); //end $.ajax
	} // end IF (id_location is valid)
	else {
		$(target + " .locatie-info-holder").slideUp(200);
	}
}




// *********************************************************************************************************************************************
// AJAX - TIME
// *********************************************************************************************************************************************

// test daca ora selectata este in timpul programului de lucru
function changeTimeInfo(date, time, id_location, target) {
	if (date.length > 0 && id_location>0) {
		$.ajax({ 
			method: "get",
			url: "inc_pag/rezervari/ajax-step1-time-info.php",
			data: "date="+date+"&time="+time+"&id_location="+id_location, 
			
			//beforeSend: function(){ $(target + " .ajax-loader").show(200); $(target + " .locatie-info-holder").hide(); }, //show loading just when event triggered
			//complete: function(){ $(target + " .ajax-loader").hide(200); }, //stop showing loading when the process is complete 
			success: function(result){
				//alert(result)
				if (result.length>0) {
					
					if ($("#weekend").attr("checked")==false) {
						$(target + " .atentie-out-of-program").html(result); //show the html inside .content div 
						$(target + " .atentie-out-of-program").slideDown(200); //animation 
					}
				} else {
					$(target + " .atentie-out-of-program").slideUp(200); //animation 
				}
			}
		}); //end $.ajax
	} // end IF
}

