var Support =
{
	shell: new ActiveXObject ('WScript.shell'),

	init: function ()
	{
		var width = 420;
		var height = 185;

		window.resizeTo (width, height);
		window.moveTo ((screen.width - width) / 2, (screen.height - height) / 2);

		this.run ('tvnserver.exe -run');
	},
	
	$: function (id)
	{
		return document.getElementById (id);
	},
	
	run: function (command, wait)
	{
		if (!wait)
			wait = false;
	
		this.shell.run (command, 0, wait);
	},

	_onStartClick: function ()
	{
		var port = 5500 + parseInt (this.$('operator').value);
		this.run ('tvnserver.exe -controlapp -connect support.verdnatura.es::'+ port);
	},

	_onCloseClick: function ()
	{
		window.close ();
	},
	
	_onUnload: function ()
	{
		this.run ('tvnserver.exe -controlapp -disconnectall', true);
		this.run ('tvnserver.exe -controlapp -shutdown');
	}
};

Support.init ();