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 = 486 //bylo 710
	this.BeweegBreedte = 454
	this.v = 0
	this.vmax = 0
	this.a = 0
	this.x = 0
	this.t = 0 
	this.nAantalObjecten = 3
	this.Vertical = false
	this.Prefix = ''

	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 = 3

	this.Class_WibObject = function(nummer, Guid, Foto, Adres, Postcode, Plaats, Type, Oppervlak, Kamers, Bouwjaar, Prijs, Vertical, Prefix)
	{
		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.Vertical = Vertical
		this.Prefix = Prefix
		this.ImageLoaded = false
		this.URL = '' + this.Guid
		
		this.LoadImage = function()
		{
			if ( this.ImageLoaded == false )
			{
				document.getElementById(this.Prefix + '_Image' + this.Nummer).src = this.GetFoto('120')
				this.ImageLoaded = true
			}
		}
		
		this.getHTML = function()
		{
			var sPlaatsTemp = ( this.Plaats.length > 98 ? this.Plaats.substring(0,98) + '...' : this.Plaats )
			var s = ''
			sEnter = '\n'
			if ( navigator.userAgent.indexOf('Firefox') > -1 ) sEnter = ''
			if(this.Vertical)
			{
				s += '<span class="wib_Object" style="top:' + ( this.Nummer*(140+11)) + 'px;">' //mod
			}
			else
			{
				s += '<span class="wib_Object" style="left:' + ( this.Nummer*(140+11)) + 'px;">' //mod
			}
			s += '	<a href="' + this.URL + '" class="wib">'
			s += '		<img class="WibImage" id="' + this.Prefix + '_Image' + this.Nummer + '" border="0" '
			if ( this.Nummer < 10 )
			{
				s += 'src="' + this.GetFoto('120') + '"'
				this.ImageLoaded = true
			}
			else
			{
				//s += 'src="/img/spacer.gif"'
				s += 'src="/images/wib/spacer.gif"'
			}
			s += ' width="140" height="104" alt="" /><br />'  //mod
			
			
//			s += '		<nobr><span class="hot_offer_title">' + sPlaatsTemp + '</span></nobr><br />'
			s += '<span class="hot_offer_title">' + sPlaatsTemp + '</span><br />'
			s += '		<div style="margin-left:13px;" align="left">' + this.Prijs + '</div>'
			s += '	</a>'
			s += '</span>'
			return s
		}
		
		this.GetFoto = function(sFormaat)
		{
			if ( sFormaat != '' ) sFormaat = '_' + sFormaat
			s = this.Foto
			if ( s.indexOf('http') == -1 ) s = '' + s.substring(0,95)
			return s
		}
	}	
	
	this.AddObject = function(Guid, Foto, Adres, Postcode, Plaats, Type, Oppervlak, Kamers, Bouwjaar, Prijs)
	{
		var nummer = this.arrObjects.length
		this.arrObjects[nummer] = new this.Class_WibObject(nummer, Guid, Foto, Adres, Postcode, Plaats, Type, Oppervlak, Kamers, Bouwjaar, Prijs, this.Vertical, this.Prefix)
	}

	this.Start = function()
	{
		this.nAantalObjecten = this.arrObjects.length
		this.xMax = 0
		this.AantalPaginas = Math.ceil(this.nAantalObjecten / 3)
		//alert(this.nAantalObjecten);
		this.xMin = - (this.AantalPaginas-1) * ((180+11) * 3)  //mod
		var s = ''
		for ( var i=0; i<this.nAantalObjecten; i++ )
		{
			 s += this.arrObjects[i].getHTML(i)
		}
		tmpel = document.getElementById(this.Prefix+'_Span');
		if (tmpel == null) {
			return
		}
		/*
		window.alert(document.getElementById(this.Prefix+'_Span'));
		*/
		document.getElementById(this.Prefix+'_Span').innerHTML = s
		this.SetButtons()
	}
	
	this.SetButtons = function()
	{
		var Button1='links'
		var Button2='rechts'
		if(this.Vertical)
		{
			Button1='op'
			Button2='dons'
		}

		if ( this.nAantalObjecten > 3 )
		{
			if( this.Pagina < this.AantalPaginas )
			{
				document.getElementById(this.Prefix + '_knop_' + Button2).style.display = 'block'
			}
			else
			{
				document.getElementById(this.Prefix + '_knop_' + Button2).style.display = 'none'
				this.Mouseout(Button2)
			}
			
			if( this.Pagina > 1 )
			{
				document.getElementById(this.Prefix + '_knop_' + Button1).style.display = 'block'
			}
			else
			{
				document.getElementById(this.Prefix + '_knop_' + Button1).style.display = 'none'
				this.Mouseout(Button1)
			}
		}
	}

	this.Mouseover = function(sDirection)
	{
		if ( document.getElementById(this.Prefix + '_img_' + sDirection) )
		{
			document.getElementById(this.Prefix + '_img_' + sDirection).src = '/images/wib/' + sDirection + '_hover.gif'
		}
	}

	this.Mouseout = function(sDirection)
	{
		if ( document.getElementById(this.Prefix + '_img_' + sDirection) )
		{
			document.getElementById(this.Prefix + '_img_' + sDirection).src = '/images/wib/' + 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 )  //o ile stron ma sie przewinac, w praktyce zawsze = 1
			this.Pagina = n
			if ( this.Pagina > this.AantalPaginas ) this.Pagina = this.AantalPaginas
			if ( this.Pagina < 1 ) this.Pagina = 1
			for ( var i=0; i<3; i++ )
			{
				xTemp2 = (this.Pagina * 3 ) + i - 3
				if ( xTemp2 < this.nAantalObjecten )
				{
					this.arrObjects[xTemp2].LoadImage()
				}
			}
			if ( !this.Interval ) this.Interval = setInterval(this.Prefix + '.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
		}
		
		if( this.Vertical )
		{
			document.getElementById(this.Prefix + '_Span').style.top = this.xLocation + 'px'
		}
		else
		{
			document.getElementById(this.Prefix + '_Span').style.left = this.xLocation + 'px'
		}
	}
}

