﻿var resetDirtyFlag = false;

var dirtyflag = false;

var IsFading = false;


function HandleBeginRequest(sender, args) {




    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm.get_isInAsyncPostBack()) {
        args.set_cancel(true);
    }

    start = new Date();

    var _keepalive = false;

    if ($get('__EVENTTARGET').value == "KeepAliveTimer") {
        TE_Postback(null, null);
        _keepalive = true;
    }

    if (dirtyflag) {
        dirtyflag = !confirm("Er zijn items op de pagina aangepast die nog niet opgeslagen zijn,\nweet u zeker dat u het scherm wilt verlaten?");
    }

    if (dirtyflag) {
        args.set_cancel(true);
    }

    document.body.style.cursor = "progress";
/*
    if (IsFading) {
        //Hij is klaar met faden

    if (!_keepalive)
        ContainerFadeOut();


         }


        );





        //setTimeout('IsFading = false; __doPostBack(sender, args);', 3000);

    }
*/


    if (!_keepalive) {
        //ContainerFadeOut();
        //setTimeout('', 5000);
        //alert("ik ga door!");

    }
}

function HandlePageLoading(sender, args) {

    //alert("HandlePageLoading");

    if ($get('__EVENTTARGET').value != "KeepAliveTimer") {
        //ContainerFadeOut();
    }

    //ContainerFadeIn();
}



function HandlePageLoaded(sender, args) {

    //alert("HandlePageLoaded");

    if ($get('__EVENTTARGET').value != "KeepAliveTimer") {
        //ContainerFadeIn();
    }

    //ContainerFadeIn();
}

function HandleDirtyflag() {
    if (dirtyflag) {
        dirtyflag = !confirm("Er zijn items op de pagina aangepast die nog niet opgeslagen zijn,\nweet u zeker dat u het scherm wilt verlaten?");
    }

    return !dirtyflag;

}

function TE_ValueChanged(sender, args) {
    dirtyflag = true;
}

function TE_Postback(sender, args) {
    if (dirtyflag) {
        dirtyflag = false;
        resetDirtyFlag = true;
    }
}

function doPostBackAsync(eventName, eventArgs) {

    var prm = Sys.WebForms.PageRequestManager.getInstance();

    if (!Array.contains(prm._asyncPostBackControlIDs, eventName)) {

        prm._asyncPostBackControlIDs.push(eventName);

    }

    if (!Array.contains(prm._asyncPostBackControlClientIDs, eventName)) {

        prm._asyncPostBackControlClientIDs.push(eventName);

    }

    __doPostBack(eventName, eventArgs);

}


function KaosJavascriptPostback(EventArgs) {
    doPostBackAsync("btnJSPostback", EventArgs);
}




$(document).ready(function() {


    $("a .fade").hover(function() {
        $(this).children().addClass("tag_hover");
        $(this).children().children().addClass("tag_right_hover");
    }, function() {
        $(this).find(".tag").removeClass("tag_hover");
        $(this).find(".tag_right").removeClass("tag_right_hover");
    });

    $(".hovereffect").hover(function() {
        $(this).addClass("bg_hover");
    }, function() {
        $(this).removeClass("bg_hover");
    });



    $(window).resize(function() {
        AutoInfoSize();
    });

});


$(document).ready(function() {

    //AJAX errors afvangen
    $(document).ajaxError(

            function(event, XMLHttpRequest, ajaxOptions, thrownError) {
                // thrownError only passed if an error was caught
                alert("Er is iets mis gegaan bij het ophalen van de gegevens. \n\nURL: " + ajaxOptions.url + '\n\nResponse: ' + XMLHttpRequest.responseText + '\n\nThrown error: ' + thrownError);
            }

        );

});

var delay = (function() {
    var timer = 0;
    return function(callback, ms) {
        clearTimeout(timer);
        timer = setTimeout(callback, ms);
    };
})();

function AnimationMenu(i){
        if (AllowSmallAnimations == 1) {
            $(".icons ul li").css("bottom", "-600px");
            //Show icons with effect OPTIONEEL                
                var AantalLi = $(".icons ul li").size();
                if (i != AantalLi){
                    $(".icons ul li").eq(i).animate({
                        bottom: "5px"
                    }, 1500); 
                    i++;
                    setTimeout("AnimationMenu("+i+")", 200);              
                }  
            }
            else{
            
            }
}


function doSifr() {
    jQuery.fn.exists = function() { return jQuery(this).length > 0; }
    //alert("bezich met sifr");
    if ($(".sIFR-replaced").exists()) {
       // alert("sifr gevonden");
        $(".sIFR-replaced").css("opacity", "1.0");
        $(".sIFR-replaced").addClass("hasSifr");
       // alert("gesifrt en class toegevoegd");
        if ($(".sIFR-replaced").hasClass("hasSifr") == false){
       //     alert("sifr niet gevonden");
            setTimeout("doSifr()", 1000);            
        }
    }
}

function InputSelect(){
    $("input.search_bottom").click(function() {
        //$(this).select();
    });
}

function ContainerFadeIn() {
    //Hack for fade in        
    if (AllowFades == 1) {
        $(".container_content").css("display", "none");
        $(".container_content").fadeIn(1500);
    }
    else {
        $(".container_content").css("display", "block");
    }
}

function ContainerFadeOut() {
    //Hack for fade in        
    if (AllowFades == 1) {
        $(".container_content").fadeOut(1000);
    }
    else {
        $(".container_content").css("display", "none");
    }
}

function AutoSuggestJquery() {
    globalTimeout = null;
    $(".autosuggest_container").css("display", "block");
    $(".autosuggest_container").css("height", "auto");
    $(".autosuggest_container").animate({
        height: "auto",
        paddingTop: "10px",
        paddingBottom: "10px"
    }, 1200);

    $(".autosuggest_container").addClass("active");

    var userinput = $(".search_bottom").val();
    if (userinput == "") {
        userinput = "!-!";
    }

    $.getJSON("/TagAutoSuggest.axd?like=" + userinput + "&Keyword=" + userinput + "",
        function(data) {
            var _aantalData = data.length;
            var i = 0;
            var newTags = "";

            while (i != _aantalData) {
                //alert(data[i]);            
                newTags = '<div class="tag_click"><div class="tag">' + data[i] + '<div class="tag_right"></div></div></div>' + newTags;
                i++;
            }
            //Maak de autosuggest box.
            if (newTags == "") {
                $(".autosuggest_container").animate({
                    height: "0px",
                    paddingTop: "0px",
                    paddingBottom: "0px"
                }, 1, function() { $(".autosuggest_container").css("display", "none"); });
            }
            else {
                $(".autosuggest_container").html(newTags);
            }


        });





}


function MergeJSONtoTemplate(url, templateid, destinationid, callback) {

    //alert("MergeJSONtoTemplate");

    //try
    //{
    $.getJSON(url, function(data) {

        if (data.ItemCount > 0) {

            var template = $(templateid).html();

            var node = $(template).bindTo(data);

            $(node).appendTo(destinationid);
        }
        else {
            $(destinationid).append("<div style=\"padding:30px;\">Uw zoekopdracht heeft geen resultaten opgeleverd</div>");
        }
        //alert("json klaar");


        //Callback uitvoeren
        cb = callback(data);
    });
    //}
    //catch(exception) {
    //    alert('Er is iets mis gegaan bij het ophalen van de gegevens. Onze excuses voor het ongemak\n' + exception);
    //}    

}





function AutoInfoSize() {
    if ($(".blok_results").length > 0) {
        $('#pane1').jScrollPaneRemove();
        $("#pane1").css("overflow", "hidden");
        var BodyHeightReal = $("body").outerHeight();
        var BodyHeight = BodyHeightReal - 500;
        var top_height = (BodyHeight * 0.063) + 75;
        var infosize = (BodyHeight * 0.075) + 110;
        var infosize = BodyHeightReal - (infosize + top_height) - 160;

        /*$(".blok_results .height265").animate({
            height: infosize
        }, 1000, function() { $('#pane1').jScrollPane({ reinitialiseOnImageLoad: true }); $(".jScrollPaneContainer").css("height", infosize);});
       */
       setTimeout("AutoInfoSizeDelay("+infosize+")", 500);

   }

   if ($(".blok_results_vraag").length > 0) {
       $('.blok_results_vraag #pane1').jScrollPaneRemove();
       $(" .blok_results_vraag #pane1").css("overflow", "hidden");
       var BodyHeightReal = $("body").outerHeight();
       var BodyHeight = BodyHeightReal - 500;
       var top_height = (BodyHeight * 0.063) + 75;
       var infosize = (BodyHeight * 0.075) + 110;
       
       var _VraagHeight = $(".blok_vraag").outerHeight();

       var infosize = BodyHeightReal - (infosize + top_height) - 160 - _VraagHeight;


       setTimeout("AutoInfoSizeDelayVraag(" + infosize + ")", 1);

   }
}

function AutoInfoSizeDelay(infosize){
    //alert("test");
        $(".blok_results .height265").animate({
            height: infosize
        }, 500, function() {
            $('#pane1').jScrollPane({ reinitialiseOnImageLoad: true });

        });

        $(".blok_results .jScrollPaneContainer").animate({
        height: infosize
        }, 500);
    }

    function AutoInfoSizeDelayVraag(infosize) {
        //alert("test");
        $(".blok_results_vraag .height265").animate({
            height: infosize
        }, 500, function() {
            $('.blok_results_vraag #pane1').jScrollPane({ reinitialiseOnImageLoad: true, animateTo: true, animateInterval: 50, animateStep: 5 });       
        });

        $(".blok_results_vraag .jScrollPaneContainer").animate({
            height: infosize
        }, 500);
    }


/*function MakeTag(Content){
//alert(Content);
GetNieuwTag = $(".tags").html();
//alert(GetNieuwTag);
MakeHTML = ''+ GetNieuwTag +'<div class="fade needtofade" style="display:none"><div class="tag">'+ Content +'<div class="tag_right_cross"></div></div></div>';
$(".tags").html(MakeHTML);
$(".needtofade").fadeIn(1000);
$(".needtofade").removeClass("needtofade");       
       
$(".tag_right_cross").click(function(){            
$(this).parent().parent().fadeOut(1000);            
//$(this).closest(".blok_container").find(".header").effect("highlight", {color: "#a9a9a9"}, 3000);
});       
}*/

function Centercontainer_content() {
    if ($("div").is(":animated")) {
        setTimeout("Centercontainer_content()", 200);
    } else {
        var BodyHeight = $("body").outerHeight();
        //var BodyHeight = BodyHeight - 500;
        var container_contentHeight = $(".container_content").outerHeight();
        var top_height = (BodyHeight - container_contentHeight) / 3;
        //alert(BodyHeight);
        //alert(container_contentHeight);
        //alert(top_height);
        if (AllowSmallAnimations == 0) {
            var top_height = top_height / 2;
        }
        $(".container_content").css("top", top_height);
        $(".container_content").css("visibility", "visible");

        doSifr();
    }
}


function MakeShadow() {
    $("html, body").css("overflow", "hidden");
    var aantal = $(".witbg").length;
    var i = 0;
    while (i != aantal) {
        if ($(".witbg").eq(i).hasClass("hasShaduw") == true) {
            //alert("gevonden");
        }
        else {
            
            //var GetHTML = $(".blok_container").eq(i).html();
            var MakeHTML = '<div class="schaduw_top"><div class="schaduw_left"></div><div class="schaduw_right"></div></div><div class="schaduw_links"></div><div class="schaduw_rechts"></div><div class="schaduw_onder"><div class="schaduw_left"></div><div class="schaduw_right"></div></div>';
            //$(".blok_container .witbg").eq(i).html(MakeHTML);
            $(MakeHTML).insertAfter(".witbg:eq(" + i + ")");
            $(".witbg").eq(i).addClass("hasShaduw");

        }
        i++;
    }
}

function ShadowFixIE(){
    if (AllowShadows == 1){
        var GetHTML = $(".bottom_search .blok_container").html();
        var MakeHTML = GetHTML + '<div class="schaduw_top_fix"><div class="schaduw_left_fix"></div><div class="schaduw_right_fix"></div></div>';
        $(".bottom_search .blok_container").html(MakeHTML);    
    }
    else{}
}

function DrawVlineIe() {
    // vtxt is geen css class maar word alleen gebruikt voor IE6 om de vline op 100% te krijgen.  
    var aantalVline = $(".vline").size();
    var i = 0;
    while (i != aantalVline) {
        var GetParentHeight = $(".vline").eq(i).parent().outerHeight();
        $(".vline").eq(i).css("height", GetParentHeight);
        i++;
    }
}



function infotypesearchsubmit(){
    $(".infotypesearchsubmit").click(function() {
        var usersearch = $(".infotypesearchtxt").val();
        //alert(userinput);
        if (!FilterKeywordInArray(usersearch)) {
            $(".tags").css("display", "block");
            $(".tags").addClass("active");
            addFilterKeyword(usersearch);
            var id = $(".blok_results").attr("id");
            rebindInfoContainer(id);
            var iswat = "Keyword";
            setTimeout('MakeTag(\'' + usersearch + '\', \'' + id + '\', \'' + iswat + '\')', 500);
            setTimeout("$('.infotypesearchtxt').val('Zoeken...').select();", 500);
            $('.infotypesearchtxt').attr('rel', 'Zoeken...');

        }



        return false;
    });
    
    $('.infotypesearchtxt').keypress(function(e) {
        if(e.which == 13) {
            jQuery(this).blur();
            jQuery('.infotypesearchsubmit').focus().click();
        }
    });

}

function InfoCollectionProvider() {
    $(".ui-radio, .radiofield label").click(function() {
        var id = $(".blok_results").attr("id");
        if (getIsBusy(id) == 0) {
            setIsBusy(id, 1);
            var valueRadio = $(this).parent().find("input:radio").val();

            setInfoCollectionProvider(id, valueRadio);

            rebindInfoContainer(id);
        }

    });
}

function CheckRadioButton(id) {
    id = "#" + id;
    $(id).checkBox('changeCheckStatus', true)
}

function MenuHover(){

// Icons hover text effect
            $(".icons ul li").hover(function() {
                $(this).find(".icons_hover").css("opacity", "0.01");
                $(this).find(".icons_hover").css("display", "block");
                $(this).find(".icons_hover").stop(true, false).animate({ opacity: 0.99 }, 500);
            }, function() {
                $(this).find(".icons_hover").stop(true, false).animate({ opacity: 0.01 }, 500);
            });

            //Icons hover image effect
            $(".icons ul li .icon_dashboard img").hover(function() {
                $(this).attr("src", "/images/icons/logo_dashboard_hover.png");
            }, function() {
                $(this).attr("src", "/images/icons/logo_dashboard.png");
                
                if($(".icon_dashboard").hasClass("active") == true ){
                $(".icon_dashboard img").attr("src", "/images/icons/logo_dashboard_hover.png");
            }
            });
            
            if($(".icon_dashboard").hasClass("active") == true ){
                $(".icon_dashboard img").attr("src", "/images/icons/logo_dashboard_hover.png");
            }

            //Agenda (yellow)
            $(".icons ul li .icon_agenda_panel img").hover(function() {
                $(this).attr("src", "LeonardoPortal.PortalImages.logo_agenda_hover.png");                
            }, function() {
                $(this).attr("src", "LeonardoPortal.PortalImages.logo_agenda.png");
                
                if($(".icon_agenda_panel").hasClass("active") == true ){
                $(".icon_agenda_panel img").attr("src", "LeonardoPortal.PortalImages.logo_agenda_hover.png");
            }
            });
            
            if($(".icon_agenda_panel").hasClass("active") == true ){
                $(".icon_agenda_panel img").attr("src", "LeonardoPortal.PortalImages.logo_agenda_hover.png");
            }

            
            //Les-project (orange)
            $(".icons ul li .icon_lesproject_panel img").hover(function() {
                $(this).attr("src", "LeonardoPortal.PortalImages.logo_lesproject_hover.png");
            }, function() {
                $(this).attr("src", "LeonardoPortal.PortalImages.logo_lesproject.png");
                
                if($(".icon_lesproject_panel").hasClass("active") == true ){
                $(".icon_lesproject_panel img").attr("src", "LeonardoPortal.PortalImages.logo_lesproject_hover.png");
            }
                
            });
            
            if($(".icon_lesproject_panel").hasClass("active") == true ){
                $(".icon_lesproject_panel img").attr("src", "LeonardoPortal.PortalImages.logo_lesproject_hover.png");
            }

            //Vraag (groen)
            $(".icons ul li .icon_vraag_panel img").hover(function() {
                $(this).attr("src", "LeonardoPortal.PortalImages.logo_vraag_hover.png");
            }, function() {
                $(this).attr("src", "LeonardoPortal.PortalImages.logo_vraag.png");

                if ($(".icon_vraag_panel").hasClass("active") == true) {
                    $(".icon_vraag_panel img").attr("src", "LeonardoPortal.PortalImages.logo_vraag_hover.png");
                }

            });

            if ($(".icon_vraag_panel").hasClass("active") == true) {
                $(".icon_vraag_panel img").attr("src", "LeonardoPortal.PortalImages.logo_vraag_hover.png");
            }

}

function HoverTagsCloud(){
    $("a .fade").hover(function() {
        $(this).children().addClass("tag_hover");
        $(this).children().children().addClass("tag_right_hover");
    }, function() {
        $(this).find(".tag").removeClass("tag_hover");
        $(this).find(".tag_right").removeClass("tag_right_hover");
    });
}

function trim(value) {
    value = value.replace(/^\s+/, '');
    value = value.replace(/\s+$/, '');
    return value;
}

function SwitchDiv(DivHigher, DivLower) {

    if (AllowHeavyAnimations == 1) {
        DivHigher = "." + DivHigher;
        DivLower = "." + DivLower;

        //Hoogte orginele div uitrekenen
        var _DivHigherHeight = $(DivHigher).outerHeight();
        var _DivLowerHeight = $(DivLower).outerHeight();

        //Fake div aanmaken zodat content op de zelfde plek blijf staan.
        $(DivHigher).before("<div class='tempdivHigher' style='position:relative;display:none;width:100%;height:" + _DivHigherHeight + "px;'></div>");
        $(DivLower).before("<div class='tempdivLower' style='position:relative;display:none;width:100%;height:" + _DivLowerHeight + "px;'></div>");


        //Absolute position DivHigher
        var DivHigherposition = $(DivHigher).position();
        DivHigherposition = DivHigherposition.top;

        //Absolute position DivLower
        var DivLowerposition = $(DivLower).position();
        DivLowerposition = DivLowerposition.top;


        $(DivHigher).css("position", "absolute");
        $(DivHigher).css("top", DivHigherposition);
        $(DivHigher).css("z-index", "999");
        $(DivHigher).css("background-image", "url('/images/white20_bg.png')");
        $(".tempdivHigher").css("display", "block");

        $(DivLower).css("position", "absolute");
        $(DivLower).css("top", DivLowerposition);
        $(DivLower).css("z-index", "998");
        $(DivLower).css("background-image", "url('/images/white20_bg.png')");
        $(".tempdivLower").css("display", "block");

        $(".tempdivLower").animate({
            height: _DivHigherHeight
        }, 500);


        $(DivHigher).animate({
            top: DivLowerposition
        }, 1500, function() {
            var DivHigherClass = $(DivHigher).attr("class");
            var DivHigherId = $(DivHigher).attr("id");
            var DivHigherHTML = $(DivHigher).html();

            $(DivHigher).remove();
            $(".tempdivLower").html(DivHigherHTML);
            $(".tempdivLower").addClass(DivHigherClass);
            $(".tempdivLower").attr("id", DivHigherId);
            $(".tempdivLower").css("height", "auto");
            $(".tempdivLower").removeClass("tempdivLower");
            $('#pane1')[0].scrollTo(DivLowerposition);
        });

        $(".tempdivHigher").animate({
            height: _DivLowerHeight
        }, 500);


        var _diff = _DivHigherHeight - _DivLowerHeight;

        DivHigherposition = DivHigherposition + _diff;

        $(DivLower).animate({
            top: DivHigherposition
        }, 1500, function() {
            var DivLowerClass = $(DivLower).attr("class");
            var DivLowerId = $(DivLower).attr("id");
            var DivLowerHTML = $(DivLower).html();

            $(DivLower).remove();
            $(".tempdivHigher").html(DivLowerHTML);
            $(".tempdivHigher").addClass(DivLowerClass);
            $(".tempdivHigher").attr("id", DivLowerId);
            $(".tempdivHigher").css("height", "auto");
            $(".tempdivHigher").removeClass("tempdivHigher");
        });
    }
    else if (AllowHeavyAnimations == 0 && AllowSmallAnimations == 1) {
        DivHigher = "." + DivHigher;
        DivLower = "." + DivLower;
    
        var DivHigherHTML = $(DivHigher).html();
        var DivLowerHTML = $(DivLower).html();

        $(DivHigher).html(DivLowerHTML);
        $(DivLower).html(DivHigherHTML);

        
    }
    else {
        //alert("Ga gvd eens updaten naar een nieuwere versie");
    }
}

function PreInitFX() {
    jQuery.fn.exists = function() { return jQuery(this).length > 0; }
    
    if ($.browser.msie && $.browser.version == "6.0") {
        //IE6 fix voor PNG
        $("html").pngFix();
        setTimeout("DrawVlineIe()", 500);
        $(".open").css("display", "none");
    };

    if ($("input:radio").length > 0) {
        $('input:radio').checkBox();
    }

    if (AllowShadows == 1) {
       MakeShadow();
    }
    else {
    }

    if ($("#pane2").hasClass("done") == false) {
        $("#pane2").jScrollPane({ reinitialiseOnImageLoad: true });
        $(".blok_vraag .jScrollPaneContainer").css("height", "110px");
        //$("#pane2").addClass("done");
    }
}

function PostInitFX() {
   
    
       
    MenuHover();

    InputSelect();    
    
    launchSIFR();
  
    setTimeout("Centercontainer_content();", 1000);

    //Tijdelijk hier, Leon fixt :)
    InfoCollectionProvider();

    if ($("#pane2").hasClass("done") == false) {
        $("#pane2").jScrollPane({ reinitialiseOnImageLoad: true });
        $(".blok_vraag .jScrollPaneContainer").css("height", "110px");
        $("#pane2").addClass("done");
    }
   
    
    $(".controls .open").click(function() {

        if ($(".controls .open").hasClass("close") == true) {

            $(".blok_vraag .witbg, .blok_vraag .witbg .content").animate({
                height: "110px"
            }, 500, function() {
                /*$(".blok_vraag .jScrollPaneContainer").animate({
                height: "110px"
                }, 500);  */
                $(".blok_vraag .jScrollPaneContainer").css("height", "110px");
                $('.blok_vraag #pane2').jScrollPane({ reinitialiseOnImageLoad: true });
                $(".controls .open").removeClass("close");
                AutoInfoSize();
            });

        }
        else {

            $('.blok_vraag #pane2').jScrollPaneRemove();
            $(" .blok_vraag #pane2").css("overflow", "hidden");
            
            var _LeftHeigt = $(".container_content .left").outerHeight();
            var _ContentHeight = $(".blok_vraag .containercontent").outerHeight();
            var _ContentHeightRelative = $(".container_content .left").outerHeight() * 0.66;
            if (_ContentHeight > _ContentHeightRelative) {
                var _ContentHeight = _LeftHeigt * 0.66;

            }

            var _HeightAnswers = _LeftHeigt - _ContentHeight - 60;

            $(".blok_vraag .witbg, .blok_vraag .witbg .content").animate({
                height: _ContentHeight
            }, 500, function() {
                $(".blok_vraag .jScrollPaneContainer").css("height", _ContentHeight);
                $('.blok_vraag #pane2').jScrollPane({ reinitialiseOnImageLoad: true });
                $(".controls .open").addClass("close");
                AutoInfoSize();
            });

        }

    });

 
    
    
        $(".blurinput").focus(function(){
    
        var Waarde = $(this).val();

        if (Waarde == $(this).attr("rel")) {
            $(this).val("");
            InputBlurSearch();
        }
        else {

        }
        
    });


}

function ValidateForm() {

    var _AantalForms = $("input:text.validate").length;
    var i = 0;
    var _ok = true;    
    while (i != _AantalForms) {

        if ($("input:text").hasClass("validate") == true) {            
            var _DefaultValue = $("input:text.validate").eq(i).attr("rel");
            if ($("input:text.validate").eq(i).val() == _DefaultValue || $("input:text.validate").eq(i).val() == "" || $("input:text.validate").eq(i).val() == " ") {

                $("input:text.validate").eq(i).css("border", "2px solid #a60033");
                //$("input:text").eq(i).val(_DefaultValue + " (Dit veld is verplicht)");

                _ok = false;
        

            }
            else {
                $("input:text.validate").eq(i).css("border", "2px solid #6D6D6D");


            }

            //Email validatie
            if (_DefaultValue == "Hier uw E-mailadres") {
                var _reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                var _adres = $("input:text.validate").eq(i).val();
                if (_reg.test(_adres) == false) {
                    $("input:text.validate").eq(i).css("border", "2px solid #a60033");
                    _ok = false;
                }
            }

            //Postcode validatie
            if (_DefaultValue == "Postcode") {

                var reg = new RegExp(/^[0-9]{4}[ ]?[A-Za-z]{2}$/);
                if (reg.exec($("input:text.validate").eq(i).val()) == null) {
                    $("input:text.validate").eq(i).css("border", "2px solid #a60033");
                    _ok = false;
                }

            }


        }
        i++;

    }
   
    return _ok;
    
}

function CheckPostcode() {
    if ($(".results").hasClass("active") == true) {
        $(".results").hide("blind", { direction: "vertical" }, 1000);
        $(".results").removeClass("active");
    }
}

function GetPostcode() {

    var _UserInput = $(".postcode").val();

    $.get('Postcode.axd?postcode=' + _UserInput + '', function(data) {
        $('.results').html(data);
        //$('.results').show("slide", { direction: "up" }, 1000);
        //$(".results").show("fold", {}, 1000);
        $(".results").show("blind", { direction: "vertical" }, 1000);
        $(".results").addClass("active");

       $(".results a").html("Open de website");
       
       
    });

}

function InputBlurSearch(Waarde){
   // $("#footer_txtSearch, #KaosControl_lesproject_panel_searchlesproject_txtZoeken, #KaosControl_agenda_panel_searchagenda_txtZoeken, #KaosControl_searchresultspanel_searchgeneric_txtZoeken, #KaosControl_vraag_panel_searchvraag_txtZoeken").blur(function(){
    $(".blurinput").blur(function(){
    var Userwaarde = $(this).val();
    if (Userwaarde == "" || Userwaarde == $(this).attr("rel")) {
        $(this).val($(this).attr("rel"));

    }
    else {
        //$(this).addClass("changed");
    }

    Waarde = "";
  });
  
}


