<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">بصريات</a></li>
            <li class="active">المقاسات</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">المقاسات</div>
            <div class="panel-body">
                <form class="form-inline hidden-print" action="sizecalculator.php" method="post" id="sizeCalculator-form">
                    <label class="sr-only">مقاس اللوح&nbsp;&nbsp;&nbsp;</label>
                    <div class="form-group">
                        <label class="sr-only">الطول</label>
                        <input type="text" class="form-control positivefloat" name="boardDim1" id="boardDim1">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">العرض</label>
                        <input type="text" class="form-control positivefloat" name="boardDim2" id="boardDim2">
                    </div>
                    <span id="boardError" class="alert-block alert-danger fade in" style="padding: 2px 5px 5px 5px;display: none;"></span>
                    <div style="clear: both"></div>
                    <br />
                    <label class="sr-only">مقاس القطعة</label>
                    <div class="form-group">
                        <label class="sr-only">الطول</label>
                        <input type="text" class="form-control positivefloat" name="pieceDim1" id="pieceDim1">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">العرض</label>
                        <input type="text" class="form-control positivefloat" name="pieceDim2" id="pieceDim2">
                    </div>
                    <span id="pieceError" class="alert-block alert-danger fade in" style="padding: 2px 5px 5px 5px;display: none;"></span>
                    <div style="clear: both"></div>
                    <br />
                    <button type="button" class="btn btn-primary" style="margin-right: 80px;" id="calcSize">احسب</button>
                </form>
                <div style="clear: both"></div>
                <br />
            </div>
            <div class="panel panel-default panel-m" style="display: none" id="results">

            </div>

        </div>
    </div>
</div>
{literal}
<script>
    $('#calcSize').live('click', function () {
        var boardDim1 = Number($('#boardDim1').val());
        var boardDim2 = Number($('#boardDim2').val());
        var pieceDim1 = Number($('#pieceDim1').val());
        var pieceDim2 = Number($('#pieceDim2').val());

        var valid = 1;
        //ck required
        if (boardDim1 == "0" || boardDim2 == "0") {
            $('#boardError').html('ادخل مقاسات اللوح');
            $('#boardError').show();
            valid = 0;
        }
        else
        {
            $('#boardError').hide();
        }
        if (pieceDim1 == "0" || pieceDim2 == "0") {
            $('#pieceError').html('ادخل مقاسات القطعة');
            $('#pieceError').show();
            valid = 0;
            return false;
        }
        else
        {
            $('#pieceError').hide();
        }
        //ck length > width
        if (boardDim1 < boardDim2) {
            $('#boardError').html('لابد ان يكون الطول اكبر من العرض');
            $('#boardError').show();
            valid = 0;
        }
        else
        {
            $('#boardError').hide();
        }
        if (pieceDim1 < pieceDim2) {
            $('#pieceError').html('لابد ان يكون الطول اكبر من العرض');
            $('#pieceError').show();
            valid = 0;
            return false;
        }
        else
        {
            $('#pieceError').hide();
        }
        if (valid)
        {

            $.post('sizecalculator.php?do=calc', $('#sizeCalculator-form').serialize(), function (data) {
                $('#results').html(data);
                $('#results').show();
            });
        }

    });
</script>
{/literal}

