function setMenuExpanded(type)
{
	xmlhttp = null;

	if (window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (xmlhttp != null)
	{
		xmlhttp.open("GET", "./set_menu_expanded.php?type="+type, true);
		xmlhttp.send(null);
	}
	
	var normal_arrow_img = './gfx/arrow_double.jpg';
	var activ_arrow_img = './gfx/arrow_activ.jpg';
	
	var sell_arrow = document.getElementById('sell_arrow');
	var rent_arrow = document.getElementById('rent_arrow');
	
	if(sell_arrow != null && rent_arrow != null)
	{
		if(type == 'rent')
		{
			sell_arrow.src = normal_arrow_img;
			rent_arrow.src = activ_arrow_img;
		}
		else
		{
			sell_arrow.src = activ_arrow_img;
			rent_arrow.src = normal_arrow_img;
		}
	}
}

var typeOfMenuExpanded = 0;

var myAccordion = null;

//				domready / load
window.addEvent('domready', function()
{
	var menuExpanded = document.getElementById('menu_expanded');
	
	if(menuExpanded != null)
	{
		if(menuExpanded.value == 'rent')
		{
			typeOfMenuExpanded = 1;
		}
	}
});

window.addEvent('domready', function()
{
	$$('span.flex').each(function(el)
	{ 
		var colored = false;
		
		el.addEvent('mouseenter',function()
		{
			var c = el.getStyle('color');
			if(c != '#99cc66')
			{
				el.setStyle('color', '#99cc66');
				colored = true;
			}
		})
		
		el.addEvent('mouseleave',function()
		{
			if(colored)
			{
				el.setStyle('color', '#ffffff');
			}
			colored = false;
		})
		
		el.addEvent('click',function()
		{
			//var sectionSell = document.getElementById('menu-section-sell');
			//var sectionRent = document.getElementById('menu-section-rent');
		
			//sectionSell.style.display = 'block';
			//sectionRent.style.display = 'block';

			colored = false;
			
			if(this.hasClass('section-rent'))
			{
				setMenuExpanded('rent');
			}
			else
			{
				setMenuExpanded('sell');
			}
		})
	
	});
	
	myAccordion = new Accordion($('menu'), 'span.flex', 'div.flex-content', {
		opacity: false,
		show: typeOfMenuExpanded,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#99cc66');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#ffffff');
		}
	});
});

window.addEvent('domready', function()
{
	setTimeout('setMenuDisplay()', 100);
});

function setMenuDisplay()
{
	myAccordion.display(1-typeOfMenuExpanded);
	myAccordion.display(typeOfMenuExpanded);
	myAccordion.display(1-typeOfMenuExpanded);
	myAccordion.display(typeOfMenuExpanded);
}