//
// Copyright 2006 by Rainer Typke. All rights reserved.
//

function searchingpleasewait() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Suche l&auml;uft... Bitte warten.";
  if (url.indexOf('zh.') > -1)
    return "&#27491;&#22312;&#25628;&#32034;...&#35831;&#31245;&#20505;";
  if (url.indexOf('fr.') > -1)
    return "Recherche&nbsp;en&nbsp;cours...&nbsp;Veuillez&nbsp;patienter";
  return "Searching... Please Wait";
}
function directoryurl() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "verzeichnis";
  if (url.indexOf('zh.') > -1)
    return 'baike';
  if (url.indexOf('fr.') > -1)
    return "encyclopedie";
  return "directory";
}
function contoururl() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "kontur";
  if (url.indexOf('zh.') > -1)
    return 'contour';
  return "contour";
}
function searchmusipedia() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Suchen";
  if (url.indexOf('zh.') > -1)
    return '&#25628;&#32034; Musipedia';
  if (url.indexOf('fr.')>-1)
    return "Rechercher sur Musipedia";
  return "Search";
}
function searchtheweb() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Suche im Internet";
  if (url.indexOf('zh.') > -1)
    return '&#25628;&#32034;&#32593;&#39029;';
  if (url.indexOf('fr.')>-1)
    return "Rechercher sur le Web";
  return "Search the Web";
}
function pleaseenter() {
  var url=document.location.href;
  if (url.indexOf('melody_editor') > -1)
    return "";
  if (url.indexOf('de.') > -1)
    return "Bitte geben Sie mindestens 5 Noten ein.";
  if (url.indexOf('zh.') > -1)
    return '&#35831;&#36755;&#20837;&#33267;&#23569;5&#20010;&#38899;&#31526;';
  if (url.indexOf('fr.') > -1)
    return "Veuillez entrer au moins 5 notes avant de lancer la recherche.";
  return 'Please enter at least 5 notes before searching.';
}
function getplay() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Abspielen";
  if (url.indexOf('zh.') > -1)
    return '&#28436;&#22863;';
  if (url.indexOf('fr.') > -1)
    return "Ecouter";
  return 'Play';
}
function getplaying() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Abspielen l&auml;uft...";
  if (url.indexOf('zh.') > -1)
    return '&#27491;&#22312;&#28436;&#22863;...';
  if (url.indexOf('fr.') > -1)
    return "Ecoute en cours";
  return 'Playing...';
}
function gettapping() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Rhythmus-Aufnahme l&auml;uft. Bitte dr&uuml;cken Sie eine beliebige Taste im gew&uuml;nschten Rhythmus.<br/><b>Wenn Sie fertig sind, klicken Sie hier!</b>";
  if (url.indexOf('zh.') > -1)
    return '&#27491;&#22312;&#24405;&#21046;...&#35831;&#25353;&#24076;&#26395;&#30340;&#33410;&#22863;&#36731;&#25293;&#20219;&#24847;&#38190;&#12290;&#23436;&#25104;&#21518;&#28857;&#20987;"&#20572;&#27490;&#36731;&#25970;"&#12290;';
  if (url.indexOf('fr.') > -1)
    return "Enregistrement... Tapez le rythme souhait&eacute; avec n'importe quelle touche.<br/><b>Cliquez ici</b> pour terminer!";
  return 'Recording... Please tap any key in the desired rhythm.<br/><b>Click here</b> when you are done!';
}
function getthisisrh() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Sie k&ouml;nnen jetzt:<ul><li>entweder gleich auf den Suchknopf unten rechts klicken</li><li>oder vorher noch Suchphrasen und/oder Kategorien eingeben, falls gew&uuml;nscht</li></ul>";
  if (url.indexOf('zh.') > -1)
    return '<ul><li>&#29616;&#22312;&#20320;&#21487;&#20197;&#28857;&#20987;&#21491;&#19979;&#26041;&#30340;&#25628;&#32034;&#25353;&#38062;</li><li>&#25110;&#22312;&#25628;&#32034;&#21069;&#36755;&#20837;&#20851;&#38190;&#23383;&#12289;&#25628;&#32034;&#30701;&#35821;&#21644;/&#25110;&#25628;&#32034;&#31867;&#21035;&#12290;</li></ul>';
  if (url.indexOf('fr.') > -1)
    return "<ul><li>Vous pouvez d&egrave;s maintenant cliquer sur le bouton Rechercher en bas &agrave; droite</li><li>ou pr&eacute;ciser des mots-cl&eacute;s, une expression, et/ou des cat&eacute;gories avant de lancer la recherche.</li></ul>";
  return '<ul><li>You can now click on the search button at the bottom right</li><li>or enter keywords, search phrases, and/or search categories before searching.</li></ul>';
}
function getstarttapping() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Rhythmus aufnehmen";
  if (url.indexOf('zh.') > -1)
    return '&#24320;&#22987;&#36731;&#25970;';
  if (url.indexOf('fr.') > -1)
    return "Enregistrer le rythme";
  return 'Start Tapping';
}
function getstoptapping() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Aufnahme beenden";
  if (url.indexOf('zh.') > -1)
    return '&#20572;&#27490;&#36731;&#25970;';
  if (url.indexOf('fr.') > -1)
    return "Arr&ecirc;ter l'enregistrement";
  return 'Stop Tapping';
}
function getfinishing() {
  var url=document.location.href;
  if (url.indexOf('de.') > -1)
    return "Aufnahme wird beendet. Bitte einen Moment Geduld...";
  if (url.indexOf('zh.') > -1)
    return '&#27491;&#22312;&#20572;&#27490;...&#35831;&#31245;&#20505;';
  if (url.indexOf('fr.') > -1)
    return "Arr&ecirc;t en cours. Veuillez patienter...";
  return 'Stopping. Please wait...';
}


var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";


function gh(notes){
  A=notes.split(/\s+/);
  var res='';
  for (i=0; i<A.length; ++i) {
    if (A[i] != '')
      res = res+'<img src="/med/'+A[i]+'.gif">';
  } // for
  return '<img src="/med/clef.gif">'+res;
}

function cntn() {
   var lily = document.getElementById("lily");
   A = lily.value.split(/\s+/);
   var cnt = 0;
   for(i=0; i<A.length; i++) {
     if (A[i].match(/^\s*(.)(is|es|s)?(\'*)(\d*)(\.?)\s*$/))
	 //.substring(0,1) != 'r' && A[i].substring(0,1) != ' ')
	 cnt++;
   }
   return cnt;
}

function sch(coll) {
  //  alert("sch");
  var lily=document.getElementById("lily");
  var butt=document.getElementById("search");
  var wbutt=document.getElementById("wsearch");
  //  var catC=document.getElementById("CatClass").checked?"C":"";
  //  var catP=document.getElementById("CatPop").checked?"P":"";
  //  var catF=document.getElementById("CatFolk").checked?"F":"";
  //  var catH=document.getElementById("CatHymn").checked?"H":"";
  //  var catA=document.getElementById("CatNA").checked?"A":"";
  var filt=document.getElementById("filtertext");
  var omf=document.getElementById("onlymatchfr").value;

  var cnt = cntn();
  if (cnt > 0 && cnt < 5) {
    var notes = document.getElementById("notes");
    notes.innerHTML += '&nbsp;<b><font color="red">'+pleaseenter()+'</font></b>';
    return;
  }
  
  butt.innerHTML = searchingpleasewait();
  wbutt.innerHTML = '';
  //  alert(directoryurl());
  //alert("/"+directoryurl()+"/lily"+lily.value.replace(/\s+/g,"+")+"&categories="+catC+catP+catF+catH+catA+"&filtertext="+filt.value.replace(/\s+/g,"+")+"&coll="+coll);
  document.location.href = "/"+directoryurl()+"/lily"+lily.value.replace(/\s+/g,"+")+"&categories="+/*catC+catP+catF+catH+catA+*/"&filtertext="+filt.value.replace(/\s+/g,"+")+"&coll="+coll+"&onlymatchfrom="+omf;
}
function gr(oldarr){
  return '<a href="#" onClick="rs('+"'"+oldarr.replace(/'/g, "y")+"'"+')"><img src="/med/dl.gif" border="0"></a>';
}
function grw(oldarr){
  return '<a href="#" onClick="rsw('+"'"+oldarr.replace(/'/g, "y")+"'"+')"><img src="/med/dl.gif" border="0"></a>';
}
function rs(rest_notes) {
   var notes = document.getElementById("notes");
   var lily = document.getElementById("lily");
   var srch = document.getElementById("search");
   var wsrch = document.getElementById("wsearch");
   var play = document.getElementById("play");
   A = rest_notes.split(/\s+/);
   oneless = "";
   lily.value = "";
   for(i=0; i<A.length-1; ++i) {
     oneless = oneless + ' ' + A[i];
     lily.value = lily.value + " " + A[i].replace(/y/g,"'");
   }
   lily.value = lily.value + " " + A[A.length-1].replace(/y/g,"'");
   if (A.length>0) {
     srch.innerHTML = '<input type="submit" onclick="sch(\'m\')" value="'+searchmusipedia()+'">';
//     wsrch.innerHTML = '<input type="submit" onclick="sch(\'w\')" value="'+searchtheweb()+'">';
   }
   else
     srch.innerHTML = pleaseenter();
   notes.innerHTML = gh(rest_notes.replace(/y/g,"'"));
   if (rest_notes != "")
     notes.innerHTML += gr(oneless);
   //   document.getElementById("arr").value = rest_notes;
   play.innerHTML =    '<input type="submit" onclick="'+ playonclick() + '" value="'+getplay()+'">';
}
function rsw(rest_notes) {
   var notes = document.getElementById("notes");
   var lily = document.getElementById("lily");
   var srch = document.getElementById("search");
   var wsrch = document.getElementById("wsearch");
   var play = document.getElementById("play");
   A = rest_notes.split(/\s+/);
   oneless = "";
   lily.value = "";
   for(i=0; i<A.length-1; ++i) {
     oneless = oneless + ' ' + A[i];
     lily.value = lily.value + " " + A[i].replace(/y/g,"'");
   }
   lily.value = lily.value + " " + A[A.length-1].replace(/y/g,"'");
   notes.innerHTML = gh(rest_notes.replace(/y/g,"'"));
   if (rest_notes != "")
     notes.innerHTML += grw(oneless);
   //   document.getElementById("arr").value = rest_notes;
   play.innerHTML =   '<input type="submit" onclick="'+ playonclick() + '" value="'+getplay()+'">';
}
function CA() {
   var notes = document.getElementById("notes");
   var lily = document.getElementById("lily");
   var srch = document.getElementById("search");
   lily.value = "";
   srch.innerHTML = pleaseenter();
   document.getElementById("wsearch").innerHTML = "";
   notes.innerHTML = gh("");
   document.getElementById("play").innerHTML = "";
}
function CA_t() {
   var times = document.getElementById("times");
   var srch = document.getElementById("search");
   times.value='';
   document.getElementById("wsearch").innerHTML = "";
   document.getElementById("notes").innerHTML = "";
   document.getElementById("filtertext").value = "";
   srch.innerHTML = "";
}
function AN(newnote) {
   var notes = document.getElementById("notes");
   var lily = document.getElementById("lily");
   //   var arr = document.getElementById("arr");
   var srch = document.getElementById("search");
   var wsrch = document.getElementById("wsearch");
   var play = document.getElementById("play");
   var nhtml = notes.innerHTML;
   var oldlily = lily.value;
   lily.value = lily.value+' '+newnote.replace(/y/g,"'");
   notes.innerHTML = gh(lily.value)+gr(oldlily);
   srch.innerHTML = '<input type="submit" onClick="sch(\'m\')" value="'+searchmusipedia()+'">';
//   wsrch.innerHTML = '<input type="submit" onClick="sch(\'w\')" value="'+searchtheweb()+'">';
   play.innerHTML = '<input type="submit" onClick="' + playonclick() + '" value="'+getplay()+'">';
}
function ANw(newnote) {
   var notes = document.getElementById("notes");
   var lily = document.getElementById("lily");
   //   var arr = document.getElementById("arr");
   var srch = document.getElementById("search");
   var wsrch = document.getElementById("wsearch");
   var play = document.getElementById("play");
   var nhtml = notes.innerHTML;
   var oldlily = lily.value;
   lily.value = lily.value+' '+newnote.replace(/y/g,"'");
   notes.innerHTML = gh(lily.value)+grw(oldlily);


   play.innerHTML =  '<input type="submit" onclick="'+ playonclick() + '" value="'+getplay()+'">';//'<a class="butt" href="' + playurl() + '">'+getplay()+'</a>';
}

function pla() {
  pl(document.getElementById('lily').value);
}

function pl(str) { 
  var play = document.getElementById("play");
  if (str.length < 2) {
    play.innerHTML =  '<input type="submit" onclick="' + playonclick() + '" value="'+getplay()+'">';
    return;
  }
  play.innerHTML =  '<input type="submit" onclick="document.location.href='+"'/fileadmin/scripts/play.cgi?lily=" + document.getElementById("lily").value.replace(/ /g,"+").replace(/\'/g,'\\'+"'")+ "'" + '" value="'+getplaying()+'">';
  var notes=str.split(/\s+/);
  var note = notes.shift();
  var tn = note.match(/^(.)(is|es|s)?(\'*)(\d*)(\.?)$/);
  if (tn != null) {
    var dotted = tn[5] != "";
    var pitch = tn[1];
    if (tn[2] == "is" || tn[2] == "es" || tn[2] == "s")
      pitch += tn[2];
    var oct = tn[3];
    var dur = tn[4];
    soundManager.play(pitch+(oct.length)+'_8');
    var whole=dotted?3000:2000;
    window.setTimeout('pl("'+notes.join(" ")+'")', Math.round(whole/dur));
    //alert('pl("'+notes.join(" ")+'")'+ Math.round(whole/dur)); pl(notes.join(" "));
  } else
    pl(notes.join(" "));
}

function playonclick() {
  if (flashversion < 2) {
    var iesucks = document.getElementById("lily").value.replace(/ /g,"+").replace(/\'/g, '\\'+"'");
    iesucks = "document.location.href='/fileadmin/scripts/play.cgi?lily="+iesucks+"';";
    return iesucks;// "document.location.href='/fileadmin/scripts/play.cgi?lily="+iesucks+"'";
  }
  return (flashversion < 2? 
	  "document.location.href='/fileadmin/scripts/play.cgi?lily=" + document.getElementById("lily").value.replace(/ /g,"+").replace(/\'/g, '\\'+"'") + "'" :
	  'pla()');
}

function ls() {
  //  alert("ls1");
  var srch = document.getElementById("search");
  var wsrch = document.getElementById("wsearch");
  var play = document.getElementById("play");
//  wsrch.innerHTML = '<input type="submit" onClick="sch(\'w\')" value="'+searchtheweb()+'">';
  srch.innerHTML = '<input type="submit" onClick="sch(\'m\')" value="'+searchmusipedia()+'">';
  play.innerHTML =  '<input type="submit" onClick="' + playonclick() + '" value="'+getplay()+'">';
// '<a class="butt" href="' + playurl() + '">'+getplay()+'</a>';
//  alert("ls2");

}

function ts() { 
  var lily = document.getElementById("lily");
  if (lily.value == "") {
    //alert("ts");
    document.getElementById("search").innerHTML = '<input type="submit" onClick="sch(\'m\')" value="'+searchmusipedia()+'">';
//     document.getElementById("wsearch").innerHTML = '<input type="submit" onClick="sch(\'w\')" value="'+searchtheweb()+'">';
  }
}

function query() {
  var query=this.location.search.substring(1);
  if (query.length > 0) {
    var params=query.split("&");
    for (var i=0 ; i<params.length ; i++){
      var pos = params[i].indexOf("=");
      var name = params[i].substring(0, pos);
      var value = params[i].substring(pos + 1);
      if (name == "lily")
	rs(((value.replace(/%25/g,"%")).replace(/\+/g," ")).replace(/%27/g,"'"));
      if (name == "filtertext")
        document.getElementById("filtertext").value=value.replace(/%20/," ");
      if (name == "categories" && value != "") {
        document.getElementById("CatClass").checked = value.indexOf("C")>-1;
        document.getElementById("CatPop").checked = value.indexOf("P")>-1;
        document.getElementById("CatFolk").checked = value.indexOf("F")>-1;
        document.getElementById("CatHymn").checked = value.indexOf("H")>-1;
        document.getElementById("CatNA").checked = value.indexOf("A")>-1;
      }
    }
  }
}

var dts;

function tap(e) {
  var d = new Date();
  document.getElementById("times").value += "/"+d.valueOf();
  dts += ".";
  document.getElementById("dots").innerHTML = dts;
  return true;
}

function notap(e) {
  if(window.event)
      keynum = e.keyCode;
  else if(e.which) // Netscape/Firefox/Opera
      keynum = e.which;
  
  return keynum;
}

var orig_hand;

function statap() {
  var d = new Date();
  dts = "<br/>"; document.getElementById("dots").innerHTML = dts;
  document.getElementById("times").value = d.valueOf();
  orig_hand = document.onkeydown;
  document.onkeydown = tap;
  document.getElementById("tbutt").innerHTML='<input type="submit" onclick="stotap()" value="'+getstoptapping()+'">';
  document.getElementById("notes").innerHTML='<a href="#" onclick="stotap()"><font color="green">'+gettapping()+'</font></a>';
}

function stotap() {
  document.getElementById("notes").innerHTML=getfinishing();
  window.setTimeout("fintap()", 100);
}

function showrh() {
 var notes = document.getElementById("notes");
  var tim = document.getElementById("times");
  var times = tim.value.split("/");
  var dur = times[times.length-1]-times[0];
  if (dur == 0) dur = 1;
  var totwidth = 400+((times[1]-times[0])/dur);
  notes.innerHTML = '<img src="/med/rclef.png" width="22" height="20"><img src="/med/tap.png" height="20" width="10">';
  for (i=2; i<times.length; i++)
    notes.innerHTML += '<img src="/med/rli.png" height="20" width="'+(totwidth*(times[i]-times[i-1])/dur)+'"><img src="/med/tap.png" height="20" width="10">';
  var qs = '';
  for (i=1; i<times.length; i++)
    qs += "/"+((diff=times[i]-times[0])/1000)+"-0-1";
  tim.value = qs.substr(1);
}

function fintap() {
  document.onkeydown = orig_hand;
  showrh();
  var times = document.getElementById("times").value.split("/");
  var srch=document.getElementById("search");
  if (times.length>=5) {
    srch.innerHTML = '<input type="submit" onClick="scht(\'m\')" value="'+searchmusipedia()+'">'; 
    document.getElementById("dots").innerHTML = '<font color="green">'+getthisisrh()+'</font>';
     //     wsrch.innerHTML = '<a class="butt" href="#" onClick="scht(\'w\')">'+searchtheweb()+'</a>';
   }
  else {
    srch.innerHTML = '';
    document.getElementById("dots").innerHTML = '<font color="red">'+pleaseenter()+'</font>';
  }
  document.getElementById("tbutt").innerHTML='<input type="submit" onclick="statap()" value="'+getstarttapping()+'">';
}

function scht() {
  var butt=document.getElementById("search");
  //  var wbutt=document.getElementById("wsearch");
  var catC=document.getElementById("CatClass").checked?"C":"";
  var catP=document.getElementById("CatPop").checked?"P":"";
  var catF=document.getElementById("CatFolk").checked?"F":"";
  var catH=document.getElementById("CatHymn").checked?"H":"";
  var catA=document.getElementById("CatNA").checked?"A":"";
  var filt=document.getElementById("filtertext");
  var omf=document.getElementById("onlymatchfr").value;
  
  butt.innerHTML = searchingpleasewait();
  //wbutt.innerHTML = '';
  document.location.href = "/"+directoryurl()+"/hum "+document.getElementById("times").value+"&categories="+catC+catP+catF+catH+catA+"&filtertext="+filt.value.replace(/\s+/g,"+")+"&coll=r&onlymatchfrom="+omf;
}




// This script determines correct code required to embed MEDIA files
// for a large number of browsers, including AOL and WebTV
// Windows Media Player is required and always used, except for WebTV
// Written by Les Gorven, http://midistudio.com/
// Ver. 3.0  Last Updated: January 17, 2006


function playMedia(mediaURL,height,width,from,to) {

  var mediaURL,height,width;

if (GetBrowser() == "Netscape")
	embedMPlayer(mediaURL,height,width);
if (GetBrowser() == "IE")
	embedIEobject(mediaURL,height,width);
if (navigator.appName.substring(0,5) == "WebTV")
  embedSource(mediaURL,height,width);
}

function embedSource(mediaURL,height,width,from,to) {

  var CodeGen = "";
  var mediaURL,height,width;
 		 	
	 CodeGen = '<embed src="' + mediaURL + '"' + '\n' ;
	 CodeGen += ' height=' + height + ' width=' + width + 'autostart="false" starttime="' + from+ '" ENDTIME="'+to+'" \n';
	 CodeGen += ' LOOP="false"' + //rpt +
 '>';
	
    document.write(CodeGen);

}


function embedMPlayer(mediaURL,height,width)	{


		CodeGen = "";
    	var mediaURL,height,width;
				 	
		CodeGen = '<embed type="application/x-mplayer2" ' + '\n' ;
		// http://www.microsoft.com/Windows/MediaPlayer/
    	CodeGen = CodeGen + 'pluginspage="http://www.apple.com/quicktime/download/" ' + '\n' ;
	 	CodeGen = CodeGen + 'Name="MediaPlayer" ' + 'src="' + mediaURL + '" '
+ '\n' ;
	 	CodeGen = CodeGen + 'autoStart=0 ' ;
		if ((height == 24) && (width == 299))
			CodeGen = CodeGen + 'ShowStatusBar=1 ';
		if ((height >= 50) && (width >= 200))
			CodeGen = CodeGen + 'ShowStatusBar=1 ';
		if ((height <= 49) && (width != 299))
			CodeGen = CodeGen + 'ShowStatusBar=0 ';
		
		CodeGen = CodeGen + 'playCount=1' + ' ' ;
		CodeGen = CodeGen + 'volume=-1 ' ;
		CodeGen = CodeGen + 'HEIGHT=20'  + ' WIDTH=' + width + '>'
				
		
		document.write(CodeGen)
	
}

function embedIEobject(mediaURL,height,width){


		CodeGen = ""
    	var mediaURL,height,width

		CodeGen = '<object id=Player' + '\n' ;
		CodeGen +=
'codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902'
+ '\n' ;
		CodeGen += 'type=application/x-oleobject height=' + height + ' width='
+ width + '\n' ;
		CodeGen += ' standby="Loading Microsoft® Windows® Media Player components..." ' + '\n' ;
		CodeGen += 'classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"> ' +
'\n' ;
		CodeGen += '<param NAME="Filename" VALUE="' + mediaURL + '">' + '\n' ;
		if ((height == 24) && (width == 299))
			CodeGen += '<param NAME="ShowStatusBar" VALUE= "true">';
		if ((height >= 50) && (width >= 200))
			CodeGen += '<param NAME="ShowStatusBar" VALUE= "true">';
		if ((height <= 49) && (width != 299))
			CodeGen += '<param NAME="ShowStatusBar" VALUE= "false"> ';
		
		CodeGen += '<param NAME="autoStart" VALUE="false"><param NAME="Volume" VALUE="-1">' + '\n' ;
		CodeGen += '<param NAME="playCount" VALUE=1' + '></object>'
		
		  document.write(CodeGen);

}

function GetBrowser()
{
   var agt=navigator.userAgent.toLowerCase();
   if( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) )
       return "IE";
   else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
         && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
         && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
       return "Netscape";
   else
       return "unknown";
}


// The following functions are by Guillaume Fallet.



function jsmenu_hover(obj,state)
{
  UL = obj.getElementsByTagName('ul');
  if (UL.length > 0) {
    submenu = UL[0].style;
    if (state == 1) {
      submenu.display = 'block';
    } else {
      submenu.display = 'none';
    }
  }
}

function jsmenu_clean()
{
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  // hide all nested popup menus (in reverse order because hiding parents before their childs doesn't work properly)
  for (i=nLI-1; i >= 0; i--) {
      jsmenu_hover(LI[i],0);
  }
}

var jsmenu_timeout;

function jsmenu_init()
{
  if (!document.getElementById('menu'))
      return;

  jsmenu_timeout=-1;
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;

  for (i=0; i < nLI; i++) {
    // add onmousexxx events on all LI elements
    LI[i].onmouseover = function() {
        if (jsmenu_timeout != 0) {
            clearTimeout(jsmenu_timeout);
            jsmenu_timeout = 0;
            jsmenu_clean();
        }
        jsmenu_hover(this,1);
    }
    LI[i].onmouseout = function() {
        if (jsmenu_timeout == 0)
            jsmenu_timeout = setTimeout(jsmenu_clean, 500);
    }
  }
}
