$(document).ready(function(){

    $('.formrow input').focusin(function(){
        $(this).parents('.formrow').find('.formrow_balloon').show('fast');
        
    });
    
    $('.formrow input').focusout(function(){
        $(this).parents('.formrow').find('.formrow_balloon').hide();
    });

    $('#generateOLD').click(function() {
        
        var url = CI.base_url + "linkedin/generate";
        var data = $("#generateform").serialize();
        
        $('#result textarea').text('');
        $('#loader').show();
        
        $.ajax({
          type: 'POST',
          url: url,
          data: data,
          success: function(res) {
            
            var text = res.recommendation;
            
            $('#resultplaceholder').hide();
            $('#result textarea').show();
            $('#result textarea').text(text);
            $('#result textarea').focus().trigger('end').trigger('keydown');
            $('#loader').hide();
          },
          dataType: 'json'
        });
        return false;
    });
    
    $('#result textarea').autoResize({
        // On resize:
        onResize : function() {
            $(this).css({opacity:0.9});
        },
        // After resize:
        animateCallback : function() {
            $(this).css({opacity:1});
        },
        // Quite slow animation:
        animateDuration : 200,
        // More extra space:
        extraSpace : 40
    });
    
    $('.item_row').hover( function(){
         $(this).addClass('hover');
    },
    function(){
         $(this).removeClass('hover');
    });
    
    $('.copy').click( function() { 
        var text = $(this).parents('.item_row').find('.item_content').text();
        /*
        $.zclip({
            path:'js/copy/ZeroClipboard.swf',
            copy:text
        });*/
        alert('Recommendation was copied to your clipboard. ' + text);
    } );

});
  
