//clear the starting address field if it's the default
function clearField() {
	var f = document.drivingdirectionsForm;
	
	var start_location = f.starting_location.value;
	if(start_location == "Starting Address")
		f.starting_location.value = "";
}

//set the starting address field to the default
function setField() {
	var f = document.drivingdirectionsForm;
	
	var start_location = f.starting_location.value;
	if(start_location == "")
		f.starting_location.value = "Starting Address";
}

//open a new window with driving directions from google
function getDrivingDirections() {
	var f = document.drivingdirectionsForm;
	var start_location = f.starting_location.value;
	
	//remove any special characters except space and comma
	//trim spaces and replace remaining spaces with a plus sign
	start_location = start_location.replace(/[^, a-zA-Z0-9]/g,"");
	start_location = start_location.replace(/  /g," ");
	start_location = start_location.replace(/ /g,"+");
	
	//go to the map
	if(start_location != "" && start_location != "Starting+Address") {
		
		var googleDD = "http://maps.google.com/maps?f=d&hl=en&saddr="+start_location+"&daddr=468+N.+Camden+Dr.+%23200+Beverly+Hills,+CA+90210&sll=34.166221,-118.794651&sspn=0.048292,0.070381&layer=&ie=UTF8&om=1";
		var googlewin = window.open(googleDD,"ddbygoogle","width=800,height=600,toolbar,location,directories,status,scrollbars,resizable,menubar");
		
		//var yahooDD = "http://maps.yahoo.com/index.php#mvt=m&q2=468+N.+Camden+Dr.+%23200+Beverly+Hills,+CA+90210&q1="+start_location+"&trf=0&lon=-118.79272&lat=34.165831&mag=4";
		//var yahoowin = window.open(yahooDD,"ddbyyahoo","width=800,height=600,toolbar,location,directories,status,scrollbars,resizable,menubar");
	} else {
		alert("Please enter your starting address.");
	}
	return false;
}