var detect = navigator.userAgent.toLowerCase();
function checkPlatform(string)
{
    place = detect.indexOf(string) + 1;
    thestring = string;
    return place;
}

var IE7 = (checkPlatform("msie 7.") && checkPlatform("win") );
var windowsIE = (checkPlatform("msie") && checkPlatform("win"));
var win = checkPlatform("win");

var launchTID;
launchTID = 0;

function launchApplet() {
    if (javaVersionCheck("1.1")) {
        clearInterval(launchTID);
	document.refresh();
    }    
}

function javaVersionCheck(versionString) {
    // Mozilla may not recognize new plugins without this refresh
    navigator.plugins.refresh(false);
    
    for(var i = 0; i < navigator.mimeTypes.length; ++i) {
         pluginType = navigator.mimeTypes[i].type;
         if (pluginType == "application/x-java-applet;version=" + versionString) {
             return true;
         }
      }   
      
      return false;
 }
 
function createPlugin(server, id, text)
{
//alert(server);
	
//alert(navigator.javaEnabled());
	
	var noJava = false;
	if(!windowsIE && win){
		if(!javaVersionCheck("1.1")) {
    		//window.open("http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com",
    		//window.open("http://www.java.com/en/download/manual.jsp",
        	//	"needdownload");
        
    		//launchTID = setInterval(laucnhApplet, 2000);
    		noJava = true;
		}
	}

	if( text == null )
		text = "If you don't see the applet you may need to install the Java Runtime Environment"
	
	if( IE7 )
		document.write("<APPLET CODE='mentorwave.Player' ARCHIVE='http://" + server + "/mwPlayer.jar' WIDTH=627 HEIGHT=328>");
	else
		document.write("<APPLET CODEBASE='http://" + server + "' CODE='mentorwave.Player' ARCHIVE='mwPlayer.jar' WIDTH=627 HEIGHT=328>");
	
	document.write("<PARAM name='ServerURL' value='" + server + "' />");
	document.write("<PARAM name='SiteID' value='" + id + "' />");
	document.write("<PARAM name='CacheSize' value='16' />");
	//document.write("<p><BR>" + text); // manually from <a href='http://www.java.com/en/download/manual.jsp'>here</a>");
	document.write("<a href='http://www.java.com/en/download/manual.jsp'><IMG SRC='http://www.mentorwave.com/no_java.jpg'></a>");	
	document.write("</APPLET>"); 
	
	/*if( (windowsIE && win) || (noJava == true) )
	{
		document.write("<br>If you don't see the applet you may need to install the Java Runtime Environment manually from <a href='http://www.java.com/en/download/manual.jsp'>here</a>");
		document.write("<br><a href='http://www.java.com/en/download/manual.jsp'><IMG SRC='http://streaming.mentorwave.com/java_download.gif'></a>");	
	}*/
}

function createPluginEx(server, id, text)
{
	//alert(navigator.javaEnabled());
	
	var noJava = false;
	var rvText = "";
	if(!windowsIE && win){
		if(!javaVersionCheck("1.1")) {
    		//window.open("http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com",
    		//window.open("http://www.java.com/en/download/manual.jsp",
        	//	"needdownload");
        
    		//launchTID = setInterval(laucnhApplet, 2000);
    		noJava = true;
		}
	}

	if( text == null )
		text = "If you don't see the applet you may need to install the Java Runtime Environment"
	
	if( IE7 )
		rvText = "<APPLET CODE='mentorwave.Player' ARCHIVE='http://" + server + "/mwPlayer.jar' WIDTH=627 HEIGHT=328>";
	else
		rvText = "<APPLET CODEBASE='http://" + server + "' CODE='mentorwave.Player' ARCHIVE='mwPlayer.jar' WIDTH=627 HEIGHT=328>";
	
	rvText += "<PARAM name='ServerURL' value='" + server + "' />";
	rvText += "<PARAM name='SiteID' value='" + id + "' />";
	rvText += "<PARAM name='CacheSize' value='16' />";
	rvText += "<a href='http://www.java.com/en/download/manual.jsp'><IMG SRC='http://www.mentorwave.com/no_java.jpg'></a>";	
	rvText += "</APPLET>"; 
	
	/*if( (windowsIE && win) || (noJava == true) )
	{
		document.write("<br>If you don't see the applet you may need to install the Java Runtime Environment manually from <a href='http://www.java.com/en/download/manual.jsp'>here</a>");
		document.write("<br><a href='http://www.java.com/en/download/manual.jsp'><IMG SRC='http://streaming.mentorwave.com/java_download.gif'></a>");	
	}*/

	//alert(rvText);

	return rvText;
}