
var currentPos		= 0;
var prehuizen		= 10;
var decrease		= 0.1;

var positions		= new Array('0' , '520' , '1040' , '1560', '2080', '2600', '3120', '3640', '4160', '4680', '5200','5720','6240');
var positionsmall	= new Array('520' , '416' , '312' , '208', '104');

var rows, thePos, scrollerTime, dataobj, totalImages, leftOver;

function initpositions(w)
{
	var i;
	positionsmall[0] = 5 * w;
	positionsmall[1] = 4 * w;
	positionsmall[2] = 3 * w;
	positionsmall[3] = 2 * w;
	positionsmall[4] = 1 * w;

	positions[0] = 0 * positionsmall[0];
	positions[1] = 1 * positionsmall[0];
	positions[2] = 2 * positionsmall[0];
	positions[3] = 3 * positionsmall[0];
	positions[4] = 4 * positionsmall[0];
	positions[5] = 5 * positionsmall[0];
	positions[6] = 6 * positionsmall[0];
	positions[7] = 7 * positionsmall[0];
	positions[8] = 8 * positionsmall[0];
	positions[9] = 9 * positionsmall[0];
	positions[10] = 10 * positionsmall[0];
	positions[11] = 11 * positionsmall[0];
}

initpositions(125);
/*initpositions(104);*/

function initialize(pos,slide){
	dataobj		= document.all? document.all.datacontainer : document.getElementById("datacontainer");
	leftOver	= parseInt( Math.ceil( totalImages % 5 ) );
	rows		= parseInt( Math.ceil( totalImages / 5 ) );

	slidePosition(pos,slide);

	if (currentPos==0){
		parent.backwardToggle('off');
	}
	else if (currentPos>=1 && slide=='slideforward'){
		parent.backwardToggle('on');
	}

	if (currentPos>=parseInt(rows-1)){
		parent.forwardToggle('off');
	}
	else if (currentPos>=0 && slide=='slidebackward'){
		parent.forwardToggle('on');
	}

}

function slidePosition(pos,slide){
	var	distance;

	distance	= 0;
	thePos		= parseInt(dataobj.style.left)*(-1);

	if (leftOver>=1 && currentPos >= parseInt(rows-1) )
		var distance = parseInt(parseInt(positions[pos]-positionsmall[leftOver])-(thePos));
	else
		var distance = parseInt(positions[pos]-(thePos));

	scrollerTime = setTimeout("slidePosition('"+pos+"','"+slide+"')",(1));

	if (thePos==parseInt(positions[pos]-positionsmall[leftOver]) && currentPos>=parseInt(rows-1) && leftOver>0){
		clearTimeout(scrollerTime);
	}
	else if (thePos==parseInt(positions[pos])){
		clearTimeout(scrollerTime);
	}
	else if (thePos<parseInt(positions[pos])){
		var steps = Math.ceil(distance*decrease);

		dataobj.style.left=parseInt(dataobj.style.left)-steps;
	}
	else if (thePos>parseInt(positions[pos])){
		var steps = Math.ceil((distance*decrease)*(-1));

		dataobj.style.left=parseInt(dataobj.style.left)+steps;
	}

}

//functie voor vooruit sliden en laden van nieuwe huizen per 5 huizen tegelijk
function slideForward()
{
	clearTimeout(scrollerTime);

	if (prehuizen<parseInt(totalImages-4)){

		for (var i=prehuizen;i<=parseInt(prehuizen+4);i++)
		{
			var one=eval( immoOne[i] );
	var temp;

	temp='<a href="'+one[1]+'" target="_top">';
	temp=temp+'<img src="'+one[0]+'" class="boxC1" height="75" width="100"></a><br>';
	temp=temp+'<a href="'+one[1]+'" target="_top" class="linkC1strong">';
	temp=temp+one[3];
	temp=temp+'</a><br>';
	temp=temp+'<a href="'+one[1]+'" target="_top" class="linkC1strong">';
	temp=temp+one[2];
	temp=temp+'</a>';
	
	document.getElementById('one'+i).innerHTML=temp;
		}

		prehuizen=parseInt(prehuizen+5);
	}
	else if ( prehuizen>=parseInt(totalImages-leftOver) && totalImages>=11 ){

		for (var i=(prehuizen-1);i<=parseInt((prehuizen-1)+leftOver);i++){
		var one=eval( immoOne[i] );
		var temp;

	temp='<a href="'+one[1]+'" target="_top">';
	temp=temp+'<img src="'+one[0]+'" class="boxC1" height="75" width="100"></a><br>';
	temp=temp+'<a href="'+one[1]+'" target="_top" class="linkC1strong">';
	temp=temp+one[3];
	temp=temp+'</a><br>';
	temp=temp+'<a href="'+one[1]+'" target="_top" class="linkC1strong">';
	temp=temp+one[2];
	temp=temp+'</a>';

		document.getElementById('one'+i).innerHTML=temp;
		
			
			
		}

	}

	if (currentPos<parseInt(rows-1)){
		currentPos++;
		initialize(currentPos,'slideforward');
	}

}

//functie voor terug te sliden
function slideBack(){
	clearTimeout(scrollerTime);

	if (currentPos>=1){
		currentPos--;
		initialize(currentPos,'slidebackward')
	}

}