/////////////////////
//Launch New Window
/////////////////////
function launchMap(winName,whatWi,whatHe, ReSize, sBars, tBars, mBars, myLoc) {

  var myCity = document.getElementById("city").value;
  var myState = document.getElementById("state").value;
  var myAddress = document.getElementById("address").value;
  var myZip = document.getElementById("zip").value;
  var myRegExp = /\ /g; //search for the " " (empty spaces)
  
  var myCity = myCity.replace(myRegExp, "+");
  var myAddress = myAddress.replace(myRegExp, "+");

  var URL = "http://maps.google.com/maps?daddr=34344+Street+of+the+Green+Lantern,+Dana+Point,+CA+92629&saddr=" + myAddress + ".,+ " + myCity + ",+ " + myState + ",+ " + myZip + "&f=li&hl=en&cid=&ie=UTF8&om=1";

  var winName;
  openvalues = 'width=' + whatWi + ',' + 'height=' + whatHe + ',resizable=' + ReSize + ',scrollbars=' + sBars + ',toolbars=' + tBars + ',menubars=' + mBars +',location=' +myLoc;
  window.open(URL,winName, openvalues);
  
}
//end launch new window

function formChecker() {
	var myCity = document.getElementById("city");
	var myState = document.getElementById("state");
	var myAddress = document.getElementById("address");
	var myZip = document.getElementById("zip");
   
	var isValid = true;
	 
	if (myAddress.value=="") {
		alert("Please enter an address.");
		myAddress.focus();
		isValid = false;
	}
	
	if (myCity.value=="") {
		alert("Please enter a city.");
		myCity.focus();
		isValid = false;
	}
	   
	if (myState.value=="") {
		alert("Please select a state.");
		myState.focus();
		isValid = false;
	}
	   
	if (isNaN(myZip.value)) {
		alert("Please enter a number for the zip code");
		myZip.focus();
		isValid = false;
	}
	
	if (isValid) {
		launchMap('map',800,600, 'yes', 'yes', 'no', 'no', 'no');
	} else {
		return false;	
	}
}

// Start Google Map
function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		var point = new GLatLng(33.463669, -117.707691)
		var centrePoint = new GLatLng(33.483669, -117.697691)
		var marker = new GMarker(point);
		var address = "<strong>Cannons Seafood Grill</strong><br />34344 Street of the Green Lantern<br />Dana Point, CA 92629";

		map.setCenter(centrePoint, 13);
		map.addControl(new GSmallMapControl());
		map.addOverlay(marker);

		marker.openInfoWindowHtml(address);
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(address);
		});
		return marker;
	}
}

