//
// Random Image Class
//
RandomImage = function()
{
	this.imgs = [];
	this.id = "";
	//
	this.onLoad(this, "replace");
}
RandomImage.prototype.setTarget = function(_id)
{
	this.id = _id;
}
RandomImage.prototype.add = function()
{
	this.len = arguments.length;
	for(var i=0,len=arguments.length; i<len; i++)
	{
		var a = arguments[i];
		if(typeof(a)=="string") this.imgs.push(a);
	}
}
RandomImage.prototype.onLoad = function(scope, func)
{
	Event.domReady.add(function(){ scope[func](); });
}
/*
RandomImage.prototype.onLoad = function(scope, func)
{
	var webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1;
	if(window.addEventListener&&!webkit) window.addEventListener("DOMContentLoaded", function(e){ scope[func](e); }, false);
	if(window.addEventListener&&webkit) window.addEventListener("load", function(e){ scope[func](e); }, false);
	if(window.attachEvent) window.attachEvent("onload", function(e){ scope[func](e); });
}
*/
RandomImage.prototype.replace = function(e)
{
	this.target = document.getElementById(this.id);
	var rn = Math.floor( Math.random()*this.len );
	var new_src = this.imgs[rn];
	this.target.appendChild(this.newImage(new_src));
		//console.log(rn+":"+this.imgs[rn]);
}
RandomImage.prototype.newImage = function(_src)
{
	var el = document.createElement("img");
	el.setAttribute("src", _src);
	el.setAttribute("width", 560);
	el.setAttribute("height", 300);
	el.setAttribute("alt", "");
	return el;
}