var library,
	manuscript,
	imageDirectory,
	imageName,
	fileName,
	windowName,
	imagePath,
	id,
	key;

var imageWindow = new Array();

function keyDetect(e)
{
	key = e.altKey || e.modifiers & Event.ALT_MASK || 0;
}

function getImage(href, name)
{
	var token = href.toString().split('/');
	library = token[4];
	manuscript = token[5];
	imageDirectory = (key) ? '/large_jpgs/' : '/small_jpgs/';
	imageName = name;
	fileName = href.hash.substring(1);
	windowName = manuscript + fileName;	
	imagePath = '../libraries/' + library + '/' + manuscript;
	id = manuscript.replace(/_/g, " ");
	key = null;
	showImage();
}

function showImage()
{
	var docRef = '/resources/image.html';
	var features = 'scrollbars=yes,resizable=yes,status=yes';
	imageWindow[imageWindow.length] = window.open(docRef, windowName, features);
}

function showLibrary(form)
{
	var combo = form.libraryMenu;
	if (combo.selectedIndex != 0) {
		var url = combo.options[combo.selectedIndex].value;
		main.location.href = url;
		combo.selectedIndex = 0;
	}
}

function switchLanguage(lang, newlang)
{
//	alert("SL " +doc +"SLX " +mainUrl);
//	var path = doc.split(lang);
//	var mainUrl = path[0] + newlang + path[1];
//	main.location.href = mainUrl;
	
	mainUrl = main.location.href;
//	alert("SL1 " +mainUrl);	
	while (mainUrl.indexOf(lang) > 0) mainUrl = mainUrl.replace(lang,newlang);
//	alert("SL2 " +mainUrl);	
	main.location.href = mainUrl;
}
