
function chooseImage(){
    var theImgs = new Array();
    var i = 0;
 
    theImgs[i++]='_htmlImages/initImages/img01.jpg';
    theImgs[i++]='_htmlImages/initImages/img02.jpg';
    theImgs[i++]='_htmlImages/initImages/img03.jpg';
    theImgs[i++]='_htmlImages/initImages/img04.jpg';
    theImgs[i++]='_htmlImages/initImages/img05.jpg';
    theImgs[i++]='_htmlImages/initImages/img13.jpg';
    theImgs[i++]='_htmlImages/initImages/img14.jpg';
    theImgs[i++]='_htmlImages/initImages/img15.jpg';    
    theImgs[i++]='_htmlImages/initImages/img16.jpg';
    theImgs[i++]='_htmlImages/initImages/img17.jpg';
    theImgs[i++]='_htmlImages/initImages/img18.jpg';
    theImgs[i++]='_htmlImages/initImages/img19.jpg';
    theImgs[i++]='_htmlImages/initImages/img20.jpg';
    theImgs[i++]='_htmlImages/initImages/img21.jpg';
    theImgs[i++]='_htmlImages/initImages/img22.jpg';
    theImgs[i++]='_htmlImages/initImages/img23.jpg';
    theImgs[i++]='_htmlImages/initImages/img24.jpg';
    theImgs[i++]='_htmlImages/initImages/img25.jpg';
    theImgs[i++]='_htmlImages/initImages/img26.jpg';
    theImgs[i++]='_htmlImages/initImages/img27.jpg';
    theImgs[i++]='_htmlImages/initImages/img28.jpg';
 
 
 
    rand = Math.round(Math.random() * (i-1));
    //alert("chosen (" + rand + "):" + theImgs[rand] + ":");
    document["imgToLoad"].src = theImgs[rand];
}
 



function enviamail(nom,maquina) 
{
        window.open("mailto:"+nom+'@'+maquina);
}


function GetParamValue(url, variable)
{
  var variable_may = variable.toUpperCase();
  var variable_pos = url.indexOf(variable_may);

  if (variable_pos != -1)
  {
    var pos_separador = url.indexOf("&", variable_pos);

    if (pos_separador != -1)
    {
       return url.substring(variable_pos + variable_may.length + 1,
    pos_separador);
    }
    else
    {
      return url.substring(variable_pos + variable_may.length + 1,
    url.length);
    }
  }
  else
  {
    return "-1";
  }
}


// Return the clean URL, without strange codes such %
function GetCleanURL()
{
  var remplaza = /\+/gi;
  var url = window.location.href;

  url = unescape(url);
  url = url.replace(remplaza, " ");
  url = url.toUpperCase();

  return url;
}






// Activates the current language parsing the current url parameter
function ActivateLanguage()
{
    document.writeln("<style>");

    var url = GetCleanURL();
    var pval = GetParamValue(url, "langu");

    if (pval == "CAT")
	{
	    document.writeln("div.es { display : none; }");
	    document.writeln("div.uk { display : none; }");
	}
    else if (pval == "ES")
	{
	    document.writeln("div.cat { display : none; }");
	    document.writeln("div.uk { display : none; }");
	}
    else
	{
	    document.writeln("div.es { display : none; }");
	    document.writeln("div.cat { display : none; }");
	}

    document.writeln("</style>");

}




// Write a publication item
function WritePublication(title, authors, desc, link)
{
    var plist = document.getElementById("publicationslist");

    pub = document.createElement("div");
    pub.setAttribute("class", "publicationitem");
       
    pubtitle = document.createElement("div");
    pubtitle.setAttribute("class", "publicationtitle");

    if (link == null)
	pubtitle.appendChild(document.createTextNode(title));
    else
	{
	    plink = document.createElement("a");
	    plink.setAttribute("href", link);
	    plink.innerHTML = title;
	    pubtitle.appendChild(plink);
	}

    pubauthor = document.createElement("div");
    pubauthor.setAttribute("class", "publicationauthors");
    pubauthor.appendChild(document.createTextNode(authors));

    pubdesc = document.createElement("div");
    pubdesc.setAttribute("class", "publicationdesc");
    pubdesc.appendChild(document.createTextNode(desc));

    pub.appendChild(pubtitle);
    pub.appendChild(pubauthor);
    pub.appendChild(pubdesc);
    
    plist.appendChild(pub);
}








// Write a publication thesis item
function WriteThesis(title, author, desc, advisors, link)
{
    var plist = document.getElementById("phdlist");

    pub = document.createElement("div");
    pub.setAttribute("class", "phditem");

    pubtitle = document.createElement("div");
    pubtitle.setAttribute("class", "phdtitle");

    if (link == null)
        pubtitle.appendChild(document.createTextNode(title));
    else
        {
            plink = document.createElement("a");
            plink.setAttribute("href", link);
            plink.innerHTML = title;
            pubtitle.appendChild(plink);
        }

    pubauthor = document.createElement("div");
    pubauthor.setAttribute("class", "phdauthor");
    pubauthor.appendChild(document.createTextNode(author));

    pubdesc = document.createElement("div");
    pubdesc.setAttribute("class", "phddesc");
    pubdesc.appendChild(document.createTextNode(desc));

    pubadv = document.createElement("div");
    pubadv.setAttribute("class", "phdadvisors");
    pubadv.appendChild(document.createTextNode("Advisors: "));
    pubadv.appendChild(document.createTextNode(advisors));


    pub.appendChild(pubtitle);
    pub.appendChild(pubauthor);
    pub.appendChild(pubdesc);
    pub.appendChild(pubadv);

    plist.appendChild(pub);
}














// Write the resource fields in function of current language
function WriteResource(entity, amount, period, director)
{
    document.writeln("<ul>");
      document.writeln("<li> Company/Institution : " + entity + "</li>");
      document.writeln("<li> Amount : " + amount + "</li>");
      document.writeln("<li> Period : " + period + "</li>");
      document.writeln("<li> Scientist in charge : " + director + "</li>");
    document.writeln("</ul>");

}

// Write the resource fields in function of current language
function WriteResource2(entity, period, director)
{
    document.writeln("<ul>");
      document.writeln("<li> Company/Institution : " + entity + "</li>");
      document.writeln("<li> Period : " + period + "</li>");
      document.writeln("<li> Scientist in charge : " + director + "</li>");
    document.writeln("</ul>");

}

// Write the resource fields in function of current language. Also the group
// filed has been added
function WriteResourceGR(entity, amount, period, director, group)
{
    document.writeln("<ul>");
      document.writeln("<li> Funding entity : " + entity + "</li>");
      document.writeln("<li> Amount : " + amount + "</li>");
      document.writeln("<li> Period : " + period + "</li>");
      document.writeln("<li> Scientist in charge : " + director + "</li>");
      document.writeln("<li> Participating groups : " + group + "</li>");
    document.writeln("</ul>");


}


