var isVraag = false;
var superTagBase = "";
$(document).ready(function() {

    $("#plaats").mouseup(function() {
        setTimeout("setPlaatsPost()", 50);
    });
    $("#post").mouseup(function() {
        setTimeout("setPlaatsPost()", 50);
    });
    $(".formMessageClose").click(function() {

        $(".formMessage").hide();
    });
    ///erg new window script
    if (document.getElementById("bannerStartChat")) {
        document.getElementById("bannerStartChat").target = "chat";
    }

    $("#hulpBel").click(function() {
        //   _supertag.event = 'kanaalsturing/telefoon';
        //  _supertag.submit();
        this.href = this.href + "?_st_osc=telefoon";

    });
    // alert($("#hulpBel").hre
    $("#hulpBezoek").click(function() {
        // _supertag.event = 'kanaalsturing/locatie';
        // _supertag.submit();

        this.href = this.href + "?_st_osc=loket";


    });
    $("#hulpMail").click(function() {
        // _supertag.event = 'kanaalsturing/mail';
        // _supertag.submit();
        this.href = this.href + "?_st_osc=mail";

    });
    if (document.getElementById("hulpChat")) {
        document.getElementById("hulpChat").target = "chat";
    }
    $("#hulpChat").click(function() {
        _supertag.event = 'kanaalsturing/chat';
        _supertag.submit();
        this.href = this.href + "?_st_osc=chat";

    });
    $(".haRoutebeschrijving div").hide();
    $(".haRouteOpenbaarVervoer div").hide();
    $(".setGoogleMap").click(function() {
        showGoogleAddres(this.innerHTML);
        return false;
    });
    $(".haRoutebeschrijving > a").click(function() {
        // Toggle Panel
        $(".haRoutebeschrijving > div").slideToggle(1);
        return false;
    });

    $(".haRouteOpenbaarVervoer > a").click(function() {
        // Toggle Panel
        $(".haRouteOpenbaarVervoer > div").slideToggle(1);
        return false;
    });

    $(".print").click(function() {
        _supertag.event = 'calltoaction/printen';
        if (isVraag) {
            _supertag.event = 'vraag_en_antwoord/printen';
        }
        _supertag.submit();

        window.print();
        return false;
    });
    $(".cssBtnFormMailUwVraagSubmit").click(function() {
        _supertag.event = 'calltoaction/mailen2';
        if (isVraag) {
            _supertag.event = 'vraag_en_antwoord/mailen2';
        }
        _supertag.submit();

    });
    /* main navigation : hover */
    $("#mainnav li").hover(
		function() {					/* over */
		    $(this).find("a").addClass('hover');
		    $(this).find("ul").show();

		},
		function() {					/* out */
		    $(this).find("a").removeClass('hover');
		    $(this).find("ul").hide();
		}
	);

    /* font size */
    $("#metaFontsizeSmall").attr('href', '#').click(function() {
        $("body").removeClass('fontsizeSmall fontsizeNormal fontsizeLarge').addClass('fontsizeSmall');
        $("#metanav .fontsize a").removeClass("act");
        $.cookie('fSize', 'fontsizeSmall', { path: '/' });
        $(this).addClass("act");
    });
    $("#metaFontsizeRegular").attr('href', '#').click(function() {

        $("body").removeClass('fontsizeSmall fontsizeNormal fontsizeLarge').addClass('fontsizeNormal');
        $("#metanav .fontsize a").removeClass("act");
        $.cookie('fSize', 'fontsizeNormal', { path: '/' });
        $(this).addClass("act");
    });
    $("#metaFontsizeLarge").attr('href', '#').click(function() {
        $("body").removeClass('fontsizeSmall fontsizeNormal fontsizeLarge').addClass('fontsizeLarge');
        $("#metanav .fontsize a").removeClass("act");
        $.cookie('fSize', 'fontsizeLarge', { path: '/' });
        $(this).addClass("act");
    });
    if ($.cookie('fSize')) {
        $("body").removeClass('fontsizeSmall fontsizeNormal fontsizeLarge').addClass($.cookie('fSize'));
        $("#metanav .fontsize a").removeClass("act");
        var a = $.cookie('fSize')
        var capitalCook = a.charAt(0).toUpperCase() + a.substr(1);
        $("#meta" + capitalCook).addClass("act");
    }

    if ($('.themeFaq').length > 0) {
        /* alles inklappen */
        $(".themeFaq").children("li").each(function(i) { /*  li a.act").not(".themeFaq li li a.act") */
            $(".themeFaq").children("li:eq(" + i + ")").find("a.act").addClass("inact").removeClass("act");
            $(".themeFaq").children("li:eq(" + i + ")").find("div").hide();
        });
        /* op 6.2 onderwerppagina eerste item uitklappen */
        if ($('.themeFaq').length > 0) {
            //  $(".themeFaq li:eq(0) a:eq(0)").addClass("act").removeClass("inact");
            // $(".themeFaq li:eq(0) div").show();
        }

        /* uitklappen onclick */
        $(".themeFaq > li").each(function() {

            $("a:eq(0)", this).click(function() {
                switch ($(this).attr('class')) {
                    case "inact":
                        $(this).removeClass('inact').addClass('act');
                        if (superTagBase == "") {
                            superTagBase = _supertag.antwoord;
                        }
                        _supertag.antwoord = superTagBase + ":" + $(this).text();
                      //  alert(_supertag.antwoord);
                        _supertag.event = "vraag_en_antwoord/subvraag";
                        _supertag.submit();

                        break;
                    case "act":
                        $(this).removeClass('act').addClass('inact');
                        break;
                }
                $(this).parent().find('div').toggle();
                return false;
            });
        });
    }

    /* bepaal lijnhoogte in blok #rightcontent ( even hoog als linkercontent vlak ) */
    if ($('#rightcontent .verticalline').length > 0) {
        var leftHeight = $("#leftcontent").height();
        var rightHeight = $("#hulpBannerImage").height() + $("#hulpBanner").height();
        var lineHeight = leftHeight - rightHeight - 15;
        $("#rightcontent .verticalline").height(lineHeight).show();
    }

    /* verberg antwoordformulier op '6.3 antwoordpagina' */
    if ($('#antwoordFormWrp').length > 0) {
        $('#antwoordFormWrp').hide();
        $('#showAntwoordForm').click(function() {
            $('#antwoordFormWrp').toggle();
            _supertag.event = 'calltoaction/mailen1';
            if (isVraag) {
                _supertag.event = 'vraag_en_antwoord/mailen1';
            }
            _supertag.submit();
        });
    }
    /* verberg reactieformulier op '6.3 antwoordpagina' */
    if ($('#reactieFormWrp').length > 0) {
        $('#reactieFormWrp').hide();
        $('#showReactieOpDezePagina').click(function() {
            $('#reactieFormWrp').toggle();
        });
    }

    /* hoogte persberichten + actualiteiten gelijk */
    if ($('#overviewPersberichten').length > 0 && $('#overviewActualiteiten').length > 0) {
        var heightOverviewPersberichten = $("#overviewPersberichten").height();
        var heightOverviewActualiteiten = $("#overviewActualiteiten").height();

        if (heightOverviewPersberichten > heightOverviewActualiteiten)
            $("#overviewActualiteiten").height(heightOverviewPersberichten);
        else
            $("#overviewPersberichten").height(heightOverviewActualiteiten);
    }

    /* trefwoord : onFocus leeghalen, onBlur vullen indien leeg */
    if (document.location.href.indexOf("results.aspx") > 0) {
        $(this).val('');
    } else {
        if ($("#trefwoord").length > 0) {
            var trefwoordValue = $("#trefwoord").val();
            $("#trefwoord").focus(function() {
                $(this).val('');
            });
            $("#trefwoord").blur(function() {
                if ($(this).val() == "")
                    $(this).val(trefwoordValue);
            });
        }
    }

    /* postcode : onFocus leeghalen, onBlur vullen indien leeg */
    if ($("#uwPostcode").length > 0) {
        var postcodeValue = $("#uwPostcode").val();
        $("#uwPostcode").focus(function() {
            $(this).val('');
        });
        $("#uwPostcode").blur(function() {
            if ($(this).val() == "")
                $(this).val(postcodeValue);
        });
    }

    /* clueTip plugin */
    $('a.title').cluetip({ splitTitle: '|' });

});