

// import
// ----------------------------------------------------------------------- //

$(function(){

	var timekey = (new Date()).getTime();

	var important_data_file = "info/important.dat?" + timekey;
	$("#importantArea").load(important_data_file);

	var pickup_data_file = "news/pickup.dat?" + timekey;
	$("#pickupArea").load(pickup_data_file);

	var whatsnew_data_file = "news/whatsnew.dat?" + timekey;
	$("#whatsnewArea").load(whatsnew_data_file);

});



// pickup
// ----------------------------------------------------------------------- //

$(function(){

var all_line = new Number(0);
var current_line = new Number(0);

$(".down a").addClass("off");

move();

jQuery.easing.def = "easeOutBack";


function move(str) {
	all_line1 = $("ul li.pickup .box").size();
	all_line = parseInt(all_line1 / 3) + ((all_line1 % 3) ? 1 : 0);
	all_line2 = (all_line1 % 3) ? 1 : 0;

	if ((str == "up") && (current_line < all_line - 3)) { current_line = current_line + 1; $(".down a").removeClass("off"); up(); }
	else if ((str == "down") && (current_line > 0)) { current_line = current_line - 1; $(".up a").removeClass("off"); down(); }

	$("#pickupStatus").html(current_line + "/" + all_line + "(" + all_line2 + ")");

	if (current_line <= 0) { $(".down a").addClass("off"); }
	else if (current_line >= all_line - 3) { $(".up a").addClass("off"); }

	return current_line;
}

	$(".up a").click(function(){
		move("up");
	});
	$(".down a").click(function(){
		move("down");
	});
	$(".reset a").click(function(){
		reset();
	});

	function up(){
		$("#pickupArea ul").animate({"marginTop":"-=97px"}, {duration:500});
	}
	function down(){
		$("#pickupArea ul").animate({"marginTop":"+=97px"}, {duration:500});
	}


function reset() {
		d = current_line * 97;
		d = "+=" + d + "px";
		$("#pickupArea ul").animate({"marginTop":d}, {duration:500});
		current_line = 0;
}

function goReset() {
		reset();
//		console.log("test");
}


//$.timer(20000, function (timer) {
//	move("up");
//	console.log(current_line + "-" + all_line);
//	if (current_line >= all_line - 3) {
//		$.timer(3000, function (timer2) {
//		console.log("test2");
//			timer2.stop();
//			goReset();
//		});
//		timerID = setTimeout(goReset(), 3000);
//		clearTimeout(timerID);
//	}
//    timer.stop();
//});


});

