function confirmCancel(){
  	if (confirm("Are you sure you want to clear the form? Click OK to clear it.")){
      	document.contactForm.reset();
   	}
  	return true;
}

function doSubmit(){
  	if (validateForm()){
      	document.contactForm.submit();
   	}
  	return true;
}

function scrollToPerson(name){
	
	if(name!=""){
  		window.location.hash=name;
  	}
}

function validateForm() { 

	var needAlert = 0;
	var ret = false;  
	var alertMessage= "The Following Fields are Required to Submit Form: ";
	var emailWarning= "No confirmation e-mail will be sent to you. Click ok to submit form as is. Click cancel and fill in e-mail if you would like a confirmation.";
	
	if(document.contactForm.UserName.value==""){
		alertMessage = alertMessage + "Name - ";
		needAlert=1;
	}
	
	if(document.contactForm.UserName.value==""){
		alertMessage = alertMessage + "Phone - ";
		needAlert=1;
	}
	
	if(document.contactForm.UserEmail.value==""){
		alertMessage = alertMessage + "Email - ";
		needAlert=1;
	} else {
		if (!isEmail(document.contactForm.UserEmail.value)){
			alert("Your e-mail appears invalid!! Please go back and fix it.");
			return false;
		}
	}
	
	if((document.contactForm.dwi.checked==false)&&(document.contactForm.realestate.checked==false)&&(document.contactForm.personalinjury.checked==false)&&(document.contactForm.divorce.checked==false)&&(document.contactForm.other.checked==false)){
		alertMessage = alertMessage + "Reason of Inquiry - ";
		needAlert=1;
	}
	if(document.contactForm.UserComments.value==""){
	 	alertMessage = alertMessage + "Additional Comments - ";
	 	needAlert=1;
	}
	
	if (needAlert){
		alertMessage = alertMessage + "Please fill out these fields before submitting form.";
		alert(alertMessage);
		return false;
	}
	
	return true;
}

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
else
	return false;
}    

function doLoadMap(){
	var map = new GMap(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.centerAndZoom(new GPoint(-69.992008, 41.791473), 4);
	var pointMZ = new GPoint(-69.995631, 41.783097);
	var pointC = new GPoint(-69.988489, 41.804526);
	
	var markerMZ = new GMarker(pointMZ);
	var markerC = new GMarker(pointC);
	
	map.addOverlay(markerMZ);
	map.addOverlay(markerC);
	
	var htmlMZ = "Law Offices of Michael A. Zawadzkas<br>161 Cranberry Highway (Rte. 6A)<br>Orleans, MA 02653<br>508.240.1403<br><a href='mailto:mz@mzlawonline.com'>mz@mzlawonline.com</a>";
	var htmlC = "Orleans District Court<br>1237 Rock Harbor Rd<br>Orleans, MA 02653<br>508.255.1924";
	
	markerMZ.openInfoWindowHtml(htmlMZ);
	//markerC.openInfoWindowHtml(htmlC);
	//GEvent.addListener(markerMZ, "click", function() { markerMZ.openInfoWindowHtml(htmlMZ);});
	GEvent.addListener(markerC, "click", function() { markerC.openInfoWindowHtml(htmlC);});
}
	
