var gj_err, gj_season;
function game_jump(gid, dir, season) {
    gj_season = season;
    if (dir == 'next') {
	gj_err = 'この試合が最新です';
    }
    if (dir == 'prev') {
	gj_err = 'これ以前の試合はありません';
    }
    
    var url = "http://"+location.host+"/game_jump.php";
    var pars = "gid="+gid+"&d="+dir;
    var myAjax = new Ajax.Request(
				  url, 
	{
	    method: 'get', 
	    parameters: pars, 
	    onComplete: redirect
	});
}

function redirect(req) {
    if (req.responseText == 0) {
	alert(gj_err);
    }
    else {
	var url = req.responseText;
	var t = url.split('/');
	if (gj_season != t[2]) {
	    alert('ここから'+t[2]+'シーズンの記録です');
	}
	location.href = url;
    }
}

function jump_schedule(season, nurl, ourl) {
    var d = new Date();
    var y = d.getYear();
    if (y < 100) y+= 2000;
    if (y < 2000) y+= 1900;
    if (y == season) {
	location.href = nurl;
	return;
    }
    if ((y-1) > season) {
	location.href = ourl;
	return;
    }
    // y == season+1
    if (d.getMonth() > 0) {
	location.href = ourl;
	return;
    }
    if (d.getDate() > 15) {
	location.href = ourl;
	return;
    }
    location.href = nurl;
}

