var MenuFocusLevel = 1;
var hasSpecialSubmenu = 0;
var MenuChapter = "";
var cids;
var gSearching = false;

var L1_LogoColorFade;
var L1_FrontColorFade;
//var L1_LogoColors = {home:'#fff', news:'#f00', persons:'#0f0', products:'#00f', sets:'#ff0', about:'#0ff', links:'#f60'};
//var L1_LogoColors = {home:'#A74F94', news:'#FF5C19', persons:'#00A0C4', products:'#ED0064', sets:'#FF9700', about:'#E61717', links:'#8DC04E'};
var L1_LogoColors = {home:'#3c3a47', news:'#FF5C19', persons:'#00A0C4', products:'#ED0064', sets:'#FF9700', my:'#FF0000', about:'#E61717', links:'#8DC04E'}; /*TODO: Get this from the Stylesheet (vkwicks.css) */

var L1_LogoColorsHash = new Hash(L1_LogoColors);

var L2_f = 0;
var L2_e = 0;
var L2_periodical;
var L2_scroll;
var L2_ContentFade;
var L2_L_btnFade;
var L2_R_btnFade;
var L2_PaneFx;

var L3_f = 0;
var L3_e = 0;
var L3_periodical;
var L3_scroll;
var L3_ContentFade;
var L3_L_btnFade;
var L3_R_btnFade;
var L3_PaneFx;

var frontSectionWidth;


var Menu = {

	start: function(){
		cids = MenuCid.split(",");
		//console.log( cids );
		
		Menu.Setup_Level0();
		Menu.SetupNavigation();
		Menu.Setup_Level1();
		Menu.ResizeNavigationMasks();
		Menu.Setup_Search();
		
		//console.log( "MenuInit_IsOpen: "+ MenuInit_IsOpen );
		//console.log( "MenuInit_L1_id: "+ MenuInit_L1_id );
		//console.log( "MenuInit_L2_id: "+ MenuInit_L2_id );
		//console.log( "MenuInit_L3_ids: "+ MenuInit_L3_ids );
		
		if( MenuInit_IsOpen ){
			
			// Load Items present in URL
			if( MenuInit_IsOpen ){
				cids.each( function(item){
					new Ajax('/ajax/pane.php?cid='+item, {method: 'get', onSuccess: function(res){ Panes.addPane( res, this.url ) }}).request();
				});
			}
			
			// Level1
			$$("#site_menu .sitemenu_itm").each( function(item){
				var id = item.id.split('_')[1];
				if( id == MenuInit_L1_id ){
					item.className += " selected";
					L1_LogoColorFade.start({'background-color': L1_LogoColors[id] });
					//L1_FrontColorFade.start({'background-color': L1_LogoColors[id] });
					MenuChapter = id;
					
					// Level2
					new Ajax('/ajax/menu.php?level=2&chapter='+MenuChapter, {
							method: 'get',
							update: $('level2menu'),

							onSuccess: function(){
								Menu.Setup_Level2();
								
								var i=0;
								$$("#level2menu .level2menu_itm").each( function(item){
									var id = item.id.split('_')[1];
									if( id == MenuInit_L2_id ){
										item.className += " selected";
										L2_f = i;
										L2_scroll.toElement( $$("#level2menu .level2menu_itm")[L2_f] );
									}
									i++;
								});
								
								// Level3
								Menu.menu_loadLevel3(MenuChapter, MenuInit_L2_id );
								
								// Scroll
								//console.log("INIT REVEAL PANES");
								Panes.showPane();

							}
						}).request();
				}
			});
			
			
		}else{
			// frontpage
			Menu.Navigate_home("home");
		}
		
		
	},
	
	Navigate_home: function( pageId ){
		MenuFocusLevel = 0;
		//console.log("Navigate_home, pageId:"+ pageId);
		
		$$("#site_menu .sitemenu_itm").each( function(item){
			item.className=item.className.replace(" selected", "");
		});
		$$("#site_additions .sitemenu_itm").each( function(item){
			item.className=item.className.replace(" selected", "");
		});
		
		L2_L_btnFade.start({'opacity': 0});
		L2_R_btnFade.start({'opacity': 0});
		L2_ContentFade.start({'opacity': 0});
		(function(){ L2_PaneFx.start({'height': 4}) }).delay(500);
		
		L3_L_btnFade.start({'opacity': 0});
		L3_R_btnFade.start({'opacity': 0});
		L3_ContentFade.start({'opacity': 0});
		(function(){ L3_PaneFx.start({'height': 1}) }).delay(500);
		
		Menu.ResizeNavigationMasks();
		
		// Load content
		if( pageId ) net.get( pageId );
		
		// Scroll
		Panes.showPage();
		
	},
	

	
	Setup_Level0: function(){
		// home
		$("site_logo").addEvent('click', function(event) {
			event = new Event(event).stop();
			L1_LogoColorFade.start({'background-color': L1_LogoColors['home'] });
			Menu.Navigate_home("home");
		});
		
		// about
		$("l1btn_about").addEvent('click', function(event) {
			event = new Event(event).stop();
			var id = this.id.split('_')[1];
			L1_LogoColorFade.start({'background-color': L1_LogoColors[id] });
			Menu.Navigate_home("about");
			this.className += " selected";
		});
		
		// something - links/sponsors?
		$("l1btn_links").addEvent('click', function(event) {
			event = new Event(event).stop();
			var id = this.id.split('_')[1];
			L1_LogoColorFade.start({'background-color': L1_LogoColors[id] });
			//L1_FrontColorFade.start({'background-color': L1_LogoColors[id] });
			Menu.Navigate_home("links");
			this.className += " selected";
		});
		
		// frontpage - all
		$('fplink_news').addEvent('click', function(event) {
			event = new Event(event).stop();
			$('l1btn_news').fireEvent("click");
		});
		$('fplink_persons').addEvent('click', function(event) {
			event = new Event(event).stop();
			$('l1btn_persons').fireEvent("click");
		});
		$('fplink_products').addEvent('click', function(event) {
			event = new Event(event).stop();
			$('l1btn_products').fireEvent("click");
		});	
		$('fplink_sets').addEvent('click', function(event) {
			event = new Event(event).stop();
			$('l1btn_sets').fireEvent("click");
		});	
		
	},
	

	
	
	Setup_Level1: function(){
		MenuFocusLevel = 1;
		$$("#site_menu .sitemenu_itm").each( function(item){
			
			var aid = item.id.split('_')[1];
			item.myid = aid;
			
			item.addEvent("click", function(){
				this.blur();
				var id = item.id.split('_')[1];
				MenuChapter = id;				
				Menu.menu_loadLevel2(MenuChapter);

				$$("#site_additions .sitemenu_itm").each( function(item){
					item.className=item.className.replace(" selected", "");
				});
				$$("#site_menu .sitemenu_itm").each( function(item){
					item.className=item.className.replace(" selected", "");
				})				
				this.className += " selected";
				
				L1_LogoColorFade.start({'background-color': L1_LogoColors[id] });
				L3_ContentFade.start({'opacity': 0 });
				L3_L_btnFade.start({'opacity': 0});
				L3_R_btnFade.start({'opacity': 0});		
			});
		});
	},
	
	menu_loadLevel2: function( chapter ){
		//console.log("menu_load2level: "+ chapter +" Add Hook here?");
		// ajax -> menu.php

		new Ajax('/ajax/menu.php?level=2&chapter='+chapter, {
				method: 'get',
				update: $('level2menu'),
				
				onSuccess: function(){
					Menu.Setup_Level2();
				}
			}).request();
		
		var p = panes_sortable.serialize();
		if( (p.length==0) || (chapter=="sets") ){
			// 080225: Sets special bhv
			net.get(chapter);
			//console.log("2 REVEAL PAGE.chapter="+chapter);
			Panes.showPage();
			
			if( chapter == "sets" ){
				(function(){ L2_PaneFx.start({'height': 4}) }).delay(500);
				(function(){ L3_PaneFx.start({'height': 1}) }).delay(500);	
				MenuFocusLevel = 0;
			}

			MenuFocusLevel = 1;
			
		}else{
			// Load section frontpage (only if there is NO panes loaded):
			Panes.showPane();
		}
		/*
		// Load section frontpage (only if there is NO panes loaded):
		var p = panes_sortable.serialize();
		// console.log( "p.length: "+ p.length );
		if( p.length == 0 ){
			net.get(chapter);
			console.log("2 REVEAL PAGE");
			Panes.showPage();
		}else{
			console.log("2 REVEAL PANES");
			Panes.showPane();
		}
		*/
	},
	
	
	Setup_Level2: function(){
		// Called by onComplete in menu_loadLevel2()		
		MenuFocusLevel = 2;
		L2_f = 0;
		L2_e = $$("#level2menu .level2menu_itm").length-1;
		
		if( L2_e < 0 ){
			L2_L_btnFade.start({'opacity': 0});
			L2_R_btnFade.start({'opacity': 0});
			return;
		}
		
		L2_scroll.toElement( $$("#level2menu .level2menu_itm")[L2_f] );
		if( MenuInit_IsOpen ){
			L2_ContentFade.set({'opacity': 1 });
			L2_PaneFx.set({'height': 31});
		}else{
			L2_ContentFade.start({'opacity': 1 });
			L2_PaneFx.start({'height': 31});
			L3_L_btnFade.start({'opacity': 0});
			L3_R_btnFade.start({'opacity': 0});
			(function(){ L3_PaneFx.start({'height': 0}) }).delay(500); /* */
		}
		

		
		$$("#level2menu .level2menu_itm").each( function(item){
			item.removeEvents("click");
			item.addEvent("click", function(event){
				event = new Event(event).stop();
				this.blur();
				Menu.menu_loadLevel3(MenuChapter, item.id.split('_')[1] );
				
				$$("#level2menu .level2menu_itm").each( function(item){
					item.className=item.className.replace(" selected", "");
				})
				
				this.className += " selected";
			});
		});
	},
	
	
	menu_loadLevel3: function( chapter, catid ){
			
		$$("#level3_content .level3menu_itm").each( function(item){
			// Removing the element also kills its effects - and therefore solves the error occuring if we have effects running when changing category
			item.remove();
		});	
			
		//alert("menu_load2level: "+ chapter );
		// ajax -> menu.php
		new Ajax('/ajax/menu.php?level=3&chapter='+chapter+"&catid="+catid, {
				method: 'get',
				update: $('level3_content'),
				
				onStart: function(){
					//L3_ContentFade.start({'opacity': 0.2 });
				},
				
				onSuccess: function(){
					Menu.Setup_Level3();
				}
			}).request();
			
			// Load section frontpage (only if there is NO panes loaded):
			var p = panes_sortable.serialize();
			if( p.length == 0 ){
				net.get(chapter+'_3');
				Panes.showPage();
			}else{
				Panes.showPane();
			}
		
	},
	
	Setup_Level3: function(){
		// Called by onComplete in menu_loadLevel3()
		MenuFocusLevel = 3;
		L3_f = 0;
		L3_e = $$("#level3_content .level3menu_itm").length-1;

		
		hasSpecialSubmenu = ( $("ismy") ) ? true:false; /********/
		//console.log( "Setup_Level3.hasSpecialSubmenu:"+ hasSpecialSubmenu );
		
		if( hasSpecialSubmenu && $("ismy") ){
			My.init_mymenu();	
		}		

		
		if( L3_e < 0 ){
			L3_L_btnFade.start({'opacity': 0});
			L3_R_btnFade.start({'opacity': 0});
			//return;
		}
		
		if( hasSpecialSubmenu ){
			/* my */
			L3_scroll.toElement( $("#level3_content") );
			$("level3_mask").removeClass("disabled").addClass("disabled");
		}else{
			$("level3_mask").removeClass("disabled");
			L3_scroll.toElement( $$("#level3_content .level3menu_itm")[L3_f] );
		}

		/*
		if( MenuInit_IsOpen ){
			console.log("MenuInit_IsOpen");
			L3_ContentFade.set({'opacity': 1 });
			L3_PaneFx.set({'height': 29});
			Panes.updatePanes();
		}else{
			(function(){ L3_ContentFade.start({'opacity': 1 }) }).delay(500);
			L3_ContentFade.set({'opacity': 1 }); // testing! the above should work...
			L3_PaneFx.start({'height': 29});
		}
		*/
		//L3_ContentFade.start({'opacity': 1 });
		(function(){ L3_ContentFade.start({'opacity': 1 }) }).delay(500);
		L3_PaneFx.start({'height': 29});
		
		//
		Menu.ResizeNavigationMasks();
		
		// Detail BOX init
		$$("#level3_content .level3menu_itm").each( function(item){
			item.addEvent("mouseenter", function(){
				var pos = item.getPosition();
				var item_cid = item.getParent().id.split('_')[2];
				$('level3_detail_txt').setHTML(item.alt);
				$('level3_detail').setStyle('left', pos.x-19);
				
				// Fetch images
				new Ajax('/ajax/z_get_image.php?cid='+ item_cid +'&action=0&size=1', {onSuccess: function(){
					$('level3_detail_img').setHTML( this.response.text );
				}}).request();
			});
		});
		

		// Detail BOX - hide and show
		$('site_navigation').addEvent("mouseleave", function(){
			if(!hasSpecialSubmenu) $('level3_detail').setStyle('visibility', 'hidden');
		});
		$('level2').addEvent("mouseenter", function(){
			if(!hasSpecialSubmenu) $('level3_detail').setStyle('visibility', 'hidden');
		});
		$('level3_content').addEvent("mouseenter", function(){
			if(!hasSpecialSubmenu) $('level3_detail').setStyle('visibility', 'visible');
		});
		$('level3_content').addEvent("mouseleave", function(){
			if(!hasSpecialSubmenu) $('level3_detail').setStyle('visibility', 'hidden');
		});		
		
		//
		var delay_time = 0;
		if( $("level3_content") ){
			$$("#level3_content .level3menu_itm").each( function(item){
				(function(){ item.effect('opacity', {duration: 500, transition: Fx.Transitions.linear}).start(0,1) }).delay(delay_time);
				delay_time+=50;
			
				/* */
				item.removeEvents("click");
				item.addEvent("click", function(event){
					event = new Event(event).stop();
					this.blur();
					var cid = item.getParent().id.split('_')[2];
					//console.log("calling panes.php with cid: "+ cid);
					new Ajax('/ajax/pane.php?cid='+cid, {//+'&r='+ Math.random()*99, {
							method: 'get',
							onSuccess: function(res){
								Panes.showPane();									
								Panes.addPane( res, this.url );
							}							
						}).request();
				});
			});
			
			Menu.Update_Selections_Level3();
		}
		
		Panes.hideLevel4();
		
		// By now the MenuInit caused by MenuInit_IsOpen should be completed:
		MenuInit_IsOpen = false;
	},
	
	
	Setup_Search: function(){
		
		$('search_input').addEvent("focus", function(event){
			if( this.value == "search") this.value = "";
		}),
		
		$('search_form').addEvent("submit", function(event){
			event = new Event(event).stop();
			if( !gSearching ) Menu.doSearch();
		}),			
		
		
		$('search_btn').addEvent("click", function(event){
			event = new Event(event).stop();
			if( !gSearching ) Menu.doSearch();
		});
	},
	
	doSearch: function(){
		var q = $('search_form').toQueryString();
		
		// Create a new CID and Pane
		q += "&cid=Q"+ Math.round( Math.random()*9999999 );
		
		// Pass the search_page value to the search script:
		var page = $('search_page').value;
		if( page != "" ) q += "&page="+ page;
		
		// disable the search funk while searching
		gSearching = true;
		
		$('search_input').blur();
		$('search_input').removeClass("searching").addClass("searching");
		$('search_btn').removeClass("searching").addClass("searching");
		$('search_progress').removeClass("loading").addClass("loading");
		
		// If the search_ccid field has a value, load the search results into it
		var ccid = $('search_ccid').value;
		if( ccid != "" ){
			//console.log( "search: REPLACE" );
			
			q += "&ccid="+ ccid;
			
			var tmp = document.createElement("div");
			tmp.injectBefore( $(ccid) );
			
			//console.log( "search q: "+ q );
			
			new Ajax('/ajax/search.php?'+q, {
					method: 'get',
					update: tmp,
					onSuccess: function(res){
						var rcid = $('search_ccid').value;
						
						// Clear the form, so new searches gets new panes
						$('search_page').value = "";
						$('search_ccid').value = "";
						
						q = net.splitQuery(this.url);
						var cid  = q["cid"];
						var ccid = q["ccid"];
						 
						//console.log("loaded cid(new) "+ $(cid) +", ccid(old): "+ $(ccid) +", tmp:"+ tmp);
						
						$(ccid).replaceWith( tmp.firstChild );
						tmp.remove();
						
						Panes.initPanes();
						Panes.updatePanes();
						(function(){ Panes.initPanes() }).delay(500);
						
						$('search_input').removeClass("searching");
						$('search_btn').removeClass("searching");
						$('search_progress').removeClass("loading");
						gSearching = false;
					}
				}).request();
		
		
		}else{
			//console.log( "search: NEW" );
			//console.log( "search q: "+ q );

			new Ajax('/ajax/search.php?'+q, {
					method: 'get',
					onSuccess: function(res){
						Panes.showPane();
						Panes.addPane( res, this.url );
						
						$('search_input').removeClass("searching");
						$('search_btn').removeClass("searching");
						$('search_progress').removeClass("loading");
						gSearching = false;					
					}
				}).request();
		}
	},
	
	
	feed_loadSection: function(ccid, curr, num){
		//console.log("feed_loadNext cid:"+ ccid +", curr:"+ curr +", num:"+ num);
		
		var ccid = ccid;
		var curr_e = $(ccid);
		var tmp = document.createElement("div");
		tmp.injectBefore( $(ccid) );
		new Ajax('/ajax/pane.php?cid='+ccid+'&start='+curr+'&count='+num, {
				method: 'get',
				update: tmp,
				onSuccess: function(res){
					curr_e.replaceWith( tmp.firstChild );
					tmp.remove();
					Panes.initFlashContent( ccid );
					Panes.initPanes();
					Panes.updatePanes();
					(function(){ Panes.initPanes() }).delay(1000);
				}
			}).request();
		
	},
	
	setSearchPage: function( _cid, _v ){
		$('search_ccid').value = _cid;
		$('search_page').value = _v;
		Menu.doSearch();
	},

	Update_Selections_Level3: function(){
		var doc_cids = panes_sortable.serialize();
		$$("#level3_content .level3menu_itm").each( function(item){
			item.className=item.className.replace(" selected", "");
			var id = item.getParent().id.split('_')[2];
			if( doc_cids.in_array( id ) ) item.className += " selected";
		});
	},
	

	/* */
	
	ToggleMenuScrollButtons: function(){
		// Moo1.2 Compat
		/*
		http://blog.mootools.net/2007/11/14/mootools-1-2-beta-1
		
		getTop(), getCoordinates().top		-> getPosition().y
		getCoordinates().height 			-> getOffsetSize().y
		getLeft()							-> getPosition().x
		*/
		
		// L2
		if( MenuFocusLevel < 2 ) return;
		
		var hide_left  = ($("level2menu").getPosition().x >= $("level2menu_mask").getPosition().x  );
		if( !($$("#level2menu .level2menu_itm")[L2_e]) ) return	
		var hide_right = ($$("#level2menu .level2menu_itm")[L2_e].getPosition().x <  $('level2menu_mask').getOffsetSize().x);
		//console.log("L2 hide_left: %s, hide_right: %s ", hide_left, hide_right);
		
		L2_L_btnFade.start({'opacity': (hide_left)?0:1});
		L2_R_btnFade.start({'opacity': (hide_right)?0:1});
		
		
		// L3
		if( MenuFocusLevel < 3 ) return;
		
		hide_left  = ($("level3_content").getPosition().x >= $("level3_mask").getPosition().x  ); //ok
		
		var l3_cw	= $$("#level3_content .level3menu_itm").length * 29;	// width of content
		var l3_cs	= $("level3_mask").getScroll().x;						// scroll of content (inside mask)
		var l3_mw	= $("level3_mask").getOffsetSize().x; 					// width of the mask
		var h2		= l3_cw - (l3_cs + l3_mw);
		hide_right	= (h2 < 0);
		//console.log("L3 hide_left: %s, hide_right: %s, h1: %s", hide_left, hide_right, h2);
				
		L3_L_btnFade.start({'opacity': (hide_left)?0:1});
		L3_R_btnFade.start({'opacity': (hide_right)?0:1});
	},
	
	SetupNavigation: function(){
		
		L1_LogoColorFade = $("logo_color").effects({
			wait: false,
			duration: 2000,
			transition: Fx.Transitions.Quart.easeOut
		});
		
		L1_FrontColorFade = $("front").effects({
			wait: false,
			duration: 2000,
			transition: Fx.Transitions.Quart.easeOut
		});		

		L2_ContentFade = $("level2menu").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
		L2_L_btnFade = $("level2_left").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
		L2_R_btnFade = $("level2_right").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
		L2_PaneFx = $("level2").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
				
		L3_ContentFade = $("level3_content").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
		L3_L_btnFade = $("level3_left").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
		L3_R_btnFade = $("level3_right").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut
		});
		L3_PaneFx = $("level3").effects({
			wait: false,
			duration: 1000,
			transition: Fx.Transitions.Quart.easeOut,
			onStart: function(){
				// remove childs
				if( L3_PaneFx.to.height[0].value < 10 ){
					$$("#level3_content .level3menu_itm").each( function(item){
						item.remove();
					});
					$('level3_detail').setStyle('visibility', 'hidden');
				}
			},
			onComplete: Panes.updatePanes
		});
		
		
		// Level 2
		L2_scroll = new Fx.Scroll('level2menu_mask', {
			wait: false,
			duration: 300,
			offset: {'x': 0, 'y': -9},
			transition: Fx.Transitions.Cubic.easeOut,
			onComplete: Menu.ToggleMenuScrollButtons
		});
		
		$('level2_right').addEvent('click', function(event) {
			event = new Event(event).stop();
			L2_f++;
			if(L2_f>=L2_e)L2_f=L2_e;
			L2_scroll.toElement( $$("#level2menu .level2menu_itm")[L2_f] );
			
		});
		
		$('level2_left').addEvent('click', function(event) {
			event = new Event(event).stop();
			L2_f--;
			if(L2_f<0)L2_f=0;
			L2_scroll.toElement( $$("#level2menu .level2menu_itm")[L2_f] );
		});
		
		// Level 3
		L3_scroll = new Fx.Scroll('level3_mask', {
			wait: false,
			duration: 300,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Cubic.easeOut,
			onComplete: Menu.ToggleMenuScrollButtons
		});
		
		$('level3_right').addEvent('click', function(event) {
			event = new Event(event).stop();
			L3_f += 10;
			if(L3_f>L3_e)L3_f=L3_e;
			L3_scroll.toElement($$("#level3_content .level3menu_itm")[L3_f]); 
		});
		
		$('level3_left').addEvent('click', function(event) {
			event = new Event(event).stop();
			L3_f -= 10;
			if(L3_f<0)L3_f=0;
			L3_scroll.toElement($$("#level3_content .level3menu_itm")[L3_f]);
		});
	},
	
	ResizeNavigationMasks: function(){

		var ds = document.getOffsetSize();
		//console.log("ResizeNavigationMasks, ds.x: "+ (ds.x) );

		$('display').setStyle('visibility','visible');
		$('btm_tools').setStyles({visibility:'visible'});
		$("level2menu_mask").setStyle("width", $("level2_right").getPosition().x-65);
		
		if( !hasSpecialSubmenu ){
			$("level3_mask").setStyle("width", $("level3_right").getPosition().x-65);
		}
		
		
		// test
		if( MenuFocusLevel < 3 ){
			$("level3_mask").setStyle("width", 10);
		}
		////////////////
			
		Menu.ToggleMenuScrollButtons();
		
		$('btm_tools').setStyles({visibility:'visible', height:30});
		$('btm_tools').setStyles({'width': ds.x, 'top':ds.y-30});
		
		var ztx = ds.x-200;
		ztx = $("level3_right").getPosition().x+31;
		
		$('z_tools').setStyles({'width': ztx+5, 'top':ds.y-30}); // ok
		$('z_savetools').setStyles({'left': ztx+15});
		$('z_pane').setStyles({'width': ztx+10});
		
		// front
		frontSectionWidth = ds.x;
		$('frontpage').setStyle('width', 8*(frontSectionWidth+2) );
		$$('#frontpage .frontpage_segment').each( function(e){
			e.setStyle('width', frontSectionWidth);
		});
		

	}

// end Menu
};

