
var MAX_MAP_SERVERS = 20;

var map = null;

function MapSite() {

	this.base = "";
	this.mapsource = 0;
	
}


var MapSites = new Array();

for (var i = 0; i < MAX_MAP_SERVERS; i++) {
	MapSites[i] = new MapSite();
}

MapSites[0].base = "webmap";
MapSites[0].mapsource = 0;

MapSites[1].base = "cityweb";
MapSites[1].mapsource = 1;

MapSites[2].base = "cldt";
MapSites[2].mapsource = 2;

MapSites[3].base = "127";
MapSites[3].mapsource = 3;

MapSites[4].base = "colwebworkshop";
MapSites[4].mapsource = 0;

MapSites[5].base = "intramap";
MapSites[5].mapsource = 1;

MapSites[6].base = "localhost";
MapSites[6].mapsource = 1;

MapSites[7].base = "clintradev";
MapSites[7].mapsource = 1;

MapSites[8].base = "H0440";
MapSites[8].mapsource = 1;

MapSites[9].base = "lpsintrawrkshp";
MapSites[9].mapsource = 1;

MapSites[10].base = "lpsweb";
MapSites[10].mapsource = 1;

MapSites[11].base = "j1373";
MapSites[11].mapsource = 1;

MapSites[12].base = "m0434";
MapSites[12].mapsource = 1;

MapSites[13].base = "j1393";
MapSites[13].mapsource = 5;

MapSites[14].base = "clnt_tmca";
MapSites[14].mapsource = 5;

MapSites[15].base = "j1389";
MapSites[15].mapsource = 6;

MapSites[16].base = "clintradev.col";
MapSites[16].mapsource = 1;

MapSites[17].base = "cityconnect";
MapSites[17].mapsource = 1;

MapSites[18].base = "V1416";
MapSites[18].mapsource = 10;

MapSites[19].base = "V1418";
MapSites[19].mapsource = 11;

var baseURL = "http://webmap.london.ca/mapclient/";
var baseScript = "http://webmap.london.ca/MapServer/default.aspx";

var winURL = new String();	
winURL = window.location.href;

winURL = winURL.toLowerCase();

pos = winURL.indexOf("/", 7);
strFrag = winURL.slice(7,pos);

pos = strFrag.indexOf(".", 0);

if (pos > -1) {
	strFrag = strFrag.slice(0,pos);
}


for (i = 0; i < MapSites.length; i++) {

	if (strFrag == MapSites[i].base) {
	
		switch(MapSites[i].mapsource) {
		
			case 0:
				baseURL = "http://webmap.london.ca/mapclient/";
				baseScript = "http://webmap.london.ca/MapServer/default.aspx";
				break;
			
			case 1:
				baseURL = "http://intramap.city.london.on.ca/mapclient/";
				baseScript = "http://intramap.city.london.on.ca/mapclient/mapbroker.asp";
				break;
				
			case 2:
				baseURL = "http://cldt/mapclient/";
				baseScript = "http://cldt/mapclient/mapbroker.asp";
				break;
				
			case 3:
				baseURL = "http://127.0.0.1/mapclient/";
				baseScript = "http://127.0.0.1/mapclient/mapbroker.asp";
				break;
			
			case 4:
				baseURL = "http://J0051/mapclient/";
				baseScript = "http://J0051/mapclient/mapbroker.asp";
				break;

			case 5:
				baseURL = "http://J1393/mapclient/";
				baseScript = "http://J1393/mapclient/mapbroker.asp";
				break;				

			case 6:
				baseURL = "http://J1389/mapclient/";
				baseScript = "http://J1389/mapclient/mapbroker.asp";
				break;	
				
			case 10:
				baseURL = "http://V1416/mapclient/";
				baseScript = "http://V1416/mapclient/mapbroker.asp";
				
				
				if (bMapService) {
					baseScript = "http://V1416/MapServer/default.aspx";
				}
				
				break;
				
			case 11:
				baseURL = "http://V1418/mapclient/";
				baseScript = "http://V1418/mapclient/mapbroker.asp";
				
				
				if (bMapService) {
					baseScript = "http://V1418/MapServer/default.aspx";
				}
				
				break;							
				
			default:
				var baseURL = "http://webmap.london.ca/mapclient/";
				var baseScript = "http://webmap.london.ca/MapServer/default.aspx";
				break;
		}
		break;	
	}
}


function OpenMapWindow(tmpLocation, zoomLev, tmpLabel, tmpApp) {

	var mapLocation = new String('');
	var mapLabel = new String('');

	mapLocation = tmpLocation.replace(' ', '%20');
	mapLabel = tmpLabel.replace(' ', '%20');
	mapApp = tmpApp.replace(' ', '%20');
	
	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
	if (mapApp == 'GAMES_F') {
		newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&O='+mapApp+'&U=1&L3='+mapLocation+'&Z2='+zoomLev+'&LABEL3='+mapLabel+'&K2=1&K5='+mapApp;
	} else {
		newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&O='+mapApp+'&U=1&L3='+mapLocation+'&Z2='+zoomLev+'&LABEL3='+mapLabel+'&K5='+mapApp;	
	}
}

function ShowMap(tmpAddress) {

	var address = new String('');
	
	address = tmpAddress.replace(' ', '%20');

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
	newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&U=1&L3=29-'+address+'&Z2=5&O=SubjectSites&K5=SubjectSites';

}

function ShowSite(site) {

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
	newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&U=1&L3=78-'+site+'&Z2=8&O=SubjectSites&K5=SubjectSites';

}

function ShowRealtyLand(vland,tmplabel) {

	var vlabel = new String('');

   vlabel = tmplabel.replace(' ', '%20');

 	vlabel = vlabel.replace('"','');

   newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
   newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&O=Realty&K5=Realty&U=1&L3=83-'+vland+'&Z2=5&LABEL3='+vlabel;

}

function ShowRealtyBuilding(vbldg,tmplabel) {

	var vlabel = new String('');

	vlabel = tmplabel.replace(' ', '%20');

	vlabel = vlabel.replace('"','');

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
   newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&O=Realty&K5=Realty&U=1&L3=84-'+vbldg+'&Z2=6&LABEL3='+vlabel;

}

function ShowRealtyOffice(voff,tmplabel) {

	var vlabel = new String('');

	vlabel = tmplabel.replace(' ', '%20');

	vlabel = vlabel.replace('"','');

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
	newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&O=Realty&K5=Realty&U=1&L3=85-'+voff+'&Z2=6&LABEL3='+vlabel;

}

function ShowParkingLot(vlot,tmplabel) {

	var vlabel = new String('');

	vlabel = tmplabel.replace(' ', '%20');

	vlabel = vlabel.replace('"','');

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
	newWindow.location = baseScript + '?name=WebMap&M=9&K8=1&O=Parking&K5=Parking&U=1&L3=121-'+vlot+'&Z2=6&LABEL3='+vlabel;

}

function ShowMainstreetBuilding(vbldg,tmplabel) {

	var vlabel = new String('');

	vlabel = tmplabel.replace(' ', '%20');

	vlabel = vlabel.replace('"','');	

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
    newWindow.location = baseScript + '?name=j1393&M=9&K8=1&O=MainStreet_Info&K5=MainStreet_Info&U=1&L3=116-'+vbldg+'&Z2=6&LABEL3='+vlabel;

}

function ShowMainstreetTenant(vbldg,tmplabel) {

	var vlabel = new String('');

	vlabel = tmplabel.replace(' ', '%20');

	vlabel = vlabel.replace('"','');

	newWindow = window.open("","CityMap","width=600,height=420,left=0,top=0,screenX=0,screenY=0,outerWidth=600,outerHeight=420,resizable,menubar=yes");
	
    newWindow.location = baseScript + '?name=j1393&M=9&K8=1&O=MainStreet_Info&K5=MainStreet_Info&U=1&L3=117-'+vbldg+'&Z2=6&LABEL3='+vlabel;

}