(function($){
$.blog = {
write: function($o,$cb) {
	$o.func = 'write';
	$.post($.blog.s.cgi, $o, function($j){
		var _o = JSON.parse($j);
		if (_o.status == 'ok') $cb(_o.id);
		else alert($.Trans.ESystemError);
		return false;
	});
	return false;
},
s: { cgi: '/--/p2' }
};

$.fn.permselect = function($op) {
	var _opts = $.extend({ 
		pub: $.Trans.Public, fri: $.Trans.Friends, pri: $.Trans.Private,
		type: 0, select: 1
	}, $op);

	return this.each(function() {
		var _this = $(this);
		_this.empty().addClass('perm');
		
		var _list 
			= _opts.type == 1 ? ['fri'] 
			: _opts.type == 2 ? ['pub','fri']
			: ['pub','fri','pri'];

		$.each(_list,function($i){
			$('<img title="'+_opts[this]+'" alt="'+this+'" src="/=i_'+this+'.gif">')
				.appendTo(_this);
		});
		_this.find('img').click(function(){
			if (_this.data('select'))
				_this.find('img[alt="'+_this.data('select')+'"]')
					.css('backgroundColor','transparent');

			$(this).css('backgroundColor',$.mau.s0);
			_this.data('select',$(this).attr('alt'));
		});
		_this.find('img:nth-child('+_opts.select+')').trigger('click');
	});
};
})(jQuery);
