$(document).ready(function(){
	// jquery google maps jmaps plugin stuff
	//get address from hidden field 'gaddress'
	if ($('input#gaddress').attr("value")!="") {
		//alert($('input#gaddress').attr("value"));
		var searchforaddress=$('input#gaddress').attr("value")
		
		$('#profile_map').jmap('init', {'mapType':'map','mapCenter':[51.001421,-3.116987],'mapShowjMapsIcon': false});
		//$('#map1').jmap('init', {'mapType':'map','mapCenter':[51.001421,-3.116987],'mapShowjMapsIcon': false});
	//	$('#map1').jmap('AddMarker', {'pointLatLng': [51.001421,-3.116987],'pointHTML': '<strong>Queen\'s College</strong><br />Trull Road,<br />Taunton,<br />Somerset.<br />TA1 4QS'});
		
	//	$('#address-submit-1').click(function(){
			$('#profile_map').jmap('SearchAddress', {
				'query': searchforaddress,
				'returnType': 'getLocations'
			}, function(result, options) {
				
				var valid = Mapifies.SearchCode(result.Status.code);
				if (valid.success) {
            $.each(result.Placemark, function(i, point){
				$('#profile_map').jmap('init', {'mapType':'map',
									   			'mapCenter':[point.Point.coordinates[1],point.Point.coordinates[0]],
												'mapShowjMapsIcon': false,
												'mapZoom':9
												});
                $('#profile_map').jmap('AddMarker',{
                        'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],
                       /* 'pointHTML':searchforaddress,*/
						'centermap': true
						});
				
                });
            } else {
					$('#address').val(valid.message);
				}
			});
			return false;	
		//});
		// end of jquery google maps jmaps plugin stuff
	}
});
