	
	var flBrowser = function(wpsPage, contentContainer, movieContainer){
		this.instID = 'flBrowser.' + parseInt(Math.random()*1000000);
		this.loopCount = 0;
		this.contentContainer = contentContainer;
		this.movieContainer = movieContainer;
		this.wpsPage = wpsPage;
		this.subPage = 0;
		this.projectPageIndex = 0;
		this.subPages = new Array();
		this.overriden = false;
		this.movieCreated = false;
		this.nextProjectIndex = 0;
		this.previousProjectIndex = 0;
	} 
	
	flBrowser = flBrowser.extendsFrom(wps.base);
	
	flBrowser.prototype.initialize = function(){
		var wpsRPC = new wps.rpc;
		wpsRPC.debug = true;
		wpsRPC.createCall('editpointBrowser', this.buildPage.bind(this), this);
		wpsRPC.call('getContent', 'wpsPage=' + this.wpsPage, 'objectIndex=' + this.projectPageIndex ,'subPage=' + this.subPage); 
	}
	
	flBrowser.prototype.buildPage = function(req){
		var dom = req.responseXML;
		// set some internal variables:
		this.nextProjectIndex = dom.getElementsByTagName('browser').item(0).getAttribute('nextProject');
		this.previousProjectIndex = dom.getElementsByTagName('browser').item(0).getAttribute('previousProject');
		// split the request, populate HTML-pages:
		if (!this.is_ie()){
			this.contentContainer.parentNode.style.background= 'url(../images/semi_transparent_black.png)';
		}
		$A(dom.getElementsByTagName('html')).each(
			(function(pageNode){
				this.subPages.push(new flPage(pageNode, this.contentContainer));	
			}).bind(this)
		);
		
		this.movieSrc = dom.getElementsByTagName('browser').item(0).getAttribute('movie')
		
		//create movie-object
		if (!this.movieCreated){
		    var so = new SWFObject('wpsRepos2/lib/3rd/flashPlayer/flvplayer.swf','flashPlayer','400','367','1');
		    so.addVariable("file",this.movieSrc);
		    so.addVariable("enablejs","true");
		    so.addVariable("displayheight",367);
		    so.addVariable("autostart","true");
		    so.addVariable("lightcolor","0x557722");
		    so.addVariable("backcolor","0x000000");
		    so.addVariable("frontcolor","0xCCCCCC");
		    so.addVariable("wmode","solid");
		    so.addVariable("repeat","all");
		    so.addParam("allowfullscreen","false");
		    so.addParam("showfsbutton","false");
		    so.write('player');
		    var mmw = new SWFMacMouseWheel(so); 
		    this.movieCreated = true;		
		}else{
			thisMovie('flashPlayer').loadFile({file:this.movieSrc});
			thisMovie('flashPlayer').sendEvent('playpause');
		}
	}
	
		
	flBrowser.prototype.showPage = function(currPos, remaining, index){
		if (!(currPos) && (!remaining)){
			// show page by Index
			this.subPages[index].show();
		}else{
			// check if movie is at end:
			if ((currPos > 0) && (remaining ==0)){
				this.showNextProject();
				return;
			}
			if (this.overriden) return;
			// show page by time
			var sumTime = (currPos + remaining);
			var pageCount = this.subPages.length;
			var lenghtPerPart = (sumTime / pageCount);
			var currPage =  parseInt( (((remaining / lenghtPerPart) - pageCount) * -1) );
			if (this.subPages[currPage].show()){
				this.resetPages(currPage);
				this.currPage = currPage;
				this.buildBrowser();
			}
		}
	}

	flBrowser.prototype.resetPages = function(exclude){
		for (var i=0;i<this.subPages.length;i++){
			if (i != exclude){
				var subPage = this.subPages[i];
				subPage.reset();
			}
		}
	}	
	
	flBrowser.prototype.buildBrowser = function(){
		// create browser for pages at this project
		if (!$('browserContainer')){
			var browserContainer = Builder.node('div', {id:'browserContainer'})
			this.contentContainer.parentNode.appendChild(browserContainer);
		}else{
			var browserContainer = $('browserContainer');
			Element.update(browserContainer, '');
		}
			
		//create page-browser
		var browserTop = Builder.node('div');
		browserTop.setAttribute('id', 'nav1');
		browserContainer.appendChild(browserTop);
		if (this.currPage > 0){
			var next = Builder.node('a', {title:"Terug", className:'left'}, ['< terug ']);
		}else{
			var next = Builder.node('a', {className:'left'}, [Builder.node('br')]);
		}
		//this.applyBrowserStyle(next, 'left');
		this.addEvent(next, 'click', this.overrideToPrevious.bind(this));
		browserTop.appendChild(next);
		if (this.currPage < (this.subPages.length - 1)){
			var next = Builder.node('a', {title:"Lees meer", className:'right'}, ['Lees meer >']);
		}else{
			var next = Builder.node('a', {className:'right'}, ['']);
		}
		this.addEvent(next, 'click', this.overrideToNext.bind(this));
		browserTop.appendChild(next);
		
		//create project-browser
		var browserBottom = Builder.node('div');
		browserBottom.setAttribute('id',  'nav2');
		browserContainer.appendChild(browserBottom);
		var bIsEmpty =false;
		if (this.previousProjectIndex != null){
			var next = Builder.node('a', {title:'Terug', className:'left'}, [Builder.node('img', {src:'images/project_prev1.gif', alt:'Vorige project', border:'0'} ) ]);
		}else{
			var next = Builder.node('a', {title:'Terug', alt:'vorige project', className:'left'}, ['']);
		}
		this.addEvent(next, 'click', this.showPreviousProject.bind(this));
		browserBottom.appendChild(next);

		if (this.nextProjectIndex != null){
			var next = Builder.node('a', {title:'Lees meer', className:'right'}, [Builder.node('img', {src:'images/project_next1.gif', alt:'Lees meer', border:'0'} ) ]);
		}else{
			var next = Builder.node('a', {title:'Lees meer', className:'right'}, ['']);			
		}
		this.addEvent(next, 'click', this.showNextProject.bind(this));
		browserBottom.appendChild(next);
	} 
	
	flBrowser.prototype.overrideToNext = function(){
		this.currPage++;
		this.overriden = true;
		this.subPages[this.currPage].show();
		this.buildBrowser();
	}
	
	flBrowser.prototype.overrideToPrevious = function(){
		this.currPage--;
		this.resetPages();
		this.overriden = true;
		this.subPages[this.currPage].show();
		this.buildBrowser();
	}	
	
	flBrowser.prototype.showNextProject = function(){
		this.subPages = new Array();
		this.overriden = false;
		if (this.nextProjectIndex){
			this.projectPageIndex = this.nextProjectIndex;
		}else{
		 	this.loopCount++;	
			this.projectPageIndex = 0;
			if (this.loopCount > 4) {
				window.location.reload(true);
			}	
		}
		this.subPage = 0;
		this.initialize();
	}
	
	flBrowser.prototype.showPreviousProject = function(){
		this.subPages = new Array();
		this.overriden = false;
		if (this.previousProjectIndex){
			this.projectPageIndex = this.previousProjectIndex;
			this.subPage = 0;
			this.initialize();
		}
	}