var map;
var geocoder;
var icon;
var counter = 0; 
var stores= [ { 
		stor: "Concord", street: "5296 Concord Blvd", city: "Concord, CA", zip: " 94521", phone: "(925)-825-5100",
		view: "concord", res: "concord", lat: 37.957141, lng: -121.952257
	}, {
		stor: "Oakland", street: "301 High St.", city: "Oakland, CA", zip: " 94601", phone: "(510) 351-3651",
		view: "oakland", res: "oakland", lat: 37.765109, lng: -122.224399
	}, {
		stor: "Belmont", street: "1337 Old County Rd", city: "Belmont, CA", zip: " 94002", phone: "* Coming Late 2007 *",
		view: "belmont", res: "belmont", lat: 37.518394, lng: -122.272159, hasNoImg: true
	}, {
		stor: "South San Jose", street: "131 Baroni Ave", city: "San Jose, CA", zip: " 95136", phone: "(510) 351-3651",
		view: "san-jose-baroni", res: "san-jose-4", lat: 37.275571, lng: -121.841135, use2ndImg: true
	}, {
		stor: "San Jose - Campbell", street: "3260 S Bascon Ave", city: "San Jose, CA", zip: " 95124", phone: "(408) 371-9111",
		view: "san-jose-bascom", res: "san-jose", lat: 37.26454, lng: -121.942453
	}, {
		stor: "South San Jose", street: "2900 Monterey Rd ", city: "San Jose, CA", zip: " 95111", phone: "(408) 229-2900",
		view: "san-jose-monterey", res: "san-jose-3", lat: 37.291121, lng: -121.848699
	}, {
		stor: "North San Jose", street: "1415 Old Oakland Rd", city: "San Jose, CA", zip: " 95112", phone: "(408) 293-3700",
		view: "san-jose-oldoakland", res: "san-jose-2", lat: 37.373351, lng: -121.894134
	}, {
		stor: "Anaheim", street: "3535 W. Ball Rd", city: "Anaheim, CA", zip: " 92804", phone: "(714) 220-2277",
		view: "anaheim", res: "anaheim", lat: 33.817235, lng: -118.011382
	}, {
		stor: "Cypress", street: "5081 Lincoln Ave", city: "Cypress, CA", zip: " 90630", phone: "(714) 826-6663",
		view: "cypress", res: "cypress", lat: 33.831772, lng: -118.044147
	}, {
		stor: "El Monte", street: "12260 Garvey Ave", city: "El Monte, CA", zip: " 91732", phone: "(626) 401-0300",
		view: "el-monte", res: "el-monte", lat: 34.063512, lng: -118.01245
	}, {
		stor: "Fullerton", street: "1415 W Commonwealth Ave", city: "Fullerton, CA", zip: " 92833", phone: "(714) 870-5111",
		view: "fullerton", res: "fullerton", lat: 33.870299, lng: -117.946441
	}, {
		stor: "Glendale", street: "4427 San Fernando Rd", city: "Glendale, CA", zip: " 91204", phone: "(818) 247-1444",
		view: "glendale", res: "glendale", lat: 34.132324, lng: -118.261886
	}, {
		stor: "Huntington Beach", street: "17292 Gothard St", city: "Huntington Beach, CA", zip: " 92647", phone: "(714) 596-2230",
		view: "huntington-beach", res: "huntington-beach", lat: 33.711461, lng: -118.000039
	}, {
		stor: "La Habra", street: "420 E Lambert Rd", city: "La Habra, CA", zip: " 90631", phone: "(562) 697-0477",
		view: "la-habra", res: "la-habra", lat: 33.924552, lng: -117.934176
	}, {
		stor: "North Hollywood", street: "5310 Vineland Ave", city: "N. Hollywood, CA", zip: " 91601", phone: "(818) 505-9800",
		view: "north-hollywood", res: "north-hollywood", lat: 34.16731, lng: -118.3703
	}, {
		stor: "Paramount", street: "14908 Downey Ave", city: "Paramount, CA", zip: " 90723", phone: "(562) 272-2727",
		view: "paramount", res: "paramount", lat: 33.898131, lng: -118.151393
	}, {
		stor: "Santa Ana", street: "255 S Main St", city: "Santa Ana, CA", zip: " 92707", phone: "(714) 435-0111",
		view: "santa-ana", res: "santa-ana", lat: 33.734538, lng: -117.867643
	}, {
		stor: "Torrance", street: "20704 Earl St", city: "Torrance, CA", zip: " 90503", phone: "(310) 921-2333",
		view: "torrance", res: "torrance", lat: 33.842523, lng: -118.358068
	}, {
		stor: "Chula Vista", street: "810 Lazo Ct", city: "Chula Vista, CA", zip: " 91910", phone: "(619) 656-6600",
		view: "chula-vista", res: "chula-vista", lat: 32.637853, lng: -117.027047
	}, {
		stor: "Downtown/Little Italy", street: "2235 Pacific Hwy", city: "San Diego, CA", zip: " 92101", phone: "* Coming Spring 2008 *",
		view: "downtown", res: "downtown", lat: 32.726865, lng: -117.172457, hasNoImg: true
	}, {
		stor: "El Cajon", street: "1370 N. Magnolia", city: "El Cajon, CA", zip: " 92020", phone: "(310) 921-2333",
		view: "el-cajon-magnolia", res: "el-cajon", lat: 32.813727, lng: -116.962291
	}, {
		stor: "El Cajon", street: "556 W. Main St", city: "El Cajon, CA", zip: " 92020", phone: "(619) 442-5003",
		view: "el-cajon-main", res: "el-cajon", lat: 32.794931, lng: -116.96705
	}, {
		stor: "Fashion Valley", street: "1502 Frazee Rd", city: "San Diego, CA", zip: " 92108", phone: "(619) 296-5200",
		view: "fashion-valley", res: "fashion-valley", lat: 32.773027, lng: -117.157946
	}, {
		stor: "Hotel Circle", street: "2245 Hotel Circle South", city: "San Diego, CA", zip: " 92108", phone: "(619) 295-5255",
		view: "hotelcircle", res: "hotelcircle", lat: 32.758932, lng: -117.17611
	}, {
		stor: "Kearny Mesa", street: "5654 Copley Dr", city: "San Diego, CA", zip: " 92111", phone: "(858) 560-5660",
		view: "kearny-mesa", res: "kearny-mesa", lat: 32.839845, lng: -117.166515
	}, {
		stor: "La Mesa", street: "8328 Center Dr", city: "La Mesa, CA", zip: " 91942", phone: "(619) 464-3009",
		view: "la-mesa-center", res: "la-mesa", lat: 32.773816, lng: -117.022617
	}, {
		stor: "La Mesa", street: "4981 Spring St", city: "La Mesa, CA", zip: " 91941", phone: "(619) 469-4900",
		view: "la-mesa-spring", res: "la-mesa-2", lat: 32.769041, lng: -117.022617, use2ndImg: true
	}, {
		stor: "Lakeside", street: "9893 Riverford Rd", city: "Lakeside, CA", zip: " 92040", phone: "(619) 449-0800",
		view: "lakeside", res: "lakeside", lat: 32.855737, lng: -116.947344
	}, {
		stor: "Midtown", street: "3911 Pacific Highway", city: "San Diego, CA", zip: " 92110", phone: "(619) 297-9707",
		view: "midtown", res: "midtown", lat: 32.747289, lng: -117.197727
	}, {
		stor: "Mission Valley", street: "4680 Alvarado Canyon Rd", city: "San Diego, CA", zip: " 92120", phone: "(619) 281-2400",
		view: "mission-valley", res: "mission-valley", lat: 32.780756, lng: -117.093015
	}, {
		stor: "Morena - Bay Park", street: "1190-B W. Morena Blvd", city: "San Diego, CA", zip: " 92110", phone: "(619) 276-6777",
		view: "morena-bay-park", res: "morena-bay-park", lat: 32.768762, lng: -117.202243
	}, {
		stor: "Oceanside", street: "3040 Oceanside Blvd", city: "San Oceanside, CA", zip: " 92054", phone: "(760) 722-2559",
		view: "oceanside-el-camino", res: "oceanside-2", lat: 33.201699, lng: -117.335514
	}, {
		stor: "Oceanside", street: "1783 S. Oceanside Blvd", city: "San Oceanside, CA", zip: " 92054", phone: "(760) 439-2000",
		view: "oceanside-oceanside", res: "oceanside 1", lat: 33.191523, lng: -117.359095
	}, {
		stor: "Vista", street: "130 Nettleton Rd", city: "Vista, CA", zip: " 92083", phone: "(760) 758-0202",
		view: "vista", res: "vista", lat: 33.189903, lng: -117.281464
	}
];

function load(where) {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.enableDoubleClickZoom();
	if(where == 'norcal') { map.setCenter(new GLatLng(37.6650, -122.2200), 9); }//y, x, zoom
	if(where == 'socal') { map.setCenter(new GLatLng(33.9300, -118.1550), 10); }
	if(where == 'sandiego') { map.setCenter(new GLatLng(32.9370, -117.2100), 10); }
	geocoder = new GClientGeocoder();
	
	baseIcon = new GIcon();
	//icon.image = "../images/content/locations/a1-icon.png";
	baseIcon.iconSize = new GSize(31, 30);
	baseIcon.shadowSize = new GSize(55, 32);
	for(var i=0; i < stores.length; i++) {
		map.addOverlay(createMarker(i));
	}
  }
}

function createMarker(i) {

	var point = new GLatLng(stores[i].lat, stores[i].lng);
	var icon = new GIcon(baseIcon);
	if(stores[i].use2ndImg == true) { 
		icon.image = "../images/content/locations/a1-icon2.png";
		icon.iconAnchor = new GPoint(0, 30);
		icon.shadow = "../images/content/locations/a1-shadow2.png";
	}
	else { 
		icon.image = "../images/content/locations/a1-icon.png";
		icon.iconAnchor = new GPoint(16, 30);
		icon.shadow = "../images/content/locations/a1-shadow.png";
	}
	icon.infoWindowAnchor = icon.iconAnchor;
	var marker = new GMarker(point, icon);
	var info = '<table><tr valign="top"><td>';
	if(stores[i].hasNoImg != true) { 
		info += '<img src="../images/content/locations/map-thms/'+stores[i].view+'.jpg" width="130" height="100" /></td><td>';
	}
	info += '<b>'+stores[i].stor+'</b><br />'+stores[i].street+'<br />'+stores[i].city + stores[i].zip+'<br />'+stores[i].phone+'<br /><br />Office Hours:<br />9 am - 6 pm Mon - Fri<br />9 am - 5 pm Sat - Sun<br /><br /><a href="http://www.a1storage.com/locations/'+stores[i].view+'-storage-unit.html">View Location</a><br /><a href="http://www.a1storage.com/app/index.php?fa=reservations.units&amp;location_id='+stores[i].res+'&amp;lan=en">Reserve Space</a></td></tr></table>';
	GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(info); });
	return marker;
}