
window.onload=load;
window.onunload=GUnload;

    function load() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map-canvas"), { size: new GSize(800,600)} );
			map.setUIToDefault();
			map.setCenter(new GLatLng(51.850000, 0.825520), 10);

			markers(document.forms['mainMenu']);
	      }
	    }

	    function createMarker(point, description, division) {
	      var baseIcon = new GIcon(G_DEFAULT_ICON);
	      var numberIcon = new GIcon(baseIcon);
	      numberIcon.image = "http://www.cavaliers-cc.org.uk/images/marker" + division + ".png";
	      markerOptions = { icon:numberIcon };
	      var marker = new GMarker(point, markerOptions);
	      // GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(description);});
	      return marker;
	    }
	    
	function markers(myForm) {
		map.clearOverlays();
		var html;

		if (myForm.elements['div5'].checked) {
			var clubs = new Array;
			var markers = new Array;

			clubs.push("51.892216, 0.410973,Stebbing CC,#");
			clubs.push("51.921000, 0.911000,Cavaliers CC,http://www.cavaliers-cc.org.uk");
			clubs.push("51.895350, 0.903450,Colchester and East Essex CC,http://www.colchestercricket.org/");
			clubs.push("51.798225,1.072969,St. Osyth CC,http://www.stosythcc.com/");
			clubs.push("51.77813, 0.677826,Wickham Bishops CC,http://www.wickhambishops.play-cricket.com/");
			clubs.push("51.859532,0.578799,Cressing CC,http://www.cressingcc.9k.com/");
			clubs.push("51.854098, 1.064065,Great Bentley CC,http://www.gbcc.play-cricket.com");

			for (var i = 0; i < clubs.length; i++) {
				var description = clubs[i].split(",");
				
				var point = new GLatLng(description[0], description[1]);
				markers[i] = createMarker(point, description[3], "5");
				map.addOverlay(markers[i]);
				html = "<p>" + description[2] + "</p><p><a href='" + description[3] + "'>" + description[3] + "</a></p>";
				markers[i].bindInfoWindowHtml(html, {maxWidth: 300});
			}
		}
		if (myForm.elements['div4'].checked) {
			var clubs = new Array;
			var markers = new Array;

			clubs.push("51.740736,0.496171,Springfield CC,http://www.springfieldcricketclub.co.uk/");
			clubs.push("51.884922,0.995851,Elmstead Grasshoppers CC,http://elmstead.play-cricket.com/");
			clubs.push("51.704474,0.465819,North Springfield Wanderers CC,http://nswcc.co.uk/");
			clubs.push("51.943826, 0.758708,Chappel and Wakes Colne CC,http://www.cwccc.co.uk/Home/");
			clubs.push("51.850995, 1.224854,Kirby CC,#");
			clubs.push("51.949516,0.810885,Wormingford CC,http://www.spanglefish.com/wormingfordcc/");
			clubs.push("51.901000, 0.825520,Eight Ash Green CC,http://www.eagcc.com/");
			clubs.push("51.834210, 0.918000,Abberton CC,http://adcc.moonfruit.com");
			clubs.push("51.868125,0.808879,Copford CC,http://www.copfordcc.org.uk/");
			clubs.push("51.916278, 0.885436,Real Oddies CC,http://www.realoddies.co.uk/");

			for (var i = 0; i < clubs.length; i++) {
				var description = clubs[i].split(",");
				
				var point = new GLatLng(description[0], description[1]);
				markers[i] = createMarker(point, description[3], "4");
				map.addOverlay(markers[i]);
				html = "<p>" + description[2] + "</p><p><a href='" + description[3] + "'>" + description[3] + "</a></p>";
				markers[i].bindInfoWindowHtml(html, {maxWidth: 300});
			}
		}
		if (myForm.elements['div3'].checked) {
			var clubs = new Array;
			var markers = new Array;

			clubs.push("51.793000,0.696000,Great Braxted and Tiptree CC,");
			clubs.push("51.685744,0.656111,Purleigh CC,#");
			clubs.push("51.953946,0.871117,Great Horkesley CC,http://www.gthorkesleycc.co.uk/");
			clubs.push("51.867282,1.123835,Tendring CC,http://www.freewebs.com/tendringcc");
			clubs.push("51.834210,0.918000,Abberton CC,http://adcc.moonfruit.com");
			clubs.push("51.881723,0.550636,Braintree College,#");
			clubs.push("51.953523,0.918646,Boxted CC,http://www.boxtedcricketclub.moonfruit.com");
			clubs.push("51.798517,1.161675,Little Clacton CC,#");
			clubs.push("51.895973,0.869299,Lexden CC,http://www.lexdencc.co.uk/");
			clubs.push("51.784641,0.922412,West Mersea CC,http://www.westmerseacc.co.uk/");
			clubs.push("51.809252,0.353601,High Easter CC,http://www.high-easter.netfirms.com/");

			for (var i = 0; i < clubs.length; i++) {
				var description = clubs[i].split(",");
				
				var point = new GLatLng(description[0], description[1]);
				markers[i] = createMarker(point, description[3], "3");
				map.addOverlay(markers[i]);
				html = "<p>" + description[2] + "</p><p><a href='" + description[3] + "'>" + description[3] + "</a></p>";
				markers[i].bindInfoWindowHtml(html, {maxWidth: 300});
			}
		}
		if (myForm.elements['div2'].checked) {
			var clubs = new Array;
			var markers = new Array;
			
			clubs.push("51.95027, 0.412588,Little Bardfield Village CC,http://www.lbvcc.org.uk");
			clubs.push("51.921000, 0.911000,Cavaliers CC,http://www.cavaliers-cc.org.uk");
			clubs.push("51.774924, 0.692691,Great Totham CC,http://www.greattotham.play-cricket.com");
			clubs.push("51.854098, 1.064065,Great Bentley CC,http://www.gbcc.play-cricket.com");
			clubs.push("51.796686, 1.176964,Clacton Ramblers CC,http://crcc.quizathon.com");
			clubs.push("51.928498, 0.692000,Earls Colne & Bures CC,http://www.burescricketclub.co.uk");
			clubs.push("51.732000, 0.576650,Little Baddow CC,http://www.ltbaddowcc.hitscricket.co.uk/");
			clubs.push("51.895350, 0.903450,Colchester & East Essex CC,http://www.colchestercricket.org");
			clubs.push("51.953523, 0.918646,Boxted CC,http://www.boxtedcricketclub.moonfruit.com");
			clubs.push("51.917485,0.854573,West Bergholt,http://www.westbergholtcc.co.uk/");
			clubs.push("51.936923, 0.589474,Gosfield CC,http://www.gosfieldcc.piczo.com/");

			for (var i = 0; i < clubs.length; i++) {
				var description = clubs[i].split(",");
				
				var point = new GLatLng(description[0], description[1]);
				markers[i] = createMarker(point, description[3], "2");
				map.addOverlay(markers[i]);
				html = "<p>" + description[2] + "</p><p><a href='" + description[3] + "'>" + description[3] + "</a></p>";
				markers[i].bindInfoWindowHtml(html, {maxWidth: 300});
			}
		}
		if (myForm.elements['div1'].checked) {
			var clubs = new Array;
			var markers = new Array;

			clubs.push("51.84643,0.711998,Kelvedon CC,http://www.kelvedonandfeeringcc.co.uk/");
			clubs.push("51.834210, 0.918000,Abberton CC,http://adcc.moonfruit.com");
			clubs.push("51.798225,1.072969,St. Osyth CC,http://www.stosythcc.com/");
			clubs.push("51.784641,0.922412,West Mersea CC,http://www.westmerseacc.co.uk/");
			clubs.push("51.901000, 0.825520,Eight Ash Green CC,http://www.eagcc.com/");
			clubs.push("51.887213,1.029582,Great Bromley CC,http://greatbromley.cricketclubwebsite.co.uk/");
			clubs.push("51.954065, 0.649846,Halstead CC,http://www.halsteadcricket.com/");
			clubs.push("51.943826, 0.758708,Chappel and Wakes Colne CC,http://www.cwccc.co.uk/Home/");
			clubs.push("51.903000, 0.557000,Bocking CC,http://www.www.bocking.play-cricket.com");
			clubs.push("51.922243, 0.984778,Ardleigh CC,http://www.ardleighcricketclub.co.uk");
			clubs.push("51.704474,0.465819,Galleywood CC,http://www.galleywoodcc.play-cricket.com/");

			for (var i = 0; i < clubs.length; i++) {
				var description = clubs[i].split(",");
				
				var point = new GLatLng(description[0], description[1]);
				markers[i] = createMarker(point, description[3], "1");
				map.addOverlay(markers[i]);
				html = "<p>" + description[2] + "</p><p><a href='" + description[3] + "'>" + description[3] + "</a></p>";
				markers[i].bindInfoWindowHtml(html, {maxWidth: 300});
			}
		}
			
	    // possibly drop all the teams into an array of "markers", then show / hide them as appropriate?
    }

