function MenuItem (id, width, widthmin, widthmax, step, speed)
{
	this.id 			= id;
	
	this.width			= width;
	this.widthmin		= widthmin;
	this.widthmax		= widthmax;
	
	this.currentwidth 	= width;
	
	this.step			= step;
	this.speed			= speed;
	
	this.target;
	this.timer;
	
	this.targetimage;
}

	MenuItem.prototype.Trigger = function (objectid, state)
	{
		for (var i = 0; i < items.length; i++)
		{
			if (objectid == items[i].id)
			{
				items[i].Slide(true);
			}
			else
			{
				items[i].Slide(false);
			}
		}
	}
	
	MenuItem.prototype.Initialize = function (state)
	{
		var self = this;
		
		clearTimeout (this.timer);
		
		if (state)
		{
			for (var i = 0; i < items.length; i++)
			{
				if (contextid == items[i].id)
				{
					items[i].Slide(true);
				}
				else
				{
					items[i].Slide(false);
				}
			}
		}
		else
		{
			this.timer = setTimeout (function(){self.Initialize(true)}, 50);
		}
	}
	
	MenuItem.prototype.Slide = function (state)
	{
		var self = this;
		
		clearTimeout (this.timer);
		
		this.target = document.getElementById(this.id);
		
		if (state)
		{
			if (this.currentwidth < this.widthmax)
			{
				this.currentwidth = ((this.currentwidth + this.step) > this.widthmax) ? this.widthmax : (this.currentwidth + this.step);
				this.target.style.width = this.currentwidth + 'px';
				
				if (this.currentwidth < this.widthmax)
				{
					this.timer = setTimeout (function(){self.Slide(state)}, this.speed);
				}
				else
				{
					// plaatje van hoofdmenu vergroten en de margintop aanpassen
					this.target.firstChild.firstChild.style.marginTop = '5px';
					this.target.firstChild.firstChild.src = '/images/navigation/' + this.id + '_large.gif';
					
					// submenu displayen
					this.target.lastChild.style.display = 'block';
				}
			}
		}
		else
		{
			// plaatje en margintop weer initialiseren
			this.target.firstChild.firstChild.style.marginTop = '15px';
			this.target.firstChild.firstChild.src = '/images/navigation/' + this.id + '_small.gif';
			
			// submenu verbergen
			this.target.lastChild.style.display = (this.target.lastChild.tagName == 'DIV') ? 'none' : 'block';
			
			if (this.currentwidth > this.widthmin)
			{
				this.currentwidth = ((this.currentwidth - this.step) < this.widthmin) ? this.widthmin : (this.currentwidth - this.step);
				this.target.style.width = this.currentwidth + 'px';
				
				if (this.currentwidth > this.widthmin)
				{
					this.timer = setTimeout (function(){self.Slide(state)}, this.speed);
				}
			}
		}
	}

function Initialize (object)
{
	var self 	= object;
	var element = (document.getElementById(object.id)) ? document.getElementById(object.id) : false;
	
	if (element)
	{
		self.target = document.getElementById(self.id);
		
		element.onmouseover = function ()
		{
			self.Trigger(self.id, true);
		}
		element.onmouseout = function ()
		{
			self.Initialize();
		}
		
		if (contextid == self.id)
		{
			self.Trigger(self.id, true);
		}
	}
}

var step  = 40;
var speed = 25;

var items = new Array();

items[0] = new MenuItem('kruiswijk',   211, 83, 452, step, speed);
items[1] = new MenuItem('disciplines', 213, 93, 462, step, speed);
items[2] = new MenuItem('personeel',   211, 88, 457, step, speed);

window.onload = function ()
{
	for (var i = 0; i < items.length; i++)
	{
		Initialize (items[i]);
	}
	
	if (document.URL == 'http://www.kruiswijk.eu/kruiswijk/nieuws/22/' || document.URL == 'http://www.kruiswijk.eu/kruiswijk/vacatures/' || document.URL == 'http://www.kruiswijk.eu/personeel/vacatures/')
	{
		// swf object schrijven
		var flashobject = new SWFObject("/video/kruiswijk.swf", "video", "400", "266", "8");
		flashobject.addParam("quality", "high");
		flashobject.addParam("wmode", "transparent");		
		flashobject.write("flash");
	}
	
}