function Collages(holder_id, type)
{
	this.holder_id = holder_id;
	this.url = "";
	this.type = type;
	this.images = {};
	this.like = {};

	this.construct = function()
	{
		var reg = new RegExp("(http://[^/]*)(.*)");
		var data = document.URL;
		if(data.search(reg) != -1)
		this.url = RegExp.$2;
	}

	this.add = function(img, url, like)
	{
		this.like[url] = (like)? 1: 0;

		var cnt = 0;
		if(this.images[url] == undefined)
			this.images[url] = [];
		else
			cnt = this.images[url].length;

		this.images[url][cnt] = img;
	}

	this.init = function()
	{
		var img_arr = [];

		if(this.images[this.url] != undefined)
			img_arr = this.images[this.url];
		else
		for(var url in this.images)
		{
			var i = this.url.indexOf(url);
			if(i == 0)
				if(this.like[url])
					img_arr = this.images[url];
		}

		if(img_arr.length > 1)
			this.show_rnd(img_arr);
		else if(img_arr.length == 1)
			this.show(img_arr[0]);
	}

	this.show = function(img)
	{
		var holder = this.get_holder();

		if(holder != undefined)
		{
			switch(this.type)
			{
				case "text":
				holder.innerHTML = img;
				break;
			}
		}
	}

	this.show_rnd = function(img_arr)
	{
		var i = this.get_rnd(img_arr.length);
		i = (i > 0)? i-1: 0;
		this.show(img_arr[i]);
	}

	this.get_rnd = function(picnum)
	{
		var ms = 0;
		var sec = new Date();

		ms = sec.getMilliseconds();
		rnum=Math.round(ms*Math.random()/10);

		if(rnum>picnum)
	  	{
			do
			rnum=rnum-picnum;
			while (rnum>picnum)
		}
		return rnum
	}

	this.get_holder = function()
	{
		return document.getElementById(this.holder_id);
	}

	this.construct();
}
