//VALIDATION FOR CONTACT FORM
function validateContact () {
	
	var f = document.getElementById("contactform");
	
	var name = f.name.value;
	var email = f.email.value;
	var message = f.message.value;
	
	var success = true;
	
	function validEmail(email){      
		var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		return emailReg.test(email); 
	}
	
	
	if (name == "" || email == "" || message == "") {
		success = false;
		alert ("Please fill out all the fields.");
	}else if(validEmail(email) == false){
		success = false;
		alert ("Please fill out a valid email address.");
	}
		
	if (success) {
		alert ("Thank you! Your message has been sent!");
  		f.submit();
	} 
	
		
	
}

//GOOGLE MAPS
function hide_map (container) {
	var i = document.getElementById(container);
	i.style.visibility = "hidden";
	i.style.height = "0px";
	i.style.overflow = "hidden";
}

function load(address, city, province, country, container) {
  if (GBrowserIsCompatible()) {	
	var map = new GMap2(document.getElementById(container));
	map.disableInfoWindow();
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	
	var geocoder = new GClientGeocoder();
	
	function showAddress(address) {
	  geocoder.getLatLng(
		address,
		function(point) {
		  if (!point) {
			hide_map(container);
		  } else {
			map.setCenter(point, 13);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(address);
		  }
		}
	  );
	}
	
	
	var location = address + ", " + city + ", " + province + ", " + country;
	showAddress(location);
  }
}

