/*
 * common code to check for toolbar and relevant info
 */

var TOOLBAR = {
	bInstalled: false,
	oActiveXCtl: null,
	sVersion: null,
	sUID: null,
	sPartnerID: null,
	sParentPartnerID: null,
	sChildPartnerID: null,
	sBucket: "",
	sHtmlMenuCtlId: null,
	iToolbarType: -1,
	sLatestVersion: "",
	bLatestVersion: false,
	bUpgradeRequired: false, // why was this true by default?
	bScreenSaverCtl: false,
	oScreenSaverInstaller: null,
	bToolbarErrorCaught: false,
	
	// debugging enabled/disabled
	debug_enabled: false,
	
	//-- should not be using xpi specific vars anymore
	bXPIInstalled: false,
	bXPIErrorCaught: false,
	sXPIVersion: null,
	sXPILatestVersion: "",
	bXPILatestVersion: false,
	bXPIUpgradeRequired: false,
	
	// controller objects after instantiation
	oSettingsCtl: null,
	oHtmlMenuCtl: null,
	
	xpi_interval: null,
	xpi_event: {
		TBCkElem: null,
		TBCkEvt: null
	},
	
	browser: {
		name: "",
		major_version: 0
	},
	
	toolbar_list: [ 'mws.settingsCtl', 'mws.xpi', 'vicinio.settingsCtl' ],
	toolbar_test: true,
	
	cookie: {
		config: {
			name: "tsox_data",
			data: null
		}
	},
	
	winner: {},
	
	init: function( _opts )
	{
		this.get_browser();
		if ( _opts != undefined && _opts != null ){
			if ( _opts.tb_list != undefined && _opts.tb_list != null ){
				this.toolbar_list = _opts.tb_list;
			}
			if ( _opts.find != undefined && _opts.find != null && _opts.find != "" ){
				this.toolbar_test = _opts.find;
			}
		}
		this.DEBUG("init: this.toolbar_list = " + this.toolbar_list);
		if ( this.toolbar_test ){ this.find_toolbar(); }
	},
	
	find_toolbar: function()
	{
		// loop through toolbar_list, stop on first match
		for ( var idx=0; idx < this.toolbar_list.length; idx++ ){
			var oTb = this.get_toolbar_from_master( this.toolbar_list[idx] );
			if ( this.tb_exists( oTb ) ){
				this.winner = oTb;
				this.bInstalled = true;
				return;
			}
		}
	},
	
	find_html_menu_ctl: function()
	{
		//this.DEBUG("find_html_menu_ctl: this.winner.toolbar = " + this.winner.toolbar);
		//this.DEBUG("find_html_menu_ctl: this.winner.xpi = " + this.winner.xpi);
		if ( this.winner.toolbar == null || this.winner.toolbar == undefined || this.winner.toolbar == "" ){
			return;
		}
		var oTb = this.get_toolbar_from_master( this.winner.toolbar + ".htmlMenuCtl" );
		this.get_toolbar_data( oTb );
	},
	
	get_toolbar_data: function( _ctl )
	{
		this.DEBUG("get_toolbar_data: _ctl.xpi = " + _ctl.xpi);
		this.DEBUG("get_toolbar_data: this.cookie.config.data = " + this.cookie.config.data);
		if ( _ctl.xpi && this.cookie.config.data == null ){
			this.DEBUG("get_toolbar_data: xpi is true, coookie data is null");
			GetXpiConfig( this );
		} else if ( _ctl.xpi && this.cookie.config.data != null ){
			this.DEBUG("get_toolbar_data: xpi is true, coookie data is NOT null");
			this.set_xpi_data();
		} else if ( _ctl.exe ){
			this.DEBUG("get_toolbar_data: xpi is false, exe is true");
			// instantiate the control we want to use
			this.instantiate( _ctl );
		}
	},
	
	version_check: function( _ctl )
	{
		this.DEBUG("version_check: _ctl.name = " + _ctl.name);
		this.DEBUG("version_check: this.bInstalled = " + this.bInstalled);
		if ( this.bInstalled ){
			var versionCheck = this.check_versions( this.sVersion, _ctl.max_version, _ctl.required_version );
			this.bLatestVersion = versionCheck.latest;
			this.bUpgradeRequired = versionCheck.upgrade;
			if( this.bXPIInstalled ){
				this.bXPILatestVersion = this.bLatestVersion;
				this.bXPIUpgradeRequired = this.bUpgradeRequired;
			}
		}
	},
	
	set_xpi_data: function( _props )
	{
		if ( this.cookie.config.data != null ){
			this.DEBUG("set_xpi_data: cookie data is NOT null");
			try {
				this.DEBUG("set_xpi_data: this.cookie.config.data.gu = " + this.cookie.config.data.gu);
				this.sVersion = this.cookie.config.data.ver
				this.sUID = this.cookie.config.data.gu;
				this.sPartnerID = this.cookie.config.data.cb;
				this.sBucket = this.cookie.config.data.trk;
				var partner = this.parse_partner( this.sPartnerID );
				
				this.sParentPartnerID = partner.parentid;
				this.sChildPartnerID = partner.childid;
				this.sBucket = partner.bucket;
			} catch(Err){
				//this.DEBUG("set_xpi_data: woops! " + Err);
				this.bXPIErrorCaught = true;
			}
		} else {
			try {
				this.sUID = document.getElementsByTagName("TSOX_TBCk")[0].getAttribute("tbid");
				this.sPartnerID = document.getElementsByTagName("TSOX_TBCk")[0].getAttribute("cbid");
				this.sBucket = document.getElementsByTagName("TSOX_TBCk")[0].getAttribute("trkid");
				var partner = this.parse_partner( this.sPartnerID );
				
				this.sParentPartnerID = partner.parentid;
				this.sChildPartnerID = partner.childid;
				this.sBucket = partner.bucket;
			} catch(Err){
				//this.DEBUG("set_xpi_data: woops! " + Err);
				this.bXPIErrorCaught = true;
			}
		}
	},
	
	get_settingsCtl_data: function()
	{
		try {
			this.sUID = this.oSettingsCtl.I;
			this.sPartnerID = this.oSettingsCtl.P;
			this.sVersion = this.oSettingsCtl.GetVersion('');
			var partner = this.parse_partner( this.sPartnerID );
			
			this.sParentPartnerID = partner.parentid;
			this.sChildPartnerID = partner.childid;
			this.sBucket = partner.bucket;
			this.iToolbarType = this.oSettingsCtl.Type;
			// oToolbarController.iToolbarType = oToolbarController.oActiveXCtl.Type;
		} catch(Err){
			this.bToolbarErrorCaught=true;
		}
	},
	
	get_htmlCtl_data: function()
	{
		this.sHtmlMenuCtlId = this.oHtmlMenuCtl.GetUID('http://www.funwebproducts.com/');
		this.DEBUG("get_htmlCtl_data: this.sHtmlMenuCtlId  = " + this.sHtmlMenuCtlId );
		//this.DEBUG("get_htmlCtl_data: this.winner.classid  = " + this.winner.classid );
		//this.DEBUG("get_htmlCtl_data: winner = " + this.winner.toolbar + "." + this.winner.name );
	},
	
	parse_partner: function( _partnerid )
	{
		var parentid = null;
		var childid = null;
		var bucket = null;
		if ( _partnerid.indexOf("_") > -1 ){
			var parts = _partnerid.split("_");
			parentid = parts[1];
			childid = parts[0];
		} else {
			parentid = _partnerid;
		}
		bucket = ( parentid.length >= 10 ) ? parentid.substr(8,2) : null ;
		return {
			parentid: parentid,
			childid: childid,
			bucket: bucket
		};
		//this.sParentPartnerID = parentid;
		//this.sBucket = ( bucket ) ? bucket : "" ;
	},
	
	instantiate: function( _props )
	{
		// switch
		switch ( _props.name ){
			case 'settingsCtl':
				this._instantiate_Ctl( _props );
				this.DEBUG("instantiate: [settingsCtl] _props.html_id = " + _props.html_id);
				this.DEBUG("instantiate: [settingsCtl] document.getElementById( _props.html_id ) = " + document.getElementById( _props.html_id ));
				this.oSettingsCtl = document.getElementById( _props.html_id );
				this.get_settingsCtl_data();
				break;
			case 'htmlMenuCtl':
				this._instantiate_Ctl( _props );
				this.DEBUG("instantiate: [htmlMenuCtl] _props.html_id = " + _props.html_id);
				this.DEBUG("instantiate: [htmlMenuCtl] document.getElementById( _props.html_id ) = " + document.getElementById( _props.html_id ));
				this.oHtmlMenuCtl = document.getElementById( _props.html_id );
				this.get_htmlCtl_data( _props );
				break;
		}
	},
	
	_instantiate_Ctl: function( _props )
	{
		try {
			if ( window.ActiveXObject ){
				new ActiveXObject( _props.activeX_object );
				//var object_tag = "<object id=\""+_props.html_id+"\" classid=\"clsid:"+_props.classid+"\" width=1 height=1>&nbsp;</object>";
				var object_tag = this.get_tag_html( { tagname:"object", attribs: _props } );
				//this.DEBUG("_instantiate_Ctl: object_tag = " + object_tag);
				document.write(object_tag);
				//this.bInstalled = true;
			} else if ( this.plugin_exists( _props.mimetype ) ){
				/*
				var embed_tag = "<embed id=\""+_props.html_id+"\"" +
								" type=\""+_props.mimetype+"\"" +
								" ProgId=\""+_props.prog_id+"\"" +
								" width=2 height=2>&nbsp;</embed>";
				*/
				var embed_tag = this.get_tag_html( { tagname:"embed", attribs: _props } );
				document.write(embed_tag);
				//this.bInstalled = true;
			}
		} catch(Err){
			this.bToolbarErrorCaught=true;
		}
	},
	
	get_tag_html: function( _props )
	{
		if ( _props.tagname == undefined || _props.tagname == "" || _props.tagname == null ){ _props.tagname = "object"; }
		var html = "";
		if ( _props.tagname == 'embed' ){
			html = this._get_embed_tag_html( _props.attribs );
		} else {
			html = this._get_object_tag_html( _props.attribs );
		}
		return html;
	},
	
	_get_object_tag_html: function( _props )
	{
		var tag_html = "<object id=\""+_props.html_id+"\"" +
						" classid=\"clsid:"+_props.classid+"\"" +
						" width=1 height=1>&nbsp;</object>";
		return tag_html;
	},
	
	_get_embed_tag_html: function( _props )
	{
		var tag_html = "<embed id=\""+_props.html_id+"\"" +
						" type=\""+_props.mimetype+"\"" +
						" ProgId=\""+_props.prog_id+"\"" +
						" width=2 height=2>&nbsp;</embed>";
		return tag_html;
	},
	
	get_toolbar_from_master: function( _key )
	{
		var parts = _key.split(".");
		//this.DEBUG("get_toolbar_from_master: _key = " + _key);
		//this.DEBUG("get_toolbar_from_master: parts = " + parts);
		//this.DEBUG("get_toolbar_from_master: parts[0] = " + parts[0]);
		//this.DEBUG("get_toolbar_from_master: parts[1] = " + parts[1]);
		return this.master_list[parts[0]][parts[1]];
	},
	
	tb_exists: function( _props )
	{
		//this.DEBUG("tb_exists: is it exe/xpi = " + _props.exe + "/" + _props.xpi);
		if ( _props.exe ){
			var bExe = this._exe_exists( _props );
			this.DEBUG("tb_exists: bExe = " + bExe);
			return bExe;
		} else if ( _props.xpi ){
			var bXpi = this._xpi_exists( _props );
			return bXpi;
		}
	},
	
	_exe_exists: function( _props )
	{
		try {
			if (window.ActiveXObject) {
				new ActiveXObject( _props.activeX_object );
				return true;
			} else {
				if ( this.plugin_exists( _props.mimetype ) ){
					return true;
				}
			}
		} catch(Err){
			this.DEBUG("_exe_exists: Err = " + Err);
		}
		return false;
	},
	
	_xpi_exists: function( _props )
	{
		if ( this.browser.name == "firefox" ){
			var tsox_el = document.getElementById('tsox_ver_el');
			this.DEBUG("_xpi_exists: tsox_el = " + tsox_el);
			if ( tsox_el ){
				try {
					this.bInstalled = this.bXPIInstalled = true;
					this.sVersion = this.sXPIVersion = tsox_el.getAttribute('ver');
					return true;
				} catch(Err){}
			} else {
				this.get_tsox_cookies();
				if ( this.cookie.config.data != null ){
					this.bInstalled = this.bXPIInstalled = true;
					this.bXPILatestVersion = this.bLatestVersion;
					return true;
				} else {
					return false;
				}
				//return ( this.cookie.config.data != null );
			}
		}
		return false;
	},
	
	get_tsox_cookies: function()
	{
		//var cookie_strings = document.cookie.split(";");
		var cookie = {};
		var start = document.cookie.indexOf(this.cookie.config.name + "=");
		if ( start < 0 ){ return; }
		var end = document.cookie.indexOf(";",start);
		if ( end < 0 ){ end = document.cookie.length; }
		start += ( this.cookie.config.name.length + 1 );
		//this.DEBUG("get_tsox_cookies: start = " + start);
		//this.DEBUG("get_tsox_cookies: end = " + end);
		var data = unescape( document.cookie.substring(start,end) );
		this.DEBUG("get_tsox_cookies: data = " + data);
		var params = data.split("&");
		//this.DEBUG("get_tsox_cookies: params.length = " + params.length);
		for ( kvp in params ){
			var key = params[kvp].split("=")[0];
			var val = params[kvp].split("=")[1];
			//this.DEBUG("get_tsox_cookies: " + key + " = " + val);
			cookie[key] = val;
		}
		this.cookie.config.data = cookie;
	},

	NeedsUpgrade: function( _compare )
	{
		this.DEBUG("NeedsUpgrade: typeof(_compare) = " + typeof(_compare));
		if ( typeof(_compare) == "string" ){
			if ( this.sVersion != this.get_max_version( _compare, this.sVersion ) ){
		 		return true;
		    }	
		} else if( _compare != null && _compare != undefined ) {
			this.DEBUG("NeedsUpgrade: _compare.tb = " + _compare.tb );
			this.DEBUG("NeedsUpgrade: _compare.ver = " + _compare.ver );
			try {
				var parts = _compare.tb.split(".");
				var check = false;
				if ( this.winner.toolbar == parts[0] && this.winner.name == parts[1] ){ check = true; }
				this.DEBUG("NeedsUpgrade: check = " + check );
				if ( check ){
					this.DEBUG("NeedsUpgrade: version match = " + ( this.sVersion != this.get_max_version( _compare.ver, this.sVersion ) ) );
					return ( this.sVersion != this.get_max_version( _compare.ver, this.sVersion ) );
				}
			} catch(Err){}
		}
		
	    return false;
	},
	
	check_versions: function( _current, _latest, _required )
	{
		this.DEBUG("check_versions: _current = " + _current);
		this.DEBUG("check_versions: _latest = " + _latest);
		this.DEBUG("check_versions: _required = " + _required);
		if ( _current == null || _current == undefined ){ _current = ""; }
		if ( _latest == null || _latest == undefined ){ _latest = ""; }
		if ( _required == null || _required == undefined ){ _required = ""; }
		var aToolbarVersion = ( _current != "" ) ? _current.split('.') : [];
		var aLatestVersion = ( _latest != "" ) ? _latest.split('.') : ['0','0'];
		var aRequiredVersion = _required.split('.');
		
		for (i=0; i < aToolbarVersion.length; i++){
			//this.DEBUG("check_versions: i = " + i);
			if ( aToolbarVersion[i].length == 1 ) aToolbarVersion[i] = "0" + aToolbarVersion[i];
			if ( aLatestVersion[i].length == 1 ) aLatestVersion[i] = "0" + aLatestVersion[i];
			if ( aRequiredVersion[i].length == 1 ) aRequiredVersion[i] = "0" + aRequiredVersion[i];
		}
		
		var iToolbarVersion = aToolbarVersion.join("");
		var iLatestToolbarVersion = aLatestVersion.join("");
		var iRequiredToolbarVersion = aRequiredVersion.join("");
		
		//this.DEBUG("check_versions: iToolbarVersion = " + iToolbarVersion);
		//this.DEBUG("check_versions: iLatestToolbarVersion = " + iLatestToolbarVersion);
		//this.DEBUG("check_versions: iRequiredToolbarVersion = " + iRequiredToolbarVersion);
		
		iToolbarVersion = iToolbarVersion - 0;
		iLatestToolbarVersion = iLatestToolbarVersion - 0;
		iRequiredToolbarVersion = iRequiredToolbarVersion - 0;
		
		return {
				latest:(iToolbarVersion >= iLatestToolbarVersion),
				upgrade:(iToolbarVersion < iRequiredToolbarVersion)
		};
	},
	
	get_max_version: function( _v1, _v2 )
	{
		this.DEBUG("get_max_version: _v1 = " + _v1);
		this.DEBUG("get_max_version: _v2 = " + _v2);
		var aVersion1 = _v1.split(".");
		var aVersion2 = _v2.split('.');
		if ( aVersion1.length < aVersion2.length ){
			aVersion1 = this._pad_version_number( aVersion1, aVersion2.length );
		} else if ( aVersion1.length > aVersion2.length ){
			aVersion2 = this._pad_version_number( aVersion2, aVersion1.length );
		}
		for (i=0; i < aVersion1.length; i++){
			if (aVersion1[i].length == 1) aVersion1[i] = "0" + aVersion1[i];
			if (aVersion2[i].length == 1) aVersion2[i] = "0" + aVersion2[i];
		}
		this.DEBUG("get_max_version: aVersion1 = " + aVersion1.join("."));
		this.DEBUG("get_max_version: aVersion2 = " + aVersion2.join("."));
		
		var iToolbarVersion = aVersion1.join("");
		var iLatestToolbarVersion = aVersion2.join("");
		iToolbarVersion = iToolbarVersion - 0;
		iLatestToolbarVersion = iLatestToolbarVersion - 0;
		
		return ( iToolbarVersion >= iLatestToolbarVersion ) ? _v1 : _v2 ;
	},
	
	_pad_version_number: function( _value_array, _max )
	{
		this.DEBUG("_pad_version_number: _value_array.length = " + _value_array.length);
		this.DEBUG("_pad_version_number: _max = " + _max);
		for( var idx=_value_array.length; idx < _max; idx++ ){
			_value_array[idx] = "0";
		}
		return _value_array;
	},
	
	plugin_exists: function( _mimetype )
	{
		navigator.plugins.refresh(false);
		var numPlugins = navigator.plugins.length;
		for (var i = 0; i < numPlugins; i++) {
			var plugin = navigator.plugins[i];
			var numTypes = plugin.length;
	        var mimetype;
	        var enabled;
	        var enabledPlugin;
	        for (var j = 0; j < numTypes; j++) {
	            mimetype = plugin[j];
	            if (mimetype) {
	                if (mimetype.type == _mimetype) {
	                	return true;
	                } 
	            }
	        }
		}
		return false;
	},
	
	get_browser: function()
	{
		if ( navigator.userAgent.search(/Firefox/i) > -1 ){
			this.browser.name = "firefox";
			try {
				this.browser.major_version = navigator.userAgent.match(/Firefox\/(\d+(\.\d*)*)/i)[1].split(".")[0];
			} catch(err){}
			return;
		}
		// make sure it's not Opera which sometimes reports itself as IE
		if ( navigator.appName.search(/Internet Explorer/i) > -1 ){
			if ( navigator.userAgent.search(/Opera\s/i) < 0 ){
				this.name = "msie";
				try {
					this.browser.major_version = navigator.userAgent.match(/msie\s(\d+(\.\d*)*)/i)[1].split(".")[0];
				} catch(err){}
				return;
			}
		}
	},
	
	get_property: function( _prop, _alt )
	{
		if ( _prop == undefined || _prop == null || _prop == "" ){ return ""; }
		if ( _alt == undefined ){ _alt = ""; }
		var pvalue = ( this[_prop] ) ? this[_prop] : _alt ;
		this.DEBUG("get_property: this["+_prop+"] = " + this[_prop]);
		return pvalue;
	},
	
	DEBUG: function( _msg )
	{
		if ( !this.debug_enabled ){ return; }
		try {
			console.log( _msg );
		}catch(err){
			/*
			try {
				document.getElementById('data_output').innerHTML += _msg + "<br />\n";
			} catch(err2){
				debug_string += _msg + "<br />\n";
			}
			*/
		}
	}
};

TOOLBAR.master_list = {
	mws: {
		settingsCtl: {
			name: "settingsCtl",
			toolbar: "mws",
			exe: true,
			xpi: false,
			mimetype: "application/x-mws-mywebsearchplugin",
			prog_id: "MyWebSearchToolBar.SettingsPlugin",
			activeX_object: "MyWebSearchToolBar.SettingsPlugin",
			classid:"07B18EAB-A523-4961-B6BB-170DE4475CCA",
			html_id: "ToolbarCtlMWS",
			min_version: "",
			max_version: "2.3.50.42",
			required_version: "2.0.4.16",
			params: {}
		},
		htmlMenuCtl: {
			name: "htmlMenuCtl",
			toolbar: "mws",
			exe: true,
			xpi: false,
			mimetype: "application/x-mws-mywebsearchplugin",
			prog_id: "FunWebProducts.HTMLMenu.2",
			activeX_object: "MyWebSearchToolBar.SettingsPlugin",
			classid:"3DC201FB-E9C9-499C-A11F-23C360D7C3F8",
			html_id: "HTMLMenuCtl",
			min_version: "",
			max_version: "2.3.50.42",
			required_version: "2.0.4.16",
			params: {}
		},
		screenSaverCtl: {
			name: "screenSaverCtl",
			toolbar: "mws",
			exe: true,
			xpi: false,
			mimetype: "application/x-mws-mywebsearchplugin",
			prog_id: "ScreenSaverControl.ScreenSaverInstaller",
			activeX_object: "ScreenSaverControl.ScreenSaverInstaller",
			classid:"9FF05104-B030-46FC-94B8-81276E4E27DF",
			html_id: "ScreenSaverInstaller",
			min_version: "",
			max_version: "2.3.50.42",
			required_version: "2.0.4.16",
			params: {
				PM: "efkfpetrqjgksgnteltlofgnoiiiiqkngkmimlfhsnfeogokhehfhghhhihjhkhlhmhnifigihiiijik",
				L: "psnllmmrkrgosmekokerjsohgneknhpehjfhpnlqsqgnokhohehfhghhhihjhkhlhmhnifigihiiijik"
			}
		},
		dataCtl: {
			name: "dataCtl",
			toolbar: "mws",
			exe: true,
			xpi: false,
			mimetype: "application/x-mws-mywebsearchplugin",
			prog_id: "FunWebProducts.DataControl",
			activeX_object: "FunWebProducts.DataControl",
			classid:"25560540-9571-4D7B-9389-0F166788785A",
			html_id: "DataControl",
			min_version: "",
			max_version: "2.3.50.42",
			required_version: "2.0.4.16",
			params: {}
		},
		xpi: {
			name: "xpi",
			toolbar: "mws",
			exe: false,
			xpi: true,
			min_version: "",
			max_version: "1.0",
			required_version: "1.0",
			element: "tsox_ver_el"
		}
	},
	vicinio: {
		settingsCtl: {
			name: "settingsCtl",
			toolbar: "vicinio",
			exe: true,
			xpi: false,
			mimetype: "application/x-selfserviceplugin",
			prog_id: "SelfServiceToolBar.SettingsPlugin",
			activeX_object: "SelfServiceToolBar.SettingsPlugin",
			classid:"4971362f-8e35-11dd-88bb-000d562c920a",
			html_id: "SettingsCtl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {}
		},
		htmlMenuCtl: {
			name: "htmlMenuCtl",
			toolbar: "vicinio",
			exe: true,
			xpi: false,
			mimetype: "application/x-selfserviceplugin",
			prog_id: "SelfService.HTMLMenu",
			activeX_object: "SelfService.HTMLMenu",
			classid:"4971365c-8e35-11dd-88bb-000d562c920a",
			html_id: "HTMLMenuCtl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {}
		},
		screenSaverCtl: {
			name: "screenSaverCtl",
			toolbar: "vicinio",
			exe: true,
			xpi: false,
			mimetype: "application/x-selfserviceplugin",
			prog_id: "SelfService.ScreenSaverInstaller",
			activeX_object: "SelfService.ScreenSaverInstaller",
			classid:"49713669-8e35-11dd-88bb-000d562c920a",
			html_id: "screenSaverCtl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {
				PM: "efkfpetrqjgksgnteltlofgnoiiiiqkngkmimlfhsnfeogokhehfhghhhihjhkhlhmhnifigihiiijik",
				L: "psnllmmrkrgosmekokerjsohgneknhpehjfhpnlqsqgnokhohehfhghhhihjhkhlhmhnifigihiiijik"
			}
		},
		dataCtl: {
			name: "dataCtl",
			toolbar: "vicinio",
			exe: true,
			xpi: false,
			mimetype: "application/x-selfserviceplugin",
			prog_id: "SelfService.DataControl",
			activeX_object: "SelfService.DataControl",
			classid:"49713653-8e35-11dd-88bb-000d562c920a",
			html_id: "DataControl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {}
		}
	},
	mindpsark: {
		settingsCtl: {
			name: "settingsCtl",
			toolbar: "mindpsark",
			exe: true,
			xpi: false,
			mimetype: "application/x-m5-mindsparkplugin",
			prog_id: "MindSpark.SettingsPlugin",
			activeX_object: "MindSpark.SettingsPlugin",
			classid:"21DBA35B-05C1-4339-9694-13D8D9133339",
			html_id: "SettingsCtl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {}
		},
		htmlMenuCtl: {
			name: "htmlMenuCtl",
			toolbar: "mindpsark",
			exe: true,
			xpi: false,
			mimetype: "application/x-m5-mindsparkplugin",
			prog_id: "MindSpark.HTMLMenu",
			activeX_object: "MindSpark.HTMLMenu",
			classid:"288FEAAB-B810-40ad-9AAC-310230590855",
			html_id: "HTMLMenuCtl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {}
		},
		screenSaverCtl: {
			name: "screenSaverCtl",
			toolbar: "mindpsark",
			exe: true,
			xpi: false,
			mimetype: "application/x-m5-mindsparkplugin",
			prog_id: "MindSpark.ScreenSaverSettings",
			activeX_object: "MindSpark.ScreenSaverSettings",
			classid:"C51F4A54-EBD1-4e21-AC05-1CCF7E8849E8",
			html_id: "screenSaverCtl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {
				PM: "efkfpetrqjgksgnteltlofgnoiiiiqkngkmimlfhsnfeogokhehfhghhhihjhkhlhmhnifigihiiijik",
				L: "psnllmmrkrgosmekokerjsohgneknhpehjfhpnlqsqgnokhohehfhghhhihjhkhlhmhnifigihiiijik"
			}
		},
		dataCtl: {
			name: "dataCtl",
			toolbar: "mindpsark",
			exe: true,
			xpi: false,
			mimetype: "application/x-m5-mindsparkplugin",
			prog_id: "MindSpark.DataControl",
			activeX_object: "MindSpark.DataControl",
			classid:"0AB15BD0-37D5-4567-9238-9781EF77E890",
			html_id: "DataControl",
			min_version: "",
			max_version: "2.3.50.19",
			required_version: "2.3.50.19",
			params: {}
		}
	}
};

function GetXpiConfig( _tb_object )
{
	var tsox_el = document.getElementById('tsox_ver_el');
	//this.DEBUG("GetXpiConfig: tsox_el = " + tsox_el);
	if ( tsox_el ) {
		try {
			TBCkElem = document.createElement("TSOX_TBCk");
			document.getElementsByTagName('head')[0].appendChild(TBCkElem);
			TBCkEvt = document.createEvent('Events');
			TBCkEvt.initEvent('TSOX_TBChkHandlerEvent', true, false);
			TBCkElem.dispatchEvent(TBCkEvt);
			(
				function(){
					if ( document.getElementsByTagName("TSOX_TBCk")[0].getAttribute("tbid")==null ){
						setTimeout( arguments.callee,50 );
					} else {
						_tb_object.set_xpi_data( { event: TBCkEvt, element: TBCkElem } );
					}
				}
			)();
		} catch(ERR){
			//this.DEBUG("GetXpiConfig: ERR = " + ERR);
		}
	} else if( this.cookie.config.data != null ) {
		
	}
}
