$(document).ready(function () {
    $("a").unbind('click.confirm');
	$("a").bind('click.confirm', function() {
        var sourcHtml = $('<div>').append($(this).clone()).html();
        var isXlinkHref = sourcHtml.toLowerCase().indexOf('class="self-report-link self-event"') > 1 && sourcHtml.toLowerCase().indexOf("xlink:href") > 1;
        if (typeof existUnsavedData !== 'undefined' && existUnsavedData && typeof gConfirmsavelesValue !== 'undefined' && gConfirmsavelesValue !== null){
            if (!existUnsavedData || isXlinkHref || ($(this).hasClass("self-event") && !$(this).hasClass("mainmenulink"))) {
                return true;
            } else {
                if (confirm(gConfirmsavelesValue)){
                    return true;
                } else {
                    event.preventDefault();
                    return false;
                }
            }
        }
    });
});
