function cenTPXSettings(emu)
{
	if (!emu || !(emu == "unix" || emu == "ibm3270" || emu == "ibm5250")) {
		emu = "unix";
	}

	this.filename = '';

	this.tpxSettings = new Object();

	this.tpxSettings['node'] 		= 	'';
	this.tpxSettings['port'] 		= 	'23';
	this.tpxSettings['commtype'] 	= 	0;		// Telnet

	this.tpxSettings['windowTitle'] =   'Century HostTE';
	this.tpxSettings['windowType']  =   '0'; // 0 = Window, 1 = Tab
	this.tpxSettings['title'] 		=	'Default';
	this.tpxSettings["bsdel"]		=	1;

	if (emu == "unix") {
		this.tpxSettings["emulate"] = 11;
		
		this.tpxSettings["MBMode"] = false;

 		this.tpxSettings["lines"] = 25;
		this.tpxSettings["col"] = 80;

		this.tpxSettings['colorbg0'] = 2;
		this.tpxSettings['colorfg0'] = 15;
		this.tpxSettings['colorfg4'] = 16;

		this.tpxSettings["CursorColor"] = 10;
	}
	else if (emu == "ibm3270") {
		this.tpxSettings["emulate"] = 24;

		this.tpxSettings['3270colfg0'] = 8;
		this.tpxSettings['3270colfg1'] = 12;
		this.tpxSettings['3270colfg2'] = 11;
		this.tpxSettings['3270colfg3'] = 16;
	}
	else {
		this.tpxSettings["emulate"] = 25;	

	    this.tpxSettings['5250colfg0'] =     '5';
	    this.tpxSettings['5250colfg1'] =     '5';
	    this.tpxSettings['5250colfg2'] =     '0';
	    this.tpxSettings['5250colfg3'] =     '0';
	    this.tpxSettings['5250colfg4'] =     '5';
	    this.tpxSettings['5250colfg5'] =     '5';
	    this.tpxSettings['5250colfg6'] =     '0';
	    this.tpxSettings['5250colfg7'] =     '1';
	    this.tpxSettings['5250colfg8'] =     '2';
	    this.tpxSettings['5250colfg9'] =     '2';
	    this.tpxSettings['5250colfg10'] =    '2';
	    this.tpxSettings['5250colfg11'] =    '2';
	    this.tpxSettings['5250colfg12'] =    '2';
	    this.tpxSettings['5250colfg13'] =    '2';
	    this.tpxSettings['5250colfg14'] =    '2';
	    this.tpxSettings['5250colfg15'] =    '1';
	    this.tpxSettings['5250colfg16'] =    '7';
	    this.tpxSettings['5250colfg17'] =    '7';
	    this.tpxSettings['5250colfg18'] =    '11';
	    this.tpxSettings['5250colfg19'] =    '11';
	    this.tpxSettings['5250colfg20'] =    '7';
	    this.tpxSettings['5250colfg21'] =    '7';
	    this.tpxSettings['5250colfg22'] =    '11';
	    this.tpxSettings['5250colfg23'] =    '1';
	    this.tpxSettings['5250colfg24'] =    '13';
	    this.tpxSettings['5250colfg25'] =    '13';
	    this.tpxSettings['5250colfg26'] =    '7';
	    this.tpxSettings['5250colfg27'] =    '8';
	    this.tpxSettings['5250colfg28'] =    '13';
	    this.tpxSettings['5250colfg29'] =    '13';
	    this.tpxSettings['5250colfg30'] =    '8';
	    this.tpxSettings['5250colfg31'] =    '1';
	    this.tpxSettings['5250colfg32'] =    '1';
	}

	if (emu == "unix") {
		this.tpxSettings["cpdecmn"] = "VT200 Multinational Mapping";
		this.tpxSettings["cpdecsg"] = "VT200 Special Graphics Mapping";
		this.tpxSettings["cpdecvt"] = "VT100 Special Graphics Mapping";
		this.tpxSettings["cptrxin"] = "STD 437 MS-DOS Latin US";
		this.tpxSettings["cptrxout"] = "STD 437 MS-DOS Latin US";	
	}
	else {
		this.tpxSettings['cptrxout']    =    '1140 (Latin-1 w/Euro)';
		this.tpxSettings['cptrxin']     =    '1140 (Latin-1 w/Euro)';
		this.tpxSettings['3270KeybSch'] =    'Default';
		this.tpxSettings['5250KeybSch'] =    'Default';
		this.tpxSettings['DBCSFont'] =       'PMingLiu';
	}
	
	this.componentToHex = function(c) {
	    var hex = c.toString(16);
		return hex.length == 1 ? "0" + hex : hex;
	}
	
	this.RGB = function(r, g, b) {
	    return  this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
	}

	this.IBMRGBDefault = [
		this.RGB(0, 0, 0),
		this.RGB(0, 0, 128),
		this.RGB(0, 128, 0),
		this.RGB(0, 128, 128),
		this.RGB(128, 0, 0),
		this.RGB(128, 0, 128),
		this.RGB(128, 128, 128),
		this.RGB(193, 193, 193),
		this.RGB(128, 128, 128),
		this.RGB(0, 0, 255),
		this.RGB(0, 255, 0),
		this.RGB(0, 255, 255),
		this.RGB(255, 0, 0),
		this.RGB(255, 0, 255),
		this.RGB(255, 255, 0),
		this.RGB(255, 255, 255)
	];

	this.save = function() {
		var filename = '';
		
		if(arguments.length == 1) {
			filename = arguments[0];
			if(typeof(filename) != 'string') {
				return -1;
			}
		} else if(this.filename != '') {
			filename = this.filename;
		} else {
			return -1;
		}
		
		this.filename = filename;
		
		localStorage.setItem(filename, JSON.stringify(this.tpxSettings));
		
		return 0;	
	}
	
	this.load = function() {
		var filename = '';
		
		if(arguments.length == 1) {
			filename = arguments[0];
			if(typeof(filename) != 'string') {
				return -1;
			}
		} else if(this.filename != '') {
			filename = this.filename;
		} else {
			return -1;
		}

		this.filename = filename;

		var loadedString = localStorage.getItem(filename);

		if(typeof(loadedString) != 'string') {
			return -1;
		}
		
		this.tpxSettings = JSON.parse(loadedString);
		
		return 0;
	}

	this.isEmulationUNIX = function () {
		var emulation = this.tpxSettings['emulate'];
		return (emulation >= 0 && emulation <= 20) || (emulation >= 28 || emulation <= 3);
	};

	this.isEmulation3270 = function() {
		var emulation = this.tpxSettings['emulate'];
		return (emulation > 23 && emulation < 28);
	}
	
	this.isEmulation5250 = function() {
		var emulation = this.tpxSettings['emulate'];
		return (emulation == 22 || emulation == 23);
	}

	this.update = function () {
		cenAX.hteConnection.setTPXConfig(this.tpxSettings);
		cenAX.hteConnection.loadConfig(false, false);
	}

	this.attach = function (errCb) {
		cenAX.hteConnection.setTPXConfig(this.tpxSettings);
		cenAX.hteConnection.attach(function (errno, str) {
			if (errno = HTE_CONFIG_ERROR.SESSION_NOT_FOUND) {
				if (errCb) {
					errCb();
				}
			}
			else {
				alert(str);
			}
		});
	}

	this.connect = function(loadConfig, errCb) {
		cenAX.hteConnection.setTPXConfig(this.tpxSettings);

		var sid = cenAX.hteConnection.getSessionId();

		if (loadConfig || !sid) {
			cenAX.hteConnection.loadConfig(true, true, function (errno, str) {
				alert(str);	
			});
		}
		else {
			cenAX.hteConnection.attach(function (errno, str) {
				if (errno == HTE_CONFIG_ERROR.SESSION_NOT_FOUND) {
					errCb();
				}
				else {
					alert(str);
				}
			});
		}
	}
	
	this.disconnect = function() {
		return 0;
	}

	this.copy = function() {
		var newTPX = new cenTPXSettings();
		
		for(var key in this.tpxSettings) {
			newTPX.tpxSettings[key]	= this.tpxSettings[key];
		}
		
		newTPX.filename = this.filename;
		
		return newTPX;
	}
}	
