var map;
var directionsPanel;
var directions;
var cplAddress = "28700 Euclid Ave. Wickliffe, OH 44092";
var point = new GLatLng(41.596785, -81.486958);
var markerText = "<p style='font-size:.8em'>The FEST<br>28700 Euclid Ave.<br>Wickliffe, OH 44092</p><div><form onsubmit='doDirections(this.address.value); return false;'><p style='font-size:.8em;'>Enter Your Address: <input type='text' id='address'><br><input type='submit' value='Go'><br></p></form></div>";
var testText = "TEST";
var marker;

function initialize() {
	map = new GMap2(document.getElementById("map"));
	map.setCenter(point, 13);
	map.addControl(new GSmallMapControl());
	createMarker(point, markerText);
	map.addOverlay(marker);
	setTimeout("marker.openInfoWindowHtml(markerText)", 1000);
	directionsPanel = document.getElementById("text_directions");
}

function doDirections(address){
	directions = new GDirections(map, directionsPanel);
	directions.load(address + " to " + cplAddress);
	map.removeOverlay(marker);
	
	if($(".content").height() + 900 > $(".sponsors").height()){
		$(".main").height($(".content").height() + 900);
	}
}

function createMarker(point, html){
	marker = new GMarker(point);
	GEvent.addListener(marker, "click", function(){
		marker.openInfoWindowHtml(markerText);
	});
	return marker;
}