  function subwinsrch(jj,sww,swh,srcharg) {
    var wprog  = "/cgi-bin/pub/pubsrch"+jj+"?"+srcharg;
    var wname  = "PubSubWindow";
    var wspecs = "toolbar=yes,location=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes";
        wspecs = wspecs+",width="+sww+",height="+swh;
    // alert(wprog+'; '+wname+'; '+wspecs);
    window.open(wprog,wname,wspecs);
  }
  function subwinpage(sww,swh,pageurl) {
    var wname  = "PubSubWindow";
    var wspecs = "toolbar=yes,location=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes";
        wspecs = wspecs+",width="+sww+",height="+swh;
    // alert(wprog+'; '+wname+'; '+wspecs);
    window.open(pageurl,wname,wspecs);
  }

  function USLorder(id) { // Update SELF List (order)
    ordlist = document.forms['PubSearch'].orderlist.value;
    idrex = new RegExp(id, 'i');
    if (ordlist.search(idrex) > -1) {
      alert(id + ' is already in Order List: ' + ordlist + '.');
    } else {
      ordlist = id + ' ' + ordlist;
      alert(id + ' added to Order List.');
    }
    document.forms['PubSearch'].orderlist.value = ordlist;
  }
  function UOLorder(id) { // Update OPENER List (order)
    // alert(':' + opener + ':');
    if (opener == null) {
	UOLorderNO(id);
    } else {
	UOLorderOK(id);
    }
  }
  function UOLorderNO(id) { // No Update of OPENER possible
    alert('Sorry, you cannot yet place an IIASA order via this page. ("' + opener + '")');
  }
  function UOLorderOK(id) { // Update OPENER List (order)
    ordlist = opener.document.forms['PubSearch'].orderlist.value;
    idrex = new RegExp(id, 'i');
    if (ordlist.search(idrex) > -1) {
      alert(id + ' is already in OrderList: ' + ordlist + '.');
    } else {
      ordlist = id + ' ' + ordlist;
      alert(id + ' added to Order List.');
    }
    opener.document.forms['PubSearch'].orderlist.value = ordlist;
  }

  function USLauth(auth) {
    auth = '"' + auth + '"';
    authlist = document.forms['PubSearch'].authors.value;
    authrex = new RegExp(auth, 'i');
    if (authlist.search(authrex) > -1) {
      alert(auth + ' is already in AuthorList: ' + authlist + '.');
    } else {
      authlist = authlist + ' ' + auth;
    }
    document.forms['PubSearch'].authors.value = authlist;
  }
  function UOLauth(auth) {
    auth = '"' + auth + '"';
    authlist = opener.document.forms['PubSearch'].authors.value;
    authrex = new RegExp(auth, 'i');
    if (authlist.search(authrex) > -1) {
        alert(auth + ' is already in AuthorList: ' + authlist + '.');
    } else {
        authlist = authlist + ' ' + auth;
    }
    opener.document.forms['PubSearch'].authors.value = authlist;
  }

  function UOLprog(prog) {
    proglist = opener.document.forms['PubSearch'].programs.value;
    progrex = new RegExp(prog, 'i');
    if (proglist.search(progrex) > -1) {
        alert(prog + ' is already in ProgramList: ' + proglist + '.');
    } else {
        proglist = proglist + ' ' + prog;
    }
    opener.document.forms['PubSearch'].programs.value = proglist;
  }

  function UOLtype(type) {
    typelist = opener.document.forms['PubSearch'].types.value;
    typerex = new RegExp(type, 'i');
    if (typelist.search(typerex) > -1) {
        alert(type + ' is already in TypeList: ' + typelist + '.');
    } else {
        typelist = typelist + ' ' + type;
    }
    opener.document.forms['PubSearch'].types.value = typelist;
  }

  function UOLyear(year) {
    yearlist = opener.document.forms['PubSearch'].years.value;
    yearrex = new RegExp(year, 'i');
    if (yearlist.search(yearrex) > -1) {
        alert(year + ' is already in YearList: ' + yearlist + '.');
    } else {
        yearlist = yearlist + ' ' + year;
    }
    opener.document.forms['PubSearch'].years.value = yearlist;
  }
  function UOLyrange(year) {
    yearlist = opener.document.forms['PubSearch'].years.value;
    yearrex = new RegExp(year, ' ');
    if (yearlist.search(yearrex) > -1) {
        alert(year + ' is already in YearList: ' + yearlist + '.');
    } else {
        yearlist = yearlist + '-' + year;
    }
    opener.document.forms['PubSearch'].years.value = yearlist;
  }

  function GetPubCookie(cookieName) {
    cookieName = 'IIPUBSRCH.'+cookieName;
    var theCookie=''+document.cookie;
    var beg=theCookie.indexOf(cookieName);
    var doccookie = 'GET:'+unescape(theCookie.substring(beg,beg+100));
    if (beg==-1) return ''; 
    var end=theCookie.indexOf(';',beg); if (end==-1) end=theCookie.length; 
    return unescape(theCookie.substring(beg+cookieName.length+1,end));
  }
  function SetPubCookie(cookieName,cookieValue) {
    var today = new Date(); var expire = new Date(); var nDays = null;
    if (nDays==null || nDays==0) nDays=365;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    cookieName = 'IIPUBSRCH.'+cookieName;
    var doccookie = 'SET:'+cookieName+'='+cookieValue+';expires='+expire.toGMTString();
    document.cookie = cookieName+'='+escape(cookieValue)+';expires='+expire.toGMTString();
  }
