// Copyright (c) 2002 nTeras Corporation. All rights Reserved.

var JauntObj = null

function JauntLaunch(strServer, strApp, strSvc, strParm)
{
	var ShowHelp = false;
	
	if(J_IsNetscape())
	{
		ShowHelp = confirm("Netscape usually requires additional steps to connect.\r\nSelect \"OK\" to display a help page, or \"Cancel\" to try your request without help.");
	} else if(document.getElementById("JauntLaunchNotLoaded")) // see if the previous try failed
	{
		ShowHelp = confirm("The JauntLaunch control could not be created.\r\nSelect \"OK\" to display a help and troubleshooting page or \"Cancel\" to retry your request.");
	}
	
	if(ShowHelp)
	{
		var strUrl;		
		strUrl = "http://www.rapidassist.com/JauntLaunchHelp.asp?";
			
		if(strServer)
			strUrl += "Server="+strServer+"&";

		if(strApp)
			strUrl += "Application="+strApp+"&";

		if(strSvc)
			strUrl += "Service="+strSvc+"&";

		if(strParm)
			strUrl += "Parameters="+strParm;

		window.open(strUrl);
		return;
	}
	

	// check for a previouusly created Jaunt object
	JauntObj = document.getElementById("Jaunt");
	if(JauntObj)
	{
		if(JauntObj.Server)
		{
			JauntObj.Launch(strServer, strApp, strSvc, strParm, "");
			return;
		}
	}
	
	CreateJauntLaunchObject(strServer, strApp, strSvc, strParm);
			
	JauntObj = document.getElementById("Jaunt");
			
	if(!JauntObj)
	{
		if(navigator.appName != "Netscape")
			Alert("Unable to start Jaunt -- redirecting to troubleshooting page");
	} else
	{
	}
}

function J_IsIE()
{
	if (navigator.appName == "Microsoft Internet Explorer")
		return true;
	else
		return false;
}

function J_IsNetscape()
{
	if (navigator.appName == "Netscape")
		return true;
	else
		return false;
}

function CreateJauntLaunchObject(strServer, strApplication, strService, strParms)
{
	var strObj
	
	if(J_IsNetscape())
	{
		strObj = 
			    "  <EMBED type=application/x-nTeras-Windows-Plugin-Jaunt \r\n" +
				//"      pluginspage=\"\"\r\n" +
				"      HIDDEN=\"TRUE\" \r\n" +
				"      server=\"" + strServer + "\" \r\n" +
				"      app=\"" + strApplication + "\" \r\n" +
				"      parm=\"" + strParms + "\" \r\n" +
				"      JauntPath=\"http://www.rapidassist.com/Jaunt\">\r\n\r\n";
//		strObj = 
//				"<OBJECT ID=\"Jaunt\" type=app lication/x-nTeras-Windows-Plugin-Jaunt\r\n" +
//				"<PARAM NAME=\"JauntPath\" VALUE=\"http://www.rapidassist.com/Jaunt\">\r\n" +
//				"<PARAM NAME=\"server\" VALUE=\"" + strServer + "\">\r\n" +
//				"<PARAM NAME=\"app\" VALUE=\"" + strApplication + "\">\r\n" +
//	//			"<PARAM NAME=\"Service\" VALUE=\"" + strService + "\">\r\n" +
//				"<PARAM NAME=\"parm\" VALUE=\"" + strParms + "\">\r\n" +
//	//			"<PARAM NAME=\"ReuseConnection\" VALUE=\"" + JauntReuseFlag + "\">\r\n" +
//				"<PARAM NAME=\"AutoLaunch\" VALUE=TRUE>\r\n" +
//				"<p><SPAN ID=\"JauntLaunchNotLoaded\">JauntLaunchNotLoaded</SPAN></p>" +
//				"</OBJECT>";
	} else if (J_IsIE())
	{
		strObj = 
				"<OBJECT ID=\"Jaunt\" CLASSID=\"CLSID:8E66A776-A350-4D69-8783-906DB0E6DF14\"\r\n" +
				"CODEBASE=\"http://download.jaunt.com/public/jaunt.cab#version=1,1,0,7\">\r\n" +
	//7-8-02	"<PARAM NAME=\"JauntPath\" VALUE=\"http://www.rapidassist.com/Jaunt\">\r\n" +
				"<PARAM NAME=\"Server\" VALUE=\"" + strServer + "\">\r\n" +
				"<PARAM NAME=\"Application\" VALUE=\"" + strApplication + "\">\r\n" +
				"<PARAM NAME=\"Service\" VALUE=\"" + strService + "\">\r\n" +
				"<PARAM NAME=\"Parameters\" VALUE=\"" + strParms + "\">\r\n" +
	//			"<PARAM NAME=\"ReuseConnection\" VALUE=\"" + JauntReuseFlag + "\">\r\n" +
				"<PARAM NAME=\"AutoLaunch\" VALUE=1>\r\n" +
				"<SPAN ID=\"JauntLaunchNotLoaded\">" +
			"<table align=center cellpadding=\"0\">"+
				"<tr><td align=\"center\"><font size=\"2\">Automatic connecting requires the installation of an ActiveX Control<br>"+
				"To Install, click on the information bar (near the top of your browser),<br> then select \"Install ActiveX Control\" as shown below</font></td></tr>"+
				"<tr>"+
					"<td align=\"center\"><IMG src=\"http://download.jaunt.com/Images/install_ax-80.JPG\"></td>"+
				"</tr>"+
			"</table>"+
				"</SPAN>" +
				"</OBJECT>";
	} else
	{
		alert("Jaunt requires Internet Explorer or Netscape");
		return;
	}

	var tag = document.createElement("p");
					
	tag.innerHTML = strObj;
	document.body.appendChild(tag);
}
