
function albumcycler(_outer_name)
{
	this.items = [];
	this.imgs = [];
	this.links_1 = [];
	this.links_2 = [];
	this.artists = [];
	this.rates = [];
	this.visible_length = 0;
	for(var i = 0, j = 255; i < j; i++)
	{
		var tag;
		if(tag = document.getElementById('f_album_img_' + i))
		{
			this.imgs[this.visible_length] = tag;
			this.links_1[this.visible_length] = document.getElementById('f_album_link_1_' + i);
			this.links_2[this.visible_length] = document.getElementById('f_album_link_2_' + i);
			this.artists[this.visible_length] = document.getElementById('f_artist_' + i);
			this.rates[this.visible_length] = document.getElementById('f_rate_' + i);
			this.visible_length++;
		}
		else
			break;
	}
	
	this.outer_name = _outer_name;
	this.index = this.visible_length;
	this.items_length = 0;
	this.timer_id = false;
	
	this.addalbum = function(item)
	{
		this.items[this.items_length] = item;
		this.items_length++;
		
		return true;
	}
	
	this.run = function()
	{
		if(this.timer_id == false)
			this.timer_id = setInterval("" + this.outer_name + '.shift()', 5000);
	}
	
	this.stop = function()
	{
		if(this.timer_id != false)
			clearInterval(this.timer_id);
		this.timer_id = false;
	}
	
	this.shift = function()
	{
		for(var i = 0; i < this.visible_length; i++)
		{
			this.imgs[i].src = this.items[this.index].img;
			this.imgs[i].setAttribute('alt', this.items[this.index].name);
			this.links_1[i].setAttribute('href', this.items[this.index].url);
			this.links_2[i].setAttribute('href', this.items[this.index].url);
			this.links_2[i].innerHTML = this.items[this.index].name;
			this.artists[i].innerHTML = this.items[this.index].artist;
			this.rates[i].innerHTML = this.items[this.index].rate;
			
			this.index++;
			if(this.index >= this.items_length)
				this.index = 0;
		}
		
		return true;
	}
	
	return this;
}

function albumitem(name, url, img, artist, rate)
{
	this.name = name;
	this.url = url;
	this.img = img;
	this.artist = artist;
	this.rate = rate;
	
	return this;
}


var ac = null;
function cycle_start()
{
	ac = new albumcycler('ac');
			ac.addalbum(new albumitem('Mehfilan', '/portal/music/albums/20445/', '/files/music/2009/07/mehfilan-VeerDavinder-1_1__thumb.jpg', 'Veer Davinder', '<strong title="0 Ratings"><img class="abs" src="/images/star_wh.gif"/><img class="abs" src="/images/star_wh.gif"/><img class="abs" src="/images/star_wh.gif"/><img class="abs" src="/images/star_wh.gif"/><img class="abs" src="/images/star_wh.gif"/></strong>'));
		
	ac.run();
}
setTimeout('cycle_start()', 2000);
