function nnwAnimbox(n){
	this.aHtmlNavi = [];
	this.oHtmlContent = null;
	this.iHtmlContentChilds = 0;
	this.iHtmlContentWidth = 0;
	this.iMoveWidth = 0;
	this.iCurrentDirection = 0;
	this.iCurrentIndex = 0;
	this.iTimeOutValue = 0;
	this.iPauseDuration = 3000;
	this.bPause = false;
	this.init(n);
}
nnwAnimbox.prototype.init = function(n, p){
	var oContainer = document.getElementById(n);
	if (oContainer && oContainer.hasChildNodes()){
		var len = oContainer.childNodes.length - 1;
		var thisObj = this;
		if (1 < len){
			while (len >= 0){
				if ('undefined' != typeof(oContainer.childNodes[len].className) && '' != oContainer.childNodes[len].className){
					if ('animbox-cont' == oContainer.childNodes[len].className){
						this.oHtmlContent = oContainer.childNodes[len];
						this.onlyRealNodes(this.oHtmlContent);
						this.iHtmlContentChilds = this.oHtmlContent.childNodes.length;
					}else if (0 == oContainer.childNodes[len].className.indexOf('animbox-nav')){
						this.aHtmlNavi.push(oContainer.childNodes[len]);
						oContainer.childNodes[len].firstChild.onclick = function(){
							thisObj.navigate(this);
							return false;
						}
						oContainer.childNodes[len].firstChild.onmouseover = function(){
							thisObj.pause();
						}
						oContainer.childNodes[len].firstChild.onmouseout = function(){
							thisObj.restart();
						}
					}
				}
				len--;
			}
		}
		if (this.oHtmlContent && 1 < this.iHtmlContentChilds){
			this.iCurrentDirection = 1;
			this.iCurrentIndex = 0;
			this.iTimeOutValue = 0;
			this.bPause = false;
			this.iHtmlContentWidth = this.oHtmlContent.offsetWidth;
			this.iMoveWidth = Math.ceil(this.iHtmlContentWidth/10);

			this.oHtmlContent.onmouseover = function(){
				thisObj.pause();
			}
			this.oHtmlContent.onmouseout = function(){
				thisObj.restart();
			}
		}
	}
}
nnwAnimbox.prototype.onlyRealNodes = function(o){
	for (var i = o.childNodes.length - 1; i >= 0; i--){
		if (1 != o.childNodes[i].nodeType){
			o.removeChild(o.childNodes[i]);
		}
	}
}
nnwAnimbox.prototype.setNavi = function(b){
	for (var i in this.aHtmlNavi){
		this.aHtmlNavi[i].style.display = b ? 'block' : 'none';
	}
}
nnwAnimbox.prototype.animate = function(){
	if (0 != this.iCurrentDirection){
		this.setNavi(true);
		this.moveInit();
	}
}
nnwAnimbox.prototype.setMoveInterval = function(p){
	this.iPauseDuration = p;
}
nnwAnimbox.prototype.moveInit = function(noTimeout){
	window.clearTimeout(this.iTimeOutValue);
	for (var i = 0; i < this.iHtmlContentChilds; i++){
		this.oHtmlContent.childNodes[i].style.display = 'none';
		this.oHtmlContent.childNodes[i].style.left = '0px';
	}
	var pos = 0;
	var idx = this.iCurrentIndex;
	for (i = 0; i < 2; i++){
		this.oHtmlContent.childNodes[idx].style.left = pos + 'px';
		this.oHtmlContent.childNodes[idx].style.display = 'block';
		pos += this.iHtmlContentWidth * this.iCurrentDirection;
		idx = this.neighbour(this.iCurrentDirection);
	}
	if ('undefined' == typeof(noTimeout) || 0 == noTimeout){
		this.iTimeOutValue = this.moveTimeout(this.iPauseDuration);
	}
}
nnwAnimbox.prototype.moveTimeout = function(delay){
	var thisObj = this;
	var move = function(){
		thisObj.move();
	}
	return window.setTimeout(move, delay);
}
nnwAnimbox.prototype.move = function(){
	var i, bFinished;
	window.clearTimeout(this.iTimeOutValue);
	var idx = this.iCurrentIndex;
	for (i = 0; i < 2; i++){
		this.oHtmlContent.childNodes[idx].style.left = (this.oHtmlContent.childNodes[idx].offsetLeft - (this.iMoveWidth * this.iCurrentDirection)) + 'px';
		idx = this.neighbour(this.iCurrentDirection);
	}
	if (1 == this.iCurrentDirection && this.oHtmlContent.childNodes[this.iCurrentIndex].offsetLeft + this.oHtmlContent.childNodes[this.iCurrentIndex].offsetWidth <= 0){
		bFinished = 1;
	}else if (-1 == this.iCurrentDirection && this.iHtmlContentWidth <= this.oHtmlContent.childNodes[this.iCurrentIndex].offsetLeft){
		bFinished = 1;
	}else{
		bFinished = 0;
	}
	if (0 == bFinished){
		this.iTimeOutValue = this.moveTimeout(40);
	}else if (0 == this.bPause){
		this.iCurrentIndex = this.neighbour(this.iCurrentDirection);
		this.moveInit();
	}
}
nnwAnimbox.prototype.neighbour = function(dir){
	var d = this.iCurrentIndex + dir;
	if (0 > d){
		d = this.iHtmlContentChilds - 1;
	}else if (d >= this.iHtmlContentChilds){
		d = 0;
	}
	return d;
}
nnwAnimbox.prototype.pause = function(){
	window.clearTimeout(this.iTimeOutValue);
	this.bPause = true;
}
nnwAnimbox.prototype.restart = function(){
	if (true == this.bPause){
		this.bPause = false;
		this.iTimeOutValue = this.moveTimeout(500);
	}
}
nnwAnimbox.prototype.navigate = function(el){
	if (-1 != el.parentNode.className.indexOf('-fwd')){
		this.iCurrentDirection = 1;
		this.iCurrentIndex = this.neighbour(1);
	}else{
		this.iCurrentDirection = -1;
		this.iCurrentIndex = this.neighbour(-1);
	}
	this.moveInit(1);
}