//adds the publication display block into the css so ti can be manipulated
if (document.all || document.getElementById) { // if IE4 or NS6+
	document.write('<style type="text/css">\n');
	document.write('.pub{display: block; padding-bottom: 0.5em;}\n');
	document.write('</style>');
}

var curcontentindex=0;
var papers=new Array();

window.onload=function(){
//reads all elements with class id 'pub' (publication) into the paper array
	if (document.all || document.getElementById){
		collectElementByClass("pub");
	}
}

function collectElementByClass(classname) {
//puts all elements with class name 'classname' into paper array
	var inc=0;
	var alltags=document.all? document.all : document.getElementsByTagName("*");
	var myRE = new RegExp(" *"+classname+" *");
	for (i=0; i<alltags.length; i++) {
		var name = alltags[i].className;
		if (name.match(myRE)) {
			papers[inc++]=alltags[i];
		}
	}
}

function display() {
	//action of click on display button 
	var content_val; //value of checked content radio button
	var type_val; //value of checked type radio button
	//checks through content radio buttons for the checked one
	for (var i=0; i<document.selectForm.content.length; i++) {
		if (document.selectForm.content[i].checked) {
			content_val = document.selectForm.content[i].value;
		}
	}
	//checks through type radio buttons for the checked one
	for (var i=0; i<document.selectForm.type.length; i++) {
		if (document.selectForm.type[i].checked) {
			type_val = document.selectForm.type[i].value;
		}
	}								
	displayByClass(content_val,type_val);
	//searches through the list of papers for any with the given pair of class names
}

function displayByClass(cName1,cName2) {
//sets display on papers with classnames cName1 and cName2 to true
//sets other papers to display none
	var inc=0;
	var myRE1 = new RegExp(" *"+cName1+" *");
	var myRE2 = new RegExp(" *"+cName2+" *");
	for (i=0; i<papers.length; i++) {
		var name = papers[i].className;
		if (name.match(myRE1)&&name.match(myRE2))
			papers[i].style.display="block";
		else
			papers[i].style.display="none";
	}
}
