// JavaScript Document
	
	function getPubs()
	{
		//alert("making Pubs");
		try{
		var table = document.createElement("table");
		formatTable(table)
		//document.getElementById("pubsHolder").appendChild(table);
		
		var headerrow = table.insertRow(0);
		headerrow.insertCell(0).appendChild(document.createTextNode("Publication"));

		headerrow.getElementsByTagName("td")[0].setAttribute("width","100%")
		
		var tabletemp = document.createElement("table");
		tabletemp = table.cloneNode(true);
		
		headerrow = tabletemp.insertRow(1);
		switcher = document.createElement("td");
		switcher.setAttribute("onClick","showSomePubs()");
		switcher.setAttribute("colspan",3);
		var switchButton = document.createElement("button");
		switchButton.onclick = showSomePubs;
		switchButton.setAttribute("style","width: 100%;");
		switchButton.appendChild(document.createTextNode("Minimize"));
		switcher.appendChild(switchButton);
		headerrow.appendChild(switcher)	;
		
		headerrow = table.insertRow(1);
		switcher = document.createElement("td");
		switcher.setAttribute("onClick","showAllPubs()");
		switcher.setAttribute("colspan",3);
		var switchButton = document.createElement("button");
		switchButton.onclick = showAllPubs;
		switchButton.setAttribute("style","width: 100%;");
		switchButton.appendChild(document.createTextNode("Maximize - See All"));
		switcher.appendChild(switchButton);
		headerrow.appendChild(switcher)	;
	
		
		var pubsList = xmlDoc.getElementsByTagName("paper");
		//alert(pubsList.length);
		
		for ( var i=0; i < 3; i++)
		{
			
			var e = pubsList[i];
			var title = e.getElementsByTagName("title")[0].firstChild.data;
			var author = e.getElementsByTagName("author")[0].firstChild.data;
			var linkline = e.getElementsByTagName("link")[0].firstChild.data;
			var pubType = e.getElementsByTagName("PubType")[0].firstChild.data;
			var date =  e.getElementsByTagName("date")[0].firstChild.data;
			//alert("loop " +i + "title"+title + "author" +author+"pubType"+pubType);	
			
			
			var row = table.insertRow(i+2);
			var anchorT = document.createElement("a");
			anchorT.setAttribute("href",linkline);
			var text = title + " " + pubType + " " + date + " " + author;
			anchorT.appendChild(document.createTextNode(text));
			
			row.insertCell(0).appendChild(anchorT);
			var spacerrow = table.insertRow(i+3)
		}
	
		
		shortPubsTable = table
		
		//	alert("marker")
		
	//	alert(pubsList.length);
		for ( var i=0; i < pubsList.length; i++)
		{
			//alert("loop " +i);
			var e = pubsList[i];
			var title = e.getElementsByTagName("title")[0].firstChild.data;
			var author = e.getElementsByTagName("author")[0].firstChild.data;
			var linkline = e.getElementsByTagName("link")[0].firstChild.data;
			var pubType = e.getElementsByTagName("PubType")[0].firstChild.data;
			var date =  e.getElementsByTagName("date")[0].firstChild.data;
			//alert("loop " +i + "title"+title + "author" +author+"pubType"+pubType);	
			
			var row = tabletemp.insertRow(i+2);
			var anchorT = document.createElement("a");
			anchorT.setAttribute("href",linkline);
			var text = title + " " + pubType + " " + date + " " + author;
			//alert(text)
			anchorT.appendChild(document.createTextNode(text));
			
			row.insertCell(0).appendChild(anchorT);
		}
			
		allPubsTable = tabletemp
		}catch(e){
			
			alert(e)	
		}
		initPubs();	
	}
	
	function initPubs()
	{
		//alert("in init pubs")
		document.getElementById("pubsContent").appendChild(shortPubsTable);
		loadXML("RecentTalks.xml");
	}
	function showAllPubs()
	{	
		document.getElementById("pubsHolder").removeChild(document.getElementById("pubsContent"));
		var div = document.createElement("div");
		div.setAttribute("id","pubsContent");	
		document.getElementById("pubsHolder").appendChild(div);
		document.getElementById("pubsContent").appendChild(allPubsTable);
	}
	function showSomePubs()
	{	
		document.getElementById("pubsHolder").removeChild(document.getElementById("pubsContent"));
		var div = document.createElement("div");
		div.setAttribute("id","pubsContent");	
		document.getElementById("pubsHolder").appendChild(div);
		document.getElementById("pubsContent").appendChild(shortPubsTable);
	}