/* wwwopac.js  Copyright (C) 1999 Databasix Information Systems B.V. 
    Description: 
      Contains general javascript functions for WWWOPAC pages.
   
    History:        
    1998.11.20 AAE Initial coding.

*/  

var WhatAmI

// ThisIs
//
// This function tries to figure out what browser and what
// version of javascript is being used.
//
function ThisIs ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()

    // *** BROWSER VERSION ***
    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)

    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major == 4))
    this.nav4up = this.nav && (this.major >= 4)
    this.navonly      = (this.nav && (agt.indexOf(";nav") != -1))

    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = (this.ie && (this.major == 4))
    this.ie4up  = this.ie  && (this.major >= 4)

    this.opera = (agt.indexOf("opera") != -1)

    // *** Javascript Version ***
    if (this.nav2 || this.ie3) this.js = 1.0
    else if (this.nav3 || this.opera) this.js = 1.1
    else if (this.nav4 || this.ie4) this.js = 1.2
    else if ((this.nav && (this.minor > 4.05)) || (this.ie && (this.major > 4)))
         this.js = 1.2
    else this.js = 0.0 
}

// EnterCheck
//
// Checks if the enter key was pressed
//
function enterCheck(field,event)
{ 
  if (WhatAmI.ie) 
    keycode=event.keyCode;
  else if (WhatAmI.nav4)
    keycode=event.which;
  if (keycode == 13 &&
      WhatAmI.js >= 1.2 &&
	  field.value != '')
  { 
      field.form.submit();
  }
}	 

//
// theslink
// 
// This function uses a form called 'thesau' to commit a query
// Parameters:
//    dbase: database name
//    tag:   query tag
//    field: field in the original form containing the query value
//
function theslink(dbase, tag, field)
  {
    document.thesau.DATABASE.value = dbase;
    document.thesau.FLD1.value = tag;
    if (field.value != ''){
      newwindow = window.open('loadingpage.htm','LIST','top=160,left=40,width=650,height=400,scrollbars=yes,toolbar=no');
      newwindow.focus();
      document.thesau.VAL1.value = field.value;
      document.thesau.target = 'LIST';
      document.thesau.submit();
    } else {
	  switch (document.thesau.LANGUAGE.value) {
        case '0': alert ('no value entered!');
 	      break;
        case '1': alert ('geen waarde ingevuld!');
	      break;
        case '2': alert ('ne rempliez pas une valeur!');
	      break;
		default:   alert ('no value entered at all!');
		  break;
	  
      }
    }
  }


// opacbuttons
//
// Shows the appropriate buttons
//
function opacbuttons()
{
    if (WhatAmI.js< 1.1) {
	  switch (document.form.LANGUAGE.value) {
        case '0': document.write('<INPUT TYPE="reset" NAME="reset" VALUE="Reset Form">');
 	      break;
        case '1': document.write('<INPUT TYPE="reset" NAME="reset" VALUE="Wis formulier">');
	      break;
        case '2': document.write('<INPUT TYPE="reset" NAME="reset" VALUE="Recommencer">');
	      break;
		default:  document.write('<INPUT TYPE="reset" NAME="reset" VALUE="Reset">');
		  break;
	  
      }
    } else {
	  switch (document.form.LANGUAGE.value) {
        case '0': document.write('<A HREF="javascript:document.form.reset()"><IMG SRC="/adlib/icons/cleargb.gif" ALT="Reset Form" BORDER="0"></A>');
 	      break;
        case '1': document.write('<A HREF="javascript:document.form.reset()"><IMG SRC="/adlib/icons/clearnl.gif" ALT="Wis formulier" BORDER="0"></A>');
	      break;
        case '2': document.write('<A HREF="javascript:document.form.reset()"><IMG SRC="/adlib/icons/clearfr.gif" ALT="Recommence le formulaire" BORDER="0"></A>');
	      break;
		default:  document.write('<A HREF="javascript:document.form.reset()"><IMG SRC="/adlib/icons/cleargb.gif" ALT="Reset" BORDER="0"></A>');
		  break;
	  }
    }

}
// Determine browser/javascript version

WhatAmI = new ThisIs();

// Andrew's functions added 11/10/2000
  
 function DisplayData() {
    newwindow = window.open('loadingpage.htm','DATA','top=160,left=40,width=650,height=400,scrollbars=yes,toolbar=no')
    newwindow.focus()
    return true
  }
  
  
 function Displaylist() {
    newwindow = window.open('loadingpage.htm','LIST','top=160,left=40,width=650,height=400,scrollbars=yes,toolbar=no')
    newwindow.focus()
    return true
  }

 function DisplayDetail() {
    newwindow = window.open('loadingpage.htm','DETAIL','top=160,left=40,width=650,height=400,scrollbars=yes,toolbar=no')
    newwindow.focus()
    return true
  }
  
 function DisplayImage() {
    newwindow = window.open('loadingpage.htm','IMAGE','top=1,left=1,width=800,height=600,scrollbars=yes,toolbar=no')
    newwindow.focus()
    return true
  }

// Yvette function for executing link from list (and then closing the window)
function Link (url)
{
  OpenWin = this.open(url,"zoek","");
  OpenWin.focus();
  javascript:window.close();
}


