﻿
/* ---------------------------------------------------------------------------------- */
/* ----- Functies: onLoad ----------------------------------------------------------- */
/* ---------------------------------------------------------------------------------- */

$(document).ready(function() {
if ($("a[rel*='lightbox']").length > 0)
    $("a[rel*='lightbox']").lightbox();
});

/* ---------------------------------------------------------------------------------- */
/* ----- Functies: Algemeen --------------------------------------------------------- */
/* ---------------------------------------------------------------------------------- */

// Standaard-tekst in input verbergen (onFocus)
function textFieldFocus(object, defaultValue) {
    if (object.value == defaultValue) {
        object.value = "";
    }
}

// Standaard-tekst in input tonen (onBlur)
function textFieldBlur(object, defaultValue) {
    if (object.value == "") {
        object.value = defaultValue;
    }
}

// Zoekvlak op home laten oplichten (onFocus, onBlur)
function toggleFocus(object, defaultValue) {
    if ($(".zoekveld .inputwrapper_active").length > 0) {
        $(".zoekveld .inputwrapper").removeClass("inputwrapper_active");
        textFieldBlur(object, defaultValue);
        setTimeout('$("#zoeksuggesties").hide()', 200);
    } else {
        $(".zoekveld .inputwrapper").addClass("inputwrapper_active");
        textFieldFocus(object, defaultValue);
        strWaarde = (object.value).replace("'", "");
        if (strWaarde != defaultValue && strWaarde != "") {
            zoeken(strWaarde);
        }
    }
}

var _timeout = null;
var _timer = 300;

// Zoekfunctie op home (input uitlezen)
function zoeken(zoekTerm) {
    zoekTerm = zoekTerm.replace(/'/g,"").replace(/ /g,"");
    if ((zoekTerm != '') && (zoekTerm.length > 2)) {
        document.getElementById("zoeken_veld").style.color = "#000000";
        var Url = '/pages/ajax/zoeken.aspx?z=' + zoekTerm;
        if (_timeout != null) {
            clearTimeout(_timeout);
            _timeout = null;
        }
        
        _timeout = setTimeout("getZoekData('" + Url.replace("'","\'") + "')", _timer);
    } else {
        $("#zoeksuggesties").hide();
    }
}

// Zoekfunctie op home (data ophalen)
function getZoekData(url) {
    $.get(url, function(data) {
        $('#zoeksuggesties').empty(); $('#zoeksuggesties').html(data);
    });
    $("#zoeksuggesties").show();
}

/* ---------------------------------------------------------------------------------- */
/* ----- Functies: Algemeen --------------------------------------------------------- */
/* ---------------------------------------------------------------------------------- */
