function calculate(length, height, weight)
{
    var lInt= parseFloat(length);
    var hInt= parseFloat(height);
    var wtInt= parseFloat(weight);
    var sqFtInt= lInt * hInt;
    var result= sqFtInt * wtInt;
    
    if (lInt >= 100 || hInt >= 100) {
        wtInt= wtInt / 3;
        result= lInt * hInt * wtInt;
    }
    
    if (lInt >= 50 && lInt <=99 || hInt >= 50 && hInt <= 99 ) {
        wtInt= wtInt / 2.65;
        result= lInt * hInt * wtInt;
    }
    
    return result.toFixed(2);
};

$(document).ready(function() {
    var length= $('#length').val();
    var height= $('#height').val();
    var weight= $('#weight').val();
    var result= 0;
    
    $('#length').change(function() {
        length= $(this).val();
        $('#result').val( calculate(length, height, weight) ).css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);;
        $('#to-order').css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);
    });
    
    $('#height').change(function() {
        height= $(this).val();
        $('#result').val( calculate(length, height, weight) ).css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);;
        $('#to-order').css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);
    });
    
    $('#weight').change(function() {
        weight= $(this).val();
        $('#result').val( calculate(length, height, weight) ).css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);
        $('#to-order').css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);
    });
    
    $('#result').val( calculate(length, height, weight) );
    
    $('form#calculator').submit(function(event) {
        event.preventDefault();
        
        $('#result').val( calculate(length, height, weight) ).css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);
        $('#to-order').css('background-color', '#FF9900').animate({backgroundColor: 'transparent'}, 1000);
    });
});
