function getWinNm() {
// Genera un nom de finestra per a poder-ne obrir mes d'una
///////////////////////////////////////////////////////////
  var now = new Date();
  var hr = new String(now.getHours());
  var mn = new String(now.getMinutes());
  var sc = new String(now.getSeconds());
  var ms = new String(now.getMilliseconds());
  var winNm = hr + mn + sc + ms;
  return winNm;
}

function obtNumSesWok(s) { //s es el tipus de retorn --> '0' Retorna session, '1' oldsession, '2' tots dos.
  var nargs = new Number(arguments.length);
  var ns = new String();
  var s_nou = new String(''); 
  var s_vell = new String('');
    
  if (nargs<1) s = '0';
  cad=""+document.location;
  p=cad.search(/\?s=/);
  p2=cad.search(/\&o=/);
  if (p == -1) p=cad.search(/\&s=/);
  if (p2 == -1) p2=cad.search(/\?o=/);
  
  if (p != -1) s_nou = cad.substring(p+3,p+3+128);
  if (p2 != -1) s_vell = cad.substring(p2+3,p2+3+128);
	  
  //Retorna session, oldsession o tots dos segons el paràmetre passat.
  switch(s) {
    case '0': if (p == -1) return null;
    		  ns = s_nou;
              break;
    case '1': if (p2 == -1) return null;
    		  ns = s_vell;
              break;
    case '2': if ((p == -1) && (p2 == -1)) return null;
    		  ns = s_nou + s_vell;
              break;
    default:  break;
  }
  return ns;
  
}

function obreBiblioteca(s) { // s es la direccio que volem obrir
  //Les sessions les guardem de les cookies
  var cookie_s_nou = 'sCampus';
  var cookie_s_vell = 'sCampusAntiga';

  var appid = new String(s);
  var idioma = new String(top._langRel);
  if (idioma=='/c') var adr = new String('http://biblioteca.uoc.edu/eng') ;
  else var adr = new String(s) ;
  var nom = new String();
  var numSes = readCookie(cookie_s_nou);
//alert('numSes' + numSes);
  var oldNumSes = readCookie(cookie_s_vell);
//alert('oldNumSes' + oldNumSes);
  nom = 'sessio' + numSes + 'sessiovell' + oldNumSes + 'appid' + 'UOC';
  var altura=screen.height; 
  var anchura=screen.width;
  var vent_x=770;
  var vent_y=500;
  var posx=(screen.width/2)-400;
  var posy=(screen.height/2)-300;
//alert('nom' + nom);
  var finestra = window.open(adr,nom,'resizable=1,toolbar=1,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=770,height=500,screenX='+posx+',screenY='+posy+',left='+posx+',top='+posy+'');
}
