









var win = new Array();

function openPopup(name,url,size,title) {
      // open a new window
      // Note: title no longer used.
      //       It was used when we used to create a frameset
      win[name] = window.open(url,name,size);
//This seems to cause a JS error on NS6, most platforms.
//    if( ! (navigator.appName == "Navigator"
//	&& navigator.appVersion.indexOf("5.0") != -1)){
//	win[name].focus();
//    }
      if(win[name] != null && (win[name].closed == false) ){
  win[name].focus();
      } else {
  return false;
      }
}

function startWizard()
{
  openPopup("wizard", "http://cosh.horizonwimba.com:80/cosh/wizard/launcher.jsp", "scrollbars=no,resizable=yes,width=700,height=500");
}





/* *********************** Operating Systems (general) ******************** */
function w_is_Mac() {
  return ( navigator.appVersion.indexOf("Mac") != -1 );
}

function w_is_Windows() {
  return ( navigator.appVersion.indexOf("Win") != -1 );
}

function w_is_Linux() {
  return ( navigator.appVersion.indexOf("Linux") != -1 );
}

/* *********************** Operating Systems (specific) ******************** */

function w_is_Windows95() {
  MozillaSays = ( navigator.userAgent.indexOf("Win95") != -1 );
  IEsays = ( navigator.userAgent.indexOf("Windows 95") != -1 );
  return ( MozillaSays || IEsays );
}

function w_is_WindowsME() {
  return ( navigator.userAgent.indexOf("Win 9x 4.90") != -1 );
}

function w_is_Windows98() {
  MozillaSays = ( navigator.userAgent.indexOf("Win98") != -1 );
  IEsays = ( navigator.userAgent.indexOf("Windows 98") != -1 );
  return ( MozillaSays || IEsays );
}

function w_is_WindowsNT() {
  MozillaSays = ( navigator.userAgent.indexOf("WinNT") != -1 );
  IEsays = ( navigator.userAgent.indexOf("Windows NT") != -1 ) &&
           ( navigator.userAgent.indexOf("Windows NT 5.0") == -1 ) &&
           ( navigator.userAgent.indexOf("Windows NT 5.1") == -1 );
  return ( MozillaSays || IEsays );
}

function w_is_Windows2000() {
  return ( navigator.userAgent.indexOf("Windows NT 5.0") != -1 );
}

function w_is_WindowsXP() {
  return ( navigator.userAgent.indexOf("Windows NT 5.1") != -1 );
}

function w_is_MacOSX() {
  if ( ! w_is_Mac() ) {
    return false;
  }
  else return (        // Without the parenthesis, the parser would stop at the end of the line.
	(navigator.userAgent.indexOf("Mac OS X") > 0) ||
	(navigator.userAgent.indexOf("MacOS X") > 0) ||
	(navigator.userAgent.indexOf("MacOSX") > 0) ||
	(
		(navigator.userAgent.indexOf("MSIE") > 0) &&
		(navigator.userAgent.indexOf("MSIE 4.") < 0) &&
		(navigator.userAgent.indexOf("MSIE 5.0") < 0) &&
		(navigator.userAgent.indexOf("MSIE 5.12") < 0) &&
		(navigator.userAgent.indexOf("MSIE 5.13") < 0) &&
		(navigator.userAgent.indexOf("MSIE 5.14") < 0)
	) );

}

function w_is_MacOS89() {    // Indicates MacOS 8 or 9.
  return w_is_Mac() && !w_is_MacOSX();   // Not very elegant, but it works for now.
}

function w_get_OS() {    // Returns a human-readable description of the operating system.
  if ( w_is_Windows() ) {
    if ( w_is_Windows95() ) return "Windows 95";
    if ( w_is_Windows98() ) return "Windows 98 or Windows ME";
    if ( w_is_WindowsME() ) return "Windows ME";
    if ( w_is_WindowsNT() ) return "Windows NT";
    if ( w_is_Windows2000() ) return "Windows 2000";
    if ( w_is_WindowsXP() ) return "Windows XP";
    return "Windows";    // When all else fails, be general.
  }
  else if ( w_is_Mac() ) {
    if ( w_is_MacOSX() ) return "MacOS X";
    if ( w_is_MacOS89() ) return "MacOS 8/9";
    return "MacOS";      // As with Windows, when all else fails, be general.
  }
  else {
    return "unknown operating system";
  }
}

/* *********************** Browsers ******************** */

function w_is_IE() {
  // No platform that I know of uses indexOf("Internet Explorer"),
  // but I include it for good measure.
  return ( navigator.userAgent.indexOf("MSIE") != -1 ) || ( navigator.userAgent.indexOf("Internet Explorer") != -1 );
}

function w_is_AOL() {
  // No platform that I know of uses indexOf("AOL"),
  // but I include it for good measure.
  return ( navigator.userAgent.indexOf("AOL") != -1 );
}

function w_is_Safari() {
  return ( navigator.userAgent.indexOf("Safari") != -1 );
}

function w_is_Mozilla() {    // Includes both Netscape and Mozilla.
  // Many browsers try to pretend they are Mozilla, but they add
  // "(compatible; really some other browser)" on the end.
  return ( navigator.userAgent.indexOf("Mozilla") != -1 ) && ( navigator.userAgent.indexOf("(compatible") == -1 ) && !w_is_IE() && !w_is_Safari();
}

function w_is_Firefox() {
  // Firefox browser
  return ( navigator.userAgent.indexOf("Firefox") != -1 ) ;
}

function w_is_Opera() {
  // Obviously, this function only works if Opera
  // chooses to admit that it's Opera.
  return ( navigator.userAgent.indexOf("Opera") != -1 );
}


function w_get_browser_version() {   // Returns browser version as a float (NOT a string).
  if ( w_is_AOL() ) {
      searchFor = "AOL ";
  }
  else if ( w_is_IE() ) {
    searchFor = "MSIE ";
  }
  else if ( w_is_Opera() ) {
    searchFor = "Opera/";
  }
  else if ( w_is_Safari() ) {
    searchFor = "Safari/";
  }
  else if ( w_is_Firefox() ) {
    searchFor = "Firefox/";
  }
  else if ( w_is_Mozilla() ) {
    searchFor = "Mozilla/";
  }
  else {
    searchFor = "/";    // Take a wild guess.
  }
  startSearch = navigator.userAgent.indexOf(searchFor);
  if ( startSearch == -1 ) {
    return null;     // No match; return null.
  }
  else {
    startSearch += searchFor.length;
    ua = navigator.userAgent;
      // Here we use parseFloat, which is tolerant of
      // non-digits after the number.
    result = parseFloat( ua.substring(startSearch,ua.length) );
    if ( result > 0.01 ) {
      return result;
    }
    else {
      return null;
    }
  }
}


function w_get_browser() {   // Returns browser (with version) as string.
  version = w_get_browser_version();
  if ( version == null ) version = "";   // In case version can't be detected.

  if ( w_is_AOL() ) {
      browser = "AOL";
  }
  else if ( w_is_IE() ) {
    browser = "Internet Explorer";
  }
  else if ( w_is_Opera() ) {
    browser = "Opera";
  }
  else if ( w_is_Safari() ) {
    browser = "Safari";
  }
  else if ( w_is_Firefox() ) {
    browser = "Firefox or Netscape";
    version = "";
  }
   else if ( w_is_Mozilla() ) {
    if ( version < 5.0 ) {
      browser = "Netscape";
    }
    else {
      if ( navigator.userAgent.indexOf("Netscape6") != -1 ) {
        browser = "Netscape";
        version = 6;
      }
      else {
        browser = "Mozilla or Netscape";
        version = "";   // We can't detect minor versions, so it's all Mozilla 1.
      }
    }
  }
  else return "unknown browser";   // Stop here if we don't know the browser brand.

  return browser + " " + version;
}



/*
 * The following function determines any incompatibilities
 * in the user's platform. If the operating system is
 * not supported, returns "os". If the browser is not
 * supported, returns "browser". If the browser is
 * supported but needs Sun's Java 2 plug-in, returns
 * "plugin". If there is no incompatibilty, returns false.
 */
function w_not_supported()
{
  ///////////// Mac ///////////////
  if ( w_is_Mac() ) {
    if ( w_is_MacOS89() ) {
      return "os";
    }
    else if ( w_is_Firefox() ) {
      if (w_get_browser_version() < 1.5 ) {
        return true;
      }
      else {
        return false;
      }
    }
    else if ( w_is_Mozilla() ) {
      return "browser";
    }
    else if ( w_is_IE() ) {
      return "browser";
    }
    else if ( w_is_Safari() ) {
      if (w_get_browser_version () < 100 ) {// initial version of Safari on Panther
 	      return "browser";
 	    }
 	    else {
        return false;
      }
    }
    else return "browser";
  }
  ////////// Windows //////////////
  else if ( w_is_Windows() ) {
    if ( w_is_Windows95() ) {
      return "os";
    }
    else if ( w_is_Mozilla() ) {
      if ( w_get_browser_version() < 4.7 && !w_is_Firefox())
        return "browser";
      else return false;
    }
    else if ( w_is_IE() ) {
      if ( w_get_browser_version() < 5.0 )
       return "browser";
    }
    else if ( w_is_Opera() ) {
      if ( w_get_browser_version() < 6.0 )    // No point in complaining about Opera.
        return "browser";
    }
    else
      return "browser";
  }
  //////// Other Operating Systems ////////
  else {
    return "os";    // Unknown operating system.
  }
  return false;     // If we get here, no problems.
}

function w_component(p)
{
  if (document.URL.substring(0,4) == "file") {
    document.writeln("Wimba applet will be here");
    document.writeln("<br><font size=\"-1\"><i>(The applet will appear only on web pages served by a web server, not on web pages accessed through the file system)</i></font>");
    return;
  }

  w_s(p,"align","baseline",false);
  w_s(p,"codebase","http://cosh.horizonwimba.com:80",false);
  w_s(p,"context_path","/cosh",false);
  w_s(p,"font","Arial Unicode MS, Dialog",false);
  //w_s(p,"font","Arial Unicode MS, Bitstream Cyber CJK, Code2000, Dialog", false);
  w_s(p,"loglevel","warn",false);

  ////////// Macintosh //////////
  if ( w_is_Mac() ) {
    w_applet(p)
  }

  //////////// Win32 //////////
  else if ( w_is_Windows() ) {
    // Internet Explorer
    if ( w_is_IE() ) {
      w_object(p);
    }
    // Netscape: use EMBED if have Sun's Java 2 plugin.
    else if ( w_is_Mozilla()) {
      w_embed(p);
    }
    else {
      w_applet(p);
    }
  }

  //////////// Linux, Solaris, etc. (probably Netscape) ////////////
  else {
    w_applet(p);
  }

  if (p.diagnostic == "true" || p.popup == "true") {
    document.write("<p class=\"smaller\">");
  }
  if (p.diagnostic == "true") {

    if ( w_not_supported() ) {
      // TODO: find a better (internationalized) message.
      document.write("Warning: this platform does not appear to be supported.&nbsp;");
    }

    if (p.browser_check_link) {
      document.write("<a href=\"javascript:startWizard();\" class=\"smaller\">Setup Wizard</a>");
    }
  }
  if (p.popup == "true") {
    if (p.diagnostic == "true" && p.browser_check_link) {
      document.write("&nbsp;-&nbsp;");
    }
    document.write("<a href=\"javascript:window.location.reload()\" class=\"smaller\">Refresh</a>");
  }
  if (p.diagnostic == "true" || p.popup == "true") {
    document.write("</p><br>");
  }
}


function w_s(o, name, value, force)
{
  if (force || o[name]==null)
    o[name]=value;
}



function w_applet(p) 
{
  document.writeln("<applet height='" + p.height + "' width='" + p.width + "' ");
  document.writeln("codebase='" + p.codebase + "' ");
  document.writeln("code='" + p.code + "' ");
  document.writeln("id='" + p.id + "' ");
  document.writeln("name='" + p.name + "' ");
  document.writeln("align='" + p.align + "' ");
  document.writeln("archive='" + p.archive + "'>");

  // Because of a bug in Netscape 4, we don't want to
  // send the width and height to the PARAM tags.
  p.width = null;
  p.height = null;

  for (i in p) {
    if (p[i]!=null){
      document.writeln("<param name='"+i+"' value='" + p[i] + "'>");
    }
  }
  document.write("<div class='error'>Java is not installed, or the version of Java is too old.\n");
  document.write("Please, run the <a href='javascript:startwizard()'>Setup Wizard</a> and  select to install Java when prompted.</div>");
  document.writeln("</applet>");
}



function w_object(p)
{

  document.write("<OBJECT ");
  document.write("CLASSID='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' ");
  document.writeln("WIDTH = '" + p.width + "' ");
  document.writeln("HEIGHT = '" + p.height+ "' ");
  document.writeln("CODEBASE = 'http://java.sun.com/update/1.6.0/jinstall-6u26-windows-i586.cab' ");
  document.writeln("STANDBY = 'Wimba Tool loading...' ");
  document.writeln("ARCHIVE = '" + p.archive + "' ");
  document.writeln("TYPE = 'application/x-java-applet' ");
  document.write(">");

  // These result in a bug in Netscape 4.
  // Why take the chance of bugs with other browsers?
  p.width = null;
  p.height = null;

  for (i in p) {
    if (p[i]!=null){
      document.writeln("<param name='"+i+"' value='" + p[i] + "'>");
    }
  }
  document.writeln("<param name='progressbar' value='true'>");
  document.write("<div class='error'>Java is not installed, or the version of Java is too old.\n");
  document.write("Please, run the <a href='javascript:startWizard()'>Setup Wizard</a> and  select to install Java when prompted.</div>");
  document.write("</OBJECT>");
}



function w_embed(p)
{
  document.write("<EMBED ");
  document.writeln("TYPE = 'application/x-java-applet;version=1.4.2' ");
  document.writeln("PLUGINSPAGE = 'http://java.sun.com/j2se/1.5.0/download.html' ");
  for (i in p) {
    if (p[i]!=null){
      document.writeln(i + " = '" + p[i] + "' ");
    }
  }
  document.writeln("></EMBED>");
  document.writeln("<NOEMBED>");
  document.write("<div class='error'>Java is not installed, or the version of Java is too old.\n");
  document.write("Please, run the <a href='javascript:startWizard();'>Setup Wizard</a> and  select to install Java when prompted.</div>");
  document.writeln("</NOEMBED>");
}



function w_ve_play_tag(p)
{
  // Applet tag params
  w_s(p,"width","240", false);
  w_s(p,"height","48", false);
  w_s(p,"name","player",false);
  w_s(p,"id","player",false);
  w_s(p,"archive","http://cosh.horizonwimba.com:80/cosh/code/hwclients.jar",false);
  w_s(p,"code","Player.class",false);

  // JS params
  w_s(p, "diagnostic", "false", false);

  // Applet params
  w_s(p,"server_url","http://cosh.horizonwimba.com:80/cosh/com",false);
  w_s(p,"gui","http://cosh.horizonwimba.com:80/cosh/gui/player/player.zip",false);
  w_s(p,"ErrorMessage","Message does not exist.\\(You need to be online\\to play this message)",false);

  w_component(p);
}

