// Style fix
var styleFix = function(){
	if((Browser.firefox || Browser.safari) && Browser.Platform.win){
		$$('#header_top fieldset').setStyle('padding-top', 0);
	}
}

// Textslider
var textSlider = function(){
	var textSlider = $('textslider').getElement('div');
	var arrowNext = $('textslider_next');
	var arrowPrevious = $('textslider_previous');
	var fx = new Fx.Tween(textSlider, {duration: 500, transition: Fx.Transitions.Linear});
	var width = textSlider.getElement('p').getStyle('width').toInt() - 526;

	arrowNext.addEvents({
		click: function(event){
			event.preventDefault();
		},
		mousedown: function(){
			fx.start('margin-left', '-' + width);
		},
		mouseup: function(){
			fx.cancel();
		}
	});

	arrowPrevious.addEvents({
		click: function(event){
			event.preventDefault();
		},
		mousedown: function(){
			fx.start('margin-left', 0);
		},
		mouseup: function(){
			fx.cancel();
		}
	});
}

// Slideshow
var slideShow = function(item, index){
	$$('div.slideshow').setStyle('display', 'none');
	$$('div.slideshow_' + index).setStyle('display', 'block');

	$$('div.slideshow_' + index).set('tween', {duration: 150, transition: Fx.Transitions.Sine});
	$$('div.slideshow_' + index).tween('margin-left', [10, 0]);

	var fx = new Fx.Tween($('slideshow'), {duration: 300, transition: Fx.Transitions.Linear});
	fx.start('opacity', [0.7, 1]);

	$$('div.thumbs a').removeProperty('class');
	item.setProperty('class', 'active');
}

// DOM ready
window.addEvent('domready', function(){
	styleFix();
	textSlider();
});

// Favourites
function addToFav() {
	if (window.sidebar) window.sidebar.addPanel(document.title,location.href, ''); 
	else if (window.external) window.external.AddFavorite(location.href, document.title); 
	else alert('Vaš brskalnik ne podpira dodajanja med priljubljene zaznamke na ta način. Poskusite pritisniti Ctrl-D.');
}
