
function contact_us_initialize()
{
	if (GBrowserIsCompatible())
	{
		var address = "5100 South Service Road, Burlington, Ontario, Canada, L7L6A5"
		var zoom_level = 12;

		var map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var geocoder = new GClientGeocoder();

		map.clearOverlays();
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
		markerOptions = { icon:G_DEFAULT_ICON, draggable: false};
		if (geocoder)
		{
			geocoder.getLatLng(address, function(point)
										{
											if (!point)
												document.getElementById("map").innerHTML='Address \"'+  address + '\" not found' ;
											else
											{

												map.setCenter(point, zoom_level);
												/*
													G_NORMAL_MAP
													G_SATELLITE_MAP
													G_DEFAULT_MAP_TYPES
													G_HYBRID_MAP
												*/
												map.setMapType(G_NORMAL_MAP);
												var marker = new GMarker(point,markerOptions);
												map.addOverlay(marker);

												marker.openInfoWindowHtml("<b>JuNKiT! Main Office</b><br />59-5100 South Service Road<br />Burlington, Ontario, Canada, L7L6A5");

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

function SubmitComments()
{
	//Make sure they chose a department, entered a topic/name/valid email/message

	if (document.ContactForm.Department.value == "")
	{
		FocusOnField(document.ContactForm.Department);
		ShowPopup(true, "ERROR", "Please choose a department.")
	}
	else if (document.ContactForm.Topic.value == "")
	{
		FocusOnField(document.ContactForm.Topic);
		ShowPopup(true, "ERROR", "Please enter a topic.")
	}
	else if (document.ContactForm.Name.value == "")
	{
		FocusOnField(document.ContactForm.Name);
		ShowPopup(true, "ERROR", "Please enter your name.")
	}
	else if (!IsValidEmail(document.ContactForm.Email.value))
	{
		FocusOnField(document.ContactForm.Email);
		ShowPopup(true, "ERROR", "Please enter a valid email address.")
	}
	else if (document.ContactForm.Message.value == "")
	{
		FocusOnField(document.ContactForm.Message);
		ShowPopup(true, "ERROR", "Please enter your message.")
	}
	else
	{
		Parameters =
		"&Department="+document.ContactForm.Department.value+
		"&Topic="+document.ContactForm.Topic.value+
		"&Name="+document.ContactForm.Name.value+
		"&Email="+document.ContactForm.Email.value+
		"&Message="+document.ContactForm.Message.value;

		AjaxCall("POST","contact.php","SubmitMessage=1" + Parameters, "AfterSubmitComments", true);
	}
}


function AfterSubmitComments(xml, text)
{
	ShowPopup(true, "SUCCESS", text);

	document.ContactForm.Department.value = "";
	document.ContactForm.Topic.value = "";
	document.ContactForm.Name.value = "";
	document.ContactForm.Email.value = "";
	document.ContactForm.Message.value = "";
}