// JavaScript Document
var titolo;
function getFile(data)
	{
	 switch (data) {
	 	case 'All': valore = "publications/pub_all.xml";
					titolo = data;
				break;
	 	case 'Articles': valore = "publications/pub_articles.xml";
					titolo = data;
				break;
	 	case 'Proceedings': valore = "publications/pub_proceedings.xml";
					titolo = data;
				break;
		case 'Books': valore = "publications/pub_books.xml";
					titolo = data;
				break;
		case 'Reviews': valore = "publications/pub_reviews.xml";
					titolo = data;
				break;       		
    	case 'Lectures': valore = "publications/pub_lectures.xml";
					titolo = data;
				break;    
					 	case '2008': valore = "publications/pub_2008.xml";
					 titolo = data;
				break;
					 	case '2007': valore = "publications/pub_2007.xml";
					 titolo = data;
				break;
	 	case '2006': valore = "publications/pub_2006.xml";
					 titolo = data;
				break;
	 	case '2005': valore = "publications/pub_2005.xml";
					 titolo = data;
				break;
	 	case '2004': valore = "publications/pub_2004.xml";
					 titolo = data;
				break;	
	 	case '2003': valore = "publications/pub_2003.xml";
				 	 titolo = data;
				break;
	 	case '2002': valore = "publications/pub_2002.xml";
					 titolo = data;
				break;
	 	case 'FCS': valore = "publications/pub_fcs.xml";
				 	 titolo = data;
				break;
	 	case 'CARS': valore = "publications/pub_cars.xml";
					 titolo = data;
				break;
	 	case 'HolographicOpticalTweezers': valore = "publications/pub_hot.xml";
					 titolo = data;
				break;
	 	case 'Microstereolithography': valore = "publications/pub_musl.xml";
				 	 titolo = data;
				break;	
	 	case 'PulseShaping': valore = "publications/pub_pulse_shaping.xml";
					 titolo = data;
				break;        			
	 	case 'Nanoholes': valore = "publications/pub_nanoholes.xml";
					 titolo = data;
				break;						

				
		default: valore = "publications/pub_2007.xml";
				  }
     return valore;
 }

var xml_pub
function loadPublicationsXML(infos)
{
var url = getFile(infos);

xml_pub=null

// Mozilla, Safari, ...
if (window.XMLHttpRequest) 
	{ 
  	xml_pub = new XMLHttpRequest();
	if (xml_pub!=null)
  		{			
  		
		xml_pub.open("GET",url,true)
		xml_pub.onreadystatechange=state_ChangeMOZ2
  		xml_pub.send(null)
		
  		}
  	else
  		{
  		alert("Your browser does not support XMLHTTP.")
  		}
    }
// code for IE
else if (window.ActiveXObject)
  {
  xml_pub=new ActiveXObject("Microsoft.XMLHTTP")
  if (xml_pub!=null)
  	{
	xml_pub.onreadystatechange=state_ChangeMOZ2	
	xml_pub.open("GET",url,true)
  	xml_pub.send(null)

  	}
  else
  	{
  	alert("Your browser does not support XMLHTTP.")
  	}
  }

}

function state_ChangeMOZ2()
{
// if xml_pub shows "loaded"
if (xml_pub.readyState==4)
  {
  // if "OK"
  if (xml_pub.status==200)
  {
  //alert("XML data OK")
  var response = xml_pub.responseXML.documentElement;
  
  // Show the articles
  var txt="<h3>" + titolo + "</h3><br />";

	x=response.getElementsByTagName("mosaic_publication");
  	for (i=0;i<x.length;i++)
    	{		
	    xt=response.getElementsByTagName("mosaic_title")[i].firstChild.nodeValue
		xa=response.getElementsByTagName("mosaic_author")[i].firstChild.nodeValue
		xj=response.getElementsByTagName("mosaic_journal")[i].firstChild.nodeValue
		xv=response.getElementsByTagName("mosaic_volume")[i].firstChild.nodeValue
		xp=response.getElementsByTagName("mosaic_pages")[i].firstChild.nodeValue
		xy=response.getElementsByTagName("mosaic_year")[i].firstChild.nodeValue
		xabs=response.getElementsByTagName("mosaic_abstract")[i].firstChild.nodeValue
		xfn=response.getElementsByTagName("mosaic_pdf_filename")[i].firstChild.nodeValue
		r = i+1;
      	try
        	{
	        txt=txt + r +". <div style='display:inline;' class='bibtex_title'>" + xt + "</div><br> <div class='bibtex_author'>" + xa + "</div><br><div class='bibtex_journal'>" + xj + ", </div><div class='bibtex_volume'> Vol. " + xv + "</div><div class='bibtex_pages'>, pp." + xp + "</div><div class='bibtex_year'>, " + xy+ "  </div><br /><a onclick='showAbstract("+i+");'>Abstract,  </a><a href='../mosaic/publications/pdf_files/" + xfn + "'>Full article <img src='images/pdf_Logo.gif' alt='Pdf' /></a><div class='abstracts' id='testo"+ i + "'>"+xabs+"</div><hr>";
	        }
    	catch (er)
        	{
        	txt=txt + "<div class='bibtex_title'>error loading</div><br>"
        	}
      	} // for
  document.getElementById('Publications').innerHTML=txt;
   } //if
  else
  	{
  	alert("Problem retrieving XML data:" + xml_pub.status) // + xml_pub.statusText)
  	}
  }
}

function showAbstract(number)
{
var idDiv = "testo" + number;

if(document.getElementById(idDiv).style.height = '0;')
	{
	document.getElementById(idDiv).style.visibility = 'visible;';
	document.getElementById(idDiv).style.height = 'auto;';
	return;
if(document.getElementById(idDiv).style.height = 'auto;')
	{
	alert("catzo")
	document.getElementById(idDiv).style.visibility = 'collapse;'
	document.getElementById(idDiv).style.height = '0;';	
	}	}

}

