var regionOpen = null;

// Add the locations to an array
var locations = new Array();
locations[0] = new addLocation("CSS Stellar PLC", "CSSPLC", "UK", "EUR", "First Floor<br>Mermaid House<br>2 Puddle Dock<br>London<br>EC4V 3DS<br>T: +44 (0)207 332 2002<br>F: +44 (0)207 332 2003<br>W: <a href='http://www.css-stellar.com' target='_blank' class='mapLinkRed'>www.css-stellar.com</a>");
locations[1] = new addLocation("CSS Stellar Sports", "CSSMAN", "UK", "EUR", "First Floor<br>Mermaid House<br>2 Puddle Dock<br>London<br>EC4V 3DS<br>T: +44 (0)207 332 2002<br>F: +44 (0)207 332 2003<br>W: <a href='http://www.css-stellar-sports.com' target='_blank' class='mapLinkRed'>www.css-stellar-sports.com</a>");
//locations[2] = new addLocation("Icon Display Ltd", "ICD", "UK", "EUR", "130-136 Maidstone Road<br>Sidcup<br>Kent<br>DA14 5HS<br>T: +44 (0)20 8302 4921<br>F: +44 (0)20 8302 3971<br>W: <a href='http://www.icondisplay.co.uk' target='_blank' class='mapLinkRed'>www.icondisplay.co.uk</a>");
//locations[3] = new addLocation("PFD", "PFD", "UK", "EUR", "Drury House<br>34-43 Russell Street<br>Covent Garden<br>London<br>WC2B 5HA<br>T: +44 (0)20 7344 1000<br>F: +44 (0)20 7836 9539<br>W: <a href='http://www.pfd.co.uk' target='_blank' class='mapLinkRed'>www.pfd.co.uk</a>");
///locations[4] = new addLocation("PFD - New York", "PFDNY", "US", "NA", "373 Park Avenue South, 5th Floor<br>New York<br>NY 10016<br>USA<br>T: +1 917 256 0707<br>F: +1 212 685 9635");
locations[2] = new addLocation("Hambric Sports Management", "HAM", "US", "NA", "2515 McKinney Avenue<br>Suite 940<br>Dallas<br>TX75201<br>T: +1 214 720 7179<br>E: <a href='mailto:hambricgolf@aol.com' class='mapLinkBlue'>hambricgolf@aol.com</a>");
//locations[6] = new addLocation("The GEM Group - Minneapolis", "TSCMIN", "US", "NA", "5900 Rowland Road<br>Minnetonka<br>MN55343<br>T: +1 952 831 6313<br>F: +1 952 653 5900<br>W: <a href='http://www.gemgroup.com' target='_blank' class='mapLinkBlue'>www.gemgroup.com</a>");
locations[3] = new addLocation("The GEM Group - New York", "TSCNYC", "US", "NA", "33W. 19th Street<br>4th Floor<br>New York, NY 10011<br>USA<br>T: +1 212 448 9200<br>F: +1 212 685 9635<br>W: <a href='http://www.gemgroup.com' target='_blank' class='mapLinkBlue'>www.gemgroup.com</a>");
locations[4] = new addLocation("0", "0", "0", "0", "0");

function addLocation(name,code,countrycode,region,address) {
	this.name 		 = name;
	this.code 		 = code;
	this.countrycode = countrycode;
	this.region		 = region;
	this.address	 = address;
}

function changeOffices(selector) {
	var countryCode = selector.options[selector.selectedIndex].value;
	var outputField = document.dropForm['office'];
	outputField.length = locations.length;
	var counter = 1;
	outputField.options[0].text = 'Select Office';
	outputField.options[0].value = 0;
	if (countryCode != 0) {
		for (var i=0; i<locations.length; i++) {
			if (locations[i].countrycode == countryCode) {
				outputField.options[counter].text = locations[i].name;
				outputField.options[counter].value = locations[i].code;
				counter++;
			}
		}
		outputField.length = counter;
	} else {
		outputField.length = 2;
		outputField.options[1].text = '-- Select Country First --';
		outputField.options[1].value = 0;
		document.getElementById("titleHolder").style.color = '#666666';
		document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_gray.gif" width="17" height="15" alt="" border="0" align="right">INTERNATIONAL OFFICES';
		document.getElementById("officeInfoHolder").innerHTML = '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td valign="top"><img src="/images/map_info_icon.gif" width="12" height="14" alt="" border="0">&nbsp;</td><td class="mapTextGray">Click on the map for information on our international offices.</td></tr></table>';
	}
	outputField.selectedIndex = 0;
}

function changeOfficeDetails(selector) {
	var officeCode = selector.options[selector.selectedIndex].value;
	for (var i=0; i<locations.length; i++) {
		if (locations[i].code == officeCode) {
			switch(locations[i].region) {
				case "EUR":
					document.getElementById("titleHolder").style.color = '#CB1009';
					document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_red.gif" width="17" height="15" alt="" border="0" align="right">'+locations[i].name;
					document.getElementById("officeInfoHolder").innerHTML = '<span class="mapTextRed">'+locations[i].address+'</span>';
					break;
				case "NA":
					document.getElementById("titleHolder").style.color = '#300D81';
					document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_blue.gif" width="17" height="15" alt="" border="0" align="right">'+locations[i].name;
					document.getElementById("officeInfoHolder").innerHTML = '<span class="mapTextBlue">'+locations[i].address+'</span>';
					break;
				default:
					document.getElementById("titleHolder").style.color = '#666666';
					document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_gray.gif" width="17" height="15" alt="" border="0" align="right">INTERNATIONAL OFFICES';
					document.getElementById("officeInfoHolder").innerHTML = '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td valign="top"><img src="/images/map_info_icon.gif" width="12" height="14" alt="" border="0">&nbsp;</td><td class="mapTextGray">Click on the map for information on our international offices.</td></tr></table>';
			}
		}
	}
}

function changeOfficeList(region) {
	var offices = '';
	for (var i=0; i<locations.length; i++) {
		if  (locations[i].region == region)
			offices = offices+locations[i].name+'<br>';
	}
	switch(region) {
		case "EUR":
			document.getElementById("titleHolder").style.color = '#CB1009';
			document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_red.gif" width="17" height="15" alt="" border="0" align="right">EUROPEAN OFFICES';
			document.getElementById("officeInfoHolder").innerHTML = '<span class="mapTextRed">'+offices+'</span>';
			break;
		case "NA":
			document.getElementById("titleHolder").style.color = '#300D81';
			document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_blue.gif" width="17" height="15" alt="" border="0" align="right">NORTH AMERICAN OFFICES';
			document.getElementById("officeInfoHolder").innerHTML = '<span class="mapTextBlue">'+offices+'</span>';
			break;
		default:
			document.getElementById("titleHolder").style.color = '#666666';
			document.getElementById("titleHolder").innerHTML = '<img src="/images/map_arrow_gray.gif" width="17" height="15" alt="" border="0" align="right">INTERNATIONAL OFFICES';
			document.getElementById("officeInfoHolder").innerHTML = '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td valign="top"><img src="/images/map_info_icon.gif" width="12" height="14" alt="" border="0">&nbsp;</td><td class="mapTextGray">Click on the map for information on our international offices.</td></tr></table>';
	}
}

function displayOffices(region) {
	if (regionOpen != null) 
		document.getElementById(regionOpen).style.display = 'none';
	document.getElementById(region).style.display = 'block';
	regionOpen = region;
}