function Class_WIBstap()
{
	
	this.stap = 0
	this.delay = 15
	this.PaginaStap = 1
	this.Pagina = 1
	this.bTurned = false
	this.bMoving = false
	this.Interval = false
	this.accelleratie = (document.all && document.getElementById ? 1 : 8)
	this.arrObjects = new Array()
	this.BeweegBreedte = 452
	this.v = 0
	this.vmax = 0
	this.a = 0
	this.x = 0
	this.t = 0 
	this.nAantalObjecten = 0

	for(var i=0;i<100;i++)
	{
		this.t += this.accelleratie
		this.x += this.t
		if ( this.x * 2 > this.BeweegBreedte && this.vmax == 0 )
		{
			this.vmax = this.t
			this.Factor = this.BeweegBreedte / (this.x*2)
		}
	}
	this.x = 0
	this.xLocation = 0
                 
	this.Class_WibObject = function(nummer, Guid, Foto, Adres, Postcode, Plaats, Type, Oppervlak, Kamers, Bouwjaar, Prijs, sStatsString)
	{
		
		this.Nummer = nummer
		
		this.Guid = Guid
		this.Foto = Foto
		this.Adres = Adres
		this.Postcode = Postcode
		this.Plaats = Plaats
		this.Type = Type
		this.Oppervlak = Oppervlak
		this.Kamers = Kamers
		this.Bouwjaar = Bouwjaar
		this.Prijs = Prijs
		this.ImageLoaded = false
		this.StatsString = sStatsString
		
		this.URL = 'website.php?id='+this.Postcode+'&pid='+this.Guid;
		
		// Bij de eerste 5 is de bStatsRegisteren true. Bij de rest false
		this.bStatsRegistered = (nummer < 4)
		
		this.LoadImage = function()
		{
			if ( this.ImageLoaded == false )
			{
				
				document.getElementById('Image' + this.Nummer).src = this.GetFoto('100')
				this.ImageLoaded = true
			}
			
			
		}
	
		this.GetStatRegStr = function()
		{
			if ( this.bStatsRegistered == false )
			{
				this.bStatsRegistered = true
				return this.StatsString
			}
			else
			{
				return ''
			}
		}
		
		this.getHTML = function()
		{
			
			var sPlaatsTemp = ( this.Plaats.length > 30 ? this.Plaats.substring(0,30) + '...' : this.Plaats )
			var s = ''
			sEnter = '\n'
			if ( navigator.userAgent.indexOf('Firefox') > -1 ) sEnter = ''
			s += '<span class="wibstap_Object" style="left:' + (0 + this.Nummer*113) + 'px;">'
			
			if (this.GetFoto('100') == 'images/producten/thumb_verkocht.jpg') { }
			else {
				s += '	<a href="' + this.URL + '" class="wibstap">'
			}
			
			
			s += '		<img class="WibstapImage" id="Image' + this.Nummer + '" border="0" '
			if ( this.Nummer < 4 )
			{
				s += 'src="' + this.GetFoto('100') + '"'
				this.ImageLoaded = true
				
			}
			else
			{
				s += 'src="/img/spacer.gif"'
			}
			s += ' width="100" height="75" alt="' + this.Plaats + '' + this.Adres + '"  /><br>'
			
			
			s += '		' + sPlaatsTemp + ''
						
			if (this.GetFoto('100') == 'images/producten/thumb_verkocht.jpg') {}
			else {
				s += '	</a>'
			}
			
			s += '</span>'
			
			
			return s
		}
		
		this.GetFoto = function(sFormaat)
		{
			if ( sFormaat != '' ) sFormaat = '_' + sFormaat
			s = this.Foto
			if ( s.indexOf('http') == -1 ) s = 'images/producten/' + s 
			return s
		}
	}	
	
	this.AddObject = function(Guid, Foto, Adres, Postcode, Plaats, Type, Oppervlak, Kamers, Bouwjaar, Prijs, sStatsString)
	{
		
		var nummer = this.arrObjects.length
		this.arrObjects[nummer] = new this.Class_WibObject(nummer, Guid, Foto, Adres, Postcode, Plaats, Type, Oppervlak, Kamers, Bouwjaar, Prijs, sStatsString)
	}

	this.Start = function()
	{
		this.nAantalObjecten = this.arrObjects.length
		this.xMax = 0
		this.AantalPaginas = Math.ceil(this.nAantalObjecten / 4)
		this.xMin = - (this.AantalPaginas-1) * (113 * 4)
		var s = ''
		for ( var i=0; i<this.nAantalObjecten; i++ )
		{
			 s += this.arrObjects[i].getHTML(i)
		}
		
		document.getElementById('WibstapSpan').innerHTML = s
	
		this.SetButtons()
		
	}
	
	this.SetButtons = function()
	{
		if ( this.nAantalObjecten > 4 )
		{
					
			document.getElementById('WIBstap_knop_rechts').style.display = ( this.Pagina < this.AantalPaginas ? 'block' : 'none' )
			document.getElementById('WIBstap_knop_links').style.display = ( this.Pagina > 1 ? 'block' : 'none' )
			var s = ''
			for ( var i=1; i<=this.AantalPaginas; i++ ) s += '<a href="javascript:WIBstap.GaNaarPagina(' + i + ')"' + (this.Pagina == i ? ' class="sel"' : '') + '>&nbsp;' + i + '&nbsp;</a>'
			
		}
	}

	this.Mouseover = function(sDirection)
	{
		
		if ( document.getElementById('wib_img_' + sDirection) )
		{
			document.getElementById('wib_img_' + sDirection).src = 'includes/extrafunctionaliteiten/wibstap/' + sDirection + '_hover.gif'
		}
	}

	this.Mouseout = function(sDirection)
	{
		if ( document.getElementById('wib_img_' + sDirection) )
		{
			document.getElementById('wib_img_' + sDirection).src = 'includes/extrafunctionaliteiten/wibstap/' + sDirection + '.gif'
		}
	}
	
	this.MouseDown = function(_ax)
	{
		
		this.GaNaarPagina(this.Pagina-_ax)
		
	}
	
	this.GaNaarPagina = function(n)
	{
		if ( this.bMoving == false )
		{
			this.bMoving = true
			this.a = ( this.Pagina>n ? 1 : -1 ) * this.accelleratie
			this.PaginaMove = ( this.Pagina>n ? this.Pagina - n : n - this.Pagina )
			this.Pagina = n
			if ( this.Pagina > this.AantalPaginas ) this.Pagina = this.AantalPaginas
			if ( this.Pagina < 1 ) this.Pagina = 1
			sStats = ''
			for ( var i=0; i<4; i++ )
			{
				xTemp2 = (this.Pagina * 4 ) + i - 4
				if ( xTemp2 < this.nAantalObjecten )
				{
					this.arrObjects[xTemp2].LoadImage()
					s = this.arrObjects[xTemp2].GetStatRegStr()
					sStats += s + ( s == '' ? '' : ',' )
				}
			}
		
			if ( !this.Interval ) this.Interval = setInterval('WIBstap.Move()',15)
		}
	}
	
	this.Move = function()
	{
			
		this.x += this.v * this.Factor * this.PaginaMove
		
		this.xLocation = Math.round(this.x)
		if ( this.x > this.xMax ) this.x = this.xMax
		if ( this.x < this.xMin ) this.x = this.xMin
		if ( this.bTurned == false && ( this.v >= this.vmax || this.v <= -this.vmax ))
		{
			this.a = -this.a
			this.bTurned = true
		}
		else
		{
			this.v += this.a
		}
		if ( this.v == 0 )
		{
			this.bTurned = false
			this.a = 0
			clearInterval(this.Interval)
			this.bMoving = false
			this.Interval = false
			this.SetButtons()
			this.PaginaStap = 1
		}
		
		document.getElementById('WibstapSpan').style.left = this.xLocation + 'px'
	}
	
	this.showGroep = function(strGroep)
	{
		
		this.nAantalObjecten = this.arrObjects.length
		
		for ( var i=0; i<this.nAantalObjecten; i++ )
		{	
			divid = document.getElementById('groep_'+this.arrObjects[i].Guid);
			if (divid != null){ divid.style.display = "none"; }	
		}
		
		divid = document.getElementById('groep_'+strGroep);
		if (divid != null){ divid.style.display = "block"; }	
		
		divid = document.getElementById('divtekstwaarde1');
		if (divid != null){ divid.style.display = "none"; }	
		
		location = location.hash;
	}


}


