//
//	buildings.js - shared javascript for image rollover pages
//	v1.0 Miller Hare 2002
//

//c is the building code
//n is the building name
//t is the tenant, use "*" for multiple tenants
//a is the architect
//s is the building size ('sq m (net)' will get added to the end of this entry
//g is the stage of constuction (0 - under design, 1 - Groudnwork Commenced, 2 - under construction, 3 - complete(not actually shown))
//
// for all the above, use "-" for 'none'

var c = new Array("ds1", "ds2", "ds3","ds4", "ds5", "ds6", "ds7", "ds8", "hq1", "hq2", "hq3", "hq4", "hq5", "fc1", "fc2", "fc3", "fc4", "fc5", "fc6", "b4", "b5", "bp1", "bp2", "bp3", "bp4", "wf3", "wf9", "wge", "wgw", "crsn", "cp", "cas", "cs", "wc", "jp", "mp", "chpl", "jpl","ds3e" );
var g = new Array(   3,     3,     2,    3,     3,     3,     3,     3,    3,     3,     3,     3,     3,     3,     3,     3,     3,      3,     3,    3,    3,    3,     2,     2,     1,     3,     3,     3,     3,     3,     3,     3,    3,    3,     3,     3,     2,     3,    2 );
var n = new Array("5 Canada Square", "8 Canada Square", "15 Canada Square", "20 Canada Square", "25 Canada Square", "33 Canada Square", "One Canada Square", "Canada Place", "20 Bank Street", "25 Bank Street", "40 Bank Street", "50 Bank Street", "10 Upper Bank Street", "1 Cabot Square", "10 Cabot Square & 5 North Colonnade", "25 North Colonnade", "20 Cabot Square & 10 South Colonnade", "25 Cabot Square", "30 South Colonnade", "17 Columbus Courtyard", "20 Columbus Courtyard", "One Churchill Place", "5 Churchill Place", "20 Churchill Place", "25 Churchill Place", "1, 7 & 11 Westferry Circus", "15 Westferry Circus", "East Wintergarden", "West Wintergarden", "Canary Riverside", "Cabot Place", "Canada Square", "Cabot Square", "Westferry Circus", "Jubilee Park", "Montgomery Square", "Churchill Place", "Reuters Plaza", "30 North Colonnade"); 
var t = new Array("Credit Suisse, Bank of America", "HSBC", "KPMG", "Multiple Tenants", "Citigroup", "Citigroup", "*", "Waitrose Food & Home, Reebok Sports Club, Plateau", "Morgan Stanley", "Lehman Brothers", "*", "Multiple Tenants", "Clifford Chance", "Credit Suisse", "Ogilvy & Mather, Barclays Capital", "Financial Services Authority", "Barclays Capital, Morgan Stanley", "Morgan Stanley", "Reuters", "Credit Suisse", "Credit Suisse", "Barclays plc", "-", "-", "STATE STREET", "TBA", "Morgan Stanley, Tube Lines", "-", "-", "-", "[retail]", "-", "-", "-", "-", "-", "-", "-", "Fitch Ratings");
var a = new Array("Skidmore, Owings & Merrill", "Foster & Partners", "Kohn Pedersen Fox" ,"Skidmore, Owings & Merrill", "Cesar Pelli & Associates / Adamson Associates", "Foster & Partners", "Cesar Pelli & Associates", "Chapman Taylor / Zeidler Roberts Partnership", "Skidmore, Owings & Merrill", "Cesar Pelli & Associates", "Cesar Pelli & Associates", "Cesar Pelli & Associates", "Kohn Pedersen Fox", "Pei Cobb Freed & Partners", "Skidmore, Owings & Merrill", "Troughton McAslan / Adamson Associates", "Kohn Pedersen Fox", "Skidmore, Owings & Merrill", "Kohn Pedersen Fox", "Gensler", "Skidmore, Owings & Merrill", "HOK International", "HOK International",  "Kohn Pedersen Fox", "TBA", "Skidmore, Owings & Merrill / Koetter, Kim & Associates / Perkins & Will", "Terry Farrell & Partners", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",  "Kohn Pedersen Fox");
var s = new Array("46,450", "102,191", "37,161", "50,632", "111,852", "52,284", "114,751", "18,673", "47,565", "97,546", "55,740", "92,251", "92,903", "59,075", "33,426", "33,426", "51,876", "41,666", "27,359", "18,580", "25,083", "92,902", "18,580", "27,870", "32,516",  "48,100", "16,165", "-", "-", "-", "21,156", "6,232", "-", "-", "-", "-", "-", "-", "29,729")
	
var views = new Array("se","sw","nw","ne");
var viewdescs = new Array("South East", "South West", "North West", "North East");

//how much to offset the floating image to align with the background - varies due to different CSS implementations
	var offsetX = 10;
	var offsetY = 10;
				
	if (navigator.appName.indexOf("Microsoft") != -1) {

	} else {
		offsetX += 1;
		offsetY += 1;
		if (parseInt(navigator.appVersion)>4) {
			 offsetX -= 1;
			 offsetY -= 1;
		}
	}
	
	var current = -1;
	var descframe = null;
		
	if (window.parent.frames.length>1 && window.parent.frames[1].name == 'desc') {
		descframe = window.parent.frames[1];
	};

function h(which) {
	var i;
	e.hide();
	current = which;
	if (which < p.length) {
		i = codetoindex(p[which]);
		
//this is the link to the page all about a building or park
//it assumes that every building has a page called 'index.html' inside a directory named for the building's code
//you can of course change this - but you'll need to change all the links also found on the image maps in se.html, sw.html, ne.html and nw.html

		e.setBody('<a href="' + p[which] + '/index.html"><img src="' + imagedir + '/' + p[which] + '_over.' + f[which] + '" onload="loaded(' + which + ');" border="0" alt="' + buildingName(i) + '">');
		e.moveTo(x[which] + offsetX, y[which] + offsetY);
		showInfo(which);
	}
}
	
function codetoindex(code) {
	for (i = 0; i<c.length; i++) {
		if (c[i] == code) {
			return i;
		}
	}
	return -1;
}
	
function buildingName(i) {
	if (i>=0 && i < n.length) {
		if (n[i] != '-') return n[i];
	}
	return '';
}
	
function buildingSize(i) {
	if (i>=0 && i < s.length) {
		if (s[i] != '-') return s[i] + ' sq m (net)';
	}
	return '';	
}
	
function buildingArchitect(i) {
	if (i>=0 && i < a.length) {
		if (a[i] != '-') return a[i];
	}
	return '';
}
	
function buildingTenant(i) {
	if (i>=0 && i < t.length) {
		if (t[i] == '-') {
			return '';
		} else {
			if (t[i] == '*') {
				return '[multiple tenants]';
			} else {
				return t[i];
			}
		}
	}
	return '';
}

function buildingStage(i) {
	if (i>=0 && i < g.length) {
		if (g[i] == 0) return '[ under design ]';
		if (g[i] == 1) return '[ groundwork commenced ]';
		if (g[i] == 2) return '[ under construction ]';
		if (g[i] == 3) return '';
	}
	return '';
}

function u(d) {
	d.hide();
	if (descframe) descframe.hideInfo();
	current = -1;
}
		
function showInfo(which) {
	var i;
	if (descframe && which>=0) {
		i = codetoindex(p[which]);
		descframe.showInfo(buildingName(i),buildingStage(i),buildingSize(i),buildingArchitect(i),buildingTenant(i),'');
	}
}
		
function loaded(which) {
	if (which == current || current < 0) {
		e.show();
		showInfo(which);
	}
}

function ccw() {
	e.hide();
	current = -1;
	e.setBody('<a href="' + nextbody(1) + '"><img src="' + imagedir + '/ccw_over.jpg" onload="loaded(-1);" border="0" alt="View from the ' + nextview(1) + '"></a>');
	e.moveTo(ccwX+offsetX, ccwY+offsetY);
}
function cw() {
	e.hide();
	current = -1;
	e.setBody('<a href="' + nextbody(-1) + '"><img src="' + imagedir + '/cw_over.jpg" onload="loaded(-1);" border="0" alt="View from the ' + nextview(-1) + '"></a>');
	e.moveTo(cwX+offsetX, cwY+offsetY);
}
function nextbody(offset) {
	var v;
	
	for (v = 0; v < views.length; v++) {
		if (views[v] == imagedir) {
			v = (v + offset + views.length) % views.length;
			return views[v] + 'body.html';
		}
	}
	return '';
}

function nextview(offset) {
	var v;
	
	for (v = 0; v < views.length; v++) {
		if (views[v] == imagedir) {
			v = (v + offset + views.length) % views.length;
			return viewdescs[v];
		}
	}
	return '';
}