function start(){
	getEl('locationsFrame').style.display = 'none';
	icon1 = new GIcon();
	size = new GSize(23, 18);
	icon1.image = "/_images/mapping/marker1.png";
	icon1.shadow = "/_images/mapping/marker1shadow.png";
	icon1.iconSize = size;
	icon1.shadowSize = size;
	icon1.iconAnchor = new GPoint(7, 12);
	icon1.infoWindowAnchor = new GPoint(5, 1);
	
	icon2 = new GIcon();
	icon2.image = "/_images/mapping/marker2.png";
	icon2.shadow = "/_images/mapping/marker1shadow.png";
	icon2.iconSize = size;
	icon2.shadowSize = size;
	icon2.iconAnchor = new GPoint(7, 12);
	icon2.infoWindowAnchor = new GPoint(5, 1);
	
	
	oSetup = {
		elMapElement:getEl('mapEl'),
		debug:0,
		elTrace:getEl('trace'),
		startingView:{
		latlng:new GLatLng(40.70562793820589 , -79.1839599609375),
		zoom:8},
		controls:Array(new GSmallMapControl()),
		icons:{type1:icon1,type2:icon2},
		
		elDirections:getEl('directionsTemplate')
	};
	mapS = new MapSystem(oSetup);
	initalSetup();
}

showSection = function(el){
	countys = getElementsByClass("county")
	frame = getEl('locationsFrame');
	for(i in countys ){
		countys[i].style.display = "none";
	}
	el.style.display = "block";
	frame.style.display = "block";
}

zoomIn = function(marker){
	if(mapS){
		mapS._oMap.setCenter(marker.getPoint(), 15);
	}
	window.scroll(0,400);
}

initalSetup = function(){
	mapS.clearMarkers();
	mapS._oMap.setCenter(mapS._oCurView.latlng, mapS._oCurView.zoom);
	getEl('locationsFrame').style.display = 'none';
	counties = {allegheny:
	{lat:40.453203,
	 lng:-79.9807555,
	 image:"/_images/mapping/allegheny.png",
	 action:function(){loadCounty('allegheny',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}},
	 armstrong:
	{lat:40.626532,
	 lng:-79.60577649999999,
	 image:"/_images/mapping/armstrong.png",
	 action:function(){loadCounty('armstrong',{zoom:'2'});getEl('locationsFrame').style.display = 'block';}},
	 beaver:
	{lat:40.676081,
	 lng:-80.31262,
	 image:"/_images/mapping/beaver.png",
	 action:function(){loadCounty('beaver',{zoom:'12'});getEl('locationsFrame').style.display = 'block';}},
	 beadford:
	{lat:40.090048499999995,
	 lng:-78.565697,
	 image:"/_images/mapping/bedford.png",
	 action:function(){loadCounty('bedford',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}},
	blair:
	{lat:40.44299654921498,
	 lng:-78.39326453857421,
	 image:"/_images/mapping/blair.png",
	 action:function(){loadCounty('blair');getEl('locationsFrame').style.display = 'block';}},
	butler:
	{lat:40.7774705,
	 lng:-79.87941649999999,
	 image:"/_images/mapping/butler.png",
	 action:function(){loadCounty('butler',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}},
	cambria:
	{lat:40.472076,
	 lng:-78.82121,
	 image:"/_images/mapping/cambria.png",
	 action:function(){loadCounty('cambria');getEl('locationsFrame').style.display = 'block';}},
	 clearfield:
	{lat:40.973493000000005,
	 lng:-78.5596365,
	 image:"/_images/mapping/clearfield.png",
	 action:function(){loadCounty('clearfield');getEl('locationsFrame').style.display = 'block';}},
	elk:
	{lat:41.34682,
	 lng:-78.5502065,
	 image:"/_images/mapping/elk.png",
	 action:function(){loadCounty('elk',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}},
	indiana:
	{lat:40.611994499999994,
	lng:-79.03403449999999,
	 image:"/_images/mapping/indiana.png",
	 action:function(){loadCounty('indiana',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}}, 
	jeferson:
	{lat:41.094781499999996,
	lng:-78.9346845,
	 image:"/_images/mapping/jefferson.png",
	 action:function(){loadCounty('jefferson');getEl('locationsFrame').style.display = 'block';}},
	lawrence:
	{lat:41.018292,
	lng:-80.417584,
	 image:"/_images/mapping/lawrence.png",
	 action:function(){loadCounty('lawrence',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}},
	somerset:
	{lat:40.1671165,
	lng:-78.94099,
	 image:"/_images/mapping/somerset.png",
	 action:function(){loadCounty('somerset',{zoom:'-1'});getEl('locationsFrame').style.display = 'block';}},
	washington:
	{lat:40.2800935,
	lng:-80.1851775,
	 image:"/_images/mapping/washington.png",
	 action:function(){loadCounty('washington');getEl('locationsFrame').style.display = 'block';}},
	westmoreland:
	{lat:40.4177635,
	lng:-79.46606650000001,
	 image:"/_images/mapping/westmoreland.png",
	 action:function(){loadCounty('westmoreland');getEl('locationsFrame').style.display = 'block';}}};
	initMarkerIcon = new GIcon();
	initMarkerIcon.shadow = "/_images/mapping/countymarkershadow.png";
	initMarkerIcon.iconSize = new GSize(103, 35);
	initMarkerIcon.iconAnchor = new GPoint(7, 17);
	
	for(i in counties){
		initMarkerIcon.image = counties[i].image;
		marker = new GMarker(new GLatLng(counties[i].lat,counties[i].lng), initMarkerIcon);
		GEvent.addListener(marker,'click',counties[i].action);
		mapS._oMap.addOverlay(marker);
	}
}

doClick = function(t){
	mapS.getPopUp(mapS.getMarker(t.parentNode.parentNode.parentNode.id),null,zoomIn);
}

loadCounty=function(county,znc){
	GDownloadUrl("ATMs-"+county+".html", function(data, responseCode) {
	  a = getEl('data');
	  a.innerHTML = "";
	  a.innerHTML = data;
	  mapS.clearMarkers(); 
	  oParams = {el:getEl(county),callback:showSection}
		if(znc != undefined){
			if(znc.zoom != undefined){
				oParams.zoom = znc.zoom
			}
			if(znc.center != undefined){
				oParams.center = znc.center
			}
		}
	  mapS.loadSetFromXML(oParams);
	});
}

if (window.addEventListener) window.addEventListener("load",start,false);
else if (window.attachEvent) window.attachEvent("onload",start);
