function setFaders () {
	if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
		safVersion();
		return;
	}
	var imgs = document.getElementsByTagName('img');
	for (var i = 0; i < imgs.length; i++) {
		if (imgs[i].className == 'fade') {
			new FadeDecorator(imgs[i]);
		}
	}
}

function FadeDecorator (img) {
	this.HTMLObject = document.createElement('img');
	this.HTMLObject.className = 'fadedecorator';
	this.HTMLObject.src = img.id.split('|')[1];
	this.HTMLObject.style.width = img.offsetWidth;
	img.parentNode.appendChild(this.HTMLObject);
	this.HTMLObject.decorator = this;
	this.linkObject = img.parentNode.getElementsByTagName('div')[0];
	this.linkObject.decorator = this;
	this.fadingIn = -1;
	this.fadingOut = -1;
	this.HTMLObject.onmouseover = this.startFadeIn;
	this.HTMLObject.onmouseout = this.startFadeOut;
	this.href = img.id.split('|')[0];
	this.HTMLObject.onclick = function () {
		document.location.href = this.decorator.href;
	}
	this.linkObject.onmouseover = this.startFadeIn;
	this.linkObject.onmouseout = this.startFadeOut;
	this.linkObject.onclick = function () {
		document.location.href = this.decorator.href;
	}
}

/*
-------------- Fade in functions 
*/

FadeDecorator.prototype.startFadeIn = function (e) {
	var fadeInFunction = null;
	if (document.all) {
		fadeInFunction = this.decorator.fadeInWrapperIE(this.decorator);
	} else if (this.filters != 'undefined') {
		this.decorator.HTMLObject.style.opacity = 0.1;
		fadeInFunction = this.decorator.fadeInWrapperW3C(this.decorator)
	}
	if (this.decorator.fadingOut != -1) {
		clearInterval(this.decorator.fadingOut)
		this.decorator.fadingOut = -1;
	}
	this.decorator.linkObject.className = 'links_over';
	this.decorator.fadingIn = setInterval(fadeInFunction, 30);
}

FadeDecorator.prototype.fadeInWrapperIE = function (decorator) {
	return (function(){
		decorator.doFadeInIE();
    });
}

FadeDecorator.prototype.doFadeInIE = function () {
	if (this.HTMLObject.filters.alpha.opacity < 85) 
		this.HTMLObject.filters.alpha.opacity += 20;
	else {
		clearInterval(this.fadingIn);
		this.fadingIn = -1;
		this.HTMLObject.filters.alpha.opacity = 85;
	}
}

FadeDecorator.prototype.fadeInWrapperW3C = function (decorator) {
	return (function(){
		decorator.doFadeInW3C();
    });
}

FadeDecorator.prototype.doFadeInW3C = function () {
	if (parseFloat(this.HTMLObject.style.opacity) < 0.7499999) {
		this.HTMLObject.style.opacity = parseFloat(this.HTMLObject.style.opacity) + 0.1;
	} else {
		clearInterval(this.fadingIn);
		this.fadingIn = -1;
		this.HTMLObject.style.opacity = 0.8499999;
	}
}

/*
-------------- Fade out functions 
*/

FadeDecorator.prototype.startFadeOut = function () {
	var fadeOutFunction = null;
	if (document.all) {
		fadeOutFunction = this.decorator.fadeOutWrapperIE(this.decorator);
	} else if (this.filters != 'undefined') {
		fadeOutFunction = this.decorator.fadeOutWrapperW3C(this.decorator)
	}
	if (this.decorator.fadingIn != -1) {
		clearInterval(this.decorator.fadingIn);
		this.decorator.fadingIn = -1;
	}
	this.decorator.linkObject.className = 'links';
	this.decorator.fadingOut = setInterval(fadeOutFunction, 60);
}

FadeDecorator.prototype.fadeOutWrapperIE = function (decorator) {
	return (function(){
		decorator.doFadeOutIE();
    });
}

FadeDecorator.prototype.doFadeOutIE = function () {
	if (this.HTMLObject.filters.alpha.opacity > 10) {
		this.HTMLObject.filters.alpha.opacity -= 20;
	}
	else {
		clearInterval(this.fadingOut);
		this.fadingOut = -1;
		this.HTMLObject.filters.alpha.opacity = 0;
	}
}

FadeDecorator.prototype.fadeOutWrapperW3C = function (decorator) {
	return (function(){
		decorator.doFadeOutW3C();
    });
}

FadeDecorator.prototype.doFadeOutW3C = function () {
	if (parseFloat(this.HTMLObject.style.opacity) > 0.11) {
		this.HTMLObject.style.opacity = parseFloat(this.HTMLObject.style.opacity) - 0.1;
	}
	else {
		clearInterval(this.fadingOut);
		this.fadingOut = -1;
		this.HTMLObject.style.opacity = 0;
	}
}

function safVersion() {
	var entries = document.getElementsByTagName('div');
	for (var i = 0; i < entries.length; i++) {
		if (entries[i].className == 'tire') {
			entries[i].img = entries[i].getElementsByTagName('img')[0];
			if (entries[i].img.className == 'fade') {
				//Preload
				var onImageSrc = entries[i].img.id.split('|')[1];
				entries[i].img.n = entries[i].img.src;
				entries[i].img.o = entries[i].img.id.split('|')[1];
				entries[i].img.parentNode.link = entries[i].img.id.split('|')[0];
				entries[i].img.parentNode.onclick = function () {
					document.location.href = this.link;
				}
				entries[i].img.onmouseover = function () {
					this.src = this.o;
				}
				entries[i].img.onmouseout = function () {
					this.src = this.n;
				}
			}
			entries[i].links = entries[i].getElementsByTagName('div')[0];
			var onImageSrc = entries[i].img.id.split('|')[1];
			entries[i].links.n = entries[i].img.src;
			entries[i].links.o = entries[i].img.id.split('|')[1];
			entries[i].links.onmouseover = function () {
				this.parentNode.img.src = this.o;
				this.className = 'links_over';
			}
			entries[i].links.onmouseout = function () {
				this.parentNode.img.src = this.n;
				this.className = 'links';
			}
		}
	}
}