function getCookie(name, allcookies) {
	name += "=";
	var pos = allcookies.indexOf(name);
	if (pos == -1) return false;
	var start = pos + name.length;
	var end = allcookies.indexOf(";", start);
	if (end == -1) end = allcookies.length;
	var value = allcookies.substring(start, end);
	return unescape(value);
}

function launchVideo() {
	videoWindow = window.open('../video.html','video','width=550,height=450,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	videoWindow.focus();
	return false;
}

function launchInteractive(path) {
	interactiveWindow = window.open(path,'interactive','width=800,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	interactiveWindow.focus();
	return false;
}

function goNav(section, root, current) {
	var ctrlActive = false;
	if (window && window.event && window.event.ctrlKey) { ctrlActive = true; }
	if ((!root) || root == "") { root = ""; }
	var pExhibition = getCookie("aotm_" + section, document.cookie);
	if (ctrlActive && pExhibition && pExhibition != "" && (window.location.pathname + window.location.search) != pExhibition) {
		document.location = pExhibition;
	}	else {
		document.location = root + section + "/";
	}
	return false;
}

function launchAbout(path) {
	pop(path, 460, 460, 'about', 2);
	return false;
}

function launchCredits(path) {
	pop(path, 520, 460, 'credits', 2);
	return false;
}

function pop(url, width, height, name, type) {
 	if (type==1) { 
		a=window.open(url,name,'width=' + width + ',height=' + height + ',toolbar=1,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0');
	} else if (type==0) {
		a=window.open(url,name,'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
	} else if (type==2) {
		a=window.open(url,name,'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
	} else if (type==3) {
		a=window.open(url,name,'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
	}
	a.focus();
	return false;
}

function launchImage(ID) {
	var url = "image_" + ID + ".html";
	pop(url, 530, 550, 'largeImage', 2);
	return false;
}

function swapImage(strElement, objImage) {	
// this function swaps the image identified by strElement for a new one preloaded as objImage
	if (document.images && objImage && objImage.src && objImage.src != "") {
		if (document.images[strElement]) {
			document.images[strElement].src = objImage.src;
		}
	}
}

function gotoStory(sel) {
	if (!sel || !sel.selectedIndex) return;
	url = sel.options[sel.selectedIndex].value;
	document.location=url;
}

function goMedia(ID) {
	var pExhibition = getCookie("aotm_video_mode", document.cookie);

	switch (pExhibition) {
		case "real_hi" :
			url = "vid_real_hi_" + ID + ".html";
			break;
		case "real_lo" :
			url = "vid_real_lo_" + ID + ".html";
			break;
		case "wmp_hi" :
			url = "vid_wmp_hi_" + ID + ".html";
			break;
		case "wmp_lo" :
			url = "vid_wmp_lo_" + ID + ".html";
			break;
		default :
			url = "vid_menu_" + ID + ".html";
			break;
	}	

	pop(url, 340, 380, 'video', 0);
	return false;
}


