
// ElementScroll by Robert Engelhardt <engelhardt@more-style.de>
// Copyright 2007 Agentur More Style

var ElementScroll = {

	Up : function (Element, Speed) {

		if ((Element = document.getElementById(Element)) != null) {

			if (Speed == null) {

				Speed = 4;
			}

			if (Element.Frame == null) {

				Element.Frame = {

					Width  : Element.parentNode.offsetWidth,
					Height : Element.parentNode.offsetHeight
				};

			} window.clearInterval(Element.Timer);

			if (Element.Scroll == null) {

				if (Element.style.top == '') {

					Element.style.top = Element.offsetTop + 'px';
				}

				Element.Scroll = function (Speed) {

					if (this.offsetTop < 0) {

						this.style.top = (parseInt(this.style.top) + Speed) + 'px';

					} else window.clearInterval(this.Timer);
				};

			} Element.Timer = window.setInterval("document.getElementById('" + Element.id + "').Scroll(" + Speed + ")", 25);
		}
	},

	Right : function (Element, Speed) {

		if ((Element = document.getElementById(Element)) != null) {

			if (Speed == null) {

				Speed = 4;

			} window.clearInterval(Element.Timer);

			if (Element.Scroll == null) {

				if (Element.style.left == '') {

					Element.style.left = Element.offsetTop + 'px';
				}

				Element.Scroll = function (Speed) {

					if (this.offsetLeft < 0) {

						this.style.left = (parseInt(this.style.left) - Speed) + 'px';

					} else window.clearInterval(this.Timer);
				};

			} Element.Timer = window.setInterval("document.getElementById('" + Element.id + "').Scroll(" + Speed + ")", 25);
		}
	},

	Down : function (Element, Speed) {

		if ((Element = document.getElementById(Element)) != null) {

			if (Speed == null) {

				Speed = 4;

			} window.clearInterval(Element.Timer);

			if (Element.Scroll == null) {

				if (Element.style.top == '') {

					Element.style.top = Element.offsetTop + 'px';
				}

				Element.Scroll = function (Speed) {

					if (this.offsetTop > -(this.offsetHeight - this.parentNode.offsetHeight)) {

						this.style.top = (parseInt(this.style.top) - Speed) + 'px';

					} else window.clearInterval(this.Timer);
				};

			} Element.Timer = window.setInterval("document.getElementById('" + Element.id + "').Scroll(" + Speed + ")", 25);
		}
	},

	Left : function (Element, Speed) {

		if ((Element = document.getElementById(Element)) != null) {

			if (Speed == null) {

				Speed = 4;

			} window.clearInterval(Element.Timer);

			if (Element.Scroll == null) {

				if (Element.style.left == '') {

					Element.style.left = Element.offsetTop + 'px';
				}

				Element.Scroll = function (Speed) {

					if (this.offsetLeft > -(this.offsetLeft - this.parentNode.offsetWidth)) {

						this.style.left = (parseInt(this.style.left) - Speed) + 'px';

					} else window.clearInterval(this.Timer);
				};

			} Element.Timer = window.setInterval("document.getElementById('" + Element.id + "').Scroll(" + Speed + ")", 25);
		}
	},

	Stop : function (Element) {

		if ((Element = document.getElementById(Element)) != null) {

			window.clearInterval(Element.Timer);
			Element.Scroll = Element.Timer = Element.Frame = null;
		}
	}
};

var Hover = {

	Css : function (element, target, properties, value, eventType) {

		if ((element = document.getElementById(element)) != null && (target = document.getElementById(target)) != null) {
			element[eventType] = function () {
				target.style[properties] = value;
			}
		}
	}
};

function initHovers(value){
	if(value == "link1"){
		document.getElementById('wuerfel1').style.backgroundPosition = 'bottom';
	}else{
		Hover.Css('link1', 'wuerfel1', 'backgroundPosition', 'bottom', 'onmouseover');
		Hover.Css('link1', 'wuerfel1','backgroundPosition', 'top', 'onmouseout');
	}

	if(value == "link2"){
		document.getElementById('wuerfel2').style.backgroundPosition = 'bottom';
	}else{
		Hover.Css('link2', 'wuerfel2', 'backgroundPosition', 'bottom', 'onmouseover');
		Hover.Css('link2', 'wuerfel2','backgroundPosition', 'top', 'onmouseout');
	}

	if(value == "link3"){
		document.getElementById('wuerfel3').style.backgroundPosition = 'bottom';
	}else{
		Hover.Css('link3', 'wuerfel3', 'backgroundPosition', 'bottom', 'onmouseover');
		Hover.Css('link3', 'wuerfel3','backgroundPosition', 'top', 'onmouseout');
	}

	if(value == "link4"){
		document.getElementById('wuerfel4').style.backgroundPosition = 'bottom';
	}else{
		Hover.Css('link4', 'wuerfel4', 'backgroundPosition', 'bottom', 'onmouseover');
		Hover.Css('link4', 'wuerfel4','backgroundPosition', 'top', 'onmouseout');
	}
}