function Class_WIB()
{
	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 ? 3 : 8)
	this.arrObjects = new Array()
	this.BeweegBreedte = 710
	this.v = 0
	this.vmax = 0
	this.a = 0
	this.x = 0
	this.t = 0 
	this.nAantalObjecten = 0

	for(var i=0;i<120;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(number, Guid, image, adress, zipcode, place, type, m2, rooms, yearOfBuild, price, sStatsString)
	{
		this.number = number
		this.Guid = Guid
		this.image = image
		this.adress = adress
		this.zipcode = zipcode
		this.place = place
		this.type = type
		this.m2 = m2
		this.rooms = rooms
		this.yearOfBuild = yearOfBuild
		this.price = price
		this.ImageLoaded = false
		this.StatsString = sStatsString
		this.URL = '/summary.jsp?p_formNr=B&p_idProperty=' + this.Guid
		
		// Bij de eerste 5 is de bStatsRegisteren true. Bij de rest false
		this.bStatsRegistered = (number < 5)
		
		this.LoadImage = function()
		{
			if ( this.ImageLoaded == false )
			{
				document.getElementById('image' + this.number).src = this.GetImage('120')
				this.ImageLoaded = true
			}
		}
		
		this.GetStatRegStr = function()
		{
			if ( this.bStatsRegistered == false )
			{
				this.bStatsRegistered = true
				return this.StatsString
			}
			else
			{
				return ''
			}
		}
		
		this.getHTML = function()
		{
			var splaceTemp = ( this.place.length > 18 ? this.place.substring(0,18) + '...' : this.place )
			var s = ''
			sEnter = '\n'
			if ( navigator.userAgent.indexOf('Firefox') > -1 ) sEnter = ''
			s += '<span class="wib_Object" style="left:' + (-10 + this.number*142) + 'px;">'
			s += '	<a href=javascript:goToSummary("' + this.Guid+'&p_formNr=B' + '") class="wib">'
			s += '		<img class="WibImage" id="image' + this.number + '" border="0" '
			
			//alert(this.GetImage('120'));
			
			
			if ( this.number < 10 )
			{
				s += ' src="' + this.GetImage('120') + '"'
				this.ImageLoaded = true
			}
			else
			{
				s += ' src="/img/spotlight/spacer.gif"'
			}
			s += ' width="120" height="80" alt="Picture of ' + this.adress + ', ' + this.place + '" title="' + this.adress + ','
			if ( this.zipcode != '' ) s += ' ' + sEnter + '' + this.zipcode + ','
			s += ' ' + sEnter + this.place + ', ' + sEnter + this.type + ', ' + sEnter + this.m2 + '" /><br>'
			
			
			s += '		<nobr><b>' + splaceTemp + '</b></nobr><br />'
			s += '		&yen;&nbsp;' + this.price + ''
			s += '	</a>'
			s += '</span>'
			return s
		}
		
		this.GetImage = function(sFormaat)
		{
			/*
			if ( sFormaat != '' ) sFormaat = '_' + sFormaat
			s = this.image
                        //show main picture of the property
			if ( s.indexOf('http') == -1 ) s = './img/' + s.replace('.jpg', '') + sFormaat + '.jpg'
			*/
			
			s = this.image
			return s
		}
	}	
	
	this.AddObject = function(Guid, image, adress, zipcode, place, type, m2, rooms, yearOfBuild, price, sStatsString)
	{
		var number = this.arrObjects.length
		this.arrObjects[number] = new this.Class_WibObject(number, Guid, image, adress, zipcode, place, type, m2, rooms, yearOfBuild, price, sStatsString)
	}

	this.Start = function()
	{
		this.nAantalObjecten = this.arrObjects.length
		this.xMax = 0
		this.AantalPaginas = Math.ceil(this.nAantalObjecten / 5)
		this.xMin = - (this.AantalPaginas-1) * (142 * 5)
		var s = ''
		for ( var i=0; i<this.nAantalObjecten; i++ )
		{
			 s += this.arrObjects[i].getHTML(i)
		}
		//document.getElementById('WIB_knop_right');
		//alert("fdsfdsfdsf");
		//alert(document.getElementById('WIB_knop_right').id);
		
		document.getElementById('WibSpan').innerHTML = s;
		
		
		
		this.SetButtons()
	}
	
	this.SetButtons = function()
	{
		if ( this.nAantalObjecten > 5 )
		{
			document.getElementById('WIB_knop_right').style.display = ( this.Pagina < this.AantalPaginas ? 'block' : 'none' )
			document.getElementById('WIB_knop_left').style.display = ( this.Pagina > 1 ? 'block' : 'none' )
			var s = ''
			for ( var i=1; i<=this.AantalPaginas; i++ ) s += '<a href="javascript:WIB.GaNaarPagina(' + i + ')"' + (this.Pagina == i ? ' class="sel"' : '') + '>&nbsp;' + i + '&nbsp;</a>'
			//document.getElementById('wib_pagenumber').innerHTML = s
		}
	}

	this.Mouseover = function(sDirection)
	{
		if ( document.getElementById('wib_img_' + sDirection) )
		{
			document.getElementById('wib_img_' + sDirection).src = '/img/spotlight/' + sDirection + '_hover.gif'
		}
	}

	this.Mouseout = function(sDirection)
	{
		if ( document.getElementById('wib_img_' + sDirection) )
		{
			document.getElementById('wib_img_' + sDirection).src = '/img/spotlight/' + 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<5; i++ )
			{
				xTemp2 = (this.Pagina * 5 ) + i - 5
				if ( xTemp2 < this.nAantalObjecten )
				{
					this.arrObjects[xTemp2].LoadImage()
					s = this.arrObjects[xTemp2].GetStatRegStr()
					sStats += s + ( s == '' ? '' : ',' )
				}
			}
			if ( sStats != '' ) 
			{
				document.getElementById('WIB_Stats').src = '/koop/wibRegStats.asp?stats=' + sStats
			}
			if ( !this.Interval ) this.Interval = setInterval('WIB.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('WibSpan').style.left = this.xLocation + 'px'
	}


}


