function uz_feedback_validate_form(cform)
{
  var form = cform;
  form.elements['t'+'p_'+'freu'+'d'].value = (8>>1)+2*15;
  form.elements['tp'+'_em'+'ai'+'l'].value = '';
  return true;
}


$(document).ready(function(){
    $("#uz_thanks_item_dlg_name").html($("#uz_thanks_item_name").html());

    $("#thanks_dialog_div").dialog({
        autoOpen: false,
        bgiframe: true,
        height: 'auto',
        width: '500',
        modal: false
    });
    $("#thanks_dialog_div").show();
});


$(document).ready(function(){

    $("#uz_call_item_dlg_name").html($("#uz_call_item_name").html());


    var firstname = $("#firstname"),
        phone = $("#phone"),
        info = $("#info"),

        obligFields = $([]).add(firstname).add(phone).add(info),
        tips = $("#validateTips");

    function updateTips(t) {
        //tips.text(t).effect("highlight",{},1500);
        tips.text(t);
    }

    function checkForEmpty(o,n) {
        if (o.val().length == 0) {
            o.addClass('ui-state-error');
            updateTips("Поле '" + n + "' не может быть пустым..");
            o.focus();
            return false;
        } else {
            return true;
        }
    }
    function checkRegexp(o,regexp,n) {
        if ( !( regexp.test( o.val() ) ) ) {
            o.addClass('ui-state-error');
            updateTips(n);
            o.focus();
            return false;
        } else {
            return true;
        }
    }

    $("#call_dialog_div").dialog({
        autoOpen: false,
        bgiframe: true,
        height: 'auto',
        width: '500',
        modal: false,
        buttons: {
            'Заказать звонок': function() {
                // validate form
                var bValid = true;
                obligFields.removeClass('ui-state-error');

                bValid = bValid && checkForEmpty(firstname,"Имя");
                bValid = bValid && checkForEmpty(phone,"Телефон");
                bValid = bValid && checkRegexp(phone,/^[0-9+() -]+$/,"Некорректный номер телефона.");

                //bValid = bValid && checkRegexp(name,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter.");

                if (bValid) {
                    $(this).dialog('close');
                    $("#contact").submit();
                    //sendCallForm();
                    $('#thanks_dialog_div').dialog('open');
                }
            }
        },
        close: function() {
            //obligFields.val('').removeClass('ui-state-error');
            obligFields.removeClass('ui-state-error');
        }
    });
    $("#call_dialog_div").show();
});
