            // + CALL DIALOG SCRIPT
$(document).ready(function(){

    // Prepare call dialog html

    // Get event id, name, date, place
    $("#uz_call_item_dlg_name").html($("#uz_call_item_name").html());

    //uzCallCustomFields = array($("#cf_company"));

    var firstname = $("#firstname"),
        company = $("#company"),
        phone = $("#phone"),

        obligFields = $([]).add(firstname).add(phone),
        tips = $("#validateTips");


    // Check form functions

    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;
        }
    }


    // Create dialog box on call div
    $("#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');
                    $("#contact2").submit();
                    //sendCallForm();
                }
            },
            'Отмена': function() {
                $(this).dialog('close');
            }
        },
        close: function() {
            //obligFields.val('').removeClass('ui-state-error');
            obligFields.removeClass('ui-state-error');
        }
    });
    $("#call_dialog_div").show();

$("#zakaz_dialog_div").dialog({
       
        autoOpen: false,
        bgiframe: true,
        height: 'auto',
        width: '800',
        modal: false,
 buttons: {
            'Отправить': function() {
             
            
                    
                    $("#zakazform").submit();
		
                    //sendCallForm();
                
            },
            'Отмена': function() {
                $(this).dialog('close');
            }
        },
        close: function() {
            //obligFields.val('').removeClass('ui-state-error');
           // obligFields.removeClass('ui-state-error');
        }
        });



});
// - CALL DIALOG SCRIPT
