jQuery(document).ready(function(){

	$("#reload-image").click(function(){
		randomnumber=Math.floor(Math.random()*11);
		$("#captcha-image").attr("src","kcaptcha/index.php?"+randomnumber);
		return false;
	});
	$('#contact-form').submit(function(){				  
		var action = $(this).attr('action');
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			phone: $('#phone').val(),
			requirements: $('#requirements').val(),
			captcha: $('#captcha').val()
		},
		function(data){
				$('#contact-form #submit').attr('disabled','');
				$('.response').remove();
				$('#contact-form').before('<p class="response">'+data+'</p>');
				$('.response').slideDown();
				if(data=='Message sent!') $('#contact-form').slideUp();
			}
		); 
		return false;
	});
});


var varprefered = '';
jQuery(document).ready(function(){
	$('#booking-form').submit(function(){	
	
		if($("input[name='preferred-contact']:checked").val()==undefined) {
			varprefered = '';
		} else {
			varprefered = $("input[name='preferred-contact']:checked").val();
		}
		
		if($("input[name='gender']:checked").val()==undefined) {
			vargender = '';
		} else {
			vargender = $("input[name='gender']:checked").val();
		}
		
		if($("input[name='living-room-dinnig-area']:checked").val()==undefined) {
			varlivingroom = '';
		} else {
			varlivingroom = $("input[name='living-room-dinnig-area']:checked").val();
		}
		
		if($("input[name='bedrooms']:checked").val()==undefined) {
			varbedrooms = '';
		} else {
			varbedrooms = $("input[name='bedrooms']:checked").val();
		}
		
		if($("input[name='iagree']:checked").val()==undefined) {
			isagreed = '';
		} else {
			isagreed = 1;
		}
		
		var action = $(this).attr('action');
		$.post(action, { 
			bedrooms: varbedrooms,
			livingroomdinnigarea: varlivingroom,
			
			requirements: $('#requirements').val(),
			
			date: $('#date').val(),
			name: $('#name').val(),
			lastname: $('#lastname').val(),
			gender: vargender,
			
			address1: $('#address1').val(),
			address2: $('#address2').val(),
			suburb: $('#suburb').val(),
			postcode: $('#postcode').val(),
			telephonehome: $('#telephone-home').val(),
			telephonemobile: $('#telephone-mobile').val(),
			email: $('#email').val(),
			preferredcontact: varprefered,
			iagree: isagreed,
		},
		function(data){
				$('#booking-form #submit').attr('disabled','');
				$('.response').remove();
				$('#booking-form').before('<p class="response">'+data+'</p>');
				$('.response').slideDown();
				if(data=='Message sent!') $('##booking-form').slideUp();
			}
		); 
		return false;
	});
	
	$('#date').datetimepicker({
		ampm: true,
		hourGrid: 4,
		minuteGrid: 10
	});
	
	$('#timepreferred').datetimepicker({
		ampm: true,
		hourGrid: 4,
		minuteGrid: 10
	});
	

});


function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
       			map.setCenter(new GLatLng(-33.89366266698077, 151.18371963500977), 11);
					map.addControl(new GSmallMapControl());
					var coverage_area = new GPolygon([
						new GLatLng(-33.919147,151.257706),
new GLatLng(-33.914019,151.263885),
new GLatLng(-33.914019,151.267662),
new GLatLng(-33.912024,151.269379),
new GLatLng(-33.901766,151.266632),
new GLatLng(-33.890652,151.277962),
new GLatLng(-33.890367,151.285515),
new GLatLng(-33.886377,151.285172),
new GLatLng(-33.873266,151.282425),
new GLatLng(-33.863289,151.282768),
new GLatLng(-33.857017,151.284485),
new GLatLng(-33.848748,151.286888),
new GLatLng(-33.837627,151.284142),
new GLatLng(-33.833635,151.279678),
new GLatLng(-33.837342,151.277275),
new GLatLng(-33.840764,151.275902),
new GLatLng(-33.843901,151.277275),
new GLatLng(-33.847893,151.277618),
new GLatLng(-33.851599,151.275215),
new GLatLng(-33.849889,151.268692),
new GLatLng(-33.851314,151.265945),
new GLatLng(-33.855021,151.266289),
new GLatLng(-33.863004,151.269035),
new GLatLng(-33.86842,151.269379),
new GLatLng(-33.870701,151.261826),
new GLatLng(-33.87013,151.253586),
new GLatLng(-33.866425,151.254959),
new GLatLng(-33.863574,151.252556),
new GLatLng(-33.864144,151.249466),
new GLatLng(-33.86728,151.249123),
new GLatLng(-33.869845,151.248779),
new GLatLng(-33.872981,151.245689),
new GLatLng(-33.872126,151.239853),
new GLatLng(-33.86785,151.23951),
new GLatLng(-33.86899,151.234703),
new GLatLng(-33.872981,151.2323),
new GLatLng(-33.869275,151.227493),
new GLatLng(-33.863574,151.226807),
new GLatLng(-33.865854,151.221313),
new GLatLng(-33.863289,151.218567),
new GLatLng(-33.85274,151.214104),
new GLatLng(-33.850744,151.216507),
new GLatLng(-33.844756,151.221313),
new GLatLng(-33.845897,151.22921),
new GLatLng(-33.850174,151.243286),
new GLatLng(-33.843901,151.252556),
new GLatLng(-33.839053,151.257362),
new GLatLng(-33.831924,151.259766),
new GLatLng(-33.828216,151.270409),
new GLatLng(-33.823653,151.267319),
new GLatLng(-33.828787,151.253242),
new GLatLng(-33.817378,151.251869),
new GLatLng(-33.813384,151.248436),
new GLatLng(-33.80882,151.238136),
new GLatLng(-33.818519,151.22509),
new GLatLng(-33.817663,151.21994),
new GLatLng(-33.80825,151.230927),
new GLatLng(-33.804826,151.228867),
new GLatLng(-33.805112,151.222687),
new GLatLng(-33.804541,151.213417),
new GLatLng(-33.809105,151.144753),
new GLatLng(-33.822227,151.12175),
new GLatLng(-33.832494,151.107674),
new GLatLng(-33.848748,151.097031),
new GLatLng(-33.862148,151.091537),
new GLatLng(-33.878967,151.090851),
new GLatLng(-33.903191,151.089821),
new GLatLng(-33.941366,151.114883),
new GLatLng(-33.955321,151.149902),
new GLatLng(-33.955891,151.152992),
new GLatLng(-33.946208,151.168442),
new GLatLng(-33.925984,151.163635),
new GLatLng(-33.922851,151.174622),
new GLatLng(-33.926554,151.183548),
new GLatLng(-33.933391,151.191444),
new GLatLng(-33.955321,151.196938),
new GLatLng(-33.961302,151.207924),
new GLatLng(-33.966712,151.22406),
new GLatLng(-33.964149,151.251869),
new GLatLng(-33.952189,151.250496),
new GLatLng(-33.95048,151.257362),
new GLatLng(-33.941081,151.263885),
new GLatLng(-33.922851,151.258736),
new GLatLng(-33.919254,151.257706)
					], "#384970", 3, 1, "#ffcc00", 0.2);
 
				
					map.addOverlay(coverage_area);
					geocoder = new GClientGeocoder();
 
	var marker = new GMarker(new GLatLng(-33.89366266698077, 151.18371963500977));
	map.addOverlay(marker);
	marker.openInfoWindowHtml("<strong>Upholstery Cleaning Sydney<\/strong><br/> Suite 6, 134-140 King St, NEWTOWN, 2042");
      }
    }
