function showText() {
	$("#doctorLocator").html("");
	$("#doctorLocatorText").show();
}

function showDoctors(lang) {
	pc = $("#postalCode").val().toUpperCase().replace(/ /g,"").replace(/-/g,"");
	pc = pc.substr(0,3)+" "+pc.substr(3,3);
	if ( pc.length != 7 ) {
		if ( lang == 'en' ) {
			alert("Postal code is not valid"); return(false);
		} else {
			alert("Code postale n'est pas valide"); return(false);
		}
	}

	$("#postalCode").val(pc);
	
	$.getJSON("/zostavaxca/locate.jsp?postalCode="+$("#postalCode").val()+"&radius="+$("#radius").val(), function(data) {
		$("#doctorLocatorText").hide();
		if ( lang == 'en' ) {
			$("#doctorLocator").html("<p><b>"+data.length+" physicians or clinics were found within <i>"+$("#radius").val()+" km</i> of postal code <i>"+pc+"</i>:</b><br /></p>");
		} else {
			$("#doctorLocator").html("<p><b>"+data.length+" bureaux de médecins ou cliniques se trouvent dans un rayon de <i>"+$("#radius").val()+" km</i> du code postal <i>"+pc+"</i>:</b><br /></p>");
		}
		if ( data.length > 0 ) {
			$.each(data, function(i, item) {
				$("#doctorLocator").append('<div style="width: 60px; height: 100px; padding-right: 5px; float: left;"><p>'+item.distance+' km</p></div><div style="padding-left: 5px;"><p>'+((item.first_name+item.last_name != "")?('<b>'+item.first_name+' '+item.last_name+'</b><br />'):"")+((item.clinic_name != "")?'<i>'+item.clinic_name+'</i><br />':'')+item.address+((item.office_suite != "")?', '+item.office_suite:'')+'<br />'+item.city+', '+item.province+'&nbsp;&nbsp;'+item.postal_code+'<br />('+item.area_code+') '+item.phone_num.substr(0,3)+'-'+item.phone_num.substr(3)+((item.email != "")?'<br /><a href="mailto:'+item.email+'">'+item.email+'</a>':'')+((item.website != "")?'<br /><a href="'+item.website+'" target="_blank">'+item.website+'</a>':'')+'</div><div style="clear: both; height: 0px;">&nbsp;</div>');
			});
		} else {
			if ( lang == 'en' ) {
				$("#doctorLocator").append("<br /><div class='doctor'><b>No physicians or clinics have been found in the search area requested.</div>");
			} else {
				$("#doctorLocator").append("<br /><div class='doctor'><b>Aucun médecin ou clinique n'a été trouvé dans le secteur de recherche priée.</div>");
			}
		}
		$("#doctorLocator").append('<p style="clear: both"><br /><img src="images/button-back'+((lang=="fr")?"-fr":"")+'.gif" onclick="showText();"></p>');
	});
};
