var menuactive = false;
	var timer = null;
	var toactive = null;
	var onMove;
	function clearMove() {
		clearInterval(onMove);
	}
	
	$(document).ready(function() {
	var total = 0;
	var sep = total = $('#branding').width();
	var divs = $('#branding div.section');
	divs.each(function(index) {
			sep -= $(this).width();
	});
	
	sep = parseInt(sep / (divs.length-1),10);
	
	divs.each(function(index) {
		if(index < (divs.length - 1))
		{
			var item = $(this).next();
			var width = item.width();
			item.css('width', sep + 'px');
			item.css('text-align', 'center');
		} else {
			$(this).css('position', 'absolute');
			$(this).css('right', '0');
		}
	});
	
	var sep = total = $('#top-menu').width();
	
	var divs = $('#top-menu div.topmenusection');
	divs.each(function(index) {
			sep -= $(this).width();
	});
	
	sep = parseInt(sep / (divs.length-1),10);
	divs.each(function(index) {
		if(index < (divs.length - 1))
		{
			var item = $(this).next();
			var width = item.width();
			
			item.css('width', sep + 'px');
			item.css('text-align', 'center');
		} else {
			$(this).css('position', 'absolute');
			$(this).css('right', '-2px');
		}
	});
	
	function setOnMove(timeout) {
		onMove = setInterval(function(){
			if($('h1') && $('#column2-main').children(':first').hasClass('module_image'))
				if((($('h1').position().top + 13) - ($('#column2-left').height() - $('.citat').height())) > 0)
					$('.citat').css('top', '' + Math.floor(($('h1').position().top + 13) - ($('#column2-left').height() - $('.citat').height())) + 'px');
		}, 1);
		setTimeout('clearMove();', timeout);
	}
	
	function setTimer(type) {
		timer = setTimeout(function() {
			clearTimeout(timer);
			
			if(toactivate != null)
				animateMenu(toactivate);//toactivate.click();
		},type != "click" ? 1500 : 1);
	}
	
	function animateMenu(obj) {
		obj.blur();
		setTimeout(function() {menuactive = false;}, 700);
		if(obj.children('li').children('ul').css('display') == 'none') {
			$('.citat').stop(true,true).fadeTo(50,0, function() {setOnMove(650);});
			$('div.left-menu li.header').each(function(index) {
				$(this).children('ul').slideUp(200);
			});
			obj.children('li').children('ul').delay(200).slideDown(500, function() {$('.citat').fadeTo(2000, 100);});
			
		}
	}
	$('#branding div').css('color', '#808285');
	$('#branding a').css('color', '#808285');
	$('#top-menu div.carpet').css('background','transparent');
	$('#top-menu div.carpet').css('z-index','-300');
	$('div.left-menu li.header').each(function(index) {
		$(this).wrap("<a href='javascript:void(0);' class='common'></a>");
		$(this).children('ul').css('display', $(this).hasClass('selected') ? 'block' : 'none');
		var act = function() {
			toactivate = $(this);
			
			if((arguments[0].type != "click") && menuactive)
				return;
			clearTimeout(timer);
			menuactive = true;
			
			setTimer(arguments[0].type);
			//animatemenu($(this));
		};
		$(this).parent().click(act);
		$(this).parent().mouseover(act);
		$(this).parent().mouseout(function() { toactivate = null; });
	});	
	
	if($('#main_front_images')) { $('#main_front_images').html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="1000" height="400px" align="middle">'+
		'<param name="allowScriptAccess" value="sameDomain" />'+
		'<param name="movie" value="/media/frontpanel.swf?file=/da" />'+
		'<param name="quality" value="high" />'+
		'<param name="wmode" value="transparent" />'+
		'<param name="bgcolor" value="#FFFFFF" />'+
		'<embed src="/media/frontpanel.swf?file=/da" quality="high" wmode="transparent" bgcolor="#FFFFFF" width="1000" height="400px" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
		'</object>');
	}
	
	$('.mediacontainer').each(function() { var m = new media();m.evaluate($(this).attr('title')); if(m.hasFlash()) m.getFlash($(this));});
	
	if($('h1') && $('#column2-main').children(':first').hasClass('module_image')) {
		$('#column2-main').children(':first').find('img').load(function() {
			if((($('h1').position().top + 13) - ($('#column2-left').height() - $('.citat').height())) > 0)
				$('.citat').css('top', '' + Math.floor(($('h1').position().top + 13) - ($('#column2-left').height() - $('.citat').height())) + 'px');
		});
		var img = $('#column2-main').children(':first').find('img');
		img.attr('src', img.attr('src'));
		
	}
	
		
});
