$(function() {
			
			$("#mapwindow").dialog({
				height: 390,
				width: 530,
				modal: true,
				resizable: false,
				open: function(event, ui) {initialize(); },
				autoOpen: false
			});
		
			$("#showmap").click(function (){
				
				$("#mapwindow").dialog('open');
				  
			});	
			
			
			$("#sent_callback").dialog({
				height: 180,
				width: 330,
				modal: true,
				resizable: false,
				autoOpen: false,
				buttons: {'Close': function() {
					$(this).dialog('close');
				}}
			});
			
			$("#callback").dialog({
				height: 440,
				width: 350,
				modal: true,
				resizable: false,
				open: function(event, ui) {initialize(); },
				autoOpen: false,
				buttons: {
				'Call Me!': function() {
					
					$("#msg_window").html("SENDING!");
					
					var cb_data = $("#callback_form").serialize();
					
					$.ajax({
						  type: "POST",
						  url: "http://www.arcsystems.co.uk/submailer.php?page=callback",
						  cache: false,
						  data: cb_data,
						  success: function(html){
						  	
							if (html == 'Sent') {
								$("#callback").dialog('close');
								$("#sent_callback").dialog('open');
								$("#cb_name").val("");
								$("#cb_company").val("");
								$("#cb_phone").val("");
								$("#cb_email").val("");
							} else {
								
								$("#msg_window").html("<span style=\"color: red; float: left; margin: 5px 0 0 10px; font-weight: bold; font-size: 12px;\">Failed - Please Retry Later.</span>");
							}							
						  }
					});
					
				},
				Cancel: function() {
					$(this).dialog('close');
				}
				}
				});
		
			$("#showcallback").click(function (){
				
					$("#msg_window").empty();
					$("#callback").dialog('open');
				  
			});	
			
				
});


initialize=function () {
				
				var map = new GMap2(document.getElementById("map"));
				
				map.setCenter(new GLatLng(51.732123, 0.482555), 16);
				var latlng = new GLatLng(51.730890, 0.482647);
				
				map.addControl(new GSmallZoomControl());

				  var someMarker = new GMarker(latlng, { title: "Our postcode is: CM2 6HE" });
				  GEvent.addListener(someMarker, "click", function() {  someMarker.openInfoWindowHtml("ARC (UK) Systems<br>Units 1-2 Cornell Estate<br> Navigation Road<br> Chelmsford, Essex<br>CM2 6HE");  })
			
				
				map.addOverlay(someMarker);
				
			}