function Fileuploader()
{
	var self = this;
	this.card = false;
	this.dFlag = false;
	this.fullscreen = document.getElementById("fullscreen");
	this.div = document.getElementById("upload");
	this.inner = this.div.getElementsByTagName("div")[0];
	this.loading = this.div.getElementsByTagName("img")[0];
	this.close = this.div.getElementsByTagName("a")[0];
	this.form = document.forms["uploader"];
	this.button = document.forms["uploader"].elements["button"];
	
	this.loading.style.display = "none";
	
	this.close.onmouseover = function()
	{
		this.style.cursor = "pointer";
	}
	
	this.close.onclick = function()
	{
		base.editable = true;
		self.hidden();
	}
	
	this.button.onclick = function()
	{
		self.inner.style.display = "none";
		self.loading.style.display = "block";
		
		self.form.submit();
	}
}

Fileuploader.prototype.display = function(card)
{
	base.editable = false;
	this.card = card;
	this.fullscreen.style.display = "block";
	this.div.style.display = "block";
	this.div.getElementsByTagName("p")[0].childNodes[0].nodeValue = card.div.id;
	this.form.elements["cid"].value = card.div.id;
	this.dFlag = true;
}

Fileuploader.prototype.hidden = function()
{
	this.fullscreen.style.display = "none";
	this.div.style.display = "none";
}

Fileuploader.prototype.uploadResult = function(result)
{
	base.editable = true;
	this.fullscreen.style.display = "none";
	this.div.style.display = "none";

	this.inner.style.display = "block";
	this.loading.style.display = "none";
		
	if(result[0] == true)
	{
		this.card.div.img.style.display = "block";
		this.card.div.img.setAttribute("src",result[1]);
	}
}