if( typeof at == "undefined" ) at = {};
if( typeof at.treemotion == "undefined" ) at.treemotion = {};
if( typeof at.treemotion.CMS == "undefined" ) at.treemotion.CMS = {};
if( typeof at.treemotion.CMS.Menue == "undefined" ) at.treemotion.CMS.Menue = {
	ids: new Array()
	,	fix: function( jsTrack )
	{
		jsTrack.reverse();
		for( var i = 0; i < jsTrack.length; i++ )
		{
			if( at.treemotion.CMS.Menue.ids[ i ] != jsTrack[ i ] || at.treemotion.CMS.Menue.ids[ i ].length != jsTrack.length )
				var k = 0;//this.activateSection( i, jsTrack[ i ] );
		}
	}
};
at.treemotion.CMS.Menue.dyn = {
	activateSection: function( depth, id, activate )
	{
		// Wenn bereits gewählt wird dies nicht nochmals erledigt
		if( at.treemotion.CMS.Menue.ids[ depth ] == id && at.treemotion.CMS.Menue.ids.length == depth + 1
			&& typeof activate == "undefined" ) return;
		//Backend
		if( at.treemotion.CMS.backend ) at.treemotion.CMSAdm.reset();
		//Aktionen zur aktualisierung des Menues
		for( var i = at.treemotion.CMS.Menue.ids.length; i >= depth; i-- )
		{
			if( $( 'menueElement_' + i + '_' + at.treemotion.CMS.Menue.ids[ i ] ) )
			{
				$( 'menueElement_' + i + '_' + at.treemotion.CMS.Menue.ids[ i ] ).removeClassName( 'selected' );
				if( $( 'menueSub' + at.treemotion.CMS.Menue.ids[ i ] ) ) $( 'menueSub' + at.treemotion.CMS.Menue.ids[ i ] ).hide();
			}
		}
		if( typeof activate == "undefined" || activate == -2 || depth == 0 )
		{
			$('menueElement_' + depth + '_' + id ).removeClassName( 'hoovi' );
			$('menueElement_' + depth + '_' + id ).addClassName( 'selected' );
		}
		if( typeof activate != "undefined" && activate == -2 ) return;
		var idL = at.treemotion.CMS.Menue.ids.length;
		for( var i = depth + 1; i < idL; i++ )
		{
			at.treemotion.CMS.Menue.ids.pop();
		}

		at.treemotion.CMS.Menue.ids[ depth ] = id;
		bfrAdm = 'activateSections=' + at.treemotion.CMS.Menue.ids.join( '|' );
		// Untermenue laden
		if( !$( 'menueSub' + id ) ) return;
		//generate Path
		Element.show( 'menueSub' + id );
		return false;
	}
	,	hoover: function( depth, id, ret )
	{
		if( at.treemotion.CMS.Menue.ids[ depth ] != id )
		{
			//Wenn gehoovert werden soll
			if( ret ) $( 'menueElement_' + depth + '_' + id ).addClassName( 'hoovi' );
			// wenn zurück
			else $( 'menueElement_' + depth + '_' + id ).removeClassName( 'hoovi' );
		}
	}
}
