function custom_init(resMode){

	window.addEvent('resize', 
					function(){ 
						initSub(resMode);
					} );
	initSub(resMode);
	initSubmenu();
	
	var ce_sub = $$('.ce_sub')[0];
	var background = $$('#background img');
	
	if(!background.length)
			var background = $$('div.clickarea');
	
	if(tt_back.length && tt_next.length && tt_more.length){
	
		if($defined(ce_sub)){
//			var up = new Tips($('content'),{'className':'tooltip'});
//			$('content').store('tip:title', tt_back);
			
			var up = new Tips($('content'),{'className':'tooltip'});
			$('content').store('tip:title', tt_back);
			
			$('content').setStyle('cursor','pointer');
			
			var next = new Tips(ce_sub,{'className':'tooltip'});
			ce_sub.store('tip:title', tt_next);
//			$('ce_sub_content').store('tip:title', tt_next);
		}
		
		if($defined(background)){
		
			var up = new Tips(background,{'className':'tooltip'});
			background.store('tip:title', tt_more);			
			background.setStyle('cursor','pointer');

		}
	
		var browsemenu = $('browsemenu');
		if($defined(browsemenu)){
			$('content').addEvent('click',function(e){
												e.stop();
												window.location.href = browsemenu.getElements('a')[0].href;
											});
			if($defined(browsemenu.getElements('a')[1])){
//				$$('#content>div').addEvent('click',function(e){
				if($defined($('ce_sub_content'))){
					$('ce_sub_content').addEvent('click',function(e){
														e.stop();
														window.location.href = browsemenu.getElements('a')[1].href;
													});
					$('ce_sub_caption').addEvent('click',function(e){
														e.stopPropagation();
													});
				} else {
					$$('#content>div').addEvent('click',function(e){
														e.stop();
														window.location.href = browsemenu.getElements('a')[1].href;
													});
				}
			}
			browsemenu.setStyle('display','none');
		}
		
	}
}

function initSubmenu(){

	if($defined($('mm_projekte'))){

		var mp = $$('#mm_projekte li');
		
		mp.each( function(m){
						m.fade('hide');
					} );

		$$('#mm_projekte').getChildren('ul')[0].addEvent('mouseenter',
										 function(e){
												e.stop();
												var li = $$('#mm_projekte li');
												li.each(function(m,i){
													m.set('tween',{duration:(( li.length - i )*100),link:'chain'});
													m.fade('in');
												}) } );

		$$('#mm_projekte').getChildren('ul')[0].addEvent('mouseleave',
										 function(e){
												e.stop();
												var li = $$('#mm_projekte li');
												li.each(function(m,i){
													m.set('tween',{duration:(( i )*20),link:'chain'});
													m.fade('out');
												}) } );
	}
}

function initSub(resMode){

	var windowSize = window.getSize();
	var ce_sub = $$('.ce_sub')[0];
	var background = $$('#background img');
	var submenu = $('submenu');
		
	var tt = $$('.tooltip');
	
	if($defined(tt)){
		tt.each(function(t){ t.setStyles({ top:10 , left:10 } ); } );	
	}		
		
	if($defined(ce_sub)){
		var height = (windowSize.y).limit(0,600)*0.8;
		var width = height / 0.6;
		
		var left = (windowSize.x-width)/2;
		var top = (windowSize.y-height)/2.7;
		
		ce_sub.setStyle('width',width );
		ce_sub.setStyle('height',height );

		ce_sub.setStyle('left',left);
		ce_sub.setStyle('top',top);
		
		submenu.setStyle('left',(left+width-submenu.getSize().x+10));
		submenu.setStyle('top',(top+height+10));
	}

	if($defined(background)){
	
		if( m = $('mainmenu') )
			mHeight = m.getSize().y;
	
		bHeight = windowSize.y - mHeight;
		bWidth = windowSize.x;
	
		switch(resMode){
			case 'fit':
				if(bWidth < (bHeight*1.6)){
					// console.log('x < y');
					h = bHeight;
					w = h * 1.6;
					x = (bWidth - w) / 2;
					background.setStyle('width',w );
					background.setStyle('height',h );
					background.setStyle('position','absolute' );
					background.setStyle('left',x );
					background.setStyle('top',0 );
				} else {		
					// console.log('x >= y');
					w = bWidth;
					h = w / 1.6;
					y = (bHeight - h) / 2;
					background.setStyle('width',w );
					background.setStyle('height',h );
					background.setStyle('position','absolute' );
					background.setStyle('top',y );
					background.setStyle('left',0 );
				}
				break;
			case 'all':
			default:
				if(bWidth > (bHeight*1.6)){
					// console.log('x < y');
					h = bHeight;
					w = h * 1.6;
					x = (bWidth - w) / 2;
					background.setStyle('width',w );
					background.setStyle('height',h );
					background.setStyle('position','absolute' );
					background.setStyle('left',x );
					background.setStyle('top',0 );
				} else {		
					// console.log('x >= y');
					w = bWidth;
					h = w / 1.6;
					y = (bHeight - h) / 2;
					background.setStyle('width',w );
					background.setStyle('height',h );
					background.setStyle('position','absolute' );
					background.setStyle('top',y );
					background.setStyle('left',0 );
				}
				break;
			
		}
	}
}
