function imprSelec(nombre)
{
var ficha = document.getElementById(nombre);
var ventimp = window.open(' ', 'popimpr');
var style = ('<link rel="stylesheet" type="text/css" href="http://busc.usc.es/inclue/defecto.css">');
var logo = ('<p class="esquerda"><img src="http://busc.usc.es/images/novologo1.gif" valing="absmiddle"><span class="titulo">   Biblioteca Universitaria</span></p><br><table width="90%" class="esquerda"><tr><td class="esquerda">');
var copy = ('</td></tr></table><p>© BUSC</p>');
ventimp.document.write(style, logo, ficha.innerHTML, copy );
ventimp.document.close();
}



// --- Functions relating to the Printer Friendly page ----
function printer() {
  document.location=document.location+"?_print=true";
}

function printMode() {
	  if (String(document.location).match("_print=true")) {
 document.write('<link rel="stylesheet" type="text/css" href="http://busc.usc.es/inclue/imprimir1.css">');
 document.close();
  }
}


function url()
{
var url = window.location.href;
url = unescape(url);
url = url.replace("http://busc.usc.es/", "http://busc.usc.es/negativo/");
document.write("<a href="+(url)+">versi&oacute;n con contraste negativo</a>");
}


//function controlling the collapsable portions of the menus
function toggleLayer(whichLayer)
{
if (document.getElementById)
{
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}

function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes, resizable=yes"; 
  var content_vlue = document.getElementById("seleccion").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Cat&aacute;logo da Biblioteca Universitaria de Santiago de Compostela</title>'); 
   docprint.document.write('<link rel="stylesheet" type="text/css" href="http://busc.usc.es/inclue/imprimir1.css">');
   docprint.document.write('</head><body><table><tr><td>');          
   docprint.document.write('<table width="100%" summary="Biblioteca Universitaria de Santiago de Compostela"><tr><td width="100%">');          
   docprint.document.write('<a href="http://www.usc.es"><img src="http://busc.usc.es/images/novologo1.gif" alt="Logotipo da Universidade de Santiago de Compostela"></a>&nbsp;<h1>Cat&aacute;logo da Biblioteca Universitaria de Santiago de Compostela</h1></td></tr>');          
   docprint.document.write('<tr><td>'); 
   docprint.document.write(content_vlue);          
   docprint.document.write('</td></tr><tr><td>&copy; BUSC</td></tr>');          
   docprint.document.write('</td></tr></table></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}



function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  if ((cookie == "s1") || (cookie == "s2") || (cookie == "s3"))  {
  	cookie="";
  }
  //alert (cookie);
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

//Borrar value por defecto del formulario//
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

