tabboxpref = 'tbox';
tabbarpref = 'dyntabbar';
tabpref = 'dyntab';
tabboxouterpref = 'dyntabbox';
tabsel = [];
changingtab = false;
function switchtab(boxid,tabid,animated) {
	tabfid = tabpref + '_' + boxid + '_' + tabid;
	tabboxfid = tabboxpref + '_' + boxid + '_' + tabid;
	if (!(ptabid = tabsel[boxid])) { tabsel[boxid] = ptabid = 1; }
	ptabfid = tabpref + '_' + boxid + '_' + ptabid;
	ptabboxfid = tabboxpref + '_' + boxid + '_' + ptabid;
	ptabboxouterid = tabboxouterpref + '_' + boxid;
	if (animated == undefined) { animated = true; }


	if (tabsel[boxid] == tabid) { return; }

	if (atabbox = document.getElementById(tabboxfid)) {

		changingtab = true;

		ptabbox = document.getElementById(ptabboxfid);

		if (animatedtab && animated) {
			if (!$('#'+boxid).attr('notfirst')) {
				$('#'+ptabboxouterid).css('height',($('#'+ptabboxouterid).css('height')));
			}
			$('#'+ptabboxfid).css('display','none');
			$('#'+tabboxfid).fadeIn("fast");
			$('#'+ptabboxouterid).animate({
				height: getHeight(atabbox) + 'px'
			}, 200 );
		} else {
			//atabbox.style.display = "block";
			$('#'+ptabboxfid).css('display','none');
			$('#'+tabboxfid).css('display','block');
		}
		if (atab = document.getElementById(tabfid)) {
			$('#'+tabfid).addClass('sel');
			tabsel[boxid] = tabid;
		}
		/* hide prev */
		if (ptabbox) {
			if (ptab = document.getElementById(ptabfid)) {
				$('#'+ptabfid).removeClass('sel');
			}
		}
	}
	$('#'+boxid).attr('notfirst',true);
}

