 /**
       * SmoothAppletScript.js
       *
       * @author bruno augier
       * @email bruno.augier@dzzd.net
       * @website http://dzzd.net/
       * @version 1.00 2008/03/05
  */
var jvmInited=false;
var apple=(navigator.userAgent.toLowerCase().indexOf("apple")!=-1);
var firefox=(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
//var FFbugDelay=5000;


function startApplets()
{
	startJVM();
	setTimeout('startAllApplets(2000)',2000);
}

function startJVM()
{
   document.body.innerHTML+="<IFRAME NAME=JVMLOADER src=\"jvmLoader.html\" WIDTH=0 HEIGHT=0 STYLE=\"BORDER:0;MARGIN:0\"></IFRAME>"
}


function startAllApplets(time)
{
 if(!firefox && !jvmInited)
 {
	setTimeout('startAllApplets()',time)
	return;
 }
 var appletList=document.getElementsByTagName("APPLETLOADER");
 for(var x=0;x<appletList.length;x++)
 {
    var parent=appletList[x].parentNode;
	if(!firefox)
	{
		try
		{
			appletList[x].style.position="relative";
			appletList[x].style.top="-5000";
		}
		catch(e)
		{
		}
	}
	var html=parent.innerHTML.replace("APPLETLOADER","APPLET").replace("appletloader","applet");
	parent.innerHTML=html;
 }
 
 // FF Java bugs on Security Ecxpetion when javascript call Java (before) and another applet use socket
 if(!firefox)
  setTimeout("showAllApplets()",time);
 
 //else
  //setTimeout("showAllApplets()",FFbugDelay);
}

function showAllApplets()
{
 var redo=false;
 var appletList=document.getElementsByTagName("APPLET");
 for(var x=0;x<appletList.length;x++)
 {
  var parent=appletList[x].parentNode;
  try
  {
    if(appletList[x].isActive()==true)
	{
		appletList[x].style.top="0";
		parent.style.backgroundImage="";
	}
	else
		redo=true;
   }
   catch(e)
   {
   	appletList[x].style.top="0";
	parent.style.backgroundImage="";
   }
 }
 if(redo)
  setTimeout("showAllApplets()",200);
}


/*

	/*
	if(firefox)
	{
	 var url=window.location.href;
	 var protocole=url.substring(0,url.indexOf("/")+2);
	 var uri=url.substring(url.indexOf("/",protocole.length));//,url.lastIndexOf("/"));
	 //alert(protocole);
	 //alert(uri);
	 alert("codebase="+protocole+getIP()+uri);
	 html=html.replace("base=\"\"","codebase=\""+protocole+getIP()+uri+"\"");
	 alert(html);
	}
	*/
/*

function getIP()
{ 
	try
	{
	 var ip="";
	 var u=java.net.URL(window.location.href);
	 ip=java.net.InetAddress.getByName(u.getHost()).getHostAddress();
	}
	catch(e)
	{
	}
	return ip;
}
*/
