function setMainTable()
{
	var mainTable = $('maintable');
	//mainTableHeight = (mainTable.getStyle('height')).toInt();
	//windowHeight = getScrollHeight();
		//mainTable.setStyle('height', '0px');
	//mainTable.setStyle('height', windowHeight+'px');
	windowWidth = getWidth();
	$('extramenu').setStyle('width', (windowWidth-650)+'px');
	if(windowWidth < 920)
	{
		mainTable.setStyle('width', '9200px');
	} else if ( windowWidth >= 920)
	{
		mainTable.setStyle('width', '100%');
	}
	//Cookie.set('height', windowHeight, {duration: 1});
}
function setMainTable2()
{
	var mainTable = $('maintable');
	//mainTable.setStyle('height', '0px');
	//windowHeight = getScrollHeight();
	///mainTable.setStyle('height', windowHeight+'px');
	windowWidth = getWidth();
	topLogo = $('header').getTop();
	$('metroswf').setStyle('top', (topLogo+52)+'px');
	if(windowWidth < 920)
	{
		mainTable.setStyle('width', '9200px');
	} else if ( windowWidth >= 920)
	{
		mainTable.setStyle('width', '100%');
	}
	//Cookie.set('height', windowHeight, {duration: 1});
}

var news = {
	init: function()
	{
		news.setEvents();
		lastClickedYear = '';
		newsId = '';
		news.loadNews2();
		picturesHandler.init();
	},
	
	setEvents: function()
	{
		$$('#extramenu .newsitem').each(function (newsitem)
										{
											newsitem.addEvent('click', news.loadNews);
										}
									);
		$$('#extramenu .newsyear').each(function (newsYear)
										{
											newsYear.addEvent('click', news.switchYear);
										}
									);
	},
	
	loadNews: function()
	{
		newsId = this.getProperty('rel');
		var jSonRequest = new Request.JSON({url:"assets/handlers/handler.news.php", onComplete: function(newsData){news.setNews(newsData);}}).get({'id': newsId,'formaction':'getitem'});
  },
  
  	loadNews2: function()
	{
		var jSonRequest = new Request.JSON({url:"assets/handlers/handler.news.php", onComplete: function(newsData){news.setNews(newsData);}}).get({'formaction':'getlatestitem'});
  },
	
	setNews: function(newsData)
	{
		picField = $('pics');
		picField.empty();
		textField = $('contenttext');
		textField.set('html', newsData.message);
		
		title = new Element('div', {'id': 'texttitle'});
		title.set('html', newsData.title);
		title.injectTop(textField);
		scrollContent.init();
		
		picturesHandler.setPictures(newsData.pictures);
	}
} 

var expertises = {
	init: function()
	{
		expertises.setEvents();
		lastClickedExpertise = '';
	},
	
	setEvents: function()
	{
		$$('#extramenu .expertiseitem').each(function (expertiseItem)
										{
											expertiseItem.addEvent('click', expertises.switchExpertise);
										}
									);
	},
	
	loadExpertise: function()
	{
		expertiseId = this.getProperty('rel');
		var jSonRequest = new Request.JSON({url:"data/pages/getexpertise.php",onComplete: function(expertiseData){expertises.setExpertise(expertiseData);}}).get({'id': expertiseId});
  },
	
	setExpertise: function(expertiseData)
	{
		picField = $('pics');
		picField.empty();
		textField = $('contenttext');
		textField.set('html', expertiseData.info);
		
		title = new Element('div', {'id': 'texttitle'});
		title.setText(expertiseData.title);
		title.injectTop(textField);
		scrollContent.init();
		
		if (expertiseData.picture == '' || expertiseData.picture == null)
		{
			img = new Element('img', {'src': 'data/images/noimage.jpg'});
		} else
		{
			img = new Element('img', {'src': 'data/images/expertises/'+expertiseData.picture});
		}
		var myFx = new Fx.Style(img, 'opacity').set(0); 
		img.injectInside(picField);
		var myFx = new Fx.Style(img, 'opacity').start(0,1); 
	},
	
	switchExpertise: function()
	{
		if (this != lastClickedExpertise)
		{
			$$('#extramenu .expertiseitem').each(function(expertise)
											{
												if(expertise != this)
												{
													expertiseContainer = expertise.getNext();
													containerHeight = expertiseContainer.getStyle('height');
													if(containerHeight != '0px' || containerHeight == '')
													{
														currentHeight = expertiseContainer.scrollHeight;
														var myFx = new Fx.Tween(expertiseContainer);
														myFx.start('height', currentHeight, '0px');
													}
												}
											});
			thisExpertiseContainer = this.getNext();
			var myFx = new Fx.Tween(thisExpertiseContainer);
			myFx.start('height', '0px', thisExpertiseContainer.scrollHeight);
			lastClickedExpertise = this;
		}
	}
} 
var members = {
	init: function(userLanguage)
	{
		members.setEvents();
		memberInfoText = Array();
		memberInfoText[1] = Array();
		memberInfoText[2] = Array();
		memberInfoText[3] = Array();
		memberInfoText[1]['birthDate'] = 'Geboortedatum:';
		memberInfoText[1]['specialistFields'] = 'Expertises:';
		memberInfoText[1]['education'] = 'Opleiding:';
		memberInfoText[1]['noWebsite'] = 'Geen website beschikbaar';
		memberInfoText[2]['birthDate'] = 'Birthdate:';
		memberInfoText[2]['specialistFields'] = 'Specialist Fields:';
		memberInfoText[2]['education'] = 'Education:';
		memberInfoText[2]['noWebsite'] = 'No website available';
		memberInfoText[3]['birthDate'] = 'Geburtsdatum:';
		memberInfoText[3]['specialistFields'] = 'Fachgebiete:';
		memberInfoText[3]['education'] = 'Hochster erreichter Abschluss:';
		memberInfoText[3]['noWebsite'] = 'No website available';
		picturesHandler.init();
	},
	
	setEvents: function()
	{
		$$('#extramenu .extramenuitem').each(function (member)
										{
											member.addEvent('click', members.loadMember);
										}
									);
	},
	
	loadMember: function()
	{
		memberId = this.getProperty('rel');
		var jSonRequest = new Request.JSON({url:"assets/handlers/handler.members.php",onComplete: function(memberInfo){members.setMemberInfo(memberInfo);}}).get({'id': memberId,'formaction':'getmember'});
  },
	
	setMemberInfo: function(memberInfo)
	{
		picField = $('pics');
		picField.empty();
		textField = $('contenttext');
		textField.empty();
		
		info = new Element('div', {'class': 'memberinfofields'});
		info.set('text', memberInfoText[memberInfo.language]['birthDate']);
		infoData = new Element('div', {'class': 'memberinfodata'});
		birthDate = memberInfo.birthdate.split('-');
		infoData.set('text', birthDate[2]+'-'+birthDate[1]+'-'+birthDate[0]);
		info.injectInside(textField);
		infoData.injectTop(info);
		info = new Element('div', {'class': 'memberinfofields'});
		info.set('text', 'E-mail');
		infoData = new Element('div', {'class': 'memberinfodata'});
		infoData.set('text', memberInfo.email);
		info.injectInside(textField);
		infoData.injectTop(info);
		info = new Element('div', {'class': 'memberinfofields'});
		info.set('text', 'Homepage');
		infoData = new Element('div', {'class': 'memberinfodata'});
		if(memberInfo.website != null)
		{
			infoData.set('html', '<a href="http://'+memberInfo.website+'" target="_blank">'+memberInfo.website+'</a>');
		} else
		{
			infoData.set('text', memberInfoText[memberInfo.language]['noWebsite']);
		}
		info.injectInside(textField);
		infoData.injectTop(info);
		info = new Element('div', {'class': 'memberinfofields'});
		info.set('text', memberInfoText[memberInfo.language]['education']);
		infoData = new Element('div', {'class': 'memberinfodata'});
		infoData.set('text', memberInfo.education);
		info.injectInside(textField);
		infoData.injectTop(info);
		info = new Element('div', {'class': 'memberinfofields'});
		info.set('text', memberInfoText[memberInfo.language]['specialistFields']);
		infoData = new Element('div', {'class': 'memberinfodata'});
		infoData.set('text', memberInfo.specialistField);
		info.injectInside(textField);
		infoData.injectTop(info);
		
		title = new Element('div', {'id': 'texttitle'});
		title.set('text', memberInfo.name);
		title.injectTop(textField);
		scrollContent.init();
		
		picturesHandler.setPictures(memberInfo.pictures);
	}
} 
var portfolio = {
	init: function()
	{
		projectId = '';
		portfolio.setEvents();
		portfolio.loadProject2(1);
		picturesHandler.init();
	},
	
	setEvents: function()
	{
		$$('#extramenu .extramenuitem').each(function (project)
										{
											project.addEvent('click', portfolio.loadProject);
										}
									);
	},
	
	loadProject: function()
	{
		projectId = this.getProperty('rel');
		var jSonRequest = new Request.JSON({url:"assets/handlers/handler.projects.php",onComplete: function(projectInfo){portfolio.setProject(projectInfo);}}).get({'id': projectId, 'formaction': 'getitem'});
  	},
		
	loadProject2: function(id)
	{
		projectId = id;
		var jSonRequest = new Request.JSON({url:"assets/handlers/handler.projects.php",onComplete: function(projectInfo){portfolio.setProject(projectInfo);}}).get({'formaction': 'getlatestitem'});
  },
	
	setProject: function(projectInfo)
	{

		textField = $('contenttext');
		textField.set('html', projectInfo.description);
		
		title = new Element('div', {'id': 'texttitle'});
		title.set('html', projectInfo.title);
		title.injectTop(textField);
		scrollContent.init();
		
		picturesHandler.setPictures(projectInfo.pictures);
	}
} 

var picturesHandler = {
	init: function()
	{
		pictures = Array();
		currentPic = '';
		picField = $('pics');		
		prevButton = $('prevbutton');
		nextButton = $('nextbutton');
		dir = 'assets/images/content/';
		picturesHandler.setEvents();
	},
	
	setEvents: function()
	{
		prevButton.addEvent('click', function(){picturesHandler.setPicture('prev');});
		nextButton.addEvent('click', function(){picturesHandler.setPicture('next');});
	},
	
	setPictures: function(tempPictures)
	{	
		if(tempPictures != null)
		{
			loader = new Asset.image('assets/images/layout/loader.gif');
			loader.setStyles({
					'margin-left': '231px',
					'margin-top': '156px'
			});
			picField.empty();
			loader.injectInside(picField);				
			fullPictures = Array();
			tempPictures.each(
								function(img){
									fullPictures.include(dir+img);
								});	
			pictures = new Asset.images(fullPictures,
																	{onComplete: function()
																							{picturesHandler.setPicture('first');}
																	});
		}
	},
	
	setPicture: function(action)
	{
		picField.empty();
		if (action == 'prev')
		{
			pic = currentPic-1;
			currentPic = pic;
		} else if (action == 'next')
		{
			pic = currentPic+1;
			currentPic = pic;
		} else
		{
			pic = 0;
			currentPic = 0;
		}
		
		if(currentPic == 0)
		{
			prevButton.setStyle('visibility', 'hidden');
		} else 
		{
			prevButton.setStyle('visibility', 'visible');
		}
		if ((currentPic+1) >= pictures.length)
		{
			nextButton.setStyle('visibility', 'hidden');
		} else 
		{
			nextButton.setStyle('visibility', 'visible');
		}
		newImg = pictures[currentPic];
		var myFx = new Fx.Tween(newImg);
		myFx.set('opacity', 0);
		newImg.injectInside(picField);
		myFx.start('opacity', 0, 1);
	}
}
	
	

var scrollContent = {
	init: function()
	{
		scrollBlock = $('contenttext');
		scrollNav = $('scrollnav');
		scrollDistance = 105;
		sizes = scrollBlock.getSize();
		scrollSizes = scrollBlock.getScrollSize();
		if(scrollSizes.y > (sizes.y + 10))
		{
			scrollContent.setScroll();
		} else
		{
			scrollNav.setStyle('visibility','hidden');
		}
	},
	
	setScroll: function()
	{
		scrollNav.setStyle('visibility','visible');
		scrollStyle = new Fx.Scroll(scrollBlock, {wait: false,duration: 500,transition: Fx.Transitions.Quad.easeInOut});
		$$('#scrollnav .scrolltext').each(function(scroller)
																		{
																			scroller.addEvent('click', scrollContent.scrollText);
																		});
	},
	
	scrollText: function()
	{
		scrollSizes = scrollBlock.getScroll();
		
		direction = this.getProperty('rel');
		if(direction == 'up')
		{
			scrollState = scrollSizes.y - scrollDistance;
		} else
		{
			scrollState = scrollSizes.y + scrollDistance;
		}
		scrollStyle.start(0, scrollState);
	}		
}

var scrollMenu = {
	init: function()
	{
		scrollBlock2 = $('menuitems');
		scrollNav2 = $('scrollnav2');
		scrollDistance = 105;
		sizes = scrollBlock2.getSize();
		scrollSizes = scrollBlock2.getScrollSize();
		if(scrollSizes.y > (sizes.y + 10))
		{
			scrollMenu.setScroll();
		} else
		{
			scrollNav2.setStyle('visibility','hidden');
		}
	},
	
	setScroll: function()
	{
		scrollNav2.setStyle('visibility','visible');
		scrollStyle2 = new Fx.Scroll(scrollBlock2, {wait: false,duration: 500,transition: Fx.Transitions.Quad.easeInOut});
		$$('#scrollnav2 .scrolltext').each(function(scroller)
																		{
																			scroller.addEvent('click', scrollMenu.scrollText);
																		});
	},
	
	scrollText: function()
	{
		scrollSizes = scrollBlock2.getScroll();
		
		direction = this.getProperty('rel');
		if(direction == 'up')
		{
			scrollState = scrollSizes.y - scrollDistance;
		} else
		{
			scrollState = scrollSizes.y + scrollDistance;
		}
		scrollStyle2.start(0, scrollState);
	}		
}
