
// <body onload="HTMLRotation();"> の記述の必要なし
window.onload=HTMLRotation;

function HTMLRotation(){
	// バナーの数設定
	var banner_num = 7;

	var cid = GetCookie("CID");

	if(cid == ""){ cid = 1; }
	var selectnum = cid % banner_num;
	if(selectnum == 0){ selectnum = banner_num; }

	var htmls = new Array();

	for(var i = 1; i <= banner_num; i++){
		htmls[i] = document.getElementById(i).innerHTML;
	}

	for(j = selectnum, k = 1; j <= banner_num + selectnum, k <= banner_num; j++, k++){
		var idname_mod = j;

		if(j > banner_num){ idname_mod = j - banner_num; }

		document.getElementById(k).innerHTML = htmls[idname_mod];
	}

	SetCookie("CID", ++cid);
}

function GetCookie(key){
	var tmp = document.cookie + ";";
	var index1 = tmp.indexOf(key, 0);
	if(index1 != -1){
		tmp = tmp.substring(index1,tmp.length);
		var index2 = tmp.indexOf("=",0) + 1;
		var index3 = tmp.indexOf(";",index2);
		return(unescape(tmp.substring(index2,index3)));
	}
	return("");
}

function SetCookie(key, val){
	document.cookie = key + "=" + escape(val) + ";expires=Fri, 31-Dec-2030 23:59:59;";
}

