function LSF_init( id ) {

    var LSF = $('#lsForm');
    if ( $('#lsForm').length ) {

        $('#'+id).click(function(){ 
            var LSF = $('#lsForm'); 
            if ( $('#lsForm').css("display") == "none") {

                xy = $(this).offset(); 
                LSF_show( xy ); 
            }
            else {

            LSF_hide();
            }
            return false; 
        });

        LSF.pngFix();
        LSF.attr('change_value', '0');
        if ( $.browser == 'opera' ) {

            $('#lsForm input').keypress(function(event){ 
                if (event.keyCode == 13) { $('#lsForm form').get(0).submit(); }
                if (event.keyCode == 27) {

                    LSF_hide();
                }
                else {

                    $(this).attr('oldvalue', $(this).val()); 
                }
            });
            
        }
        else {

            $('#lsForm input').keydown(function(event){ 
                if (event.keyCode == 13) { $('#lsForm form').get(0).submit(); }
                if (event.keyCode == 27) {

                    LSF_hide();
                }
                else {

                    $(this).attr('oldvalue', $(this).val()); 
                }
            });
        }
    /*
        $('#lsForm input').each(function(){ 
            if (this.value == 'undefined' || !this.value ) 
                this.value = ''; 
        });
    */
        $('#lsForm input').keyup(function(event){
            if (event.keyCode != 27) {

                LSF.attr('change_value', '1'); 
            }
        });

        $('#'+id).mouseover(function(){ 
            xy = $(this).offset(); 
            LSF_show( xy ); 
        });
        $('#'+id).mouseout(function(){
            setTimeout( "LSF_hideWoChange()", 5000); 
        });
        $('#lsForm img.close').click(function(){ 
            LSF_hide(); 
        });
        $('#lsForm img.accept').click(function(){ 

            $('#lsForm form').submit(); 
        });

        xy = $('#'+id).offset(); 
//        LSF_show( xy );
        $('#lsf_auth_login').inline_caption({
            txt:      'Login', 
            txtStyle: 'margin-left: 5px; color: #999999;',
            divtop: -18
        });
        $('#lsf_auth_password').inline_caption({
            txt:      'Password', 
            txtStyle: 'margin-left: 5px; color: #999999;',
            divtop: -18
        });
        LSF_hide();
    }
}

function LSF_hideWoChange() {

    if ( $('#lsForm').attr('change_value') == '0' ) LSF_hide();
}

function LSF_hide() {

    var LSF = $('#lsForm');
    LSF.attr('change_value', '0');
    LSF.hide('slow');
}

function LSF_show( xy ) {

    var LSF = $('#lsForm');
    if ( LSF.attr('change_value') == '1' ) return;

    LSF.css('left', (xy.left-LSF.width()-5) );
    LSF.css('top', xy.top+20);

    LSF.show();

    $('#lsForm input:eq(0)').focus();
}
