
  // ================
  // Common functions
  // ================

  function openWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
  }

  function closeWindow() {
    top.window.close()
  }

  function focusWindow() {
    window.focus()
  }

  function previousPage() {
    history.go(-1)
  }

  function arrayIndex(s, a) {

    // Returns the index position of the element in the array (or -1 if the element does not exist in the array).
    for (var i=0; i<a.length; i++) if (a[i] == s) return i;
    return -1;

  }

  function reloadOpener() {

    if(top.opener) top.opener.location = top.opener.location;
    window.focus();

  }


  function focusFirstField() {

    // Sets the focus on the first textfield
    with(document.form_01) {
      for (var i=0; i<elements.length; i++) {
        if (elements[i].type == 'text' || elements[i].type == 'file') {
          elements[i].focus();
          break;
        }
      }
    }

  }

  function openMijnKunstuitleen() {

    var sProperties = 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = screen.availWidth - 150;
    var iHeight     = screen.availHeight - 250;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=mijn_frameset', 'mijn_frameset_kunstuitleen', sProperties);
    oWin.focus();

  }

  function openColofon() {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=colofon', 'colofon', sProperties);
    oWin.focus();

  }

  function openCopyright() {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=copyright', 'copyright', sProperties);
    oWin.focus();

  }

  function openHelp() {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=help', 'help', sProperties);
    oWin.focus();

  }

  function openDisclaimer() {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=disclaimer', 'disclaimer', sProperties);
    oWin.focus();

  }

  function openZoekenHelp() {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=zoeken_help', 'zoeken_help', sProperties);
    oWin.focus();

  }

  function openHuiskamer() {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
    var iWidth      = 640;
    var iHeight     = 480;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=huiskamer', 'huiskamer', sProperties);
    oWin.focus();

  }

  function selectKunstwerk(sKunstwerkId, sSkin) {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=kunstwerk_select&kunstwerk_id=' + sKunstwerkId + '&skin=' + sSkin, 'kunstwerk_reserve', sProperties);
    oWin.focus();

  }

  function reserveKunstwerk(sKunstwerkId, sSkin) {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
    var iWidth      = 400;
    var iHeight     = 350;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=kunstwerk_reserve&kunstwerk_id=' + sKunstwerkId + '&skin=' + sSkin, 'kunstwerk_select', sProperties);
    oWin.focus();

  }

  function printKunstwerk(sKunstwerkId) {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = screen.availWidth - 100;
    var iHeight     = screen.availHeight - 200;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=kunstwerk_print&kunstwerk_id=' + sKunstwerkId, 'kunstwerk_print', sProperties);
    oWin.focus();

  }

  function mailKunstwerk(sKunstwerkId, sSkin) {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
    var iWidth      = 400;
    var iHeight     = 300;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=kunstwerk_mail&kunstwerk_id=' + sKunstwerkId + '&skin=' + sSkin, 'kunstwerk_mail', sProperties);
    oWin.focus();

  }

  function zoomKunstwerk (sKunstwerkId, sSkin) {

    var sProperties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
    var iWidth      = screen.availWidth - 100;
    var iHeight     = screen.availHeight - 200;
    var iLeft       = (screen.availWidth - iWidth) / 2;
    var iTop        = (screen.availHeight - iHeight) / 2;
    var sProperties = 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',' + sProperties;
    var oWin        = window.open('index.php?option=kunstwerk_zoom&kunstwerk_id=' + sKunstwerkId + '&skin=' + sSkin, 'kunstwerk_zoom', sProperties);
    oWin.focus();

  }

  function isEmpty(oText) {

    var s = oText.value;
    var iLength = s.length;
    if (iLength==0) return true;
    for (var i=0; i<iLength; i++ ) {
      if (s.charAt(i) != ' ') return false;
    }
    return true;

  }

  function isEmail(s) {

  	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
  	return(email.test(s));

  }

  function isValidPassword(s) {

    var iLength = s.length;
    if (iLength < 6) return false;
    for (var i=0; i<iLength; i++ ) {
      if (s.charAt(i) == ' ') return false;
    }
    return true;

  }
  
  
  function wordAbonnee() {
    
    var sLocation = 'index.php?option=com_abonnee&Itemid=57';
    if (opener.opener) {
      opener.opener.location = sLocation;
      if (opener) opener.close();
      window.close();
    } else if (opener) {
      opener.location = sLocation;
      window.close();
    } else {
      window.location = sLocation;
    }
    
  }
  
  

