
 var mapNumber = 0
 // Set mapNumber to reflect the map from the current chapter:
 var chapterNo = opener.location.href.substring(opener.location.href.lastIndexOf('/') - 6 ,opener.location.href.lastIndexOf('/'))
 switch(chapterNo) {
	case "part02":
		mapNumber = 1
		break
	case  "part03":
		mapNumber = 1
		break		
	case "part04":
		mapNumber = 1
		break
	case "part05":
		mapNumber = 2
		break
	case "part06":
		mapNumber = 3
		break
	case "part07":
		mapNumber = 3
		break
	case "part08":
		mapNumber = 3
		break
	case "part09":
		mapNumber = 4
		break
	case "part10":
		mapNumber = 4
		break
	case "part11":
		mapNumber = 4
		break
	case "part12":
		mapNumber = 5
		break
	case "part13":
		mapNumber = 5
		break
	case "part14":
		mapNumber = 6
		break
	case "part15":
		mapNumber = 7
		break
	case "part16":
		mapNumber = 7
		break
	case "part17m":
		mapNumber = 8
		break
	case "part18":
		mapNumber = 10
		break
	case "part19":
		mapNumber = 10
		break
	case "part20":
		mapNumber = 12
		break
	default:
		mapNumber = 0
 }

 
 // Kartliste:
 var mapArray = new Array()
 mapArray[0] = new Image()
 mapArray[0].src = "lasamericas.gif"
 mapArray[1] = new Image()
 mapArray[1].src = "usa-east.gif"
 mapArray[2] = new Image()
 mapArray[2].src = "usa-mid.gif"
 mapArray[3] = new Image()
 mapArray[3].src = "usa-west.gif"
 mapArray[4] = new Image()
 mapArray[4].src = "usa-south-mexico-north.gif"
 mapArray[5] = new Image()
 mapArray[5].src = "mexico.gif"
 mapArray[6] = new Image()
 mapArray[6].src = "central-america.gif"
 mapArray[7] = new Image()
 mapArray[7].src = "south-america-north.gif"
 mapArray[8] = new Image()
 mapArray[8].src = "south-america-mid-north.gif"
 mapArray[9] = new Image()
 mapArray[9].src = "south-america-mid-south.gif"
 mapArray[10] = new Image()
 mapArray[10].src = "south-america-south.gif"
 mapArray[11] = new Image()
 mapArray[11].src = "south-america-mid-south-east.gif"
 mapArray[12] = new Image()
 mapArray[12].src = "europe.gif"
 
 // Step one photo up or down using the imageNumber counter
 function newMap(dir) { 
	if (dir == "prev") {
		mapNumber--
		if (mapNumber == -1) {
			mapNumber = 12
		}
	}
	else if (dir == "next") {
		mapNumber++
		if (mapNumber == 13) {
			mapNumber = 0
		}
	}
	else {
		mapNumber = 0
	}
	
	setMap(mapNumber)
	
 }

function checkIE6(mapNumber) {
	if (navigator.appVersion.indexOf("MSIE 6.0") > -1) {
		alert("We're sorry for the inconvenience, but with IE6 you cannot use this function(MS bug?).\nUse the 'Next Map' button to navigate.")
	}
	else {
		setMap(mapNumber)
	}
}
// Place the image in the image frame:
 function setMap(number) {
	mapNumber = number
 	var mapLink = ""
	document.images["map"].src = mapArray[mapNumber].src 

	// Set up to use map link when main map (no. 0) is chosen
	switch (mapNumber) {
		case 0:
			mapLink = "#america"
			break
		case 1:
			mapLink = "#mapUSAeast"
			break
		case 2:
			mapLink = "#mapUSAmid"
			break
		case 3:
			mapLink = "#mapUSAwest"
			break
		case 4:
			mapLink = "#mapUSAsouth"
			break
		case 5:
			mapLink = "#mexico"
			break
		case 6:
			mapLink = "#cenAmerica"
			break
		case 7:
			mapLink = "#ecuador"
			break
		case 8:
			mapLink = "#peru"
			break
		case 9:
			mapLink = "#chile"
			break
		case 10:
			mapLink = "#patagonia"
			break
		case 11:
			mapLink = "#argentina"
			break
		case 12:
			mapLink = "#europe"
			break
		default:
			mapLink = ""
	}
	document.images["map"].useMap = mapLink

}
	// Opens the article linked from the map in the original window 
function mapToArticle(address) {
	opener.location.href = address
	opener.focus()
}
	
var offImgArray = new Array()
offImgArray["nextMap"] = new Image()
offImgArray["prevMap"] = new Image()
offImgArray["mainMap"] = new Image()
offImgArray["photos"] = new Image()
offImgArray["close"] = new Image()

//off image paths
offImgArray["nextMap"].src = "../../buttons/nextMapOff.jpg"
offImgArray["prevMap"].src = "../../buttons/prevMapOff.jpg"
offImgArray["mainMap"].src = "../../buttons/mainMapOff.jpg"
offImgArray["photos"].src = "../../buttons/photosOff.jpg"
offImgArray["close"].src = "../../buttons/closeOff.jpg"

var onImgArray = new Array()
onImgArray["nextMap"] = new Image()
onImgArray["prevMap"] = new Image()
onImgArray["mainMap"] = new Image()
onImgArray["photos"] = new Image()
onImgArray["close"] = new Image()

//off image paths
onImgArray["nextMap"].src = "../../buttons/nextMapOn.jpg"
onImgArray["prevMap"].src = "../../buttons/prevMapOn.jpg"
onImgArray["mainMap"].src = "../../buttons/mainMapOn.jpg"
onImgArray["photos"].src = "../../buttons/photosOn.jpg"
onImgArray["close"].src = "../../buttons/closeOn.jpg"

// functions that swaps images and status bar
function imageOn(imgName) {
	if (document.images) {
		document.images[imgName].src = onImgArray[imgName].src
	}
}

function imageOff(imgName) {
	if (document.images) {
		document.images[imgName].src = offImgArray[imgName].src
	}
}


