function FoodInformationPopup()
{
	this.container 	= document.getElementById("foodinfo");	
	this.links 		= Array();
	this.popups 	= Array();
	this.fetchElements();
}

FoodInformationPopup.prototype.fetchElements = function()
{
	// <DIV> elements
	this.popups[0] = document.getElementById("tillagning");
	this.popups[1] = document.getElementById("naringsinnehall");

	var obj = this;
	
	// <A> elements
	this.links[0] 	= document.getElementById("link_tillagning");
	this.links[0].href 	= "#foodinfo";
	this.links[0].onclick	= function() {obj.resetAll(this); obj.toggle(this);};
	this.links[0].active 	= 0;

	this.links[1] = document.getElementById("link_naringsinnehall");
	this.links[1].href 	= "#foodinfo";
	this.links[1].onclick	= function() {obj.resetAll(this); obj.toggle(this);};
	this.links[1].active 	= 0;
}

// Hide all except the <A> clicked on
FoodInformationPopup.prototype.resetAll = function(e)
{
	for(var i = 0; i < this.links.length; i++)
	{
		if(this.links[i] != e) this.links[i].active = 0;
		this.hide(this.links[i]);
	}
	for(var i = 0; i < this.popups.length; i++)	this.hide(this.popups[i]);
}

FoodInformationPopup.prototype.toggle = function(e)
{
	for(var i = 0; i < this.popups.length; i++)
	{
		if("link_" +this.popups[i].id == e.id)
		{
			var popup = this.popups[i];
			break;
		}
	}
	
	if(e.active != 1)
	{
		this.show(e);
		this.show(popup);
		e.active = 1;
	}
	else
	{
		this.hide(e);
		this.hide(popup);
		e.active = 0;
	}
}

FoodInformationPopup.prototype.hide = function(e)
{
	if(e.tagName == "A") e.style.backgroundImage = "url('/images/arrow_small_right_white_red.gif')";
	else if(e.tagName == "DIV")	e.style.display = "none";
	else 							return false;
}

FoodInformationPopup.prototype.show = function(e)
{
	if(e.tagName == "A")	e.style.backgroundImage = "url('/images/arrow_small_down_white_red.gif')";
	else if(e.tagName == "DIV")	e.style.display = "block";
	else 							return false;
}