function tagGrids_StartUp (_key, _mainTag, _otherTags) {

	var _sessionID = dojo.query('input[id$=WDFSessionID]')[0].value;
	var _webPath = dojo.query('input[id$=WDFWebPath]')[0].value;
	var _url = _webPath+"/xpAJAX.xsp"+_sessionID;
	
	var xhrArgs = {	
		url : _url,
		content: {	CONTEXT	: "CONTENT",
					ACTION	: "GETRELATEDCONTENT",
					KEY		: _key,
					MAIN	: _mainTag,
					OTHERS	: _otherTags,
					LANGUAGE: "G",
					FORCE	: "1"},
		handleAs: 'xml',
		load: function(response, ioArgs) {tagsGrid_Build(response, null);},
		error	: function(response, ioArgs) {if (ioArgs.xhr.status > 0) { alert (response) }}
	}
	
	dojo.xhrGet (xhrArgs);

} // END: tagGrids_StartUp

function tagsGrid_Build (_XMLData) {
	
	
	var _mainStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'key', label: 'title', items:[]}});

	dojo.forEach (_XMLData.getElementsByTagName("MAINRECORD"), function (_record, _idx) {
		_mainStore.newItem({key		: WDFW_ScriptExt_XMLValueGet (_record, 'KEY'),
							title	: WDFW_ScriptExt_XMLValueGet (_record, 'TITLE')						
							})	
	})
	
	var _otherStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'key', label: 'title', items:[]}});

	dojo.forEach (_XMLData.getElementsByTagName("OTHERRECORD"), function (_record, _idx) {
		_otherStore.newItem({key		: WDFW_ScriptExt_XMLValueGet (_record, 'KEY'),
						title	: WDFW_ScriptExt_XMLValueGet (_record, 'TITLE')						
						})	
	})

	var _cellStyles = 'font-size:10pt; background-color: #ffffff; border:0';
	var _layout = [{ cells: [{	field: 'title',	name: 'Lezte \u00C4nderung', cellStyles : _cellStyles, width: 'auto'} ]} ];
	
	_grid = dijit.byId('tagsGridMain');
	
	if (_grid == null) {
	
		_grid = new dojox.grid.DataGrid({	id				: 'tagsGridMain',
											query			: { key: '*' },
											clientSort		: true,
											selectionMode	: 'single',
											autoHeight		: true,
											structure		: _layout},
											document.createElement('div'));

		dojo.byId("tagGridMainContainer").appendChild(_grid.domNode);
		dojo.connect(_grid, "onClick", function () {tagsGrid_Open(dijit.byId('tagsGridMain'))});
		_grid.startup();
		
		_grid.setStore (_mainStore);
		_grid.setSortIndex(0);		
	} else {
		_grid.setStore (_mainStore);
	}
	
	_grid = dijit.byId('tagsGridOther');
	
	if (_grid == null) {
	
		_grid = new dojox.grid.DataGrid({	id				: 'tagsGridOther',
											query			: { key: '*' },
											clientSort		: true,
											autoHeight		: true,
											selectionMode	: 'single',
											structure		: _layout},
											document.createElement('div'));

		dojo.byId("tagGridOtherContainer").appendChild(_grid.domNode);
		dojo.connect(_grid, "onClick", function () {tagsGrid_Open(dijit.byId('tagsGridOther'))});
		_grid.startup();
		
		_grid.setStore (_otherStore);
		_grid.setSortIndex(0);		
	} else {
		_grid.setStore (_otherStore);
	}

} // END: tagsGrid_Build

function tagsGrid_Open(_grid) {
	
	var _item = _grid.getItem(_grid.selection.selectedIndex);

	var _refreshPanel = WDFW_ScriptExt_Query ('div', 'contentRefresh');
	WDFW_ScriptExt_RunEvent(_WDFW_pageEvents['eventContentShow'], _refreshPanel.id, {}, 'KEY=' + _item.key);

} // END: tagsGrid_Open
