﻿var defaultSearchText = "Zoeken";

$(document).ready(function() {

    //$(".nav-dropdown").each(function() { if ($(this).find('ul.menu-2nd-level').size() > 1) { $(this).addClass('nav-dropdownWide'); } })

    $(function() { $("a[rel^='prettyPhoto']").prettyPhoto({ theme: 'facebook' }) });
    $('.nav').dropdown();

    $(".clickBlock").click(function() {
        var url = $(this).find("a:last").attr("href");
        var urlLen = url.length;
        var ext = url.substring(urlLen - 4, urlLen);
        if (ext == ".pdf" || ext == ".doc" || ext == "docx") {
            docWin = window.open(url, 'docWin');
            try {
                docWin.focus();
            } catch (e) { }
        } else {
            location = url;
        }
    });

    $("input[rel='searchBox']").focus(function() {
        if ($(this).val() == defaultSearchText) { $(this).val(""); }
    }).blur(function() {
        if ($(this).val() == "") { $(this).val(defaultSearchText); }
    });

});

var currFaqID = 0;
function swFaq(id) {
    if (currFaqID != 0 && currFaqID != id) {
        $("li[rel='" + currFaqID + "']").removeClass('opened');
        $("div[rel='" + currFaqID + "']").hide();
    }
    if ($("li[rel='" + id + "']").hasClass('opened')) {
        $("li[rel='" + id + "']").removeClass('opened');
        $("div[rel='" + id + "']").hide();
    } else {
        $("li[rel='" + id + "']").addClass('opened');
        $("div[rel='" + id + "']").show();
        currFaqID = id;
    }
}

function PostSearchBox(controlClientID) {
    var val = $(".search-box input[type=text]").val();
    if (val.length < 3 || val == defaultSearchText) {
        alert("Vul minimaal 3 karakters in a.u.b.");
        return false;
    }
    else {
        __doPostBack(controlClientID.replaceAll("_", "$"), '');
    }
}
String.prototype.replaceAll = function(arg1, arg2) {
    var t = this;
    while (t.indexOf(arg1) != -1) {
        t = t.replace(arg1, arg2);
    }
    return t;
};

function fnShowMap(id) {
    if (id == 0) {
        $("#regionMaps img").each(function() { $(this).hide(); });
    } else {
        $("#regionMaps img[rel='" + id + "']").show();
    }
}
