var artstal;

window.addEvent('domready', function() {
	if($("photo")){
		sikorski = new FadingThrough($$("#photo img"), 7000);
	}
	
	if($("comments")){
		comments = new FadingThrough($$("#comments p"), 4000);
	}


	if($("to_top")){
		$("to_top").addEvent("click", function(event){
			var event = new Event(event);
			event.preventDefault();
			new Fx.Scroll($(document.body)).toTop();
		});
	}
	
	var search_value = $("search_text").get("value");
	
	$("search_text").addEvent("blur", function(){
		if(this.value==""){
			this.value = search_value;
		}
	});
	
	$("search_text").addEvent("focus", function(){
		if(this.value==search_value){
			this.value = "";
		}
	});

	
});

var FadingThrough = new Class({
	initialize: function(elements, time){
		this.elements = elements;
		this.elements.fade("hide");
		this.elements[0].fade("show");
		this.current_el = 0;
		this.time = time;
		this.function_rotate = this.rotate.periodical(this.time, this);
	},
	
	rotate: function(){
		this.elements[this.current_el].fade("out");
		if(this.current_el==this.elements.length-1){
			this.current_el = 0;
		}
		else {
			this.current_el+=1;
		}
		this.elements[this.current_el].fade("in");
		
	}
})


