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

// applet vars 
var _appletArchive="vlab.jar";
var _appletCodebase="../java/";
var _appletLanguage="";
var _appletProperties="";
var _appletHeight="550";
var _appletWidth="780";
var _appletRedirect="";
var _appletRepositoryIndex="";
var _appletRepositoryName="";
var _appletUnknowns="";
var _appletUserID="";
var _appletSessionID="";
var _appletLogService="";
var _appletAuthToken="";
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) {
	_appletUserID=user;
	_appletSessionID=session;
	_appletProperties=problemName;
	_appletUnknowns=unknownsString;
	_appletDataset=dataset;
	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 (_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+"' \/>");

	document.writeln("There's no JVM installed in this system.<\/applet>");

}
