/* Common scripts for the Swedesboro Animal Hospital website. */

function initialize() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(39.755815, -75.297346), 13);
		map.openInfoWindowHtml(map.getCenter(), "<b>Swedesboro Animal Hospital</b><br />392 Kings Hwy<br />Swedesboro, NJ 08085<br />856.467.0004<br /><br /><a href=\"http://maps.google.com/maps?q=392+kings+hwy%2C+swedesboro+nj+08085\" target=\"_new\">Get Directions on Google Maps</a>" );
	}
}


function querySt(full_query_string) {
	the_substring = window.location.search.substring(1);
	split_substring = the_substring.split("&");
	for (i=0; i<split_substring.length; i++) {
		the_value = split_substring[i].split("=");
		if (the_value[0] == full_query_string) {
			return the_value[1];
		}
	}
}


function validateDate(f) {
	var requestedDate = f.the_month.value + '/' + f.the_day.value + '/' + f.the_year.value;
	var regexpDate = /^((((0[13578])|(1[02]))[\/]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\/]?(([0-2][0-9])|(30)))|(02[\/]?[0-2][0-9]))[\/]?\d{4}$/;
	if (!regexpDate.test(requestedDate)) {
		alert('Sorry, the date you entered does not appear to be valid.\nPlease make sure you enter the date in the format mm/dd/yyyy and try again.');
		return false;
	} else {
		document.forms.appointment_form.submit();
		return true;
	}
}
