/**
* Autor: Jordi Cuadros
* Functions to launch the Vlab in the same html page
*/

// applet vars 
var _appletArchive="vlab.jar, logging.jar, logclient.jar";
var _appletCodebase="../java/";
var _appletLanguage="";
var _appletProperties="";
var _appletHeight="550";
var _appletWidth="850";
var _appletRedirect="";
var _appletRepositoryIndex="";
var _appletRepositoryName="";
var _appletUnknowns="";
var _appletUserID="";
var _appletSessionID="132";
var _appletLogService="";
var _appletAuthToken="NA_AuthToken";
var _appletDataset="";

/**
* Write the HTML required to launch the specified problem in the Vlab
* @param
*		problemName
*
*/
function launchProblem(problemName) {
	_appletProperties=problemName;
	launchVLab();
}

/**
* Write the HTML required to launch the specified problem in the Vlab
* sending a string of unknowns values
*
* @param
*		problemName
*		unknownsString
*		user
*/
function launchProblemWithUnknownsAndUser(problemName, unknownsString, user, session, dataset, contextmessageid) {
	_appletUserID=user;
	_appletSessionID=session;
	_appletProperties=problemName;
	_appletUnknowns=unknownsString;
	_appletDataset=dataset;
	_appletContextMessageId=contextmessageid;
	launchVLab();
}

/**
* Launch the VLab with the actual parameters using an applet tag
*/
function launchVLab() {
	document.writeln("<applet code='irydium.vlab.VLApplet.class' archive='"+_appletArchive+"' codebase='"+_appletCodebase+"' width='"+_appletWidth+"' height='"+_appletHeight+"' >");
	
	if (_appletUnknowns!="") document.writeln("<PARAM name='unknowns' value='"+_appletUnknowns+"' \/>");
	if (_appletDataset!="") document.writeln("<PARAM name='dataset' value='"+_appletDataset+"' \/>");
	if (_appletProperties!="") document.writeln("<PARAM name='properties' value='"+_appletProperties+"' \/>");
	if (_appletLanguage!="") document.writeln("<PARAM name='language' value='"+_appletLanguage+"' \/>");
	if (_appletRedirect!="") document.writeln("<PARAM name='redirect' value='"+_appletRedirect+"' \/>");
	if (_appletRepositoryIndex!="") document.writeln("<PARAM name='repositoryIndex' value='"+_appletRepositoryIndex+"' \/>");
	if (_appletRepositoryName!="") document.writeln("<PARAM name='repositoryName' value='"+_appletRepositoryName+"' \/>");
	if (_appletUserID!="") document.writeln("<PARAM name='userID' value='"+_appletUserID+"' \/>");
	if (_appletSessionID!="") document.writeln("<PARAM name='sessionID' value='"+_appletSessionID+"' \/>");
	if (_appletAuthToken!="") document.writeln("<PARAM name='authToken' value='"+_appletAuthToken+"' \/>");
	if (_appletContextMessageId!="") document.writeln("<PARAM name='ContextMessageId' value="+_appletContextMessageId+" \/>");
	//enable logging
	document.writeln("<PARAM name='remoteLogging' value='true' \/>");
	document.writeln("<PARAM name='remoteLoggingFormat' value='OLI' \/>");
	document.writeln("There's no JVM installed in this system.<\/applet>");
}


