function sendMeson(arg)
{
    // This function sends a meson command through to the applet.

    // Note that getElementById("meson") should also get the applet, but
    // accessing via the applets array works better in Safari.

    var applet = document.applets[0];
    if (applet)
      applet.getParameter('?'+arg);
}
function hideApplet()
{
    // Hide the applet by moving it off screen (turning off visibility leads to browser instability)
    // Leave a 1x1 pixel corner on the screen to avoid event queue back-ups

    var div = document.getElementById("mesonDiv");
    var applet = document.getElementById("meson");
    div.style.left = 1-applet.width;
    div.style.top = 1-applet.height;

    // Opera does not re-lay stuff out unless you move the flash movie
    if (navigator.userAgent.toLowerCase().indexOf('opera') != -1)
    {
      div = document.getElementById("flashDiv");
      div.style.border="solid";
      setTimeout("operaHack()", 1);
    }
}
function showApplet(x,y,w,h)
{
    // Move the applet on screen, and set the size

    var div = document.getElementById("mesonDiv");
    div.style.left = 1+x;
    div.style.top = 1+y;
    div.style.width = w;
    div.style.height = h;
    var applet = document.getElementById("meson");
    applet.width = w;
    applet.height = h;

    // Opera does not re-lay stuff out unless you move the flash movie
    if (navigator.userAgent.toLowerCase().indexOf('opera') != -1)
    {
      div = document.getElementById("flashDiv");
      div.style.border="solid";
      setTimeout("operaHack()", 1);
    }
}
function operaHack()
{
    div = document.getElementById("flashDiv");
    div.style.border="none";
}

// Magic borrowed from mustardlab.com
var ua        = navigator.userAgent.toLowerCase(); 
var is_pc_ie  = ( (ua.indexOf('msie') != -1 ) && ( ua.indexOf('win') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('webtv') == -1 ) );

/* -----------------------------------------------------------
function setFlashVariables(movieid, flashquery)

movieid: id of object tag, name of movieid passed in through FlashVars
flashquery: querystring of values to set. example( var1=foo&var2=bar )
----------------------------------------------------------- */
function setFlashVariables(movieid, flashquery){
	var i,values;
	if(is_pc_ie){
		var chunk = flashquery.split("&");
		for(i in chunk){
			values = chunk[i].split("=");
			document[movieid].SetVariable(values[0],values[1]);
		}
	}else{
		var divcontainer = "flash_setvariables_"+movieid;
		if(!document.getElementById(divcontainer)){
			var divholder = document.createElement("div");
			divholder.id = divcontainer;
			document.body.appendChild(divholder);
		}
		document.getElementById(divcontainer).innerHTML = "";
		var divinfo = "<embed src='http://jam-movie.com/3d/gateway.swf' FlashVars='lc="+movieid+"&fq="+escape(flashquery)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
		document.getElementById(divcontainer).innerHTML = divinfo;
	}
}
