              
 
 function FeedBackForm(type)
        {  
              
              var type = type;
                //call
                //order
                                                  
             var blWin = new blackWin('feed_form');        
                                                 
             if(type == 'call')
             {
               formId = 'feed_call';
             }                    
             else
             {
               formId = 'feed_order'
             }                
                                                 
               //создаём форму
             $("#feed_form").formation({action: '/ajax/ajax.php?act=feedform', isAjax : true, remove: '#sm_black_window, #sm_black_window_cont', id: formId});
             
               //конфигурируем форму
             $.formation.addInput({type:"hidden",labelValue:"" ,name: type});  
             $.formation.addInput({type:"text",labelValue:"Ф.И.О. *:",required:true, name: 'fio'}); 
              
             if(type == 'call')
             {    
                 $.formation.addInput({type:"text",labelValue:"Телефон *:  <em>+7</em>", id:'phone_1',name: 'phone1'}); 
                 $.formation.addInput({type:"text", name: 'phone2',  id:'phone_2'});                                                               
                 $.formation.addInput({type:"text",labelValue:"E-mail:", validation:'email', name: 'email'}); 
                 $.formation.addTextarea({type:"text",labelValue:"Текст сообщения:", name: 'service'}); 
                 var button = $.formation.addButton({value: "Перезвоните мне"});  
                              
             }
             else if(type == 'order')
             {
                 $.formation.addInput({type:"text",labelValue:"E-mail *:",required:true, name: 'email', validation:'email'});
                 $.formation.addInput({type:"text",labelValue:"Телефон: <em>+7</em>", id:'phone_1', name: 'phone1'}); 
                 $.formation.addInput({type:"text", name: 'phone2', id:'phone_2'});  
                 $.formation.addCheckboxes({"callme":""}, {labelValue:"Хотите, чтобы Вам перезвонили?", legend:'', name: 'callme', id: "call_checkbox"});
                 $.formation.addInput({type:"text",labelValue:"Город:", name: 'city'});
                 $.formation.addInput({type:"text",labelValue:"Учебное заведение:",name: 'scool'});
                 $.formation.addTextarea({type:"text",labelValue:"Дополнительная информация:", name: 'service'}); 
                 var button = $.formation.addButton({value: "Подать заявку"});   
             } 
             
               //дополнительная проверка
              $.formation.addPreSubmit(preSubmit ); 
         
               
             
             $.formation.setErrorMessages({
                                           blank:"Обязательное поле.",
                                           email: "Некорректный e-mail.",
                                           number: "Только числа."
                                           });    
                                 
                                           
                 button.click(function(){
          
         
         //удаляем пробелы перед обработкой
         
         $('#feed_form textarea, #feed_form input').each(function(){
         
             $(this).val(trim($(this).val() ) );
         
         });
          
          }); 
       
       if(type == 'order')
               {
                  var phoneLiNum = 3;
               }
               else
               {
                  var phoneLiNum = 2;   
                }
                //добавляем id для контейнера ошибок телефона
       $('#feed_form li:eq('+phoneLiNum+') .small:eq(0)').attr('id', 'feed_phone_err');  
               
            //custom проверка      
       function preSubmit(){     
            
            
                         
             //если телефон - необязательное поле и если заполнено хотя бы одно поле - остальные становятся обязательными
             //или если телефон - обязательно поле
            if( (type == 'order' && ($('#phone_1').val() != '' || $('#phone_2').val() != '' ) ) || type == 'call' )
            {      
            
               if( type == 'call' && $('#phone_1').val() == '' && $('#phone_2').val() == '' )
               {
                   $('#phone_1').attr('class', 'formation_input error');   
                   $('#phone_2').attr('class', 'formation_input error');
                   $('#feed_phone_err').attr('class', 'small error'); 
                   $('#feed_phone_err').text('Обязательное поле.');
                   return false;
               }     
               else if($('#phone_1').val() == '' || $('#phone_2').val() == '' )
                {           
                   $('#phone_1').attr('class', 'formation_input error');   
                   $('#phone_2').attr('class', 'formation_input error');
                   $('#feed_phone_err').attr('class', 'small error'); 
                   $('#feed_phone_err').text('Необходимо заполнить полностью.');
                   return false;
                }  
                else if(!(/^[0-9]*$/).test($('#phone_1').val() ) || !(/^[0-9]*$/).test($('#phone_2').val() ) || ($('#phone_1').val().length+$('#phone_2').val().length)!=10 ) //если неверно введён номер
                {                                     
                   $('#phone_1').attr('class', 'formation_input error');
                   $('#phone_2').attr('class', 'formation_input error');
                   $('#feed_phone_err').attr('class', 'small error'); 
                   $('#feed_phone_err').text('Введите только 10 цифр - кода города+номер телефона.'); 
                   return false;
                }
               
            }
            
                          
             $('#feed_phone_err').attr('class', 'small'); 
             $('#feed_phone_err').text('');       
             
             return true;
                                  
        };                                  
                                           
               //отображаем форму                           
             blWin.show();    
        
        }
