$.fn.extend({
	initLoginBox: function(){
		var auth = getAuth();
		var $a_block  = $('.authorized_content'    , this);
		var $na_block = $('.not_authorized_content', this);
		var auth_block_state = $a_block.filter(':visible').length>0;
		var server_update_needed = (auth_block_state && !auth) || (!auth_block_state && auth && auth.id);
		//console.log(server_update_needed);
		if(server_update_needed){
			if(auth){
				auth.name = $.trim(auth.f_name+' '+auth.l_name);
				$('.user_name_box', this).text(auth.name);
				$na_block.hide();
				$a_block.show();
				server_update_needed = true;
			}else{
				$na_block.show();
				$a_block.hide();
			}
			$.post('/login?update_status', auth)
		}
	}
});

$(document).ready(function(){
  $('input').each(function(){
    if ($(this).attr('defvalue')) {
      $(this).focus(function(){
        if ($(this).attr('value') == $(this).attr('defvalue')) {
          $(this).attr('value','');
        }
      })
      .blur(function(){
        if ($(this).attr('value') == '') {
          $(this).attr('value',$(this).attr('defvalue'));
        }
      });
    }
  })
})


