/* Google Maps */
var map,geocoder;
function GMapLoad() {
  if (GBrowserIsCompatible()) {
  var mapOptions = { size:new GSize(530,364) };
	map = new GMap2(document.getElementById("Gmap"), mapOptions);
	map.addControl(new GLargeMapControl());
	geocoder = new GClientGeocoder();
  }
}

function showAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
	  	if (address.match(/^\d+/)) {
			streetOnly = address.replace(/^(\d|\s|\/)*/, '');
			showAddress(streetOnly);
			return;
		} else if (address.match(/,/g)) {
			suburbOnly = address.substring(address.indexOf(',')+1, address.length);
			showAddress(suburbOnly);
			return;
		} else {
        	alert(address + " could not be found!");
			return;
		}
      } else {
        map.setCenter(point, 16);
        var marker = new GMarker(point);
        map.addOverlay(marker);
		foundSuburbOnly = '';
		if (address.match(/^[^(,|\d)]+, Australia$/)) {
			foundSuburbOnly = '<br />(Found suburb location only!)';
		}
        marker.openInfoWindowHtml('<span style="color:black;">'+address+foundSuburbOnly+'</span>');
      }
    }
	);
  $('#photo-container img.prop-image:visible').fadeOut('slow', function () {
	map.checkResize();
	});

} 

$(document).ready( function () {
	/*
$('.property-link').each ( function () {
	
		$(this).click( function () {
			var href = $(this).attr('href');
			href = href + 'true';

			$(this).attr('href', href);
			DP_show(this.href);
			return false;
		});
	
});
*/
	/*$('.property-link').live('click', function(){
		var id = this.src.match(/[0-9]+/);
		$('.ajax-overlay-image-container img:not(.large-image-'+ id[0] +')').css('visibility', 'hidden');
		$('.ajax-overlay-image-container .large-image-'+ id[0]).css('visibility', 'visible');
	});*/



	function swap_images( current_img, current_thumb ) {
		$('.prop-image').removeClass('active');
		$('.prop-thumb').removeClass('active-thumb');
		$(current_thumb).addClass('active-thumb');
		$('.prop-image').css('s-index', '200');
		$(current_img + ':hidden')
			.css('z-index', '300')
			.addClass('active')
			.fadeIn("slow", function(){
				$('.prop-image:not(.active)').fadeOut(500);
			});
		return false;
	}
	
});

$(window).load(function() {
  GMapLoad();
});
