function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}
function validate_text(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);
	return false;
    }
  else
    {
    return true;
    }
  }
}
function validate_radio(field,alerttxt)
{
	var checked = false;
	for (var i = 0; i < field.length; i++)
	{
	var item = field[i].checked;
  if (item==false)
    {
	checked = false;
    }
  else
    {
    return true;
    }
	}
    alert(alerttxt);
	return false;
}
function validate_form(thisform)
{
with (thisform)
  {
  if (validate_text(naam,"Name must be filled out!")==false)
  {naam.focus();return false;}
  if (validate_text(company,"Company must be filled out!")==false)
  {company.focus();return false;}
  if (validate_email(email,"Email does not contain sufficient data ")==false)
  {email.focus();return false;}
  }
}

var map = "";

function setStartPos(latitude, longitude) {
	var latlng = new google.maps.LatLng(latitude,longitude);
	var settings = {
		zoom: 10,
		center: latlng,
		mapTypeControl: true,
		mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
		navigationControl: true,
		navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map"), settings);
}

function addMarker(latitude, longitude, address) {
	var companyPos = new google.maps.LatLng(latitude, longitude);
	  var companyMarker = new google.maps.Marker({
		  position: companyPos,
		  map: map,
		  title:"SAS Gouda",
		  size:"300,300"
	});

	var contentString = '<div id="map_content">'+
		'<div id="siteNotice">'+
		'</div>'+
		'<h1 id="firstHeading" class="firstHeading"><img src="http://sasgouda.spreadit.nl/templates/sas_sub/images/sas.png" /></h1>'+
		'<div id="bodyContent">'+ address +
		'<a target="_blank" href="http://maps.google.com/maps?daddr=' + latitude + ',' + longitude + '">Directions</a></p>';
		'</div>'+
		'</div>';
	 
	var infowindow = new google.maps.InfoWindow({
		content: contentString
	});
	google.maps.event.addListener(companyMarker, 'click', function() {
	  infowindow.open(map,companyMarker);
	});
}

//google maps code
function initialize() {
	var latitude = 52.089063;
	var longitude = 4.678745;
	setStartPos(latitude, longitude)
	var firstLatitude = 52.0218447;
	var firstLongitude = 4.6804519;
	var firstAddress = '<p>Tielweg 1<br />'+
		'2803 PK Gouda<br />'+
		'The Netherlands<br />';
	addMarker(firstLatitude, firstLongitude, firstAddress);
	var secLatitude = 52.136122;
	var secLongitude = 4.63917;
	var secAddress = '<p>Bedrijfsweg 23-25<br />'+
		'2404 CB Alphen aan den Rijn<br />'+
		'The Netherlands<br />';
	addMarker(secLatitude, secLongitude, secAddress);
}
