 $(function (){ 
    $('.comment:odd').css('background','#f7f7f7');
    /* Отправка формы */
    $('#sendform button').click(function(){
        $('#ajaxComment .loader, #ajaxComment .done').hide();
         $('#ajaxComment .loader').show();
        $('#ajaxResponse').html('&nbsp;');
        
        $.getJSON(
                  "/ajax/processor.php",
                  {senddata: $('#sendform').serializeArray()},
                  function(data){
                     //   data = jQuery.parseJSON(data);
                        $('#cap4a').load('/plugins/cap4a/cap4a.php');
                        $('#ajaxComment .loader').hide();
                        if(data.error){
                            var errors  = data.error; 
                            $('#ajaxResponse').html('<ul class = "corner5">'+errors+'</ul>');
                        }
                        
                        if(data.suss){
                            $('#commentContiener').prepend(data.suss);
                            $('#ajaxComment .done').show();
                            setTimeout("$('#ajaxComment .done').fadeOut()", 3000);
                        }
                        
                    }
                  );
        return false;        
    });

    
    $('input, textarea').focusin(function(){
       $(this).parent().addClass('field-active');
    		    if (this.value == this.defaultValue){ 
    		    	this.value = '';
				}
				if(this.value != this.defaultValue){
	    			this.select();
	    		}
       
    });
    
    $('input, textarea').focusout(function(){
       $(this).parent().removeClass('field-active');
    		    if ($.trim(this.value) == ''){
			    	this.value = (this.defaultValue ? this.defaultValue : '');
				}
        
    });
    
    $('select').focusin(function(){
       $(this).parent().addClass('field-active');
    });
    
    $('select').focusout(function(){
       $(this).parent().removeClass('field-active');
    });
    $('select').change(function(){
       $(this).parent().removeClass('field-active');
    });
    
      $('#select_type select').change(function(){
       
       var select_type = $(this).val();
       if(!select_type) return false;
       
       $('#select_start, #select_finish').hide();
       $('#select_'+select_type).show();
    });
    
    $('#select_start select, #select_finish select').change(function(){
        var select_doc = $(this).val();
        if(!select_doc) return false;
        $('#'+select_doc).slideDown('1000').siblings().slideUp('500');
    })
    
})
