var mt_dodatki = {

	laduj: function(){

// Dymki

	var dymek1 = new Tips($$('.mttips'), {
	className: 'mttips',
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 400, wait: false}).set(0);
	},
	onShow: function(toolTip) { this.fx.start(1);},
	onHide: function(toolTip) { this.fx.start(0);}
	});

// Powrót top

	new SmoothScroll({ duration: 2000 });
}};

window.addEvent('load',mt_dodatki.laduj);

// Pokaz slajdów

/*
	SimpleSlide v 1.1
	Developed by Gravita, www.gravita.se
	License: MIT-style license
	Modyficate: Templatka.pl - 03.2008
	Website: www.templatka.pl
*/

var SimpleSlide = new Class({
	
	initialize: function(container,options) {
		this.container = container;
		this.options = options;
		var automated;
        var direction;

		if(this.options) this.direction = this.options.direction;
		else this.direction = "forward";
		if (this.direction!="stop")
		{
		if(this.options.auto == "loop" || this.options.auto == "once") {

	 	   this.automated = this.slider.periodical(this.options.time,this,$(this.container));
		} else {
			this.slider($(this.container))
		}
        }
	},
	
	slider: function(container) {
		
		if(this.options.goTo) {
			var goTo = this.options.goTo.toInt();
				goTo -= 1;
		}
		
		if ((this.options.auto == "once" || this.options.auto == "loop") && this.direction == "stop")
		{
		   $clear(this.automated);
		}else{
		
		var child;
		var children = container.getChildren().getChildren()[0];
		children.each(function(e) {
			if(e.id == "currentChild") {
				child = e;
			}
		});
		if(goTo || goTo == 0) {
			if(container.getChildren()[0].getChildren()[goTo]) { 
			child = container.getChildren()[0].getChildren()[goTo];
			$clear(this.automated);
			}
			
			else alert("Slide "+goTo+" does not exist");
		} else {
		
			if(!child && (this.direction == "forward" || this.direction == "stop")) {
				if(this.direction == "forward") {
					child = children[0].getNext();
				}
				else if(this.direction == "back") {
					child = container.getChildren()[0].getLast();
				}
			} else {
				if(this.direction == "forward") {
					var lastElement = container.getChildren()[0].getLast();
					if(lastElement == child.getNext() && this.options.auto == "once") $clear(this.automated);
					if(lastElement == child) child = children[0];
					else child = child.getNext();
				}
				else if(this.direction == "back") {
					var firstElement = container.getChildren()[0].getFirst();
					if(firstElement == child.getPrevious() && this.options.auto == "once") $clear(this.automated);
					if(firstElement == child) child = container.getChildren()[0].getLast();
					else child = child.getPrevious();			
				}
			
			}
		}
		if(child && this.direction != "stop") {
			if(this.options.type == "scroll") this.scroll(container,children,child);
			else if(this.options.type == "fade") this.fade(container,children,child);
			else if(this.options.type == "scrollfade") this.scrollfade(container,children,child);
		}
		}
	},
		
	stop: function() {
              this.direction="stop";
              this.slider($(this.container));
    	},
	start: function() {
		   this.direction="forward";
	 	   this.automated = this.slider.periodical(this.options.time,this,$(this.container));
                             },
	
	
	slider2: function(container) {
		var direction;
		if(this.options) direction = this.options.direction;
		else direction = "forward";
		var child;
		if(this.options.goTo) {
			var goTo = this.options.goTo.toInt();
				goTo -= 1;
		}
		var children = container.getChildren().getChildren()[0];
		children.each(function(e) {
			if(e.id == "currentChild") {
				child = e;
			}
		});
		if(goTo || goTo == 0) {
			if(container.getChildren()[0].getChildren()[goTo]) child = container.getChildren()[0].getChildren()[goTo];
			else alert("Slide "+goTo+" does not exist");
		} else {
			if(!child) {
				if(direction == "forward") {
					child = children[0].getNext();
				}
				else if(direction == "back") {
					child = container.getChildren()[0].getLast();
				}
			} else {
				if(direction == "forward") {
					var lastElement = container.getChildren()[0].getLast();
					if(lastElement == child.getNext() && this.options.auto == "once") $clear(this.automated);
					if(lastElement == child) child = children[0];
					else child = child.getNext();
				}
				else if(direction == "back") {
					var firstElement = container.getChildren()[0].getFirst();
					if(firstElement == child.getPrevious() && this.options.auto == "once") $clear(this.automated);
					if(firstElement == child) child = container.getChildren()[0].getLast();
					else child = child.getPrevious();			
				}
			
			}
		}
		if(child) {
			if(this.options.type == "scroll") this.scroll(container,children,child);
			else if(this.options.type == "fade") this.fade(container,children,child);
			else if(this.options.type == "scrollfade") this.scrollfade(container,children,child);
		}
	},
	scroll: function(container,children,child) {
		var scroll = new Fx.Scroll(container,{duration: this.options.duration, onComplete: function() {
			children.each(function(e) {
				e.id = "";
			});
			child.id = "currentChild";
		}}).toElement(child);
		
	},
	fade: function(container,children,child) {
		var fade = new Fx.Style(container,'opacity',{duration: this.options.duration, onComplete: function() {
			new Fx.Scroll(container,{duration: 1,onComplete: function() {
				children.each(function(e) {
					e.id = "";
				});
				child.id = "currentChild";
				new Fx.Style(container,'opacity').start(0.01,1);
			}}).toElement(child);
		}})
		fade.start(1,0.01);
	},
	scrollfade: function(container,children,child) {
		var durationInt = this.options.duration.toInt();
		var fade = new Fx.Style(container,'opacity',{duration: (durationInt/2)})
		fade.start(1,0.01).chain(function() {
			fade.start(0.01,1);
		});
		new Fx.Scroll(container,{duration: durationInt, onComplete: function() {
			children.each(function(e) {
				e.id = "";
			});
			child.id = "currentChild";
		}}).toElement(child);
	}
});

