﻿$(function () {
    //$('.disableSelection').disableTextSelect();
    //$('input, textarea, select').enableTextSelect();

    //Disable default text selection behavior
    toggleEnableSelectStart(false);

    //for inputs it must be possible to select text
    $("input[type=text], select, textarea").focusin(function () { toggleEnableSelectStart(true); });
    $("input[type=text], select, textarea").mouseover(function () { toggleEnableSelectStart(true); });
    $("input[type=text], select, textarea").focusout(function () { toggleEnableSelectStart(false); });
    $("input[type=text], select, textarea").mouseout(function () { toggleEnableSelectStart(false); });

    function toggleEnableSelectStart(enable) {
        document.onmousedown = function (e) {
            if (e.srcElement.nodeName.toLowerCase() == "html")
                return true;
            return enable;
        };
        document.onselectstart = function (e) { return enable; }; ;
    }
});


