$(document).ready(function() {
    $('#calculateBtn').click(function() {
        // Get values from input fields
        let views = parseFloat($('#views').val());
        let cpm = parseFloat($('#cpm').val());
        let ctr = parseFloat($('#ctr').val());
        let revenueShare = parseFloat($('#revenueShare').val()) / 100;

        // Validate input values
        if (isNaN(views) || isNaN(cpm) || isNaN(ctr) || isNaN(revenueShare) || views <= 0 || cpm <= 0 || ctr <= 0 || revenueShare <= 0) {
            $('#result').text('Please fill in all fields with positive numbers.');
            return;
        }

        // Calculate estimated revenue
        let revenue = (views / 1000) * cpm * (ctr / 100) * revenueShare;

        // Display the result
        $('#result').text(`Estimated Monthly Revenue: $${revenue.toFixed(2)}`);
    });
});
