var Ad = null;
var currentIndex = null;
/**
* 広告初期化処理
*/
function AdInit(AdId) {
    // 複数の広告を含む広告枠
    var obj = $(AdId);
    
    if (obj) {
        // クラス名 ads で広告オブジェクトを検索
        Ad = obj.getElementsByClassName("ads");
        
        // 最初のバナー以外を隠す
        for (i=1; i<Ad.length; i++) {
            Ad[i].hide();
        }
        currentIndex = 0;
    }
    
    // 広告枠を表示（非表示クラスを解除）
    obj.className = "";
}
/**
* ローテーション初期化処理
*/
function rotationInit() {
    setInterval(rotation, 7000);
}
/**
* ローテーション
*/
function rotation() {
    // 表示中の広告を隠す
    Ad[currentIndex].hide();
    
    currentIndex++;
    if (currentIndex >= Ad.length) {
        currentIndex = 0;
    }
    
    // 次の広告を表示
    Ad[currentIndex].show();
}
/**
* ページ初期化処理
*/
function pageInit() {
    AdInit("Ad");
    rotationInit();
}
Event.observe(window, "load", pageInit);
