function Banner(update_time, width, height, alt_text, start_flag, random_flag, id)
{
	this.BannerObject = "bannerAd" + (Banner.count++);
	eval(this.BannerObject + "=this");
	
	if (!update_time) 
		this.update_time = 5000;
	else 
		this.update_time = update_time*1000;
		
	if (!width) 
		this.width = 460; 
	else 
		this.width = width;
		
	if (!height) 
		this.height = 68; 
	else 
		this.height = height;
		
	if (random_flag == null) 
		this.random_flag = 1; 
	else 
		this.random_flag = random_flag;
		
	this.alt_text = alt_text;
	this.ads = [];
	
    this.id = id;
    
	if (start_flag) 
		this.ad_count = start_flag-1; 
	else start_flag = null;
	
	this.size = 0;

	
	
	this.Ad = function(src, href, profile_href, target, mouseover, target_b) 
	{
		var tempImage = new Image();
		
		tempImage.src = src;
		this.ads[this.size] = new Object();
		var ad = this.ads[this.size];
		ad.src = src;
		
		if (typeof(target) == "undefined" || target == null) 
			ad.target = "_self"; 
		else 
			ad.target = target;
            
 		if (typeof(target_b) == "undefined" || target_b == null) 
			ad.target_b = "_self"; 
		else 
			ad.target_b = target_b;           
            
			
		ad.href = href;
        ad.profile_href = profile_href;
		ad.mouseover = mouseover;
		this.size++;
	}

	this.link = function()
	{
		var	ad = this.ads[this.ad_count];
		
		if (ad.target == "_self")
		{
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new")
		{
			open(ad.href,this.BannerObject + "Win");
		}
		else 
            top.frames[ad.target].location.href = ad.href;
	}
    
	this.profilelink = function()
	{
		var	ad = this.ads[this.ad_count];
		
		if (ad.target_b == "_self")
		{
			location.href = ad.profile_href;
		}
		else if (ad.target_b == "_blank" || ad.target_b == "_new")
		{
			open(ad.profile_href,this.BannerObject + "Win");
		}
		else 
            top.frames[ad.target_b].location.href = ad.profile_href;
	}

	this.showStatus = function()
	{
		var ad = this.ads[this.ad_count];
		
		if (ad.mouseover) 
			status = ad.mouseover;
		else 
			status = ad.href;
	}

	this.random_flagAd = function()
	{
		var n;
		
		do 
		{ 
			n = Math.floor(Math.random_flag() * (this.size)); 
		} 
		while(n == this.ad_count);
		
		this.ad_count = n;
	}


    this.output_image_ad = function()
    {
		var tempCode = "";
        
        //tempCode = '<a href="javascript:'+this.BannerObject+'.link();"><span id="'+this.id+'">&nbnsp;</span></a>';
        
		if (this.size > 1)
		{
			if (this.ad_count == null) 
				this.randomAd();
			if (this.ad_count >= this.size) 
				this.ad_count = this.size - 1;
				
				
			tempCode =	'<a href="javascript:'+this.BannerObject+'.link();"><img src="' + this.ads[this.ad_count].src + '" name="' + this.BannerObject + 'Img"></a>';

            
            
            document.write(tempCode);
			
			this.nextAd();
			
		} 
		else document.write("Error: two banners must be defined for the script to work.");
    }
    
    
    this.output_link = function()
    {
        tempCode = '<a href="javascript:'+this.BannerObject+'.link();"><span id="'+this.id+'">&nbnsp;</span></a>';
        document.write(tempCode);
    }
    this.output_profile = function()
    {
        tempCode =  '<a href="javascript:'+this.BannerObject+'.profilelink();">View profile</a>';
        document.write(tempCode);
    }
	this.output_image = function()
	{
		var tempCode = "";
		if (this.size > 1)
		{
			if (this.ad_count == null) 
				this.randomAd();
			if (this.ad_count >= this.size) 
				this.ad_count = this.size - 1;
				
				



			tempCode =	'<img src="' + this.ads[this.ad_count].src + '" name="' + this.BannerObject + 'Img">';

            
            
            document.write(tempCode);
			
			this.nextAd();
			
		} 
		else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newAd = function()
	{
		if (!this.random_flag)
		{	
			this.ad_count++;
			
			if (this.ad_count >= this.size)
				this.ad_count = 0;
		}
		else 
		{
			this.random_flagAd();
		}
		this.nextAd();
	}

	this.nextAd = function()
	{
		document.images[this.BannerObject+ 'Img'].src = this.ads[this.ad_count].src;
        document.getElementById(this.id).innerHTML = this.ads[this.ad_count].mouseover;
		setTimeout(this.BannerObject+'.newAd()',this.update_time)
	}
}
Banner.count = 0;
