/* Copyright (c)2002 ELR Software Pty Ltd. http://www.elr.com.au   */
/*                                                                 */
/* This program is free software; you may use, redistribute and/or */
/* modify it under the terms of the GNU General Public License as  */
/* published by the Free Software Foundation; either version 2 of  */
/* the License, or (at your option) any later version.             */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of  */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.            */
/* See the GNU General Public License for more details.            */
/* http://www.fsf.org/home.html                                    */

/* WordCue Master Object - contains generic methods to control WordCue */
function wordcueMaster () {
  this.WCObjectTag = '<object id="EIAWordCue" classid="clsid:73B989AC-7127-11D5-B5C2-00002123BA28"></object>';
  this.WCLoaded    = checkWCLoaded(this); /* Is WordCue loaded? */
  this.WCTogState  = function() {         /* Get WordCue Toggle state */
    if (this.WCLoaded) {return (EIAWordCue.Toggle) ? true : false;}
    else {return(false);}
  }
  this.WCButtonFix = function(s) {return(s+'<span style="display:none">.</span>')}; /* Fix for string in a button to ensure WC see the last word */
  this.HoldToggle  = false;               /* Holder for WordCue Toggle state */
  this.toggleWC    = function(onoff) {    /* Toggle toggle */
    if (this.WCLoaded) {
      switch (onoff) {
        case 0: {
          this.HoldToggle   = EIAWordCue.Toggle;
          EIAWordCue.Toggle = false;
          break;
        }
        case 1: {
          EIAWordCue.Toggle = this.HoldToggle;
          break;
        }
      }
    }
  }
}/* End Object */

/* Check if WordCue is available */
function checkWCLoaded(obj) {
  var wcpresent = false
  var wcloaded = false;
  for (var i = 0; i < document.applets.length; i++) {
    if ((obj.WCObjectTag.indexOf(document.applets(i).name) >= 0) &&
        (obj.WCObjectTag.indexOf(document.applets(i).classid) >= 0)) {
          wcpresent = true;
        }
  }
  if (wcpresent && ('['+EIAWordCue.Enabled+']' != '[undefined]')) {
    if ((EIAWordCue.Settings >= 0) && EIAWordCue.Enabled) {wcloaded = true}
  }
 /* alert(wcloaded); */
 return(wcloaded);
}

/* Create a WCMaster object */
var WC = new wordcueMaster();
