// --> Support function to create a marker


// --> Create a marker with bubble text
//	Parameters:
//	  flag	 The type of icon 0=> Google default, 1=> Std. HIM, 2=> Special HIM
//	  lat	 The latitude of the marker position
//	  lon	 The longitude of the marker position
//	  number The street number of the property. May be blank.
//	  street The street name of the property. May be blank.
//	  city	 The city of the property. May be blank.
//	  state	 The state of the property. May not be blank.
//	  zip	 The ZIP code of the property. May not be blank.
//	  apn	 The APN of the property. May not be blank.
//	  owner	 The property's owner name. May not be blank.
//	  format The format of the bubble. Legal values are:
//		    county - Used for county seats
//		    report - Used for property reports


String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

    function createMarker (flag, lat, lon, format, bubbleText, path, title) {

      icon = new GIcon(G_DEFAULT_ICON);
      domain = window.location.protocol + '//' + window.location.host;
      if (flag != 0) {
		iconPath = domain + path + flag + '/';
		icon.image = iconPath + 'image.png';
		icon.shadow = iconPath + 'shadow.png'
		icon.iconSize = new GSize (26, 36);
		icon.shadowSize = new GSize (44, 36);
		icon.iconAnchor = new GPoint (13, 36);
		icon.infoWindowAnchor = new GPoint (20, 4);
		icon.printImage = iconPath + 'printImage.gif';
		icon.mozPrintImage = iconPath + 'mozPrintImage.gif';
		icon.printShadow = iconPath + 'printShadow.gif';
		icon.transparent = iconPath + 'transparent.png';
		icon.imageMap = [25,0,25,1,25,2,25,3,25,4,25,5,25,6,25,7,25,8,25,9,25,10,25,11,25,12,25,13,25,14,25,15,25,16,25,17,25,18,25,19,25,20,25,21,25,22,25,23,25,24,25,25,25,26,25,27,21,28,20,29,19,30,18,31,17,32,16,33,14,34,13,35,11,35,10,34,9,33,8,32,7,31,6,30,5,29,3,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,0];
      }
	  if (title.trim() == '') {
          markerOptions = {icon:icon};
		} else {
          markerOptions = {icon:icon, title:title};
	  }

      marker = new GMarker (new GLatLng(lat, lon), markerOptions);

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

      return marker;
    }


// Object Creators

    function property (id, flag, lat, long, number, street, city, state, zip, apn, owner) {
      this.id = id;
      this.flag = flag;
      this.lat = lat;
      this.long = long;
      this.number = number;
      this.street = street;
      this.city = city;
      this.state = state;
      this.zip = zip;
      this.apn = apn;
      this.owner = owner;
      return this;
    }
      function createXMLHttpRequest() {
        try { return new XMLHttpRequest(); } catch(e) {}
        try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
        try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
        return null;
      }


