var KIOS = {};
KIOS.menuInit = function() {

var szNormal = 74, szSmall  = 37, szFull   = 220;

var kwicks = $$("#kwicks .kwick");
var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
kwicks.each(function(kwick, i) {
	kwick.addEvent("mouseenter", function(event) {
		var o = {};
		o[i] = {height: [kwick.getStyle("height").toInt(), szFull]}
		kwicks.each(function(other, j) {
			if(i != j) {
				var w = other.getStyle("height").toInt();
				if(w != szSmall) o[j] = {height: [w, szSmall]};
			}
		});
		fx.start(o);
		$('obrazok').src="/fileadmin/img/uvod_image" + (i + 1) + ".jpg";
	});
});

$("kwicks").addEvent("mouseleave", function(event) {
	var o = {};
	kwicks.each(function(kwick, i) {
		o[i] = {height: [kwick.getStyle("height").toInt(), szNormal]}
	});
	fx.start(o);
})

}


KIOS.menuInitd = function() {

	var szNormal = 182, szSmall = 150, szFull = 310, o = {};

	// zistime ci je niektora polozka menu aktivna
	var active = false;
	if ($$("#kwicks-d .active").length != 0) {
		active = true;
	}

	var kwicks = $$("#kwicks-d .kwick-d");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
	kwicks.each(function(kwick, i) {

		if (active) {
			if (kwick.getFirst().hasClass('active')) {
				o[i] = {width: [kwick.getStyle("width").toInt(), szFull]};
			} else {
				o[i] = {width: [kwick.getStyle("width").toInt(), szSmall]};
			}
		} else {
			o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]};
		}

		kwick.addEvent("mouseenter", function(event) {
			var o = {};
			o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall) o[j] = {width: [w, szSmall]};
				}
			});
			fx.start(o);
		});
	});
	fx.start(o);

	$("kwicks-d").addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			if (active) {
				if (kwick.getFirst().hasClass('active')) {
					o[i] = {width: [kwick.getStyle("width").toInt(), szFull]};
				} else {
					o[i] = {width: [kwick.getStyle("width").toInt(), szSmall]};
				}
			} else {
				o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
			}
		});
		fx.start(o);
	})
}

KIOS.menuInitop = function() {

	var szSmall = 33, o = {}, menuItemHeights = [];
	var kwicks = $$("#kwicks-op .kwick-op");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
	kwicks.each(function(kwick, i) {

		menuItemHeights[i] = kwick.getStyle('height');

		if (kwick.getFirst().getFirst().hasClass('active')) {
			o[i] = {height: [kwick.getStyle("height").toInt(), menuItemHeights[i]]};
		} else {
			o[i] = {height: [kwick.getStyle("height").toInt(), szSmall]};
		}

		kwick.addEvent("click", function(event) {
			var o = {};
				o[i] = {height: [kwick.getStyle("height").toInt(), menuItemHeights[i]]};
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("height").toInt();
						if (w != szSmall) o[j] = {height: [w, szSmall]};
					}
				});
				fx.start(o);
				//debugger;
				var aaa = event.originalTarget;
				if (!aaa) aaa = event.srcElement;
				if ($(aaa).getParent().hasClass('kwick-op')) {
					Event.preventDefault(event);
//					event.preventDefault();
				}
		});
	});
	fx.start(o);

}

KIOS.menuInitcer = function() {

	var szSmall = 33, o = {}, menuItemHeights = [];
	var kwicks = $$("#kwicks-op .kwick-op");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
	kwicks.each(function(kwick, i) {

		menuItemHeights[i] = kwick.getStyle('height');

		if (kwick.getFirst().getFirst().hasClass('active')) {
			o[i] = {height: [kwick.getStyle("height").toInt(), menuItemHeights[i]]};
		} else {
			o[i] = {height: [kwick.getStyle("height").toInt(), szSmall]};
		}

		kwick.addEvent("click", function(event) {
			var o = {};
				o[i] = {height: [kwick.getStyle("height").toInt(), menuItemHeights[i]]};
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("height").toInt();
						if (w != szSmall) o[j] = {height: [w, szSmall]};
					}
				});
				fx.start(o);

		});
	});
	fx.start(o);
}


KIOS.menuInitsc= function() {

	var szSmall = 33, szFull = 400, o = {};

	var kwicks = $$("#kwicks-op .kwick-op");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
	kwicks.each(function(kwick, i) {

		if (kwick.getFirst().hasClass('active')) {
			o[i] = {height: [kwick.getStyle("height").toInt(), szFull]};
		} else {
			o[i] = {height: [kwick.getStyle("height").toInt(), szSmall]};
		}

		kwick.addEvent("mouseenter", function(event) {
			var o = {};
				o[i] = {height: [kwick.getStyle("height").toInt(), szFull]};
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("height").toInt();
						if (w != szSmall) o[j] = {height: [w, szSmall]};
					}
				});
				fx.start(o);
		});
	});
	fx.start(o);

	$("kwicks-op").addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			if (kwick.getFirst().hasClass('active')) {
				o[i] = {height: [kwick.getStyle("height").toInt(), szFull]};
			} else {
				o[i] = {height: [kwick.getStyle("height").toInt(), szSmall]};
			}
		});
		fx.start(o);
	})
}






