function LoadMap(divid, address, htmlmaker)
{
	var map = null;
	var geocoder = null;
    if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById(divid));
		map.addControl(new GLargeMapControl());
		geocoder = new GClientGeocoder();
 
		if (geocoder) 
		{
			geocoder.getLatLng(address, function(point) 
			{
				if (!point) 
					return false;
				else 
				{
					map.setCenter(point, 15);
					map.setUIToDefault();
		
					function createMarker(point) 
					{
						var marker = new GMarker(point);
						marker.openInfoWindowHtml(htmlmaker);
						return marker;
					}

					map.addOverlay(createMarker(point));
				}
			});
		}
   }
}

function LoadMap2(divid, baddress, btitle) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById(divid));
		var geocoder = new GClientGeocoder();

		function addAddressToMap(response) {
			map.clearOverlays();
			map.addControl(new GLargeMapControl());
			if (!response || response.Status.code != 200) {
				//alert("Sorry, we were unable to geocode that address");
			} else {
				place = response.Placemark[0];
				map.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]), 14);
				point = new GLatLng(place.Point.coordinates[1],
					place.Point.coordinates[0]);
				marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml('<b>'+btitle+'</b><br />' + place.address);
			}
		}

		function showLocation(address) {
			geocoder.getLocations(address, addAddressToMap);
		}
		showLocation( baddress );               
	}
}

jQuery.preloadImages = function() {
	var a = (typeof arguments[0] == 'object')? arguments[0] : arguments;
	for(var i = a.length -1; i > 0; i--) {
		jQuery("<img>").attr("src", a[i]);
	}
}

//Ajax FUNCTIONS
function AjaxCall(element, seturl, vars)
{
	$.ajax({
		type: "GET",
		queue: "clear",
		cache: true,
		url: seturl,
		data: vars,
		dataType: "html",
		success: function(data) {
			$(element).empty().html(data);
		},
		error: function(request, error) {
			if (error == "timeout") 
				$(element).empty().html("O Server είναι απασχολημένος! Παρακαλώ ξαναδοκιμάστε..");
			else 
				$(element).empty().html("ERROR: " + error);
		}
	});
}


