﻿banners = new Array();

function LoadBanner(bannerObj){
    bObj = getObjectById(bannerObj);
    if(bObj!=null){     
        bObj.src = banners[BannerIndex].image;
        bObj.alt = banners[BannerIndex].title;
    }
}

function CreateBanner(link, title, image){
    var banner = new Object();
    banner.link = link;
    banner.title = title;
    banner.image = image;
    banners.push(banner);
}

function GetIndex(lastIndex){
    var Index = 0;
    do{
        Index = Math.floor(Math.random()*banners.length)
    }
    while(lastIndex==Index);
    return Index;
}

function BannerLink(bannerObj){
    bObj = getObjectById(bannerObj);
    if(bObj!=null){
        bObj.src = banners[BannerIndex].image;
        if(top.frames["mainframe"]!=null){
        
            top.frames["mainframe"].location.href=banners[BannerIndex].link;      
            BannerIndex = GetIndex(BannerIndex);
            LoadBanner(bannerObj);
        }
    }
}
