/**
* Sticky Notes pastebin
* @ver 0.2
* @license BSD License - www.opensource.org/licenses/bsd-license.php
*
* Copyright (c) 2011 Sayak Banerjee <sayakb@kde.org>
* All rights reserved. Do not remove this copyright notice.
*/

var IsIe = (navigator.appName.indexOf("Microsoft") >= 0) ? true : false;
var privateChecked = false, captured = false;

// Startup function
$(document).ready(function() {
    var skinPath = $('#skin_path').html();

    // Disable auto complete
    $('#paste_form').attr('autocomplete', 'off');

    // Yea, we have JS \o/
    $('#js_switch').attr('href', '');

    // Show hand for button
    $('.button').mouseover(function() {
        this.style.cursor = 'pointer';
    });

    // Remove dotted lines around links
    $('a').click(function() {
        this.blur();
    });

    // Remove dotted line for drop menus
    $('select').change(function() {
        this.blur();
    });

    // Check if private box is checked
    if ($('#paste_private').is(':checked'))
    {
        privateChecked = true;
    }
    else
    {
        privateChecked = false;
    }

    $('#paste_private').click(function() {
        if ($(this).is(':checked'))
        {
            privateChecked = true;
        }
        else
        {
            privateChecked = false;
        }
    });

    // Update private checkbox if password is entered
    setInterval(function() {
        if ($('#paste_password').val() != '') {
            $('#paste_private').attr('checked', true);
            captured = true;
        }
        else if (captured && $('#paste_password').val() == '') {
            $('#paste_private').attr('checked', privateChecked);
            captured = false;
        }
    }, 100);
    
    // Fetch author and language values from cookies
    var author = $.cookie('stickynotes_author');
    var language = $.cookie('stickynotes_language');
    var index = -1;

    if (author != null) {
        $('#paste_user').val(author);
    }

    for (i = 1; i <= 10; i++) {
        var $option = $('#paste_lang option:nth-child(' + i.toString() + ')');
        
        if ($option.attr('value') == language) {
            index = i - 1;
        }
    }

    if (language != null && index < 0) {
        $('#paste_lang').val(language);
    } else if (language != null) {
        $('#paste_lang').get(0).selectedIndex = index;
    }
    
    // Insert tab in the code box
    $('#paste_data').keydown(function (e) {      
        if (e.keyCode == 9) {
            var myValue = "\t";
            var startPos = this.selectionStart;
            var endPos = this.selectionEnd;
            var scrollTop = this.scrollTop;
            this.value = this.value.substring(0, startPos) + myValue + this.value.substring(endPos,this.value.length);
            this.focus();
            this.selectionStart = startPos + myValue.length;
            this.selectionEnd = startPos + myValue.length;
            this.scrollTop = scrollTop;

            e.preventDefault();
        }
    });

    // Alias textbox functions
    $('#paste_user')
        .click(function() {
            $(this).focus();
            $(this).select();
        })
        .focusout(function() {
            var defaultUser = $('#paste_user_default').html();
            
            if ($(this).val().length == 0) {
                $(this).val(defaultUser);
            }
        });
});
@@ -3021,16 +3021,76 @@
 nctions%0A
+    var defaultUser = $('#paste_user_default').html();%0A    %0A
     $('#
@@ -3142,24 +3142,28 @@
         
+if (
 $(this).
 focus();
@@ -3154,25 +3154,42 @@
 $(this).
-focus();%0A
+val() == defaultUser) %7B%0A  
         
@@ -3192,24 +3192,26 @@
         
+  
 $(this).
 select()
@@ -3206,17 +3206,30 @@
 is).
-select();
+val('');%0A            %7D
 %0A   
@@ -3270,72 +3270,8 @@
 () %7B
-%0A            var defaultUser = $('#paste_user_default').html();%0A
     

Use a different click textbox approach