﻿/// <reference path="jquery.intellisense.js"/>
/// <reference path="GMAPJSHelper_Release.js"/>

	// global variables to hold the mouse coords at any given time (used for custom context menus)
	var xCoord;
	var yCoord;
	
	// builds a new custom icon
	var 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.printShadow = "Images/dithshadow.gif";
	baseIcon.infoWindowAnchor = new GPoint(9, 2);
	baseIcon.infoShadowAnchor = new GPoint(18, 25);

	// assigns a bool to whether the browser is firefox
	var firefox=document.getElementById&&!document.all;

	// assigns the mouse coords to the global xCoord and yCoord varibales 
	document.onmousemove = mouseMove;

	// captures the mouse x and y coords for storage in the global xCoord and yCoord variables
	function mouseMove(e){

		if (firefox)
		{
			xCoord = e.clientX;
			yCoord = e.clientY;
		}
		else
		{
			xCoord = event.clientX;
			yCoord = event.clientY;
		}
	}
	
	function toggleVisibility(targetId,control)
	{
		var e = document.getElementById(targetId);
		if(e.style.display == 'none') {
			e.style.display = 'block';
			control.style.fontWeight = 'bold';
		}
		else {
			e.style.display = 'none';
			control.style.fontWeight = 'normal';
		}
	}

	// javascript function for a global replace in a given string
	function xreplace(checkMe,toberep,repwith){ 
		var temp = checkMe; 
		var i = temp.indexOf(toberep); 
		while(i > -1){ 
			temp = temp.replace(toberep, repwith); 
			i = temp.indexOf(toberep); 
		} 
		return temp; 
	}
	
	var i=1;

	// Creates a marker whose info window displays the letter corresponding
	// to the given index.
	function createMarker(point) {
		// Create a numbered icon for this point using our icon class
		var icon = new GIcon(baseIcon);
		icon.image = "Images/green" + i + ".png";
		icon.printImage = "Images/green" + i + ".gif";
		icon.mozPrintImage = "Images/green" + i + ".gif";
		var marker = new GMarker(point, icon);
		i++;
		return marker;
	}

	var geoxml;
	var kmlMap;

	var geoCallback = function() {
		kmlmap.setCenter(geoxml.getDefaultCenter());
		geoxml.gotoDefaultViewport(kmlmap);
	}

	function loadCategoryMap(url, center) {
		kmlmap = new GMap2(document.getElementById('categoryMap'));
		kmlmap.setCenter(center, 14);
		kmlmap.addControl(new GLargeMapControl3D());
		kmlmap.enableScrollWheelZoom();
		geoxml = new GGeoXml(url, geoCallback);
		kmlmap.addOverlay(geoxml);
	}

