$(document).ready(function(){
    var height = outerHeight;
    $('.content_block').css('minHeight',height-340);
    $('.dop_info a').click(function(eventObject){
        eventObject.preventDefault();
     var title = $(this).attr('title');
     $('.' + title).dialog({
         height: 475,
         width: 500,
         closeText: "Закрыть",
         modal: true,
         show: "slide",
         hide: "slide",
         positio: "center",
         draggable: false
     });
    }); 

    $('.man_practices').click(function(eventObject){
        eventObject.preventDefault();
        var title = $(this).attr('title');
            $('.' + title).dialog({
                height: 475,
                width: 500,
                 closeText: "Закрыть",
                 modal: true,
                 show: "slide",
                 hide: "slide",
                 draggable: false
        });        
    });
    
    $('.post_man_title a').click(function(){
        var title = $(this).attr('title');
            $('.' + title).dialog({
                height: 475,
                width: 500,
                 closeText: "Закрыть",
                 modal: true,
                 show: "slide",
                 hide: "slide",
                 draggable: false
        });        
    });
    
    $('.ask_question').click(function(){
        var cls = $(this).attr('title');
            $('.' + cls).dialog({
                 height: 600,
                 width: 500,
                 closeText: "Закрыть",
                 modal: true,
                 show: "slide",
                 hide: "slide",
                 draggable: false,
                 buttons: { 
                    "Отправить" : function() {
                        var name = $('#name').val();
                        var email = $('#email').val();
                        var code_country = $('#code_country').val();
                        var code_city = $('#code_city').val();                                                
                        var phone = $('#phone').val();
                        var organisation = $('#organisation').val();
                        var question = $('#question').val();
                        $.ajax({ 
                            type: "post", 
                            url: "/wp-includes/email.php", 
                            data: {name:name,email:email,code_country:code_country,code_city:code_city,phone:phone,organisation:organisation,question:question},
                            cache: false,
                            error:function(){ $("#dialog").dialog('close'); alert('Неизвестная ошибка');}, 
                            success : function(data){alert(data);} 
                            }); 
                        } 
                    }       
            });        
    });

    $("#submit_question").click(function(){
        var name = $('#name3').val();
        var email = $('#email3').val();
        var code_country = $('#code_country3').val();
        var code_city = $('#code_city3').val();                                                
        var phone = $('#phone3').val();
        var organisation = $('#organisation3').val();
        var question = $('#question3').val();
            $.ajax({ 
                type: "post", 
                url: "/wp-includes/email.php", 
                data: {name:name,email:email,code_country:code_country,code_city:code_city,phone:phone,organisation:organisation,question:question},
                cache: false,
                error:function(){ $("#dialog").dialog('close'); alert('Неизвестная ошибка');}, 
                success : function(data){alert(data);} 
            }); 
    });
    $('#return_call').click(function(){
        var cls = $(this).attr('id');
            $('.' + cls).dialog({
                 height: 600,
                 width: 500,
                 closeText: "Закрыть",
                 modal: true,
                 show: "slide",
                 hide: "slide",
                 draggable: false,
                 buttons: { 
                    "Отправить" : function() {
                        var name = $('#name2').val();
                        var email = $('#email2').val();
                        var code_country = $('#code_country2').val();
                        var code_city = $('#code_city2').val();                                                
                        var phone = $('#phone2').val();
                        var organisation = $('#organisation2').val();
                        $.ajax({ 
                            type: "post", 
                            url: "/wp-includes/call.php", 
                            data: {name:name,email:email,code_country:code_country,code_city:code_city,phone:phone,organisation:organisation},
                            cache: false,
                            error:function(){ $("#dialog").dialog('close'); alert('Неизвестная ошибка');}, 
                            success : function(data){ alert(data);} 
                            }); 
                        } 
                    }       
            });         
    });
    
 });
