function performAjax(type, url, params, callFunction, asynchronous) {
if(Ajax.getTransport()) {
new Ajax.Request(url, {
method: type,
asynchronous: asynchronous,
parameters: params,
onComplete: function (request) {
var json = request.responseText.evalJSON();
if(json != null) {
callFunction.call(this, json);
}
}
});
} else {
var functionName = getFunctionName(callFunction);
getAjaxByIframe(url, {
parameters: params,
onComplete: functionName
});
}
}
function getFunctionName(functionReference){
if(functionReference == null)
return null;
if(functionReference.name)
return functionReference.name;
var f = functionReference.toString();
return f.substring(9, f.indexOf("("));
}
function getAjaxByIframe(url,params)
{
var tempIFrame = document.createElement('iframe');
tempIFrame.style.display = 'none';
iframe = document.body.appendChild(tempIFrame);
iframe.src = url + "?" + params.parameters + "&jscallback=" + params.onComplete;
}
function responseAjaxByIframe(jsonObjectStr, callbackMethod)
{
var json = jsonObjectStr.evalJSON();
if(json != null)
eval(callbackMethod + "(json);");
}
function createCookieCheckDefault(partname, value, defaultValue, days) {
if (value != defaultValue) {
createCookie(partname, value, days);
}
}
function createCookie(partname, value, days){
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = "expires=" + date.toGMTString();
}
document.cookie = partname + "=" + value + ";path=/" + (days ? ";" + expires : "") + ";";
}
function readCookie(partname){
var cookies = document.cookie.split(';');
var tempCookie = "";
var cookieName = "";
var cookieValue = "";
var cookieFound = false;
for (i = 0; i < cookies.length; i++){
tempCookie = cookies[i].split('=');
cookieName = tempCookie[0].replace(/^\s+|\s+$/g, '');
if (cookieName == partname){
cookieFound = true;
if (tempCookie.length > 1)
cookieValue = unescape( tempCookie[1].replace(/^\s+|\s+$/g, '') );
return cookieValue;
}
tempCookie = "";
cookieName = "";
}
if (!cookieFound)
return null;
}
function eraseCookie(partname){
document.cookie = partname + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function setCookieEmail(field) {
var email = readCookie("email");
if(field == null) return true;
if(email && email != "") {
field.value = email;
field.style.color='#000'
} else {
field.value = 'naam@domein.nl';
field.style.color='#aaa'
}
return true;
}
function cookieEmailClickEvent(field) {
var email = readCookie("email");
if(email && email != "" && email != "naam@domein.nl") {
} else {
field.value = '';
field.style.color='#000'
}
return true;
}
var MAX_HISTORY_COOKIE_ENTRIES = 3;
function updateHistoryCookie(srch, cookieName){
if (!cookieName)
cookieName = "search_hist";
var histArr = getHistoryCookieArray(cookieName);
var i=0;
while(i<histArr.length){
if(histArr[i].toLowerCase() == srch.toLowerCase())
histArr.splice(i,1);
else i++;
}
if(histArr.unshift){
histArr.unshift(srch);
} else {
histArr = histArr.reverse();
histArr.push(srch);
histArr = histArr.reverse();
}
while(histArr.length > MAX_HISTORY_COOKIE_ENTRIES)
histArr.pop();
for(var i=0; i<histArr.length; i++){
histArr[i] = encodeURIComponent(histArr[i]);
}
createCookie(cookieName, histArr.join("."), 60);
}
function getHistoryCookieValue(i, cookieName){
if (!cookieName)
cookieName = "search_hist";
var histArr = getHistoryCookieArray(cookieName);
if(i<histArr.length)
return histArr[i];
else return null;
}
function getHistoryCookieArray(cookieName){
var histCookie = readCookie(cookieName);
var histArr = [];
if(histCookie!=null)
histArr = histCookie.split(".");
return histArr;
}
function getSavedProperties() {
var cookie = readCookie("savedProperties");
if(cookie == null || cookie == "")
return new Array();
else
return cookie.split(".");
}
function addSavedProperty(id) {
var savedProperties = getSavedProperties();
if(!isSavedProperty(id)) {
savedProperties.push(id);
}
createCookie("savedProperties", savedProperties.join("."), 60);
}
function removeSavedProperty(id) {
var savedProperties = getSavedProperties();
for(i=0; i<savedProperties.length; i++){
if(savedProperties[i]==id)
savedProperties.splice(i,1);
}
createCookie("savedProperties", savedProperties.join("."), 60);
}
function isSavedProperty(id) {
var savedProperties=getSavedProperties();
if(savedProperties==null)
return false;
for (i=0;i<savedProperties.length;i++){
if(savedProperties[i]==id)
return true;
}
return false;
}
function getAddressFromCookie() {
var address = null;
var cookieValue = readCookie('address');
if ((cookieValue != null && cookieValue != "")) {
var values = cookieValue.split(".");
address = new Object();
address.zipcode = values[0];
address.houseNumber = values[1];
address.houseNumberAddition = values[2];
}
return address;
}
function setAddressCookie(zipcode, houseNumber, houseNumberAddition) {
createCookie("address", zipcode + "." + (houseNumber != null ? houseNumber : "") + "." + (houseNumberAddition != null ? houseNumberAddition : ""), 60);
}
function dotNumberValue(priceValue) {
priceValue = priceValue.toString();
if( priceValue.length <= 3 )
return priceValue;
var returnPrice = "";
for(var i=priceValue.length; i>0 ; i-=3)
{
if(returnPrice.length>0)
returnPrice = priceValue.substring(i-3,i) + "." + returnPrice;
else
returnPrice = priceValue.substr(i-3,3);
}
return returnPrice;
}
function parsePriceValue(priceValue, veiling, showComma) {
if (veiling)
return "<i>Veiling</i>";
if( priceValue == null || priceValue == "")
return "<i>Prijs onbekend</i>";
return simpleParsePriceValue(priceValue, showComma);
}
function simpleParsePriceValue(priceValue, showComma) {
if( priceValue == null || priceValue == "")
priceValue = 0;
var returnPrice = "&euro;&nbsp;" + dotNumberValue(priceValue);
if (showComma) {
returnPrice += ",-";
}
return returnPrice;
}
function fitInMaxLength(inputString, maxNrOfChars, fillerString) {
if (inputString == null)
return null;
if( inputString.length<maxNrOfChars )
return inputString;
var nrOfTooManyChars = inputString.length-maxNrOfChars;
if( nrOfTooManyChars <= fillerString.length )
return inputString;
var splitPos = inputString.length/2;
var splitPosStart 	= splitPos - (nrOfTooManyChars/2);
var splitPosEnd 	= splitPos + (nrOfTooManyChars/2);
var startPart = inputString.substring(0,splitPosStart);
var endPart   = inputString.substring(splitPosEnd, inputString.length);
return startPart + fillerString + endPart;
}
Ajax.Autocompleter = Class.create(Ajax.Autocompleter, {
updateChoices: function(choices) {
if(!this.changed && this.hasFocus) {
this.update.innerHTML = choices;
Element.cleanWhitespace(this.update);
Element.cleanWhitespace(this.update.down());
if(this.update.firstChild && this.update.down().childNodes) {
this.entryCount =
this.update.down().childNodes.length;
for (var i = 0; i < this.entryCount; i++) {
var entry = this.getEntry(i);
entry.autocompleteIndex = i;
this.addObservers(entry);
}
} else {
this.entryCount = 0;
}
this.stopIndicator();
this.index = -1;
if(this.entryCount==1 && this.options.autoSelect) {
this.selectEntry();
this.hide();
} else {
this.render();
}
}
},
getCurrentEntry: function() {
return (this.index>=0 ? this.getEntry(this.index) : null);
},
selectEntry: function() {
this.active = false;
var entry = this.getCurrentEntry();
if(entry)
this.updateElement(entry);
}
});
function initAutoComplete(inputFieldId, dropDownDivId, action, searchType) {
var act = action || "getAutocompleteLocationList";
var params = "action=" + act;
if (searchType) {
params += "&search_type=" + searchType;
}
return new Ajax.Autocompleter(inputFieldId, dropDownDivId, "/ajax/ajaxService.do", {
paramName: "value",
minChars: 1,
frequency: 0.4,
parameters: params,
callback: function(element, entry) {
return entry + "&value=" + encodeURIComponent(element);
},
onShow: function(element, update){
if (!update.style.position || update.style.position=='absolute') {
update.style.position = 'absolute';
var ieVersion = getInternetExplorerVersion();
if (ieVersion < 8) {
Position.clone(element, update, {
setHeight: false,
offsetTop: element.offsetHeight
});
} else {
update.style.top = element.offsetHeight + 'px';
update.style.width = element.offsetWidth + 'px';
}
}
Effect.Appear(update,{duration:0.15});
}
});
}
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
rv = parseFloat(RegExp.$1);
}
}
return rv;
}
var CAROUSEL_ELEMENT_SIZE = 115;
var CAROUSEL_ELEMENT_COUNT = 24;
var carousel;
function initCarousel(carUrl) {
SpotlightCarousel = Class.create(UI.Carousel, {
options: {
url: null,
elementCount: -1,
elementSize: 0
},
initialize: function($super, element, options) {
if (!options.url)
throw("url option is required for UI.Ajax.Carousel");
$super(element, options);
this.updateHandler = this.update.bind(this);
this.runRequest.bind(this).defer({parameters: {totalCount: this.options.elementCount, visibleCount: Math.ceil(this.nbVisible)}, onSuccess: this.updateHandler});
},
runRequest: function(options) {
this.requestRunning = true;
new Ajax.Request(this.options.url, Object.extend({method: "GET"}, options));
this.fire("request:started");
return this;
},
computeElementSize: function() {
return this.options.elementSize;
},
update: function(transport, json) {
this.requestRunning = false;
this.fire("request:ended");
if (!json)
json = transport.responseJSON;
this.elements = this.container.insert({bottom: json.html}).childElements();
return this.updateButtons();
},
refresh: function() {
this.elements.each(function(element) {
element.remove();
});
this.endIndex = 0;
this.runRequest({parameters: {totalCount: this.options.elementCount, visibleCount: Math.ceil(this.nbVisible)}, onSuccess: this.updateHandler});
}
});
carousel = new SpotlightCarousel("horizontal_carousel", {url: carUrl, elementSize: CAROUSEL_ELEMENT_SIZE, elementCount: CAROUSEL_ELEMENT_COUNT});
Event.observe(window, "resize", updateCarouselSize);
}
function updateCarouselSize(event) {
carousel.updateSize();
}
function DialogOverlay(content, width, height, container) {
if (typeof container == 'undefined' )
container = document.body;
if (null == (this.container = $(container)))
throw("container is not valid");
this.content = content;
this.overlay = new Element('div');
this.overlay.addClassName('overlay');
this.dialog = new Element('div');
this.dialog.addClassName('dialog');
this.width = width;
this.height = height;
this.dialog.insert(this.content);
this.container.insert(this.overlay);
this.container.insert(this.dialog);
content.show();
}
DialogOverlay.prototype.show = function() {
var windowDim = document.viewport.getDimensions();
if (typeof this.width != 'undefined') {
this.dialog.setStyle({
'width': this.width,
'left': ((windowDim.width - parseInt(this.width)) / 2) + 'px'
});
}
if (typeof this.height != 'undefined') {
this.dialog.setStyle({
'height': this.height,
'top': ((windowDim.height - parseInt(this.height)) / 2) + 'px'
});
}
this.dialog.show();
$(this.overlay).appear({ duration: 0.5, to: 0.8 });
return this;
};
DialogOverlay.prototype.hide = function(event) {
this.dialog.hide();
this.overlay.hide();
return this;
};
function radioButtonValueConvert(radioButtonGroup) {
for (counter = 0; counter < radioButtonGroup.length; counter++) {
if (radioButtonGroup[0].checked) {
return true;
} else if (radioButtonGroup[1].checked) {
return false;
} else {
return undefined;
}
}
}
function selectRadio(radioObjId, newValue) {
radioObj = $(radioObjId).form[radioObjId];
if((!radioObj) || (!newValue))
return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
radioObj.checked = (radioObj.value == newValue.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
radioObj[i].checked = false;
if(radioObj[i].value == newValue.toString()) {
radioObj[i].checked = true;
}
}
}
function clearSearchField(element) {
if ((element.value=='Plaats of postcode') || (element.value=='Plaats, postcode of specifiek adres')) {
element.value = '';
}
}
function restoreBrokerInput(){
var searchInput = getHistoryCookieValue(0, "makelaar_search_history");
if (searchInput && (searchInput != ""))
$('search_input').value = searchInput;
var searchType = readCookie("search_type");
if(searchType != "")
selectRadio('t', searchType);
else
selectRadio('t', 'sell');
}
function saveBrokerInput(){
if ($('search_input').value == 'Plaats of postcode') {
$('search_input').value = '';
}
return true;
}
function isInt(value){
return (parseFloat(value) == parseInt(value)) && !isNaN(parseInt(value));
}
function clearInputValue(inputElement) {
inputElement.value = '';
}
function QueryStringBuilder() {
this.params = new Object();
}
QueryStringBuilder.prototype.addParam = function(name, value) {
if (value != '') {
this.params[name] = encodeURIComponent(value);
}
}
QueryStringBuilder.prototype.build = function() {
var queryString = '';
for (paramName in this.params) {
if (queryString.length > 0) {
queryString += '&';
}
queryString += paramName + '=' + this.params[paramName];
}
return queryString;
}
function getViewportScrollY() {
var scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
scrOfY = window.pageYOffset;
} else if( document.body && document.body.scrollTop ) {
scrOfY = document.body.scrollTop;
} else if( document.documentElement && document.documentElement.scrollTop ) {
scrOfY = document.documentElement.scrollTop;
}
return scrOfY;
}
function getViewportHeight(){
var myHeight = -1;
if( typeof( window.innerHeight ) == 'number' ) {
myHeight = window.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
myHeight = document.documentElement.clientHeight;
} else if( document.body && document.body.clientHeight ) {
myHeight = document.body.clientHeight;
}
return myHeight;
}
function showLoadingSpinner() {
var viewPortTop = getViewportScrollY();
var viewPortHeight = getViewportHeight();
var loaderTop = viewPortTop + viewPortHeight / 4;
$('loading_spinner').setStyle({top: loaderTop + 'px'});
$('loading_spinner').show();
}
function hideLoadingSpinner() {
$('loading_spinner').hide();
}
var EventQueue = function() {
this.queue = new Array();
Event.observe(window, 'load', function() {
this.fireEvents();
}.bind(this));
}
EventQueue.prototype.addEvent = function(eventName, listener) {
this.queue.push({event: eventName, listener: listener});
}
EventQueue.prototype.fireEvents = function () {
var e = this.queue.shift();
while (e != null) {
eval(e.event);
e.listener.writeAttribute({'onclick': ''});
e = this.queue.shift();
}
}
var AjaxDomElements = function(idsAndCallbacks, url, query) {
this.idsAndCallbacks = idsAndCallbacks;
this.url = url;
this.query = query;
this.jsonResponse = null;
this.domElements = [];
for(var i=0; i<this.idsAndCallbacks.length; i++){
this.domElements.push({
id: this.idsAndCallbacks[i].id,
available: false,
callback: this.idsAndCallbacks[i].callback});
}
this.allElementsAvailable = false;
performAjax("get", this.url, this.query, this.requestComplete.bind(this), true);
this.checkDomElementsAvailable();
var self = this;
if(!this.allElementsAvailable) {
this.timerId = setInterval(function(){
self.checkDomElementsAvailable();
}, 100);
}
window.addEventListener('load', function(){self.clearTimer()}, false);
}
AjaxDomElements.prototype.checkDomElementsAvailable = function() {
for(var i=0; i<this.domElements.length; i++){
var domElm = this.domElements[i];
domElm.available = $(domElm.id)!=null;
if(domElm.available) {
if (this.jsonResponse!=null && domElm.callback!=null) {
domElm.callback.call(this, this.jsonResponse);
domElm.callback = null;
}
}
}
this.allElementsAvailable = true;
for(var i=0; i<this.domElements.length; i++){
var domElm = this.domElements[i];
if(!domElm.available) {
this.allElementsAvailable = false;
break;
}
}
if (this.allElementsAvailable) {
this.clearTimer();
}
}
AjaxDomElements.prototype.requestComplete = function(jsonResponse) {
this.jsonResponse = jsonResponse;
this.checkDomElementsAvailable();
}
AjaxDomElements.prototype.clearTimer = function() {
clearInterval(this.timerId);
}
function ajaxDomElementLoggedInUser(jsonResponse) {
var user = jsonResponse.user;
if ((user != null) && (user.loggedIn)) {
$('loggedout_menu').hide();
$('loggedin_menu').show();
$('logged_in_user_email').innerHTML = user.email;
$('mijn_profiel_percentage').addClassName('percent' + user.percentageProfileDone);
} else {
$('loggedout_menu').show();
$('loggedin_menu').hide();
}
}
function ajaxDomElementBackToResultsTop(json){
var resp = json.details;
if (resp.backToResultsLink != "") {
$('navigation_to_results_top_active').show();
$('navigation_to_results_link_top').href = resp.backToResultsLink;
} else {
$('navigation_to_results_top_inactive').show();
}
}
function ajaxDomElementBackToResultsBottom(json){
var resp = json.details;
if (resp.backToResultsLink != "") {
$('navigation_to_results_bottom_active').show();
$('navigation_to_results_link_bottom').href = resp.backToResultsLink;
} else {
$('navigation_to_results_bottom_inactive').show();
}
}
function ajaxDomElementPreviousTop(json){
var resp = json.details;
if (resp.previousProperty != "") {
$('details_previous_top_active').show();
$('details_previous_top_active').href = resp.previousProperty;
} else {
$('details_previous_top_inactive').show();
}
}
function ajaxDomElementNextTop(json){
var resp = json.details;
if (resp.nextProperty != "") {
$('details_next_top_active').show();
$('details_next_top_active').href = resp.nextProperty;
} else {
$('details_next_top_inactive').show();
}
}
function ajaxDomElementPreviousBottom(json){
var resp = json.details;
if (resp.previousProperty != "") {
$('details_previous_bottom_active').show();
$('details_previous_bottom_active').href = resp.previousProperty;
} else {
$('details_previous_bottom_inactive').show();
}
}
function ajaxDomElementNextBottom(json){
var resp = json.details;
if (resp.nextProperty != "") {
$('details_next_bottom_active').show();
$('details_next_bottom_active').href = resp.nextProperty;
} else {
$('details_next_bottom_inactive').show();
}
}
function ajaxDomElementBewarenButton(json){
var resp = json.details;
$('button_save_href').addClassName('button_save_href_class');
if (resp.savedProperty) {
$('button_save_href').addClassName('saved');
}
}