
var previousPaneIds = new Object( );

function expandcontent(paneId, aobject, blockId) {
	// set the tab styles
	if (previousPaneIds.blockId!=null) {
		document.getElementById('TAB_' + previousPaneIds.blockId).className = 'positioningTab';
		document.getElementById('PANE_' + previousPaneIds.blockId).style.display = "none";
	}
	
	document.getElementById('TAB_' + paneId).className = 'selectedTab';
	document.getElementById('PANE_' + paneId).style.display = "block";
	
	setPrevious(paneId, blockId);
	
	if (aobject != null) if (aobject.blur) 
		aobject.blur();
	
	return false;
}


function setPrevious(paneId, blockId) {
	previousPaneIds.blockId = paneId;
	SetCookie('tabMemory' + blockId, paneId);
}

function getCurrentTab(defaultTab, blockId) {

	// have we already been using the tabs?
	if ((previousPaneIds.blockId != null)&&(doesTabExist(previousPaneIds.blockId))) {
		return previousPaneIds.blockId;
	}
	
	// is it in the qs?
	var args = getAmpArgs();
	argtab = eval('args.' + blockId);
	if ((argtab != null)&&(doesTabExist(argtab))) {
		// and 
		return argtab;
	}
	
	// is it in the cookie memory?
	ctab = GetCookie('tabMemory' + blockId);
	if ((ctab != null)&&(doesTabExist(ctab))) {
		return ctab;
	}
	
	// ok fine, you get the default.
	return defaultTab;
}

function doesTabExist(blockId) {
	if (document.getElementById('TAB_' + blockId) != null) {
		
		return true;
	}
	
	return false;
}


function selectTab(paneId, aobject, blockId) {
	// set the tab styles
	if (previousPaneIds.blockId!=null) {
		document.getElementById('TAB_' + previousPaneIds.blockId).className = '';
		document.getElementById('PANE_' + previousPaneIds.blockId).className = '';
		
		/*
		document.getElementById('TAB_' + previousPaneIds.blockId)
			.getElementsByTagName('span')[0]
			.className = 'corner_4x4 tr_tabPad_4x4';
		*/
	}
	
	document.getElementById('TAB_' + paneId).className = 'selected';
	document.getElementById('PANE_' + paneId).className = 'selected';
	
	/*
	document.getElementById('TAB_' + paneId)
		.getElementsByTagName('span')[0]
		.className = 'corner_4x4 tr_tabPadSelected_4x4';
	*/
	
	setPrevious(paneId, blockId);
	
	if (aobject != null) if (aobject.blur) 
		aobject.blur();
	
	return false;
}


