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


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

  var modDate = new Date(document.lastModified)
  var modYear = modDate.getYear()
  if (modYear < 1000) modYear += 1900

  if (pval == "CAT")     
    document.write("Ultima modificaci&oacute;: " + modDate.getDate() + "-" + (modDate.getMonth() + 1) + "-" + (modYear + ""));
  else if (pval == "ES")
    document.write("Ultima modificacion: " + modDate.getDate() + "-" + (modDate.getMonth() + 1) + "-" + (modYear + ""));
  else
    document.write("Last modified: " + modDate.getDate() + "-" + (modDate.getMonth() + 1) + "-" + (modYear + ""));
}

function Footer(level)
{
  var url = GetCleanURL();
  var pval = GetParamValue(url, "langu");

  document.writeln("<img SRC=\"" + level + "/_htmlImages/Barra2.gif\" WIDTH=\"100%\" HEIGHT=\"8\" ALIGN=\"BOTTOM\" BORDER=\"0\"><br>");
  
  document.writeln("<table WIDTH=100%>");
    document.writeln("<tr>");
      document.writeln("<td align=\"left\">");

        document.writeln("<small>");
	if (pval == "CAT") document.writeln("<i>Mantingut per <a href=\"javascript:enviamail('albertm','ima.udg.es')\">webmaster</a>");
	else if (pval == "ES") document.writeln("<i>Mantenido por <a href=\"javascript:enviamail('albertm','ima.udg.es')\">webmaster</a>");
	else document.writeln("<i>Maintained by <a href=\"javascript:enviamail('albertm','ima.udg.es')\">webmaster</a>");
	document.writeln("<br>");
	LastModified();
	document.writeln("</i>");
	document.writeln("<br>");
	document.writeln("</small>");

      document.writeln("</td>");
      document.writeln("<td align=\"right\">");
        document.writeln("<a href=\"http://www.udg.edu\" target=\"blank\"><img src=\"" + level + "/_htmlImages/udghome.gif\" border=0></a>");
      document.writeln("</td>");
}

function Header(label, level)
{
  var url = GetCleanURL();
  var pval = GetParamValue(url, "langu");

  <!-- Taula amb el nom del grup de recerca i el seu logotip -->
  document.writeln("<table WIDTH=100%>");
    document.writeln("<tr VALIGN=\"bottom\">");

    if (pval == "CAT")
      document.writeln("<td WIDTH=15%> <a HREF=\"" + level + "/index.html?langu=cat\"><img SRC=\"" + level + "/_htmlImages/logoGGG.jpg\" WIDTH=\"138\" HEIGHT=\"88\" BORDER=\"0\"> </td>");
    else if (pval == "ES")
      document.writeln("<td WIDTH=15%> <a HREF=\"" + level + "/index.html?langu=es\"><img SRC=\"" + level + "/_htmlImages/logoGGG.jpg\" WIDTH=\"138\" HEIGHT=\"88\" BORDER=\"0\"> </td>");
    else 
      document.writeln("<td WIDTH=15%> <a HREF=\"" + level + "/index.html\"><img SRC=\"" + level + "/_htmlImages/logoGGG.jpg\" WIDTH=\"138\" HEIGHT=\"88\" BORDER=\"0\"> </td>");

      document.writeln("<td WIDTH=70% ALIGN=\"center\"> <b><font COLOR=\"#000080\" SIZE=+2>" + label + "</font> </b></td>");
      document.writeln("<td WIDTH=15% ALIGN=\"right\"> <a HREF=\"http://iiia.udg.es/\"><img SRC=\"" + level + "/_htmlImages/Logoiiia.gif\" WIDTH=\"123\" HEIGHT=\"88\" BORDER=\"0\"></a></td>");


 

    document.writeln("</tr>");
  document.writeln("</table>");
  <!-- Barra separadora -->
  document.writeln("<img SRC=\"" + level + "/_htmlImages/Barra1.gif\" WIDTH=\"100%\" HEIGHT=\"8\" ALIGN=\"BOTTOM\" BORDER=\"0\">");
  document.writeln("<br>");
}


function Header2(label, label2, level)
{
  var url = GetCleanURL();
  var pval = GetParamValue(url, "langu");



  <!-- Taula amb el nom del grup de recerca i el seu logotip -->

  document.writeln("<table WIDTH=100%>");
    document.writeln("<tr VALIGN=\"bottom\">");

    if (pval == "CAT")
      document.writeln("<td WIDTH=15%> <a HREF=\"" + level + "/index.html?langu=cat\"><img SRC=\"" + level + "/_htmlImages/logoGGG.jpg\" WIDTH=\"138\" HEIGHT=\"88\" BORDER=\"0\"> </td>");
    else if (pval == "ES")
      document.writeln("<td WIDTH=15%> <a HREF=\"" + level + "/index.html?langu=es\"><img SRC=\"" + level + "/_htmlImages/logoGGG.jpg\" WIDTH=\"138\" HEIGHT=\"88\" BORDER=\"0\"> </td>");
    else
      document.writeln("<td WIDTH=15%> <a HREF=\"" + level + "/index.html\"><img SRC=\"" + level + "/_htmlImages/logoGGG.jpg\" WIDTH=\"138\" HEIGHT=\"88\" BORDER=\"0\"> </td>");

      document.writeln("<td WIDTH=70% ALIGN=\"center\"> <b><font COLOR=\"#000080\" SIZE=+2>" + label + "</font> </b> ");
      document.writeln("<br>");
      document.writeln("<b><font COLOR=\"#000080\" SIZE=+1>" + label2 + "</font> </b></td>");

      document.writeln("<td WIDTH=15% ALIGN=\"right\"> <a HREF=\"http://iiia.udg.es/\"><img SRC=\"" + level + "/_htmlImages/Logoiiia.gif\" WIDTH=\"123\" HEIGHT=\"88\" BORDER=\"0\"></a></td>");



    document.writeln("</tr>");
  document.writeln("</table>");

  <!-- Barra separadora -->
  document.writeln("<img SRC=\"" + level + "/_htmlImages/Barra1.gif\" WIDTH=\"100%\" HEIGHT=\"8\" ALIGN=\"BOTTOM\" BORDER=\"0\">");
  document.writeln("<br>");

}


// Write the publications sphere colors legend
function Legend(level)
{
  <!-- DEPRECATED -->


  <!-- Llegenda de les boles de colors per les publicacions -->
/*
  var url = GetCleanURL();
  var pval = GetParamValue(url, "langu");

  document.writeln("<table width=100% border=1 cellpadding=3 cellspacing=0>");
    document.writeln("<tr align=\"center\">");
      document.writeln("<td align=\"center\">");
  document.writeln("<table width=100%>");
    document.writeln("<tr align=\"center\" border=0>");
      document.writeln("<td border=0>");
        document.writeln("<img src=\"" + level + "/_htmlImages/yellow_sphere.gif\">");
	
	if (pval == "CAT") document.writeln(" : Articles");
	else if (pval == "ES") document.writeln(" : Art&iacute;culos");
	else document.writeln(" : Articles");

      document.writeln("</td>");
      document.writeln("<td>");
        document.writeln("<img src=\"" + level + "/_htmlImages/red_sphere.gif\">");

	if (pval == "CAT") document.writeln(" : Congressos");
	else if (pval == "ES") document.writeln(" : Congresos");
	else document.writeln(" : Congresses");

      document.writeln("</td>");
      document.writeln("<td>");
        document.writeln("<img src=\"" + level + "/_htmlImages/green_sphere.gif\">");

	if (pval == "CAT") document.writeln(" : Tesis");
	else if (pval == "ES") document.writeln(" : Tesis");
	else document.writeln(" : PhD");

      document.writeln("</td>");
      document.writeln("<td>");
        document.writeln("<img src=\"" + level + "/_htmlImages/blue_sphere.gif\">");

	if (pval == "CAT") document.writeln(" : Llibres");
	else if (pval == "ES") document.writeln(" : Libros");
	else document.writeln(" : Books");

      document.writeln("</td>");
    document.writeln("</tr>");
  document.writeln("</table>");
      document.writeln("</td>");
    document.writeln("</tr>");
  document.writeln("</table>");      
*/
}



// Return the url parameter
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;
}




// Set the style documents, with language selection
function Style()
{
  document.writeln("<style type=\"text/css\">");
    document.writeln("body {");
      document.writeln("background : #ffffff;");
      document.writeln("font-family : Verdana, Lucida, sans-serif");
    document.writeln("}");
    document.writeln("body, tr, td {");
      document.writeln("font-size : 95%");
    document.writeln("}");

  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 the resource fields in function of current language
function WriteResource(entity, amount, period, director)
{
  document.writeln("<div class=\"cat\">");
    document.writeln("<ul>");
      document.writeln("<li> Empresa/Instituci&oacute; : " + entity + "</li>");
      document.writeln("<li> Import : " + amount + "</li>");
      document.writeln("<li> Per&iacute;ode : " + period + "</li>");
      document.writeln("<li> Director : " + director + "</li>");
    document.writeln("</ul>");
  document.writeln("</div>");

  document.writeln("<div class=\"es\">");
    document.writeln("<ul>");
      document.writeln("<li> Empresa/Institucion : " + entity + "</li>");
      document.writeln("<li> Importe : " + amount + "</li>");
      document.writeln("<li> Periodo : " + period + "</li>");
      document.writeln("<li> Director : " + director + "</li>");
    document.writeln("</ul>");
  document.writeln("</div>");

  document.writeln("<div class=\"uk\">");
    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>");
  document.writeln("</div>");

}

// Write the resource fields in function of current language
function WriteResource2(entity, period, director)
{
  document.writeln("<div class=\"cat\">");
    document.writeln("<ul>");
      document.writeln("<li> Empresa/Instituci&oacute; : " + entity +
      "</li>");
      document.writeln("<li> Per&iacute;ode : " + period + "</li>");
      document.writeln("<li> Director : " + director + "</li>");
    document.writeln("</ul>");
  document.writeln("</div>");

  document.writeln("<div class=\"es\">");
    document.writeln("<ul>");
      document.writeln("<li> Empresa/Institucion : " + entity + "</li>");
      document.writeln("<li> Periodo : " + period + "</li>");
      document.writeln("<li> Director : " + director + "</li>");
    document.writeln("</ul>");
  document.writeln("</div>");

  document.writeln("<div class=\"uk\">");
    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>");
  document.writeln("</div>");

}

// 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("<div class=\"cat\">");
    document.writeln("<ul>");
      document.writeln("<li> Entitat finan&ccedil;adora : " + entity +
      "</li>");
      document.writeln("<li> Import : " + amount + "</li>");
      document.writeln("<li> Per&iacute;ode : " + period + "</li>");
      document.writeln("<li> Director : " + director + "</li>");
      document.writeln("<li> Grups participants : " + group + "</li>");
    document.writeln("</ul>");
  document.writeln("</div>");

  document.writeln("<div class=\"es\">");
    document.writeln("<ul>");
      document.writeln("<li> Entidad financiadora : " + entity + "</li>");
      document.writeln("<li> Importe : " + amount + "</li>");
      document.writeln("<li> Periodo : " + period + "</li>");
      document.writeln("<li> Director : " + director + "</li>");
      document.writeln("<li> Grupos participantes : " + group + "</li>");
    document.writeln("</ul>");
  document.writeln("</div>");

  document.writeln("<div class=\"uk\">");
    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>");
  document.writeln("</div>");

}

