/*
THE ONLY WAY YOUR EVENT LIST WILL GET UPDATED IS BY POINTING TO THIS URL
http://www.weaselsspfld.com/javascript/this_months_mc_events.js

Last Update : Sun, 15 Nov 2009 03:20:26 -0700

this javascript file gets updated by server side code.
don't just copy this file or you'll have outdated events.
point your script tag to the url above.

WFFW

Johnny T
*/
document.write("<script src=\"http://www.weaselsspfld.com/javascript/wms.js\" type=\"text/javascript\"></script>");

	var rallyMap;
	var rallyMapCenter = new GLatLng(38.8402805,-97.6114237);
	var rallyMapZoom = 5;
	var rallyMapRotateSpeed = 5000;
	var rallyMapRotateTimer = 0;
	var rallyMapDivID = "RallyMap";

	var rally_icon = new GIcon();
	rally_icon.image = "http://www.weaselsspfld.com/images/rally_mark.png";
	rally_icon.iconSize = new GSize(30, 23);
	rally_icon.iconAnchor = new GPoint(15, 12);
	rally_icon.infoWindowAnchor = new GPoint(20, 6);
	var rallyGMarkers = new Array();
	var rallies = new Array();
rallies[0]= {title:'Bama BikeFest Fall Rally',description:'OCT. 22-24-Bama BikeFest Fall Rally. Forkland. Info: 334-289-5213; www.bamabikefest.com',url:'http://www.bamabikefest.com',lat:'32.64800',long:'-87.88300'};
rallies[1]= {title:'American HeatMotorcycle Weekend',description:'OCT. TBA-American HeatMotorcycle Weekend. Palm Springs. Info: 800-200-4557; www.road-shows.com',url:'http://www.road-shows.com',lat:'33.8302961',long:'-116.5452921'};
rallies[2]= {title:'Walnecks SwapMeet',description:'OCT. 4-Walnecks SwapMeet. Dekalb County Fairgrounds, Sandwich. Info: 630-985-2097;www.walneckswap.com',url:'http://www.walneckswap.com',lat:'41.6458634',long:'-88.6217432'};
rallies[3]= {title:'Motorcycle SwapMeet',description:'OCT. 4-Motorcycle SwapMeet. Deltaplex, Grand Rapids. Info: 800-968-4242; www.motorcycleswap.com',url:'http://www.motorcycleswap.com',lat:'42.9633599',long:'-85.6680863'};
rallies[4]= {title:'Las Vegas BikeFest',description:'OCT. 1-4-Las Vegas BikeFest. Las Vegas. Info: 866-BIKEFEST; www.lasvegasbikefest.com',url:'http://www.lasvegasbikefest.com',lat:'36.1749705',long:'-115.137223'};
rallies[5]= {title:'WalnecksMotorcycle Swap Meet  and  Shows',description:'OCT. 11-WalnecksMotorcycle Swap Meet  and  Shows. Clark Co. Fairgrounds, Springfield. Info:630-985-2097; www.walneckswap.com',url:'http://www.walneckswap.com',lat:'39.9242266',long:'-83.8088172'};
rallies[6]= {title:'M/C SwapMeet',description:'OCT. 18-M/C SwapMeet. State Fair Park, Oklahoma City. Info: 816-456-4415;www.jwswapmeet.com',url:'http://www.jwswapmeet.com',lat:'35.4675602',long:'-97.5164276'};
rallies[7]= {title:'yrtle BeachFall Bike Rally',description:'OCT. TBA-Myrtle BeachFall Bike Rally. Myrtle Beach. Info: www.myrtlebeachbikeweek.com',url:'http://www.myrtlebeachbikeweek.com',lat:'33.6890603',long:'-78.8866943'};
rallies[8]= {title:'DeadmansCurve Rally',description:'OCT. 2-4-DeadmansCurve Rally. Pulaski. Info: 931-363-2411, 931-478-0076;www.deadmanscurverally.com',url:'http://www.deadmanscurverally.com',lat:'35.1998023',long:'-87.0308412'};
rallies[9]= {title:'16th AnnualSouth Padre Island BikeFest',description:'OCT. TBA-16th AnnualSouth Padre Island BikeFest. Mc Allen. Info: 956-668-7484; www.spibikefest.com',url:'http://www.spibikefest.com',lat:'26.2034071',long:'-98.2300124'};
	function rallyMapInitializeMap() {
		rallyMap = new GMap(document.getElementById( rallyMapDivID ));
		rallyMap.setCenter( rallyMapCenter, rallyMapZoom );
		rallyMap.enableDoubleClickZoom();
		rallyMap.enableContinuousZoom();
		//rallyMap.addControl(new GSmallMapControl());
		rallyMap.addControl(new GLargeMapControl());
		rallyMap.addControl(new GMapTypeControl());
		rallyMap.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(150,10))) ;
		rallyMap.addControl(new GOverviewMapControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10)));
        	rallyMap.addMapType(G_PHYSICAL_MAP);
		// a little extra from wms.js
        	rallyMap.addMapType(us_topo());
        	rallyMap.addMapType(us_nexrad());
	}

	function loadRallyMap() {
		rallyMapInitializeMap();
		for (var i in rallies) {
			rallyMap.addOverlay( createRallyMarker( i ) );
		}

		// start cycling through rally info windows
		// clicking on a icon will stop the cycleing
		changeRallyMarker();
	}

	// Creates a marker at the given point with the given number label
	function createRallyMarker( index ) {
		var rally = rallies[index];
		var marker = new GMarker( new GLatLng(rally.lat, rally.long), rally_icon );
		GEvent.addListener(marker, "mouseover", function() {
			var r = rallies[index];
			var iwHtml = "<div style='width:300px;'>";
			if( r.url.indexOf("http://www.weaselsspfld.com/") < 0 ) {
				iwHtml += "<img src='http://open.thumbshots.org/image.aspx?url="+r.url+"' style='float:left;width:120px;height:90px;margin:2px;'>";
			}
			iwHtml += "<a href='"+r.url+"' style='font-weight:bold;color:black;' target='_blank'>"+r.title+"</a>";
			iwHtml += "<p>"+r.description+"</p>";
			iwHtml += "</div>";
			marker.openInfoWindowHtml(iwHtml);
		});
		GEvent.addListener(marker, "click", function() {
			clearTimeout(rallyMapRotateTimer);
			rallyMapRotateTimer = setTimeout( "changeRallyMarker();", rallyMapRotateSpeed*4 );
		});

		rallies[index].marker = marker;
		return marker;
	}

	function changeRallyMarker() {
		var index = Math.floor(Math.random()*rallies.length)
		if( index == null )
			index = 0;
		var marker = rallies[index].marker;
		GEvent.trigger(marker,"mouseover");
		rallyMapRotateTimer = setTimeout( "changeRallyMarker();", rallyMapRotateSpeed );
	}

	/* disable javascript errors */
	//function noError(){return true;} 
	//window.onerror = noError;
