/*********************************************************************************************
*** This script is provided to insert a form that when submitted will display the 
*** directions from the entered address to the address specified in the variables below
*** in a new window.
**********************************************************************************************
*** These 2 variables represent the "To Address"
*********************************************************************************************/
var miamicircle = "";
var peachtree = "";
var taddr = "425 Peachtree Hills Avenue NE"; // Street Address
var tCSorZ = "30305"; // City, State or Zip
/********************************************************************************************/

function processForm(form) {
	/** This function processes the form. 
	*** Notice that the form is spesified in a way that will allow other forms on the page 
	*** that are not created with this script.*/
	var isValid = new Boolean();
	isValid = validateForm(form); //validate the form
	if (isValid) {
		getMap(document.frmYahooMap.addr.value, document.frmYahooMap.CSorZ.value);
	}
}
function validateForm(form) {
	/** This function validates the form by determining if the form fields are blank */
	if (document.frmYahooMap.addr.value == "") {
		alert("Please enter a street address");
		return false;
	}
	if (document.frmYahooMap.CSorZ.value == "") {
		alert("Please enter a City, State or Zip");
		return false;
	}
	return true;
}
function getMap(addr, CS) {
	var url;
	// construct the base URL
	url = "http://us.rd.yahoo.com/maps/us/insert/Tmap/extDD/*-http://maps.yahoo.com/dd_result?";
	// add users "From Address" info
	url += "addr=" + encodeURI(addr) + "&csz=" + encodeURI(CS);
	// add the "To Address" info
	url += "&taddr=" + encodeURI(taddr) + "&tcsz=" + encodeURI(tCSorZ);
	// open the winodw with the map
	window.open(url,"YourYahooMap");
}

/*******************************************************************************************
*** This will write out the HTML that will create the form.  Please notice that the form is
*** contained in a <div> tag named "divYahooMap" and the form field labels are within <span>
*** tags that have a style class of "frmYahooMapLabel".  This is done to provide the ability
*** to easily change the appearance using CSS.
*******************************************************************************************/
//document.writeln('<div id="divYahooMap">');
//document.writeln('<form name="frmYahooMap" id="frmYahooMap" method="post" action="javascript: processForm(this)">');
//document.writeln('<p><input type="text" name="addr" id="addr" />&nbsp;<span class="frmYahooMapLabel">Street Address</span></p>');
//document.writeln('<p><input type="text" name="CSorZ" id="CSorZ" />&nbsp;<span class="frmYahooMapLabel">City, State (or Zip)</span></p>');
//document.writeln('<p><input type="submit" name="Submit" value="Display Directions" /></p>');
//document.writeln('</form>');
