function callObjectsTimeout(){
	
	callObjects(null,1);	
}

function callObjectsMaybe(v, slider){
	
	var maxValue = $F(slider+'MaxValue'+getTyp());

	if(maxValue.length > 2){ roundValue = Math.pow(10, (maxValue.length-3)); } else { roundValue = 1; }

	var minVal = Math.round(maxValue*(0.01*Math.pow(v[0]*100,2)/100) / roundValue)*roundValue;
	var maxVal = Math.round(maxValue*(0.01*Math.pow(v[1]*100,2)/100) / roundValue)*roundValue;
	
	$(slider+"Exp").value = minVal+","+maxVal;

	callObjects(null,1);	
}

function swapSlider(){

	var maxValue = $F('priceMaxValue'+getTyp());
	var v = $F('price').split(",");
	if(maxValue.length > 2){ roundValue = Math.pow(10, (maxValue.length-3)); } else { roundValue = 1; }
	var minVal = Math.round(maxValue*(0.01*Math.pow(v[0]*100,2)/100) / roundValue)*roundValue;
	var maxVal = Math.round(maxValue*(0.01*Math.pow(v[1]*100,2)/100) / roundValue)*roundValue;
	$('priceExp').value = minVal+","+maxVal;
	
	var maxValue = $F('oppMaxValue'+getTyp());
	var v = $F('opp').split(",");
	if(maxValue.length > 2){ roundValue = Math.pow(10, (maxValue.length-3)); } else { roundValue = 1; }
	var minVal = Math.round(maxValue*(0.01*Math.pow(v[0]*100,2)/100) / roundValue)*roundValue;
	var maxVal = Math.round(maxValue*(0.01*Math.pow(v[1]*100,2)/100) / roundValue)*roundValue;
	$('oppExp').value = minVal+","+maxVal;	
}
function getTypeRadio()
{
	var KoopHuur='';
	if($('K').checked == true)
	{
		KoopHuur = 1;
	}
	else if($('H').checked == true)
	{
		KoopHuur = 2;
	}
	else
	{
		KoopHuur = 3;
	}
	return KoopHuur;
}
function callObjects(navigation,refreshses){

	$('content').innerHTML = '<img id="loading" src="/images/style/loading.gif" />';
	if(!navigation){ $('pages').value = 1; } 
	$('priceLabel').innerHTML = ($F('H')==2) ? 'Huurprijs' : 'Koopprijs';

	var success	= function(t){callComplete(t);}
	var failure	= function(t){callError(t);}
	
	var KoopHuur = getTypeRadio();
	var refreshSession = (refreshses == 1) ? 1:0;
	new Ajax.Updater('content', 'updater.php', { parameters: {	
																	
																	sorting:$F('sorting'),
																	ordertype: $F('desc'),
																	city: $F('plaats'),
																	price: $F('priceExp'),
																	opp: $F('oppExp'),
																	keyword: $F('keyword'),
																	pages: $F('pages'),
																	wtype: $F('wtype'),
																	koophuur: KoopHuur,
																	refreshSn: refreshSession
																	
																}, 
													
													evalScripts: true	
												}
					);
}

function getTyp(){
	if($F('K')=="1"){ return "K"; } else if($F('H')=="2") { return "H"; } else{return "B";} 
}
function navigation(pages,refreshses){

	$('pages').value = pages;
	callObjects(pages,refreshses);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	  else expires = "";
	  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	
	return null;
}

function showTooltip(slider, minmax){
	
	$('minmax').value = minmax;
	
	// Position ermitteln 
	var arrayValues = $F(slider).split(",");
	var sliderPosition = Position.cumulativeOffset($(slider+minmax));
	var horizontalCorrection = (minmax == 'Max') ? 20 : 24;
	
	
	$('sliderTooltip').style.left = ((sliderPosition[0] )- horizontalCorrection)  + "px";
	$('sliderTooltip').style.top = (sliderPosition[1] - 45) + "px";

	var value = (minmax == 'Min') ? arrayValues[0] : arrayValues[1];
	var maxValue = $F(slider+'MaxValue'+getTyp());

	if(maxValue.length > 2){
		roundValue = Math.pow(10, (maxValue.length-3));
	} else {
		roundValue = 1;
	}
	
	var outputValue = Math.round(maxValue*(0.01*Math.pow(value*100,2)/100) / roundValue)*roundValue;
	
	var sign = (slider == "price") ? '&euro;' : 'm&sup2;';
	
	var outputString = outputValue.toString();
	outputFormatted = outputString.substr(0,outputString.length-6);
	if(outputFormatted.length > 0) outputFormatted += ".";
	outputFormatted += outputString.substr(0,outputString.length-3).slice(-3);
	if(outputFormatted.length > 0) outputFormatted += ".";
	outputFormatted += outputString.slice(-3);
	
	// HTML-Ausgabe
	$('sliderTooltip').innerHTML = '<b>' + minmax + 'imum</b><br>' + outputFormatted + '&nbsp;' + sign;
	
	// Einblenden
	Element.show('sliderTooltip');
}
function reTimerInit()
{
	if($F('reTimer')==10){
		reTimer();
	} else {
		$('reTimer').value = 10;
	}
}
function reTimer()
{
	$('reTimer').value = parseInt($F('reTimer')) - 1;

	if($F('reTimer')==0){
		$('reTimer').value = 10;
		callObjects(null,1);
		
	} else {
		window.setTimeout("reTimer()", 200);
	}
}
function getInfo(id)
{
	document.location.href = '/woning-aanbod/'+id+'.html';
}
