/********************************************************
*********************************************************

Bones in Motion - BiM Active Map Tool for Google
Copyright 2006 by Bones in Motion - All Rights Reserved
January 2006 - Spencer Nassar - spencer@bim-inc.com

gmaps_ui.js - ui controls/management

*********************************************************
********************************************************/

var selectColor = '#5ffff6';
var hoverColor = '#c0c0c0';
var normalColor = '#ffffff';

function getObjPos( objID )
{
	var obj = document.getElementById(objID);
	var curwidth = obj.offsetWidth;
	var curheight = obj.offsetHeight;
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop,curwidth,curheight];
}

// initialize icons for display purposes
function setupIcons()
{
	baseIcon = new GIcon();
	baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	baseIcon.iconSize = new GSize(20, 34);
	baseIcon.shadowSize = new GSize(37, 34);
	//baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.iconAnchor = new GPoint(11, 35);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	baseIcon.infoShadowAnchor = new GPoint(18, 25);
	startIcon = new GIcon(baseIcon);
	startIcon.image = "http://www.google.com/mapfiles/dd-start.png";
	endIcon = new GIcon(baseIcon);
	endIcon.image = "http://www.google.com/mapfiles/dd-end.png";
	pauseIcon = new GIcon(baseIcon);
	pauseIcon.image = "images/gicons/pause.png";

	/*
	dotbaseIcon = new GIcon();
	dotbaseIcon.iconSize = new GSize(12, 8);
	dotbaseIcon.iconAnchor = new GPoint(6, 6);
	dotbaseIcon.infoWindowAnchor = new GPoint(12, 3);
	dotbaseIcon.infoShadowAnchor = new GPoint(22, 13);
	dotmarkerIcon = new GIcon(dotbaseIcon);
	dotmarkerIcon.image = "http://" + document.domain + "/ba/race/images/david_dot.gif";
	*/

	dotbaseIcon = new GIcon();
	dotbaseIcon.iconSize = new GSize(18, 18);
	dotbaseIcon.iconAnchor = new GPoint(11, 11);
	dotbaseIcon.infoWindowAnchor = new GPoint(18, 11);
	dotbaseIcon.infoShadowAnchor = new GPoint(18, 21);
	/*
	dotbaseIcon.iconSize = new GSize(14, 14);
	dotbaseIcon.iconAnchor = new GPoint(7, 7);
	dotbaseIcon.infoWindowAnchor = new GPoint(14, 7);
	dotbaseIcon.infoShadowAnchor = new GPoint(14, 17);
	*/
	dotmarkerIcon = new GIcon(dotbaseIcon);
	dotmarkerIcon.image = "http://" + document.domain + "/ba/ui/images/livetrack_dot.gif";

	dotmarkerPulseIcon = new GIcon(dotbaseIcon);
	dotmarkerPulseIcon.image = "http://" + document.domain + "/ba/ui/images/livetrack_dotpulsing.gif";
}

// move map position at page draw based on php set params in shared_header.tpl
function adjustMapPosition()
{
	var theObj;
	var colALoc;
	var screenFactor = 0;

	// fires function from template header, writes php set values to blobals mapOffsetX and mapOffsetY
	getMapOffset();

	if ( doGMapDynamOffset == 1 )
	{
		colALoc = getObjPos('colA');
		screenFactor = colALoc[0];
	}

	// funky stuff - unable to read the value of left and top, but able to set it
	// if the css defs for these items change, they must be changed here too

	theObj = document.getElementById('map');
	//theObj.style.left = 13 + mapOffsetX + screenFactor + 'px';
	//theObj.style.top = 193 + mapOffsetY + 'px';
}
