function setupMap() {	
	if (GBrowserIsCompatible()) 
		{ 		
		map_1 = new GMap2(document.getElementById("googlemap"));
		map_1.addControl(new GMapTypeControl());
		map_1.addControl(new GLargeMapControl());
//		map_1.enableDoubleClickZoom();
		map_1.setCenter(new GLatLng(51.750826197, 0.0896179676), 12);
		map_1.addMapType(G_NORMAL_MAP);
		map_1.setMapType(G_NORMAL_MAP);
		var marker = new GMarker(new GLatLng(51.750826197, 0.0896179676))
		map_1.addOverlay(marker);
		var html = '<strong>Harlow Motor Services</strong>';
		html = html + '<br><b>Give me directions</b> starting from : <br /><form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="51.750826197, 0.0896179676"/>';
		marker.openInfoWindowHtml(html);
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html); } );		
		}
	}

function bCheckBooking(form)
	{
		 var errormessage = new String();
	 var name = Trim(form.name.value);
	 var email = Trim(form.email.value);
	 var formOk = false;

	if(bEmpty(name))
	  {errormessage += "\n\nPlease fill in the \"Name\" field";}
	if(bEmpty(form.phone.value))
	  {errormessage += "\n\nPlease fill in the \"Phone\" field";}

	if(bEmpty(email))
		 {errormessage += "\n\nPlease fill in the \"email\" field";}
	else
		{
		if(!bOkEmail(email))
		  {errormessage += "\n\nThe entry for \"email\" does not appear to be a valid email address";}
		}

	if( !bOptDateOk(form.date.value) )
		  {errormessage += "\n\nThe date does not appear to be valid.";}	
	
	formOk = ! (errormessage.length > 2);			
	if (! formOk)
		{alert('The Form was not completed :' + errormessage + '\n'); }
	else
		{alert('Dear ' + name + '\n\nThanks for contacting us regarding your ' + form.need.value + '.\n\nWe will get back to you as soon as possible.' + '\n');	}

	return formOk;
	}

function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

function Hidden ()
{
var sStr = '<a href="mailto:';
sStr += Obscure('ko.nrj.hepraknroo@ghuj');
sStr += '">';
sStr += Obscure('ko.nrj.hepraknroo@ghuj');
sStr += "</a>";
return sStr;
}

function Obscure( sStr )
{
var iLen = sStr.length;
var aRet = new Array();
var i;
var sTemp;

for ( i=0; i < iLen; i++ )
	aRet[i] = sStr.charAt(i);
for ( i=0; i < ( iLen/ 2 ); i += 2 )
	{
	sTemp = aRet[i];
	aRet[i] = aRet[iLen-i -1];
	aRet[iLen-i-1]=sTemp;
	}
return aRet.join('');
}

function bCheckContact( form )
	{
	 var errormessage = new String();
	 var name = Trim(form.name.value);
	 var email = Trim(form.email.value);
	 var formOk = false;

	if(bEmpty(name))
	  {errormessage += "\n\nPlease fill in the \"Name\" field";}

	if(bEmpty(email))
		 {errormessage += "\n\nPlease fill in the \"email\" field";}
	else
		{
		if(!bOkEmail(email))
		  {errormessage += "\n\nThe entry for \"email\" does not appear to be a valid email address";}
		}

if(bEmpty(form.phone.value))
	  {errormessage += "\n\nPlease fill in the \"Phone\" field";}

	formOk = ! (errormessage.length > 2);			
	if (! formOk)
		{alert('The Form was not completed :' + errormessage + '\n'); }
	else
		{alert('Dear ' + name + '\n\nThanks for contacting us.\n\nWe will get in touch as soon as possible.' + '\n');	}

	return formOk;
	} 

function bOkEmail(ss)
	{
	var retval = true;
	var split;
	ss = Trim(ss);
//Check the field is not too small	
	if (5 > ss.length  )
		retval = false;

//Check the @ is present in the middle of some text, and split into name and domain			
	if ( retval )
      {
      var split = ss.match("^(.+)@(.+)$");
      if(split == null || split[1] == null || split[2] == null) 
         retval = false;
     	}

//Check the name
	if ( retval )
      {
	    var regexp_name=/^\"?[\w-_\.]*\"?$/;
	    if(split[1].match(regexp_name) == null) 
	      retval = false;
	  	}

//Check the domain
   if ( retval )
      {
	    var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
	    if(split[2].match(regexp_domain) == null)
	      retval=false;
	    }
	    
	return retval;
	}

function ClearTextareaMsg( field, defaultMsg )
{
	if ( field.value == defaultMsg )
		field.value="";
}
	
function bEmpty(ss)
	{
	return ( Trim(ss).length < 1 )
	}

function bValidDate( sDate )
	{
	re = /\d\d\/\d\d\/\d\d\d\d/;
	var bRet = false;
	
	if ( re.test(sDate) )
		{
		var iD = parseInt(sDate.substr(0, 2), 10);
		var iM = parseInt(sDate.substr(3, 2), 10) - 1;
		var iY = parseInt(sDate.substr(6, 4), 10);	
		var oDate = new Date();
		oDate.setFullYear( iY, iM, iD  );
//		sMsg = iD + "," + iM + "," + iY + " I " + oDate.getDate() + ':' +  oDate.getMonth();
		bRet = ( (oDate.getDate() == iD) && (oDate.getMonth() == iM) );
		}
//	alert(sMsg);
	return bRet;
	}

function bOptDateOk( str )
	{
	return ( bEmpty(str) || bValidDate(str) )
	}
			
var StripyTables =
{
  init: function()
  {
    var tables = Core.getElementsByClass("menuTable");

    for (var i = 0; i < tables.length; i++)
    {
      var tbodys = tables[i].getElementsByTagName("tbody");
      
      for (var j = 0; j < tbodys.length; j++)
      {
        var rows = tbodys[j].getElementsByTagName("tr");

        for (var k = 1; k < rows.length; k += 2)
        {
          Core.addClass(rows[k], "striped");
        }
      }
    }
  }
};

Core.start(StripyTables);
	
var SetCurrent =
	{
		init: function ( )
		{
		var sLinks = document.getElementById('menu').getElementsByTagName('a');
		var sHref = document.location.href.toLowerCase();
		var i=0;
		var bFoundIt = false;
		
		for ( i=0; i<sLinks.length; i++ )
			{
			if ( sLinks[i].href.toLowerCase() == sHref )
				{
				bFoundIt = true;
				Core.addClass(sLinks[i], 'current');
				}
			}
		
		if ( !bFoundIt )
			{
			for ( i=0; i<sLinks.length && !bFoundIt; i++ )
				{
				if ( sLinks[i].href.toLowerCase().indexOf('index') != -1 )
					{
					bFoundIt = true;
					Core.addClass(sLinks[i], 'current');
					}
				}
			}
		}
	};
Core.start(SetCurrent);
	