<!--
function hide(thing) { document.getElementById(thing).style.display = 'none'; }
function view(thing) { document.getElementById(thing).style.display = 'block'; }

function toggle(thing)
  {
    if ( document.getElementById(thing).style.display != 'block') { view(thing); }
    else if ( document.getElementById(thing).style.display != 'none') { hide(thing); }
  }

function changePic(image)
	{
		if (document.getElementById('picture'))
			{ document.getElementById('picture').style.backgroundImage='url("http://www.farmerspal.com/images/puppies/thumbs/'+image+'")'; }
		document.getElementById('picture2').style.backgroundImage='url("http://www.farmerspal.com/images/puppies/'+image+'")';
	}

function go(clicked)
	{
    if (eval('document.main.'+clicked+'.value') == '')
      {
        clicked = clicked.substring(0,(clicked.length-1))+String.fromCharCode(Math.max((clicked.substring((clicked.length-1),clicked.length)).charCodeAt(0)-1,97));
      }
    document.main.clicked.value=clicked;
    document.main.submit();
	}

/* DHTML textbox character counter (IE4+) script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */
function taLimit()
	{
		var taObj=event.srcElement;
		if (taObj.value.length==taObj.maxLength*1) return false;
	}

function taCount(visCnt)
	{
		var taObj=event.srcElement;
		if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
		if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
	}

// checked email boxes
function emails()
  {
    var emaillist = 'mailto:'
    for(var i=0; i < document.main.email.length; i++)
      {
        if(document.main.email[i].checked) { emaillist += document.main.email[i].value + ',' }
      }
    if(document.main.email.length==undefined)
      { if(document.main.email.checked) { emaillist += document.main.email.value } }
    document.links.emailchecked.href = emaillist
  }

function copyit(text)
  {
    var tempval=eval("document."+text);
    tempval.focus();
    tempval.select();
    therange=tempval.createTextRange();
    therange.execCommand("Copy");
  }

function toggleMap(address,mapID,type)
  {
    view(mapID);
    view(mapID+'distance');
    if (document.getElementById(mapID).style.display == 'block')
      {
        document.getElementById(mapID).style.width = '350px';
        document.getElementById(mapID).style.height = '350px';
        getCoordinates(address,mapID,type);
      }
  }

function getCoordinates(address,mapID,type)
  {
    geocoder = new google.maps.Geocoder();

    var geocoderRequest = { address: address }

    geocoder.geocode(geocoderRequest, function(results, status) {

      if (status == google.maps.GeocoderStatus.OK)
        {
          var myOptions =
            {
              zoom: 8,
              center: results[0].geometry.location,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
          var map = new google.maps.Map(document.getElementById(mapID), myOptions);

          if (type == 'directions')
            {
              var directionsService = new google.maps.DirectionsService();
              var directionsDisplay = new google.maps.DirectionsRenderer();

              directionsDisplay.setMap(map);

              // Try W3C Geolocation method (Preferred)
              if(navigator.geolocation)
                {
                  browserSupportFlag = true;
                  navigator.geolocation.getCurrentPosition(function(position) {
                    start = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
                  }, function() {
                    handleNoGeolocation(browserSupportFlag);
                  });
                }
              else if (google.gears)
                {
                  // Try Google Gears Geolocation
                  browserSupportFlag = true;
                  var geo = google.gears.factory.create('beta.geolocation');
                  geo.getCurrentPosition(function(position) {
                    start = initialLocation;
                  }, function() {
                    handleNoGeolocation(browserSupportFlag);
                  });
                }
              else
                {
                  // Browser doesn't support Geolocation
                  browserSupportFlag = false;
                  handleNoGeolocation(browserSupportFlag);
                  type = 'map';
                }

              if (type == 'directions')
                {
                  var request = {
                      origin:start,
                      destination:address,
                      travelMode: google.maps.DirectionsTravelMode.DRIVING
                  };
                  directionsService.route(request, function(response, status) {
                    if (status == google.maps.DirectionsStatus.OK)
                      {                 
                        // Display the distance:
                        document.getElementById(mapID+'distance').innerHTML = response.routes[0].legs[0].distance.text + ' - about ' + response.routes[0].legs[0].duration.text + ' | <a href="http://maps.google.com/maps?saddr='+start+'&daddr='+address+'" target="_blank"/>Google Maps</a>';
                        directionsDisplay.setDirections(response);
                      }
                    })
                }
            }
          if (type == 'map')
            {
              marker = new google.maps.Marker({ map: map });
              marker.setPosition(results[0].geometry.location);

              infowindow = new google.maps.InfoWindow();
              var content = '<strong>' + results[0].formatted_address + '</strong><br/>';
              infowindow.setContent(content);
              infowindow.open(map, marker);
              document.getElementById(mapID+'distance').innerHTML = 'Locate on <a href="http://maps.google.com/maps?q='+address+'" target="_blank"/>Google Maps</a>';
            }

        }
      else
        {
          if (status == 'ZERO_RESULTS') { alert('Address not found!'); }
          else { alert(status); }
          hide(mapID);
          hide(mapID+'distance');
          hide('hide'+mapID);
        }
    })
  }

function handleNoGeolocation(errorFlag)
  {
    if (errorFlag == true) { alert('Error: The Geolocation service failed.'); }
 //   else { alert('Error: Your browser doesn\'t support geolocation.'); }
  }

//-->
