//Tips creator.
var tips_create = function()
{
	var table = new Element("table");
	table.cellPadding = '0';
	table.cellSpacing = '0';
	table.border = '0';

	var tbody = new Element("tbody", {"class":"fc-tbx"}).inject(table);
	var tr1 = new Element("tr").inject(tbody);
	new Element("td", {"class":"tl"}).inject(tr1);
	new Element("td", {"class":'t'}).inject(tr1);
	new Element("td", {"class":"tr"}).inject(tr1);
	var tr2 = new Element("tr").inject(tbody);
	new Element("td", {"class":'l'}).inject(tr2);
	var cont = new Element ("td", {"class":'c'}).inject(tr2);
	var errors = new Element ("div", {"class":"err"}).inject(cont);
	var text = new Element ("p").inject(errors);
	var close = new Element ('a', {"class":"close"}).inject(cont);
	new Element ("td", {"class":'r'}).inject(tr2);
	var tr3 = new Element ("tr").inject(tbody);
	new Element("td", {"class":"bl"}).inject(tr3);
	new Element("td", {"class":'b'}).inject(tr3);
	new Element("td", {"class":"br"}).inject(tr3);
	return table;
};

//input01.
var input01_handlekp = function(keydown)
{
	if (this.getParent().getElement("div") != undefined)
		if (this.get("value") == "" && (keydown == undefined || keydown.key == undefined))
			this.getParent().getElement("div").addClass("display_block");
		else if (this.get("value") != "" || (keydown != undefined && keydown.key != ""))
			this.getParent().getElement("div").removeClass("display_block");
};
var input01_init = function()
{
	this.getElements(".input01-center div").each(function(e)
		{
			if (e.getParent().getElement("input") != undefined)
				e.addEvent("click", function()
					{
						this.getParent().getElement("input").focus();
					});
		});
	this.getElements(".input01-center input").each(function(e)
		{
			e.addEvents(
				{
					"focus":function()
					{
						this.getParent().getParent().addClass("input01-focused");
						input01_handlekp.call(this);
					},
					"blur":function()
					{
						this.getParent().getParent().removeClass("input01-focused");
						input01_handlekp.call(this);
					},
					"keyup":input01_handlekp,
					"keydown":input01_handlekp,
					"change":input01_handlekp
				});
			input01_handlekp.call(e);
		});
};

//plaininput01.
var plaininput01_handlefocus = function()
{
	if (this.get("name") != null) {
		if(this.get("value") == this.get("name")) {
			this.removeClass("plaininput01-inactive");
			this.set("value", "");
		} else if(this.get("value") == "") {
			this.addClass("plaininput01-inactive");
			this.set("value", this.get("name"));
		}
	}
};
var plaininput01_init = function()
{
	this.addEvents(
		{
			"focus":plaininput01_handlefocus,
			"blur":plaininput01_handlefocus
		});
	plaininput01_handlefocus.call(this);
};

window.addEvent ("domready",function ()
	{
		//input01.
		$$(".input01").each(function(e)
			{
				input01_init.call (e);
			});
		
		//checkbox01.
		$$ (".checkbox01").each(function(e)
			{
				e.addEvents(
					{
						"mouseup":function()
						{
							if (!this.hasClass("override"))
								this.toggleClass("checkbox01-selected");
							this.fireEvent("toggled", this.hasClass("checkbox01-selected"));
						}
					});
			});
		
		//plaininput01.
		$$(".plaininput01").each(function(e)
			{
				plaininput01_init.call(e);
			});
	});
