function callNavigation() {

    $("#navigation li").hover(
		function() {
		    $(this).addClass("hover");
		    $(this).children(".subnavigation").fadeIn("fast");
		},
		function() {
		    $(this).children(".subnavigation").fadeOut("fast");
		    $(this).removeClass("hover");
		}
	);
}

function callSubmenu() {
    // Submenu set borders	
    $("#submenu li ul li a.selected").parent("li").prev("li").children("a").css("border-bottom", "0px");
    $("#submenu li ul li a:last").css("border-bottom", "1px solid #E1E7EE");
    $("#submenu li a:first").css("border-top", "1px solid #E1E7EE");
    $("#submenu li ul li a:first").css("border-top", "0px");
    // Set parent on Li 
    $("#submenu li a.selected").parent("li").addClass("parent");
}

function callOverviewMenu() {
    // Check is MSIE show instead of fadeOut because of PNG bug with IE
    if ($.browser.msie) {
        $(".product_overview").hover(function() {
            $(".products").show();
        });
        $(".products").bind("mouseenter", function() { }).bind("mouseleave", function() {
            $(".products").hide();
        });
    } else {
        $(".product_overview").hover(function() {
            $(".products").fadeIn();
        });
        $(".products").bind("mouseenter", function() { }).bind("mouseleave", function() {
            $(".products").fadeOut();
        });
    }
}

function callLoginMenu() {

    //$("#startlogin").click(function() {
    //	$("#login").show();
    //});
    //$("#login .tab .title").click(function() {
    //$("#login").hide();
    //});
    //$("#login .cancel").click(function() {
    //$("#login").hide();
    //});

    // Check is MSIE show instead of fadeOut because of PNG bug with IE
    if ($.browser.msie) {
        $("#startlogin").hover(function() {
            $("#login").show();
        });
        $(document).click(function(event) {
            if ($(event.target).closest("#login").get(0) == null) {
                $("#login").hide();
            }
        });
        $("#login .cancel").click(function() {
            $("#login").hide();
        });
    } else {

        $("#startlogin").hover(function() {
            $("#login").fadeIn();
        });

        $(document).click(function(event) {
            if ($(event.target).closest("#login").get(0) == null) {
                $("#login").fadeOut();
            }
        });
        $("#login .cancel").click(function() {
            $("#login").fadeOut();
        });
    }

}


function callEditDetails() {

    // Set color textarea 
    $("textarea").click(function() {
        $(this).html('');
        $(this).css('color', '#000000');
    });

    // Hover on fieldset edit link
    $("fieldset a.link").hover(
	  function() {
	      $(this).parent("fieldset").addClass("hover");
	  },
	  function() {
	      $(this).parent("fieldset").removeClass("hover");
	  }
	);

    // Hide fieldset text and show fieldset editmode
    $("fieldset:not(.step) a.link").click(
	function() {
	    $(this).parent("fieldset").hide();
	    $(this).parent("fieldset").next("fieldset.editmode").show();

	    // Extend buttons to other fieldsets
	    $("fieldset.editmode a.button").hide();
	    $(this).parent("fieldset").parent("div").children("fieldset.editmode:visible:last").children("a.button").show();

	    // Set other label color
	    $("fieldset.editmode .fields .row label").css("color", "#ccc");
	    $("fieldset.editmode .fields .row div").css("color", "#ccc");
	    $(this).parent("fieldset").parent("div").children("fieldset.editmode:visible").children(".fields").children(".row").children("label").css("color", "#06417F");
	    return false;
	}
	);

    // Hide fieldset editmode and show fieldset text
    $("#userProfile fieldset.editmode a.cancel").click(
	function() {
	    $(this).parent("fieldset.editmode").hide();
	    $(this).parent("fieldset.editmode").prev("fieldset").show();

	    // Extend buttons to other fieldsets
	    $("fieldset.editmode a.button").hide();
	    $(this).parent("fieldset").parent("div").children("fieldset.editmode:visible:last").children("a.button").show();

	    // Set other label color
	    if ($('fieldset.editmode').is(':visible')) {
	        $("fieldset.editmode .fields .row label").css("color", "#06417F");
	        $("fieldset.editmode .fields .row div").css("color", "#000");
	    } else {
	        $(".fields .row label").css("color", "#06417F");
	        $(".fields .row div").css("color", "#000");
	    }
	    return false;
	}
	);

    // Cancel all button
    $("#userProfile fieldset.editmode a.button.cancel").click(function() {
        $("fieldset:hidden").show();
        $("fieldset.editmode:visible").hide();
        // Set other label color
        if ($('fieldset.editmode').is(':visible')) {
            $("fieldset.editmode .fields .row label").css("color", "#06417F");
            $("fieldset.editmode .fields .row div").css("color", "#000");
        } else {
            $(".fields .row label").css("color", "#06417F");
            $(".fields .row div").css("color", "#000");
        }
        return false;
    });
}

function callLoginValidation() {
    // validation
    function StopPropagation(e) {
        if (jQuery.browser.msie) e.cancelBubble = true;
        else e.stopPropagation();
    }
    $('.login .noTextVal').each(function() {
        // if empty, set error css
        $(this).blur(function() {
            if (jQuery.trim($(this).val()).length == 0)
                $(this).parent('div').addClass('error');
            else
                $(this).parent('div').removeClass('error');
        });
    });
    $('.login .noTextValBtn').click(function() {
        // if empty, set error css
        $(this).closest('fieldset').find('.noTextVal').each(function() {
            if (jQuery.trim($(this).val()).length == 0)
                $(this).parent('div').addClass('error');
            else
                $(this).parent('div').removeClass('error');
        });
    });
    $('#login .noTextVal').each(function() {
        $(this).parent('div').children('span').hide();

        // if empty, set error css
        $(this).blur(function() {
            if (jQuery.trim($(this).val()).length == 0) {
                $(this).parent('div').addClass('error');
                $(this).parent('div').children('span').show();
            } else {
                $(this).parent('div').removeClass('error');
                $(this).parent('div').children('span').hide();
            }
        });
    });
    $('#login .noTextValBtn').click(function(e) {
        var allowClick = true;

        // if empty, set error css and prevent click
        var inputs = $(this).closest('fieldset').find('.noTextVal');
        for (var i = 0, len = inputs.length; i < len; i++) {
            var tb = inputs.eq(i);
            if (jQuery.trim(tb.val()).length == 0) {
                tb.parent('div').children('span.error').show();
                tb.parent('div').addClass('error');
                allowClick = false;
            } else {
                tb.parent('div').children('span.error').hide();
                tb.parent('div').removeClass('error');
            }
        }

        if (allowClick == false) {
            StopPropagation(e);
            return false;
        }
    });

    function DoPasswordLength(password) {

        var pass = password.val();
        if (pass.length > 0 && pass.length < 6) {
            password.addClass('error');
            password.nextAll('.passwordLength').show();
            return false;
        }
        else {
            password.removeClass('error');
            password.nextAll('.passwordLength').hide();
            return true;
        }
    }

    function DoPasswordValidation(password, passwordAgain) {
        var pass = password.val();
        var pass2 = passwordAgain.val();

        if (pass.length > 0 && pass2.length > 0) {
            //if (pass != pass2) {
            if (pass != pass2 || !DoPasswordLength(password)) {
                password.addClass('error');
                passwordAgain.addClass('error');
                passwordAgain.nextAll('.passwordMismatch').show();
                return false;
            } else {
                password.removeClass('error');
                passwordAgain.removeClass('error');
                passwordAgain.nextAll('.passwordMismatch').hide();
                return true;
            }
        }
    }
    function DoEmptyValidation(elem) {
        if (jQuery.trim(elem.val()).length == 0) {
            elem.addClass('error');
            elem.nextAll('span.error:first').show();
            return false;
        } else {
            elem.removeClass('error');
            elem.nextAll('span.error:first').hide();
            return true;
        }
    }
    function DoDDLValidation(elem) {
        if (jQuery.trim(elem.val()).length == 0) {
            elem.addClass('error');
            elem.nextAll('span.error:first').show();
            return false;
        } else {
            elem.removeClass('error');
            elem.nextAll('span.error:first').hide();
            return true;
        }
    }
    function DoCBValidation(elem) {
        if (!elem.is(':checkbox')) elem = elem.find(':checkbox:first');

        if (!elem.is(':checked')) {
            elem.closest('.cbVal').addClass('error');
            elem.closest('.cbVal').find('span.error:first').show();
            return false;
        } else {
            elem.closest('.cbVal').removeClass('error');
            elem.closest('.cbVal').find('span.error:first').hide();
            return true;
        }
    }

    function DoZipCodeValidation(elem) {
        var zip = elem.val();
        if (zip.length > 0) {
            var re = new RegExp('^[1-9][0-9]{3}\\s?[a-z]{2}$', 'i');
            if (re.exec(zip) == null) {
                elem.addClass('error');
                elem.nextAll('span.error:first').show();
                return false;
            } else {
                elem.removeClass('error');
                elem.nextAll('span.error:first').hide();
                return true;
            }
        }
    }

    function DoNumberValidation(elem) {
        var nr = elem.val();
        if (nr.length > 0) {
            var re = new RegExp('^[0-9]*$');
            if (re.exec(nr) == null) {
                elem.addClass('error');
                elem.nextAll('span.error:first').show();
                return false;
            } else {
                elem.removeClass('error');
                elem.nextAll('span.error:first').hide();
                return true;
            }
        }
    }

    function DoPhoneValidation(elem) {
        var phone = elem.val();
        if (phone.length > 0) {
            // todo: make the next regex work
            // allowed: 0318-321654, 0318321654, +31318-321654, +31318321654, 06-12345678, 06123456789, +316-12345678, +31612345678
            //var re = new RegExp('^\+31(\d{2}-?\d{7}|\d{3}-?\d{6})|0(\d{2}-?\d{7}|\d{3}-?\d{6})|06-?\d{8}|\+316-?\d{8}$');
            var re = new RegExp('^[0-9+\\- .]{6,15}$');
            if (re.exec(phone) == null) {
                elem.addClass('error');
                elem.nextAll('span.error:first').show();
                return false;
            } else {
                elem.removeClass('error');
                elem.nextAll('span.error:first').hide();
                return true;
            }
        }
    }

    function DoDateValidation(elem) {
        var date = elem.val();
        if (date.length > 0) {
            var re = new RegExp('^[0-9]{1,4}[- /.][0-9]{1,2}[- /.][0-9]{1,4}$');
            if (re.exec(date) == null) {
                elem.addClass('error');
                elem.nextAll('span.error:first').show();
                return false;
            } else {
                elem.removeClass('error');
                elem.nextAll('span.error:first').hide();
                return true;
            }
        }
    }

    function DoEmailValidation(elem) {
        // note: if email is empty the email is valid (because otherwise it would be impossible to make some fields not required)
        //       use the empty validator (.noTextVal) as well if this is not what you want
        var email = elem.val();
        if (email.length > 0) {
            var re = new RegExp('^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$', 'i');

            // email.lastIndexOf('@') > email.lastIndexOf('.') makes sure aa@bb is not valid (javascript does not evaluate the regex the way we want)
            if (re.exec(email) == null || email.lastIndexOf('@') > email.lastIndexOf('.')) {
                elem.addClass('error');
                elem.nextAll('span.error:first').show();
                return false;
            } else {
                elem.removeClass('error');
                elem.nextAll('span.error:first').hide();
                return true;
            }
        }
    }

    function ValidateElements(elems, validateFunc) {
        var validates = true;

        for (var i = 0, len = elems.length; i < len; i++) {
            var input = elems.eq(i);
            if (validateFunc(input) == false) {
                validates = false;
            }
        }

        return validates;
    }

    function ValidateAll(el) {
        var allowClick = true;

        var parent = el.closest('.validationGroup');

        // if textbox empty, set error css and prevent click
        var inputs = parent.find('fieldset:visible .noTextVal:visible'); // all inputs which are visible
        if (ValidateElements(inputs, DoEmptyValidation) == false) {
            allowClick = false;
        }

        // if no ddl choice, set error css and prevent click
        var ddls = parent.find('fieldset:visible .noDDLVal:visible'); // all ddls which are visible
        if (ValidateElements(ddls, DoDDLValidation) == false) {
            allowClick = false;
        }

        // if not correct email format, set error css and prevent click
        var emails = parent.find('fieldset:visible .emailVal:visible'); // all emails which are visible
        if (ValidateElements(emails, DoEmailValidation) == false) {
            allowClick = false;
        }

        var checks = parent.find('fieldset:visible .noCBVal:visible'); // all checkboxes which are visible
        if (ValidateElements(checks, DoCBValidation) == false) {
            allowClick = false;
        }

        var dates = parent.find('fieldset:visible .dateVal:visible'); // all dates which are visible
        if (ValidateElements(dates, DoDateValidation) == false) {
            allowClick = false;
        }

        var zips = parent.find('fieldset:visible .zipVal:visible'); // all zip codes which are visible
        if (ValidateElements(zips, DoZipCodeValidation) == false) {
            allowClick = false;
        }

        var phones = parent.find('.phoneVal:visible'); // all phone numbers which are visible
        if (ValidateElements(phones, DoPhoneValidation) == false) {
            allowClick = false;
        }

        var numbers = parent.find('fieldset:visible .numberVal:visible'); // all numbers which are visible
        if (ValidateElements(numbers, DoNumberValidation) == false) {
            allowClick = false;
        }

        // password change validation
        var password = parent.find('.password:visible');
        var passwordAgain = parent.find('.passwordAgain:visible');
        if (password.length > 0 && passwordAgain.length > 0) {
            if (DoPasswordValidation(password, passwordAgain) == false) {
                allowClick = false;
            }
        }

        // if loader still busy, do not allow safe
        if (parent.find('.fieldLoad:visible').length > 0) allowClick = false;

        // if email service error message is visible, form does not validate
        var emailChecker = parent.find('.emailCheckService:visible');
        if (emailChecker.length > 0) {
            // todo: make sure it does not only check the first email address it finds, but others as well (foreach)
            if (emailChecker.closest('.row').find('.emailCheckError:visible').length > 0) {
                allowClick = false;
            }
        }

        // if email service error message is visible, form does not validate
        var emailChecker2 = parent.find('.userNameCheck:visible');
        if (emailChecker2.length > 0 && emailChecker2.hasClass('false')) {
            allowClick = false;
        }

        return allowClick;
    }

    $(".validationGroup .save").click(function(e) {
        var allowClick = ValidateAll($(this));
        if (allowClick == false) {
            $(this).removeClass("loading");
            StopPropagation(e);
            return false;
        } else {
            $(this).addClass("loading");
        }
    });

    $('fieldset .noTextVal').blur(function() {
        DoEmptyValidation($(this));
    });
    $('fieldset .noDDLVal').change(function() {
        DoDDLValidation($(this));
    });
    $('fieldset .emailVal').blur(function() {
        DoEmailValidation($(this));
    });
    $('fieldset .dateVal').blur(function() {
        DoDateValidation($(this));
    });
    $('fieldset .zipVal').blur(function() {
        DoZipCodeValidation($(this));
    });
    $('fieldset .numberVal').blur(function() {
        DoNumberValidation($(this));
    });
    $('.phoneVal').blur(function() {
        DoPhoneValidation($(this));
    });
    $('.validationGroup .password').blur(function() {
        DoPasswordLength($(this));
    });
    $('.validationGroup .passwordAgain').blur(function() {
        DoPasswordValidation($('.validationGroup .password'), $(this));
    });

    function InitOnEnter() {
        $('.onEnterClick').each(function() {
            $(this).keypress(function(e) {
                var key = (e.keyCode ? e.keyCode : e.which);
                if (key == 13) {
                    var elem = $('.submitOnEnter');
                    if (elem.length != 0) {
                        if (ValidateAll(elem) == true) {
                            var href = elem.attr('href');
                            elem.addClass('loading');
                            if (href != null && href.toLowerCase().indexOf('javascript') != -1) {
                                eval(href);
                            } else {
                                elem.click();
                            }
                        }

                        return false;
                    }
                }
            });
        });
        $('.onEnterClick2').each(function() {
            $(this).keypress(function(e) {
                var key = (e.keyCode ? e.keyCode : e.which);
                if (key == 13) {
                    var elem = $('.submitOnEnter2');
                    if (elem.length != 0) {
                        /*if (ValidateAll(elem) == true) {*/
                        var href = elem.attr('href');
                        elem.addClass('loading');
                        if (href != null && href.toLowerCase().indexOf('javascript') != -1) {
                            eval(href);
                        } else {
                            elem.click();
                        }
                        /*}*/

                        return false;
                    }
                }
            });
        });
    }
    InitOnEnter();
}
// Add loading to button
//    $(".validationGroup fieldset.editmode a.save").click(function(){
//	    $(this).addClass("loading");
//	    return true;
//	});

function addSelectLoading() {
    if ( $(".ddlEmails").length > 0 ) {
        $(".ddlEmails select").change(function(){ 
            $(this).next(".fieldLoad").show();
        });
    }
}
function callSuccessMsg() {
    jQuery(function() {
        setTimeout(function() { // After 3500 ms fade out the menu
            $(".successmsg").animate({ opacity: 0 }, 500);
        }, 3500);
    });
}
function searchWatermark() {
    $("#header #search .search:text").click(function() {
        if (!$(this).hasClass('nowatermark')) {
            $(this).val("");
            $(this).addClass('nowatermark');
        }
    });

    $("#header #search .search:text").blur(function() {
        if (jQuery.trim($(this).val()).length == 0) {
            $(this).val("zoeken");
            $(this).removeClass('nowatermark');
        }
    });
}

function IsNumericKey(e) {
    // ignore if letter is not digit
    if ((e.shiftKey && e.keyCode == 45) || e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57))
        return false;
    return true;
}
function IsDecimalKey(e) {
    // ignore if letter is not digit or comma
    if ((e.shiftKey && e.keyCode == 45) || e.which != 8 && e.which != 0 && e.which != 44 && (e.which < 48 || e.which > 57))
        return false;
    return true;
}
function InitNrInput() {
    $('.numeric').keypress(function(e) {
        if (!IsNumericKey(e)) return false;
    });
    $('.decimal').keypress(function(e) {
        if (!IsDecimalKey(e)) return false;
    });
}

function jazekerCheckService() {
    $("#wizardsteps li:not(.done) a").removeAttr("href");

    $(".appointmentYesNo input[value='0']").click(function() { appShowList(false); });
    $(".appointmentYesNo input[value='1']").click(function() { appShowList(true); });

    $(".situationNo").click(function() { changeSituation(false); });
    $(".situationYes").click(function() { changeSituation(true); });

    $("#contactStep a.link.edit").click(function() {
        $("#contactStep fieldset:not(.editmode)").hide();
        $("#contactStep fieldset.editmode").show();
        return false;
    });
    $("#contactStep a.cancel").click(function() {
        $("#contactStep fieldset:not(.editmode)").show();
        $("#contactStep fieldset.editmode").hide();
        return false;
    });
}

function appShowList(show) {
    $(".appointmentinfo dl").toggle(show);
}

function changeSituation(show) {
    if (show) {
        $("#changeSituation .rbl").css('display', 'block');
    } else {
        $("#changeSituation .rbl").hide();
    }
}

function doProgressBar(parentID, percentage, currentStep, width, fillAllDone) {
    $('#' + parentID).progressBar(percentage, { // Config: http://t.wits.sg/jquery-progress-bar/jquery-progress-bar-configuration/
        steps: 20,
        stepDuration: 20,
        max: 100,
        showText: false,
        textFormat: 'percentage',
        width: width,
        height: 15,
        callback: null,
        boxImage: '/images/progressbar' + width + '.gif',
        barImage: '/images/progressbg_green' + width + '.gif' //{
        //0:  '/images/progressbg_red.gif',
        //30: '/images/progressbg_orange.gif',
        //70: '/images/progressbg_green.gif'
        //}
    });

    //var parent = $('#' + parentID).parents('div');
    var parent = $('#' + parentID).closest('.pbcontainer');
    var steps = parent.find(" .checkpoints li");
    for (var i = 1, len = steps.length; i <= len; i++) {
        var step = parent.find('.checkpoint' + i);
        if (!fillAllDone) {
            step.toggleClass('done', i <= currentStep);
        } else {
            step.toggleClass('done', i == currentStep);
        }
        step.toggleClass("active", i == currentStep);
    }

    steps.css('width', (width / steps.length) + 'px');

    // bug fix: the first and last where removed (todo: find out why)
    checkpointTooltip();
    $(".progress .product:last").addClass("last");

    if ($.browser.msie && $.browser.version.substr(0, 1) < 8) {
        $(function() {
            var zIndexNumber = 1000;
            $('div').each(function() {
                $(this).css('zIndex', zIndexNumber);
                zIndexNumber -= 10;
            });
        });
    }
}

function checkpointTooltip() {
    $(".checkpoints li").hover(function() {
        $(this).children(".tooltip").show();
    }, function() {
        $(this).children(".tooltip").hide();
    });

    $('ul.checkpoints').each(function() {
        $(this).find("li:first").addClass('first');
        $(this).find("li:last").addClass('last');
    });
};

//function appointmentOverview() {
//	
//	var hideTxt = "Verberg afspraken uit het verleden";
//	var showTxt = "Toon afspraken uit het verleden";
//	var a = true;
//	
//	$("#showAppHistory").click(function(){
//		$("#appointment_overview .history").toggle();
//		if(a == true) {
//			$(this).html(hideTxt);
//			a = false;
//		} else {
//			$(this).html(showTxt);
//			a = true;
//		}
//		return false;
//	});
//	
//	$("#makeNewApp").click(function(){
//		$("#makeAppointment").show();
//		$(this).hide();
//		return false;
//	});
//	$("#makeAppointment .cancel").click(function(){
//		$("#makeAppointment").hide();
//		$("#makeNewApp").show();
//		return false;
//	});
//	
//	$("#appointment_overview .appointment:last").addClass("last");
//};
function appointmentOverview() {

    var hideTxt = "Verberg afspraken uit het verleden";
    var showTxt = "Toon afspraken uit het verleden";
    var a = true;

    $("#makeNewApp").click(function() {
        $("#makeAppointment").slideDown();
        $(this).hide();
        return false;
    });
    $("#makeAppointment .cancel").click(function() {
        $("#makeAppointment").slideUp();
        $("#makeNewApp").show();
        return false;
    });

    $("#appointment_overview .current .appointment:last").addClass("last");
    $("#appointment_overview .history .appointment:last").addClass("last");

};
function addAdviceComment(e) {
    if (e.prev('div').is(':visible')) {
        e.html("Opmerkingen toevoegen");
        e.prev('div').hide();
    } else {
        e.html("Verberg opmerking");
        e.prev('div').show();
    }
    return false;
}

/* Message Box */

function onLoadMsg() {
    $("#inbox ul.overview li:visible").removeClass("last");
    $("#inbox ul.overview li:visible:last").addClass("last");
    $("#composeMsgLink").click(function() {
        $("#composeMsgLink").hide();
    });
}

function setTab(elem, cssClass) {
    if ($("." + cssClass).length > 0) {
        $("span.noMsg").html("");
    } else {
        $("span.noMsg").html("<br/><p>Er zijn geen berichten van dit type.</p>");
    }

    $("#inbox ul.overview li").show();

    if ($(elem).hasClass("first")) {
        $("span.noMsg").html("");
        $("#inbox ul.overview li.prefpane, #inbox ul.overview li.oldEntry").hide();
    } else {
        $("#inbox ul.overview li:not(." + cssClass + ")").hide();
    }
    $("#inbox .tabs li a").removeClass("active");

    $(elem).addClass("active");

    onLoadMsg();

    if ($('.fullcontent').is(':visible')) {
        $("a.more").html("Lees meer");
        $('.fullcontent').hide();
    }
}

function closeTab(e) {
    e.stopPropagation();
    $("#oldMsg a").hide();
    setTab($(".tabs .first"));
    return false;
}

function readOldMsg() {
    $("#oldMsg a").hide();
    $(".oldMessages a").click(function() {
        var title = $(this).html().substr(0, 12);
        $("#oldMsg a").html(title + "..." + "<span>close</span>");
        $("#oldMsg a").show();
        $("#oldMsg a span").click(function(e) { closeTab(e); });
        setTab(this, 'oldEntry');
        $("#oldMsg a").addClass("active");
    });
    $("#oldMsg a").click(function(e) {
        setTab($(this), 'oldEntry');
        return false;
    });
}

function showFullMsg(e) {

    if (e.parent().is('h3')) {
        e.parent().parent().find('.fullcontent').slideDown();
        e.parent().parent().find('a.more').html("Lees minder");
    } else {
        if (e.prev('.fullcontent').is(':visible')) {
            e.html("Lees meer");
            e.prev('.fullcontent').slideUp();
        } else {
            $("#inbox .content a.more").html("Lees meer");
            e.html("Lees minder");
            $('.fullcontent').slideUp();
            e.prev('.fullcontent').slideDown();
        }
        return false;
    }
}

function makeNewMsg(e) {
    $(e).parent().next(".NewMsg").slideDown();
    return false;
}
function cancelNewMsg() {
    $(".NewMsg .cancel").click(function() {
        $(this).parents(".NewMsg").slideUp();
        $(".makeNewMsg").show();
        $("#composeMsgLink").show();
        return false;
    });
}

function checkBirthDate(elem) {
    if ($(elem).is(":checked")) {
        $(elem).parent().parent().parent().next().show();
    } else {
        $(elem).parent().parent().parent().next().hide();
    }
    setLastBorder();
}

function getNearestVestiging(elem) {
    $(elem).next("span").show();
    $(".getNearestVestiging").show();
    //$("#getNearestVestiging").show();
    $("#setNearestVestiging").hide();
    setLastBorder();
}
function setNearestVestiging() {
    $(".fieldLoad").hide();
    $("#setNearestVestiging").show();
    //$("#getNearestVestiging").hide();
    $(".getNearestVestiging").hide();
    setLastBorder();
}

function setLastBorder() {
    $('.fields').each(function() {
        $(this).find(".row:visible:last").addClass('last');
        $(this).find(".row:visible").prev().removeClass('last');
    });
    $('#product_overview').each(function() {
        $(this).find(".product:last").addClass('last');
    });
}

function showRouteDescription(elem) {
    if ($(elem).hasClass("hide")) {
        $(elem).html("Verberg routebeschrijving");
        $("#dir-container").slideDown();
        $(elem).removeClass("hide");
    } else {
        $(elem).html("Toon routebeschrijving");
        $("#dir-container").slideUp();
        $(elem).addClass("hide");
    }
    return false;
}
function init() {
    // Call all init functions
    callNavigation();
    callSubmenu();
    callOverviewMenu();
    callLoginMenu();
    callEditDetails();
    callLoginValidation();
    callSuccessMsg();
    searchWatermark();
    InitNrInput();
    jazekerCheckService();
    appointmentOverview();
    checkpointTooltip();
    appointmentOverview();
    onLoadMsg();
    readOldMsg();
    cancelNewMsg();
    setLastBorder();
    showRouteDescription();
    addSelectLoading();
    //InitOnEnter();

    $('#wizardsteps a').each(function() { $(this).removeAttr('disabled'); });

    // Set borders subscriptions
    if ($(".subscription").length > 0) {
        $('.subscription input:checkbox').each(function() {
            $(this).change(function() {
                $('<div class="checkbox-loader"></div>').insertBefore($(this));
                $(this).hide();
            });
        });

        $('.subscription .fieldblock').each(function() {
            $(this).find("p:last").addClass('last');
            $(this).find("li:last").addClass('last');
        });
    }

    if ($("#content-right").children().length < 1) {
        $("#content-right").remove();
    }
}

$(document).ready(function() {
    init();
});