var image = '../../../components/com_search/views/advancesearch/js/img/marker.png';
var map;
function initializeGmap(lat, lng, contentString) {
	
	//$("#availability-wrapper").hide();
	$("#search-blue-box-wrapper-show").hide();
	
	$("#villa-map-search-results").show();
	
	window.location.hash = "";
	window.location.hash="villa-map-search-results"; 
	
	var myOptions = {
		      zoom: 5,
		      center: new google.maps.LatLng(46.619261,2.457275),
		      mapTypeId: google.maps.MapTypeId.ROADMAP,
		      maxZoom: 10,
		      disableDefaultUI: true,
		      navigationControl: true,
		      mapTypeControl: false,
		      scaleControl: false
		    };
	map = new google.maps.Map(document.getElementById("villa-map-search-results"),
		        myOptions);
	
	var villaMarker = new google.maps.Marker({
		position: new google.maps.LatLng(lat,lng),
		map: map,
		icon: image
		});
	var infowindow = new google.maps.InfoWindow({maxWidth: '100px'});
	
	google.maps.event.addListener(villaMarker, 'mouseover', function() {
		infowindow.setContent(contentString);
		infowindow.open(map,villaMarker);
		});

}
function minimizeAvailability() {
	//$("#availability-wrapper").hide();
	$("#search-blue-box-wrapper-show").hide();
}


function showAvailability(huis_id,huis_code,region,city) {
	
	$("#villa-map-search-results").hide();
	var url = 'option=com_availability&format=raw&view=availability&huis_id='+huis_id;
	
	$.ajax({
		   type: "GET",
		   url: "index.php?",
		   data:url,
		   datatype: 'html',
		   async: false,
		   success: function(msg){
		   	window.location.hash = "";
		   	window.location.hash="availability-box"; 
		   	$("#show-availability").html(msg);
			   $("#availability-wrapper").show();
			   $("#search-blue-box-wrapper-show").show();
			   $("#villa-location").html(region+"/"+city+":");
			   $("#villa-code").html(huis_code);
			   loadAvailability();
		   },
		   error:function (){
            //alert(xhr.status+": "+ajaxOptions);
            
            alert(" We apologize, but there was an error while retriving availability"); 
            }
		 });
}

