var Content = {

	Update : function(name) {

		// set that we're started
		this.started = true;

		// test column
		var column = "left";
		if(name == "rekomendacja" || name == "sukcesy" || name == "lustracja" || name == "kontakt") { column = "right"; }

		// disappear content
		Effect.Fade(column + "_content", {duration: 0.2, afterFinish: function() {

			// fill content
			var pars = false;

			var myAjax = new Ajax.Updater(
				column + "_content",
				"texts/" + name + ".html",
					{
					method: 'get',
					parameters: pars,
					onComplete: function() {

						Behaviour.apply(ProjectDOM);
						Effect.Appear(column + "_content", {duration: 0.3});
					},
					onFailure: function(request) { alert(request.responseText); }
			});
		}});
	}

}

var ProjectDOM = {

	// content clicks
	'a.dropdown' : function(a) {

		a.onclick = function(click) {
			var tgtDiv = a.id + "_content";

			if($(tgtDiv).style.display == "none") {

				Effect.BlindDown(tgtDiv, { duration: 0.5 });
			}
			else {
				Effect.BlindUp(tgtDiv, { duration: 0.5 });
			}

			return false;
		}
	},

	// intro
	'a#intro_click' : function(a) {

		a.onclick = function(click) {

			Effect.Fade('intro', { afterFinish: function() {

				Effect.Appear('main');
			}});

			return false;
		}
	},

	// topmenu clicks
	'#menu a' : function(a) {

		// don't reapply
		if(!Content.started) {

			a.onclick = function(click) {

				Content.Update(a.name);
				return false;
			}
		}
	},

	// global startup
	'body' : function(body) {

		// don't reapply
		if(!Content.started) {
			Content.Update('sylwetka');
			Content.Update('rekomendacja');
		}
	}
}

Behaviour.register(ProjectDOM);
