var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var sObj = InternetExplorer ? "pron" : "document.pron";
var pronunciationPath = "/media/mmhe2/pronunciations";
var checkEvent;

function pronounce(ID, term) {
term = escape(term);
setTimeout('pronounceTerm("'+ID+'","'+term+'");',1);
}

function check_load() {
    if (eval(sObj+".PercentLoaded()") == 100) { 
        clearTimeout(checkEvent);
        setTimeout('eval(sObj+".Play()")',1);
    } 
}

function pronounceTerm(ID, term) {
  var isMacIE = eval(navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
      navigator.userAgent.indexOf("Windows") == -1);
  var isSafari = eval(navigator.userAgent.indexOf("Safari") != -1);
  if (MM_FlashCanPlay && !(isMacIE) && !(isSafari)) {
    setTimeout('eval(sObj+".LoadMovie(0, \''+pronunciationPath+'/'+ID+'.swf\')")',1);
    //wait for load
    checkEvent = setInterval('check_load()', 10);
    } else {
    window.open('/media/mmhe2/pronounce_popup.htm?'+pronunciationPath+'_nostop/'+ID+'&term='+term,'pronounce','width=300,height=100,scrollbars=yes,resizable=yes');
  }
}

// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
      navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
    document.write('<SCRIPT LANGUAGE=VBScript\> \n');
    document.write('on error resume next \n');
    document.write('Sub pron_FSCommand(ByVal command, ByVal args)\n');
    document.write('  call pronounceTerm(command, args)\n');
    document.write('end sub\n');
    document.write('</SCRIPT\> \n');
}

var isBrokenNS = eval(navigator.userAgent.indexOf('Netscape6') != -1);
var MM_contentVersion = 3;
if (isBrokenNS) {
    MM_contentVersion = 7;
}
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
        var words = navigator.plugins["Shockwave Flash"].description.split(" ");
        for (var i = 0; i < words.length; ++i)
        {
        if (isNaN(parseInt(words[i])))
        continue;
        var MM_PluginVersion = words[i]; 
        }
    var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
    document.write('on error resume next \n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
        document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
    document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
    document.write(' ID="pron" WIDTH="1" HEIGHT="1">');
    document.write(' <PARAM NAME=movie VALUE="/media/mmhe2/s.swf"> <PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>  '); 
    document.write(' <EMBED src="/media/mmhe2/s.swf" quality=high bgcolor=#FFFFFF ');
    document.write(' swLiveConnect=TRUE loop=FALSE WIDTH="1" HEIGHT="1" NAME="pron" ');
    document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
    document.write(' </EMBED>');
    document.write(' </OBJECT>');
}
