/****************************************************
INITS
****************************************************/
//var home="http://aviatlas.goswitchboard.com/";
var home="http://www.aviatlas.com/";


var MAP_TOOL_PAN = 0;
var MAP_TOOL_ADD_HOTSPOT = 1;
var MAP_TOOL_ADD_PROFILE = 2;
var MAP_TOOL_MOVE_HOTSPOT = 3;
var MAP_TOOL_MOVE_PROFILE = 4;
var MAP_TOOL_WAYPOINT = 5;
var MAP_TOOL_POLYLINE = 6;
var MAP_TOOL_POLYGON = 7;
var MAP_TOOL_ADD_SIGHTING = 8;

var MAP_MODE_NONE = 0;
var MAP_MODE_HOTSPOT = 1;
var MAP_MODE_PEOPLE = 2;

var map_tool_mode = MAP_TOOL_PAN;
var map_mode = MAP_MODE_HOTSPOT;

var ADD_HOTSPOT_THRESHOLD = 11;

var map = null;
var gmarkers = []; //keeps track of hotspot/people markers on map
var gmarkersIds = [];

var waypoints = [];             // keeps track of waypoints on map
var undefined_hotspot = null;   // keeps track of an unsaved new hotspot marker
var undefined_profile = null;   // keeps track of an unsaved new profile marker
var undefined_waypoint = null;  // keeps track of an unsaved new waypoint marker
var undefined_sighting = null;  // keeps track of an unsaved new sighting marker
var shape_preview = null;        // show shape as it's being drawn
var geocoder = null;

var waypoint_remove_working_line = function() {};
var waypoint_working_latlngs = [];
var waypoint_working_line_markers = []; //keeps track of line markers on map

var eventListenerClick = null;
var eventListenerDblClick = null;

var undefined_line = "";

var tooltip = null;

var cal=null;
var cal2=null;
var way_cal_start=null;
var way_cal_end=null;

var validators = [];

var sliderForgotPassword=null;
var	screen_name = '';

var crosshairs=null;

/****************************************************
function: empty
description: utility function that empties a DOM element
****************************************************/
function empty(elm){
	if (elm){
		while(elm.hasChildNodes()){
			elm.removeChild(elm.childNodes[elm.childNodes.length-1]);
		}
	} else {
		alert("Undefined element passed to 'empty'");
	}
}


//Create an icon for all the marker types

if (typeof GIcon!="undefined") {

  var iHspG = new GIcon();
  iHspG.image = "/images/mm_20_grey.png";
  iHspG.shadow = "/images/mm_20_shadow.png";
  iHspG.iconSize = new GSize(12, 20);
  iHspG.shadowSize = new GSize(22, 20);
  iHspG.iconAnchor = new GPoint(6, 20);
  iHspG.infoWindowAnchor = new GPoint(5, 1);
  iHspG.infoShadowAnchor = new GPoint(12, 13);

  var iHsp0 = new GIcon();
  iHsp0.image = "/images/mm_20_red.png";
  iHsp0.shadow = "/images/mm_20_shadow.png";
  iHsp0.iconSize = new GSize(12, 20);
  iHsp0.shadowSize = new GSize(22, 20);
  iHsp0.iconAnchor = new GPoint(6, 20);
  iHsp0.infoWindowAnchor = new GPoint(5, 1);
  iHsp0.infoShadowAnchor = new GPoint(12, 13);

  var iHsp1 = new GIcon();
  iHsp1.image = "/images/mm_20_orange.png";
  iHsp1.shadow = "/images/mm_20_shadow.png";
  iHsp1.iconSize = new GSize(12, 20);
  iHsp1.shadowSize = new GSize(22, 20);
  iHsp1.iconAnchor = new GPoint(6, 20);
  iHsp1.infoWindowAnchor = new GPoint(5, 1);
  iHsp1.infoShadowAnchor = new GPoint(12, 13);

  var iHsp2 = new GIcon();
  iHsp2.image = "/images/mm_20_yellow.png";
  iHsp2.shadow = "/images/mm_20_shadow.png";
  iHsp2.iconSize = new GSize(12, 20);
  iHsp2.shadowSize = new GSize(22, 20);
  iHsp2.iconAnchor = new GPoint(6, 20);
  iHsp2.infoWindowAnchor = new GPoint(5, 1);
  iHsp2.infoShadowAnchor = new GPoint(12, 13);

  var iBlu = new GIcon();
  iBlu.image = "/images/mm_20_blue.png";
  iBlu.shadow = "/images/mm_20_shadow.png";
  iBlu.iconSize = new GSize(12, 20);
  iBlu.shadowSize = new GSize(22, 20);
  iBlu.iconAnchor = new GPoint(6, 20);
  iBlu.infoWindowAnchor = new GPoint(5, 1);

  var iconWaypoint = new GIcon();
  iconWaypoint.image = "./images/trip-marker.png";
  //	icon.shadow = "./images/waypoint_shadow.png";
  iconWaypoint.iconSize = new GSize(37, 32);
  //	icon.shadowSize = new GSize(37, 32);
  iconWaypoint.iconAnchor = new GPoint(18, 16);
  iconWaypoint.infoWindowAnchor = new GPoint(18, 1);

  var iconSighting = new GIcon();
  iconSighting.image = "./images/favicon.png";
  iconSighting.iconSize = new GSize(16, 16);
  iconSighting.iconAnchor = new GPoint(8, 8);
  iconSighting.infoWindowAnchor = new GPoint(8, 8);

}