    var map;
    var geocoder;
    var markers = [];
    
    
		$(document).ready(function() {
			
			if(("#replyForm")){			
			 $("#replyForm").validate({
					submitHandler: function(form) {
						jQuery(form).ajaxSubmit({
							target: "#result"
						});
					}
				});
	  	}
								
			
		
		if(document.getElementById("map")){	
			if (GBrowserIsCompatible()) {
				// Initialize the map.
				
				map = new GMap2(document.getElementById("map"));
							
				geocoder = new GClientGeocoder();
				map.addControl(new GLargeMapControl());
				map.setCenter(new GLatLng(-33.873818,151.206465), 15);
												
				var sAddress = $("#mapPostCodeForMap").val() + ' , ' + 'Australia';
				var sSuburb = $("#mapSuburbForMap").val();
				var sGFriendly = $("#GFriendly").val();
				
				if(sGFriendly != ""){				
      	 showAddress(sGFriendly, sGFriendly);
      	}
      	else
      	{
      	 showAddress(sAddress, sSuburb);
      	}
       }
      }
      

		});
		
		$(document.body).unload(function() {
			if (GBrowserIsCompatible()) {
				GUnload();
			}
		});
		
		function showAddress(address, addressHTML) {
			 if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (point) {
            	map.setCenter(point, 15);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(addressHTML);
              }
             }
           );
        }
      }

function PreviewAction(action,form)
{
	if(action=='edit')
	{
		$("#previewform").attr("action",form + "?do=edit"); 
		$('#previewform').submit();
		return true;
	}
	else if(action=='submit')
	{
  	$("#previewform").attr("action",form + "?do=submit"); 
		$('#previewform').submit();
		return true;
	}

	return false;
}
