function	mail_listing_prev() {
	mail_listing(parseInt(document.LISTING.from.value) - 10) ;
}
function	mail_listing_next() {
	mail_listing(parseInt(document.LISTING.from.value) + 10) ;
}
function	mail_listing(from) {
	try	{
		var	url			=	top.location.href.split('?') ;
		var	last_slash	=	url[0].lastIndexOf('/') ;
		var	request		=	url[0].substr(0,last_slash) ;
		var	uid			=	url[0].substring(last_slash + 1,url[0].length) ;
		$.ajax({
			type		:	"POST",
			url			:	request ,
			data		:	{
							cmd		:	'listing',
							from	:	from,
							focus	:	uid
							},
			success		:	function(x) {
				var	r		=	eval('(' + x + ')') ;
				if	(r['opcode'] == 1)	{
					var	html	= '' ;
					var	pages	=	((r['total'] % 10) > 0)	? Math.round(r['total'] / 10) + 1 : Math.round(r['total'] / 10) ;
					var	p		=	Math.round(r['from'] / 10) + 1 ;
					document.LISTING.from.value	=	r['from'] ;
					for	(var i in r['list'])	{
						html	+=	(r['list'][i]['UID'] == uid)
								?	'<li class="focus"><A HREF="' + request + ' / ' + r['list'][i]['UID'] + '">' + r['list'][i]['TITLE'] + '</a></li>'
								:	'<li><a href="' + request + '/' + r['list'][i]['UID'] + '">' + r['list'][i]['TITLE'] + '</a></li>' ;
					}
					$('table[title=controller] td[title=page]').html(p + '/' + pages) ;
					var	prev_disabled	=	(p == 1)	? true : false ;
					var	next_disabled	=	(p == pages)? true : false ;
					$('table[title=controller] td[title=prev] button').attr('disabled',prev_disabled) ;
					$('table[title=controller] td[title=next] button').attr('disabled',next_disabled) ;
					$('ol#mail_listing').find('li').remove().end().attr('start',parseInt(r['from'] + 1)).append(html) ;
				}
			}
		}) ;
	} catch(e) {
		alert(e.message) ;
	}
}
function	pulldown(y) {
	$('DIV#mail_listing_panel').css('top',y + 'px') ;
}
function	pulldown_r(y) {
	$('DIV#right_float_panel').css('top',y + 'px') ;
}
function	pulldown_location(){
	try	{
		var	pos		=	$('#mail_listing_panel').offset() ;
		var	pos_r	=	$('#right_float_panel').offset() ;
		mail_listing_panel_top	=	pos.top ;
		right_panel_top			=	pos_r.top ;
	} catch(e){}
}

var	mail_listing_panel_top	=	0 ;
var	right_panel_top			=	0 ;
$(document).ready(function(){
	setTimeout("pulldown_location()",3000) ;
	mail_listing('') ;
});
$(window).scroll(function(){
	if	(mail_listing_panel_top > 0) {
		var	offset_g	=	document.documentElement.scrollTop	|| document.body.scrollTop ;
		var	offset_l	=	(offset_g > mail_listing_panel_top) ? offset_g - mail_listing_panel_top + 7 : 0 ;
		var	offset_r	=	(offset_g > right_panel_top)		? offset_g - right_panel_top + 7		: 0 ;
/*
		if	(offset_g == 0)	{
			var	pos		=	$('#mail_listing_panel').offset() ;
			var	pos_r	=	$('#right_float_panel').offset() ;
			mail_listing_panel_top	=	pos.top ;
			right_panel_top			=	pos_r.top ;
		}
*/
		setTimeout("pulldown(" + offset_l + ")",333) ;
		setTimeout("pulldown_r(" + offset_r + ")",333) ;
		setTimeout("yahoo_fixed(" + offset_g + ")",250) ;
	}
}) ;
