$(document).ready(
function()
{
	getBackdrop();
	var pm, pageNum, cur, extra, drag=false, scrollee, scrollRatio, scrollHeight, 
	scrollTarget=0, pointerTarget, pointerHeight, curScrollOffset, dragMouseOffset=0, pageRatio, textHeight, pageHeight, pageWidth, virgin=true, loading=false, listeners=[],
	$b=$('body'),
	$wr=$('div#wrapper'),
	$pm=$('div#pageMenu'),
	$sm=$('div#smallmenu'),
	$pmt=$pm.find('div#logoText'),
	$pmsl=$pm.find('div#smalllogo'),
	$pml=$pm.find('div#logo'),
	$it,
	$its,
	$itu;	
/*	--------------------------------------------------------------- INIT:											*/
			init();
			function init(){  
				//if(!jQuery.support.leadingWhitespace) DD_belatedPNG.fix('.adres a img, .mail a img, .partner a img, .logo img, .logoText img, .but img');
				$('.panel').fadeOut(0); 
				$b.hide(); 
				current=setCur($('#item1'));
				resizePanel();
				if(($its=$('div.item.selected')).attr('id')=='item1'){
					setIntro();
				}else{
					resetIntro()
				};
				//resetDimensions();
				$wr.width(0.3*pageWidth);
				$its.css({width:'64%'});
				$('.item').not(".selected").css({width:"12%"}).find('.content').css({width:'1px'});
				$pm.hide(); 
				initMainListeners();
				$b.show(); 
				extra=_extra()
				startUpAnimation();
			};
			function loadPage(page, target, noAnimate){
				$.get(page, function(data){
					if(($its=$('div.item.selected')).attr('id')=='item1'){
						setIntro();
					}else{
						resetIntro();
					};
					$its.find('#content').width(parseInt(pageWidth*0.64)-39-$pm.width()).css('left', $pm.width());
					var t=($('<div></div>').html(data));
					target.append(t.find('div:first'));
					if(!$(target).hasClass('subPage')){
						if(target.find('#subjectContainer').html()!=null)setSubject(target.find('#page')) ;
						if($("div[ik=flipper]").length)$("div[ik=flipper]").flipper($("div[ik=flipper]"), $(target));
						if(!target.find('#subjectContainer').length){
							scrollee=$its.find('#page') ;
							assessScroll(noAnimate);
							$b.ikScroll({container:target, scrollee:target.find('#page'), size:[39, 180], position:'right'});
						} 
					}else{
						scrollee=target;
						assessScroll(noAnimate);
						$b.ikScroll({container:target, scrollee:target.find('#subPage'), size:[40, 180], position:'right'});
					}; 
				}); 
			};
			function assessScroll(resized){
				contentDimensions();		
				try{
					if(scrollee.parent().attr('id')!=($its=$('div.item.selected')).find('#content').attr('id')){
						scrollee.parent().parent().css({height:pageHeight-scrollee.parent().parent().offset().top});
						scrollee.parent().css({height:pageHeight-scrollee.parent().offset().top-20});
					};
					if(!virgin&&!resized){
							if(scrollee.parent().attr('id')==$its.find('#content').attr('id')){if($('div.flipper').hasClass('flipper'))setFlipper.call($('#flip1'));
						}else{
							openSubjectContent();
						}
					} 
					else{
						virgin=false;
					}
				}catch(er){
				}
			};					/*	init final animation based on content type		*/
/*	END INIT -------------------------------------------------------------*/
			function getBackdrop(){
				$('body, #bgLeft').addClass('bg'+parseInt(Math.random()*3));
			};
			function clearListeners(){
				var i=0, l=listeners.length-1;
				for(i=l; i >= 0; i--){
					$(listeners[i][0])[listeners[i][1]]=null;
					listeners.pop();
				};
			};
/*	--------------------------------------------------------------- SUBPAGE SUBJECT-STYLE:PEOPLE				*/			
			function setSubject(tar){
			//	if(!jQuery.support.leadingWhitespace) DD_belatedPNG.fix('.menu img');
				$(tar).css({'padding-left':'0px'});
				var w=0, obj =jQuery.makeArray($('.item.selected').find('div[scale]'));
				$('#subjectContainer').find('a.menu').click( function(e){ menuClick(e); });
				listeners.push([$('#subjectContainer').find('a.menu'), 'click']);
				$('a.menu').hover( function(){$(this).find('img.hi').fadeTo(300, 1);}, function(){$(this).find('img.hi').fadeTo(300, 0);});
				listeners.push([$('#subjectContainer').find('a.menu'), 'hover']);
				for(key in obj){
					var $o=$(obj[key]),sc=$o.attr('scale'),$lo=$o.find('img.lo'),$hi=$o.find('img.hi');
					listeners.push([$o, 'click']);
					$o.click(function(e){subjectClick(e)});
					$lo.css({ width:$lo.width()*sc, height:$lo.height()*sc});
					$hi.css({ width:$hi.width()*sc, height:$hi.height()*sc});
					$o.css({ width:$hi.width(), height:$hi.height(), left:(40*key)+70, top:((0.25-sc)*230)-10, 'z-index':key}) ;};
				$('#subjectContent').height(pageHeight).width('100%');
				$('#subjectContainer').css({top:'20px', width:'100%', height:'112px'}); 
				loadPage('people00.html', $('#contentContainer').find('div.subPage'));
			};
			var hi, h, i;
			function subjectMove(e){
				h=e.clientX;
				i=e.clientY; 
				$(e.currentTarget).find('img').each(setScale);
				$('#subjectHeader').html($(e.target).attr('name'));
			}
			function setScale(){
				var $t, f=(i -(($t=$(this)).offset().top+$t.height()));
				f =((f/2 > 0)?((f/2 < 30)?f/2:30):0);
				var d =(h -($t.offset().left+(15))) ;
				d =((30-Math.abs(d/2) >= 0)?30-Math.abs(d/2):0) ;
				d =((d-f > 0)?d-f:0);
				$t.css({width:30+d, height:80+((80/30)*d)});
				if(d > 20) setSubjectHeader($t.attr('alt'));
			}
			function setSubjectHeader(name){
				if( name==null)name=$('#subjectContainer').find('div.clicked').attr('name');
				if($('div.subjectHeader').html()!=null){
					clearSubjectHeader($('div.subjectHeader'),name);
				}else{
					if(name!=null)openSubjectHeader($('div.subjectHeader'),name);
				};
			}
			function clearSubjectHeader(obj, name){
				(obj=$(obj)).animate({'font-size':'1px', bottom:10},{queue:true, duration:400, complete:function(){
						obj.empty();
						if(name!=null)openSubjectHeader(obj,name);
					}
				});
			}
			function openSubjectHeader(obj, name){
				(obj=$(obj)).html(name).animate({'font-size':'20px', bottom:17},{queue:true, duration:800, easing:'easeOutBack'});
			};
			function openSubjectContent(){
				if(scrollee.find('.subjectList').html() != null){
					scrollee.find('#subject').mousedown(
						function(){
							var e ={'currentTarget':$('#subjectContainer div[name=\"'+$(this).text()+'\"]')}
							subjectClick.call($('#subjectContainer div[name=\"'+$(this).text()+'\"]'), e)});
					listeners.push([scrollee.find('#subject'), 'mousedown']);
					scrollee.find('#subject').hover(
						function(){$('#subjectContainer div[name=\"'+$(this).text()+'\"]').find('img.hi').animate({opacity:1}, 500)},
						function(){$('#subjectContainer div[name=\"'+$(this).text()+'\"]').find('img.hi').animate({opacity:0}, 500)});
					listeners.push([scrollee.find('#subject'), 'hover']);};
				var scrollHeight=$('#contentContainer').height();
				$('#contentContainer').height(0).animate({height:scrollHeight},{duration:750, easing:'easeOutBack'});
			};
			function subjectClick(e){
				var an=$('#page').find('div:animated');
				if(an&&an.length<1){	
					if(!$(e.currentTarget).hasClass('clicked')){
						if($('#subjectContainer').find('div.clicked').html() != null){
							$($('#subjectContainer').find('div.clicked').find('img.hi')).animate({opacity:0},{queue:false, duration:500});
							setSubjectHeader($(e.currentTarget).attr('name'));
							removeSubjectContent($(e.currentTarget));
							$('#subjectContainer').find('div.clicked').removeClass('clicked');}
						else{
							setSubjectHeader($(e.currentTarget).attr('name'));
							if(scrollee.parent().height() > 10){
								removeSubjectContent(e.currentTarget);}
							else{
								addSubjectContent(e.currentTarget);
							};
						};
					}else{
						$(e.currentTarget).removeClass('clicked');
						setSubjectHeader(null);
						$(e.currentTarget).find('img.hi').animate({opacity:0}, 500);
						removeSubjectContent('people00.html');
					};
				};
				return false;
			}
			function addSubjectContent(tar){
				 if(typeof tar=='object'){
					var c=$(tar).clone();
					$(tar).addClass('clicked');
					$(c).find('img.hi').remove();
					$(c).appendTo('#contentImage');
					$(tar).find('img.hi').animate({opacity:1}, 500);
					$('#subjectContent').find('#contentImage').css({top:$(tar).offset().top});
					$($('#subjectContent').find('#subject')).animate({width:150, height:400},{duration:800, easing:'easeOutQuad'});
					$($('#subjectContent').find('img')).animate({ width:150, height:400, opacity:0.2},{duration:800, easing:'easeOutQuad'});
					$($('#subjectContent').find('#contentImage')).animate({left:-$(tar).find('img').offset().left+(0.35*$('#subjectContent').width()), top:20},{duration:800, easing:'easeOutBack', complete:function(){
							loadPage($(tar).attr('url'), $('#contentContainer').find('div.subPage'));
							$('#page').find('.hide').css('visibility', 'visible');
							return false;
						}
					});
				}else{
					loadPage('people00.html', $('#contentContainer').find('div.subPage'));
				};
			}
			function removeSubjectContent(tar){
				$('#contentImage').animate({left:-500},{queue:false, duration:400, easing:'easeInBack',complete:function(){
						$('#page').find('.hide').css('visibility', 'hidden');
						$('#contentImage').empty();
						$('#contentImage').css({left:0});
					}
				});
				scrollee.parent().animate({height:0},{duration:700, easing:'easeInQuad',complete:function(){
						scrollee.empty();
						if(tar != null){
							addSubjectContent(tar); 
						}else{
							$('.item.selected').find('#page').css({'padding-left':'10px'});
						}
					}
				});
			};
/*	--------------------------------------------------------------- CONTENT:*/			
			function setCur(newCurrent){  
				$('.item.selected').addClass('unselected').removeClass('selected');
				newCurrent.addClass('selected');
				current=newCurrent;   
				return current;
			};   
			var t;
/*	--------------------------------------------------------------- INTERACTION:			*/				
			var curContent;
			function menuClick(e){
				if($(this).attr('id')=='address'){
					e.preventDefault(); 
					addressHandler(e, $(this).attr('href')); 
					return false;
				}else if($(e.currentTarget).attr('id')=='back'){
					e.preventDefault(); 
					backHandler(); 
					return false;
				}else{
				}
			}
			function _extra(){
				var ob,_box,
				_end =function(e, url){GUnload();$('#overlay').css('visibility', 'hidden');},
				autoRotate =function(){
 					if(map.isRotatable){
						setTimeout('map.changeHeading(90)', 3000);
						setTimeout('map.changeHeading(180)',6000);
						setTimeout('map.changeHeading(270)',9000);  
						setTimeout('map.changeHeading(0)',12000);  
					}
				},
				_markers=[],
				_info={},
				_setmarkers=function(m, gll, t, i){
					var q=new GMarker(gll); 
					q.value=i
					_info[i]=t.html();
					GEvent.addListener(q, "click", function(e){
    						m.openInfoWindowHtml(gll, _info[this.value]);
						});
					return q;
				},
				_map=function(){
					$('#map', $('#overlay')).css({height:pageHeight*0.6, width:'60%'})
    				var map=new GMap2(document.getElementById('map')),
					amsterdam=new GLatLng(52.354858,4.912155),
					utrecht=new GLatLng(52.089794,5.131640),
					center=new GLatLng(52.240415,5.009766);
    				map.setCenter(center, 9);
					map.setMapType(G_HYBRID_MAP); 
					map.enableRotation();
					map.addOverlay(_setmarkers(map, amsterdam, $('#amsterdam', $('#overlay'))), 0)
					map.addOverlay(_setmarkers(map, utrecht, $('#utrecht', $('#overlay')))), 1}
 				_box=$('#overlay').ikContent({
					name:'extra', 
					destination:[pageWidth*0.15+'px', pageHeight*0.2+'px', pageWidth*0.7+'px',  pageHeight*0.6+'px'],
					scale:[1, 1], 
					ease:['easeOutBack', 'easeInBack'], 
					handle:[null, null, _end, _map], 
					shape:'rounded', 
     				cornerSource:"white",
     				cornerSize:18,
    	 			sourceDir:"images/rounded",
					opacity:0.8,	
					nav:{buttons:['close']},
					cover:'black', 
					preload:true
				})
				return{
					spawn:function(e, url){ob=e.currentTarget;
						$('#overlay').ikContent(null, [url, $(e.currentTarget.parentElement), _box]);
					}
				}
			}
			function addressHandler(e, url){//ABQIAAAACGiFVlMfrTHnkAhEqtUbBhSPAMVnqb_c-r0DUEV7vP4Gt8i7whRP-3IYL7GSAgp5r_CMvmI5P45pwg
				extra.spawn(e, url);
				return false;
			}
			function backHandler(noload){
				if($('#overlay').css('visibility')=='visible'){$('#overlay').css({visibility:'hidden'}); $('.item.selected').find('#page').css({visibility:'visible'});}
				else if($('#subjectContainer').find('div.clicked').html() != null){
					$('#subjectContainer').find('div.clicked').removeClass('clicked');
					setSubjectHeader(null);
					$('#subjectContainer').find('img.hi').animate({opacity:0}, 500);
					removeSubjectContent(((!noload)?'people00.html':null));};
				return false;
			};		
			function initMainListeners(){
				$('a.menu').click(menuClick).hover(										
					function(){$(this).find('img.hi').animate({opacity:1},{queue:false, duration:300});},
					function(){$(this).find('img.hi').animate({opacity:0},{queue:false, duration:300});});
				$('.panel').click(
					function(){
						if(!loading){
							backHandler(true); 
							clearListeners(); 
							loading=true; 
							current=setCur($($(this).attr('name'))); 
							fadeDelete(); 
							animateItem($(this).attr('href'));
						};
						return false;
					});
			}
/*	--------------------------------------------------------------- SCROLL:							*/
			function resetScroll(){
				drag=false;	
				dragMouseOffset=0;
				scrollee.css({top:0});
			};
			function initDragScroll(){
				scrollee.draggable({
					axis:'y', 
					containment:[scrollee.position().left, scrollHeight-textHeight -50, (scrollee.position().left+scrollee.width()), scrollee.position().top],
					drag:function(e){
						var c =(e.clientY-dragMouseOffset),
						bound =((c > 0)?0:scrollHeight-textHeight),
						t =(c > 0)?((c < bound)?c:bound):((c > bound)?c:bound),
						sh=$('div#scrollPointer').height(),
						scr=-(scrollee.position().top/scrollRatio);
						if(!scrollCount)curScrollOffset=scrollee.offset().top;
						scrollCount=!scrollCount;
						pointerTarget=(scr+sh>50)?50-sh:scr;
						$('div#scrollPointer').css({top:pointerTarget});
					}
				});
			}				/*		init drag scroll			*/
/*	--------------------------------------------------------------- ANIMATION:							*/				
			function startUpAnimation(){  
				$('.content').height(pageHeight);
				$wr.animate({width:'100%'}, 1000);   
				($its=$('div.item.selected')).animate({width:parseInt(pageWidth*0.64)}, 1000).find('.content').animate({width:'100%'},{duration:1000, complete:$wr.delay(500,showMenu)});
			};	/*		animate page first time		-->	showMenu		*/
			function animateItem(url){
				contentDimensions();
				($its=$('.item.selected')).find('#content').css('left', $pm.width()).height(pageHeight);
				($itu=$('.item.unselected')).find('.content').delay(200).animate({width:'1px'},{duration:600, easing:'easeInSine'});
				$itu.delay(200).animate({width:parseInt(pageWidth*0.12)},{duration:600, easing:'easeInSine',complete:function(){
						$its.find('#content').css('left', $pm.width());
						setEnd(url);
					}
				});
			};
				/*		animate page default::close current item	-->	setEnd			*/
			function setEnd(url){
				if(($its=$('div.item.selected')).attr('id')=='item1'){setIntro()} else{resetIntro()};
				if(!virgin)$its.find('.panel').fadeOut(250);
				($itu=$('.item.unselected')).find('.panel').fadeIn(250);
				$itu.find('#page').html('').remove();
				$itu.find('#content').empty().height(pageHeight).css('left', $pm.width());
				$('.item').height(pageHeight);
				$('.item:not(.selected)').width(parseInt(pageWidth*0.12));		
				$itu.removeClass('unselected');   
				$its.delay(0).animate({width:parseInt(pageWidth*0.64)},{duration:800, easing:'easeOutCirc'}).find('.content').delay(0).animate({width:'100%'},{duration:800, easing:'easeOutCirc',complete:function(){
						loadPage(url, $(current).find('#content'));
						showMenu(); 
					}
				}); 
			};
/*		animate page default::open new item		-->	showMenu		*/
			function showMenu(){
				$its=$('div.item.selected');
				$pm.css({left:$its.offset().left, visibility:'visible'});
				$pm.delay(400).fadeTo(500, 1);
				$sm.delay(800).animate({width:16},{duration:500, easing:'easeOutBack'});
				$its.find('#sideBar').css({'right':'-1px','width':'39px','height':pageHeight,'visibility':'visible'});
				$its.find('#sideBar').delay(0).fadeTo(500, 0.6);
				if(virgin){
					loadPage('home01.html', $its.find('#content'));
					$('.item').not('.selected').find('.panel').fadeIn(500);
				};
				loading=false;
			};   						/*		position and show pagemenu and sidebar right									*/
			function fadeDelete(){
				$sm.delay(0).animate({width:0},{queue:false, duration:500, easing:'easeInBack'});
				$pm.delay(400).fadeOut( 200,  function(){$pm.css('visibility', 'hidden')});
			};    				  		/*		hide pagemenu and sidebar right														*/ 
			function setIntro(){
				$pmt.css('visibility', 'hidden');
				$pmsl.css('visibility', 'hidden');
				$pml.css('visibility', 'visible');
				$pm.css({'width':'199px'});
				$('.item.selected').find('#content').css({'left':'199px'});
			}; 				  		/*		set custom layout intro page															*/
			function resetIntro(){
				$pmt.css({'visibility':'visible'});
				$pmsl.css('visibility','visible');
				$pml.css('visibility', 'hidden');
				$pm.css({'width':'113px'});
				$('.item.selected').find('#content').css({'left':'113px'});
			};   						/*		set default layout																			*/
/*	--------------------------------------------------------------- DIMENSIONS:									*/			
			function resetDimensions(){  
				$wr.css({'width':'100%', 'height':pageHeight});
				$pm.height(pageHeight);
				$('.item').height(pageHeight);
				$('.item').not('.selected').css({'width':parseInt(pageWidth*0.12)});
				($its=$('div.item.selected')).css({'width':parseInt(pageWidth*0.64)}).find('.content').css({'width':'100%'});
				$its.find('#content').css({'width':$its.width()-$pm.width()-39+'px'});
				$pm.css({'left':$its.offset().left});
			};   			/*		reset dimensions layout elements; called by init and user windowresize	*/
			function contentDimensions(){
				$wr.css({'left':'0px','top':'0px','width':'100%','height':pageHeight});    
				$('.content').height(pageHeight);
				$('.item').find('#sideBar').height(pageHeight);
				$('.item').find('#content').height(pageHeight);
				$('.item.selected').find('#content').css('left', $pm.width());
			};
			function resizePanel(){  
				pageWidth =(!jQuery.support.leadingWhitespace)?document.body.clientWidth:window.innerWidth;
				pageHeight =(!jQuery.support.leadingWhitespace)?document.body.clientHeight:window.innerHeight;
			};
			$(window).resize(function(){ resizePanel(); resetDimensions(); assessScroll(true);});   
})
