// Initialization
$.scrollText = {
	init: function() {
		for (module in $.scrollText) {
			if ($.scrollText[module].init)
				$.scrollText[module].init();
		}
	}
};

$(document).ready($.scrollText.init);

$.scrollText.fn = {
	init: function() {
		var scroll = $("#scrollText").append('<div class="scroll"><div class="up"></div><div class="down"></div></div>');
		$("#scrollText div.up").css({opacity:0},0);
		$("#scrollText div.down").css({opacity:0},0);
		$("#scrollText div.up").delay(2000).animate({opacity:1},1000);
		$("#scrollText div.up").bind('click', this.scrollUp)
		.bind('mouseover', this.enter)
		.bind('mouseout', this.exit)
		.each(this.preload);
		$("#scrollText div.down").delay(2000).animate({opacity:1},1000);
		$("#scrollText div.down").bind('click', this.scrollDown)
		.bind('mouseover', this.enter)
		.bind('mouseout', this.exit)
		.each(this.preload);
	},
	preload: function() {
		$(this).animate({opacity:0.6},500);
//		this.offset = pos.top+70;
	},
	scrollUp: function() {
		var pos = $("#scrollText .box").position();
		var offset = pos.top+70;
		offset=(0<offset)?0:offset;
		$('#scrollText .box').animate({top:offset}, 500);
		return false;
	},
	scrollDown: function() {
		var pos = $("#scrollText .box").position();
		var offset = pos.top-70;
		var max = $("#scrollText").outerHeight({margin: true}) - $("#scrollText .box").outerHeight({margin: true})-117;
//		console.log(offset+":"+max);
		offset=(offset<max)?pos.top:offset;
		$('#scrollText .box').animate({top:offset}, 500);
		return false;
	},
	enter: function() {
		$(this).animate({opacity:1},500);
	},
	exit: function() {
		$(this).animate({opacity:0.6},500);
	}
};

//EOF
