$j(document).ready(function () {
    $j('#type_of_get_PDF').on('change', function () {
        if (this.value === 'own') {
            $j('#common_URL_tr').attr('hidden',true);
        } else {
            $j('#common_URL_tr').attr('hidden',false);
        }
    })

    $j('.validate_number').keypress(validateNumber);

    function validateNumber(event) {
        var key = window.event ? event.keyCode : event.which;
        if (event.keyCode === 8 || event.keyCode === 46) {
            return true;
        } else if (key === 45) {
            if (!this.value) {
                return true;
            } else  {
                return false;
            }
        } else if ( key < 48 || key > 57 ) {
            return false;
        } else {
            return true;
        }
    };
});

//отправка изменившихся данных
function changeStampCoordinates(elem) {
    send_ajax_request({cmd:'print_order/change_test_order_param',value:elem.value,input_name:elem.name,print_order_id:elem.getAttribute('print_order_id')}) ;
}

function changeStampSelect(elem) {
    send_ajax_request({cmd:'print_order/change_test_order_param',value:elem.value,input_name:elem.name,print_order_id:elem.getAttribute('print_order_id')}) ;
}

function showChangeValue(elem) {
    document.getElementById('for_' + elem.getAttribute('id')).innerHTML=elem.value;
}

function togglePrintStamp(elem) {
    console.log(elem);
    let value=0;
    if (elem.checked) {
        value = 1;
        $j('.dependOnPrintStamp').attr('hidden',false);
        if ($j('#type_of_get_PDF')[0].value=='own') $j('#common_URL_tr').attr('hidden',true);
    } else {
        $j('.dependOnPrintStamp').attr('hidden',true);
    }
    send_ajax_request({cmd:'print_order/change_test_order_param',value:value,input_name:elem.name,print_order_id:elem.getAttribute('print_order_id')}) ;
}