﻿function objStore(code, name, location, address, unit, city, sprovincecode, postal, phone, lat, longit)
{
	this.code = code;
	this.name = name;
	this.location = location;
	this.address = address;
	this.unit = unit;
	this.city = city;
	this.sprovincecode = sprovincecode;
	this.postal = postal;
	this.phone = phone;
	this.lat = lat;
	this.longit = longit;
}

var province = new Array();
province["AB"] = "Alberta";
province["MB"] = "Manitoba";
province["NB"] = "New Brunswick";
province["NL"] = "Newfoundland";
province["NS"] = "Nova Scotia";
province["ON"] = "Ontario";

var as = new Array();
as[as.length] = new objStore("CA001","OnX","Thornhill, ON (Head Office)","155 Commerce Valley Drive E.","","Thornhill","ON","L3T 7T2","(905) 482-2292",43.842265,-79.374504);
as[as.length] = new objStore("CA002","OnX","Ottawa, ON","150 Isabella Street","Suite 610","Ottawa","ON","K1S 1V7","(866) 906-4669",45.40973,-75.689025);
as[as.length] = new objStore("CA003","OnX","Ottawa, ON","300 March Road","Suite 203","Kanata","ON","K2K 2E2","(613) 287-3660",45.334709,-75.905923);
as[as.length] = new objStore("CA004","OnX","Cambridge, ON","231 Shearson Cres","Suite 104","Cambridge","ON","N1T 1J5","(905) 482-2292",43.398094,-80.297099);
as[as.length] = new objStore("CA005","OnX","Windsor, ON","1 Riverside Drive West","14th Floor","Windsor","ON","N9A 5K3","(905) 881-4414",42.319457,-83.041078);
as[as.length] = new objStore("CA006","OnX","London, ON","148 York Street","Suite 303,","London","ON","N6A 1A9","(866) 906-4669 ext. 7100",42.981233,-81.249309);
as[as.length] = new objStore("CA007","OnX","Calgary, AB","4000 4th St. S. E.","Suite 212,","Calgary","AB","T2G 2W3","(866) 906-4669",51.021845,-114.04879);
as[as.length] = new objStore("CA008","OnX","Edmonton, AB","10180 101 Street","Suite 1150, Manulife Place","Edmonton","AB","T5J 3S4","(866) 906-4669",53.54194,-113.494263);
as[as.length] = new objStore("CA009","OnX","Winnipeg, MB","CanWest Place, 201 Portage Ave","18th Floor","Winnipeg","MB","R3B 3K6","(204) 926-8570",49.895328,-97.139796);
as[as.length] = new objStore("CA010","OnX","Fredericton, NB","527 Dundonald St","Suite 224","Fredericton","NB","E3B 1X5","(800) 663-6699 ext. 7241",45.953681,-66.647198);
as[as.length] = new objStore("CA011","OnX","Halifax, NS","3045 Robie Street","Suite 23","Halifax","NS","B3K 4P6","(800) 663-6699 ext. 7522",44.659161,-63.601036);
as[as.length] = new objStore("CA012","OnX","Mount Pearl, NL","8 Centennial Square","PO Box 997","Mount Pearl","NL","A1N 1E0","(800) 647-6363 ext. 7962",47.518899,-52.805689);
as[as.length] = new objStore("CA013","OnX","Vancouver,BC","666 Burrard St","Suite 500","Vancouver","BC","V6C 3P6","",49.284973,-123.119106);

as[as.length] = new objStore("US001","OnX","Atlanta, GA","12600 Deerfield Parkway","Suite 100","Alpharetta","GA","30004","(678) 566-3665",34.089506,-84.270769);
as[as.length] = new objStore("US002","OnX","Dallas, TX","1431 Greenway Drive","Suite 800","Irving","TX","75038","(972) 870-4434",32.88957,-96.975417);
as[as.length] = new objStore("US003","OnX","Manhattan, NY","5 Penn Plaza","14th Floor","New York","NY","10001","(212) 631-4700",40.75179,-73.994321);
as[as.length] = new objStore("US004","OnX","Edison, NJ","204 Fernwood Avenue","","Edison","NJ","08837","(732) 417-1162",40.503749,-74.355297);
as[as.length] = new objStore("US005","OnX","Burlington, MA","20 Mall Road","Suite 425","Burlington","MA","01803","(781) 993-5100",42.490897,-71.196985);
as[as.length] = new objStore("US006","OnX","Chicago, IL","1001 Warrenville Road","Suite #200","Liste","IL","60532","(630) 743-2330",41.807869,-88.071771);
as[as.length] = new objStore("US007","OnX","Tampa, FL","3000 Bayport Drive","Suite #860","Tampa","FL","33607","(813) 864-3476",27.967114,-82.551983);
as[as.length] = new objStore("US008","OnX","Boulder, CO","1711 Pearl Street","Suite 300","Boulder","CO","80302","(303) 524-7215",40.019446,-105.27306);
as[as.length] = new objStore("US009","OnX","Irvine, CA","1642 Kaiser Avenue","","Irvine","CA","92614","(949) 752-5225",33.694638,-117.8509);
as[as.length] = new objStore("US010","OnX","Mayfield Heights, OH","5910 Landerbrook Drive","","Mayfield Heights","OH","44124","(440) 569-2300",41.50343,-81.466302);

as[as.length] = new objStore("UK001","OnX","Weybridge","Abbey Business Centre, FL 1 Wellington Way, Brooklands Bus","","Weybridge","Surrey","KT13 OTT","44 (0) 1932 268389",51.349076,-0.461424);


// Creates a marker at the given point with the given number label
function createMarker(point, content) {
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(content.toString());
  });
  return marker;
}

function listOffice(thecode) {
    var map = new GMap2(document.getElementById("map"));
    
	//map.addControl(new GLargeMapControl());
	map.setUIToDefault();
	
	var bounds =  new GLatLngBounds();

	for (i=0;i < as.length;i++) {
		if (as[i].code == thecode) {
			uni = "";
			if (as[i].unit != "") {
				uni = ',&nbsp;' + as[i].unit ;
			}
			mark = as[i].name + '<br />' + as[i].location + '<br />' + as[i].address  + uni + '<br />' + as[i].city + '&nbsp;' + as[i].sprovincecode + ',&nbsp;' + as[i].postal + '<br />' + as[i].phone;
			var point = new GLatLng(as[i].lat, as[i].longit);
			map.addOverlay(createMarker(point, mark));
			bounds.extend(point);
		}
	}
	
	map.addOverlay(createMarker(point, mark));
	bounds.extend(point);
	
	map.setCenter(bounds.getCenter());
	
	if (map.getBoundsZoomLevel(bounds) > 15) {
		zoom = 15;
	}
	else {
		zoom = map.getBoundsZoomLevel(bounds);
	}
	
	map.setZoom(zoom);
}

function loadGoogleMap(lat, lon, zoom, country) {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
		
		for (i=0;i < as.length;i++) {
		
			locationCode = as[i].code;
			
			if (locationCode.substr(0, 2) == country) {
				uni = "";
				if (as[i].unit != "") {
					uni = ',&nbsp;' + as[i].unit ;
				}
				mark = as[i].name + '<br />' + as[i].location + '<br />' + as[i].address  + uni + '<br />' + as[i].city + '&nbsp;' + as[i].sprovincecode + ',&nbsp;' + as[i].postal + '<br />' + as[i].phone;
				var point = new GLatLng(as[i].lat, as[i].longit);
				map.addOverlay(createMarker(point, mark));
			}
		}

        map.setCenter(new GLatLng(lat, lon), zoom);
        map.setUIToDefault();
    }
}
