/*  Fitzwillaim Archive JS */

function setTranscript(text) {
	var trans = text;
	if(document.getElementById("transcriptText"))
	{
		var obj = document.getElementById("transcriptText")
		if(trans.length>0)
		{
			obj.innerHTML = trans;
			obj.style.height = "275px";
			obj.style.width = "98%";
			obj.style.overflow = "scroll";
			obj.style.border = "solid 2px #5B5B8F";
		} else { obj.style.display = "none"; }
	}
}

function openComments (c) {
    window.open(c, 'comments', 'width=360,height=570,scrollbars=yes,status=yes,resizable=yes');
}

function validateComment(f) {
	var errors = new String();
	if(f.elements.name.value.length==0)
		errors = "Please enter your name\r";
	if(f.elements.email.value.length==0)
		errors += "Please enter your email address\r";
	if(f.elements.comments.value.length==0)
		errors += "Please enter a comment\r";
	
	if(errors.length==0)
		return true;
	else {
		alert(errors);
		return false;
	}
}

function submitKeywords(f) {
	if(document.forms[0].elements.keywords.value.length>0) {
		document.forms[0].submit();
	} else { document.forms[0].elements.keywords.focus(); }
}

function validateKeywords(f) {
	if(f.elements.keywords.value.length==0) {
		return false;
	}
}

function filterType(o) {
	document.forms[0].elements.start.value = "0";
	document.forms[0].submit();
}

function setComboByValue(obj, val) {
	for(var i=0; i<obj.options.length; i++) {
		if(parseInt(obj.options[i].value) == parseInt(val)) {
			obj.options[i].selected = true;
			obj.options.selectedIndex = i;
		}
	}
}

function setComboByValue2(obj, val) {
	for(var i=0; i<obj.options.length; i++) {
		if(obj.options[i].text == val) {
			obj.options[i].selected = true;
			obj.options.selectedIndex = i;
		}
	}
}