function NewsScroller(name) {
	this.name = name;
	this.contDivID;
	this.news;
	this.transition;
	this.cIndex = 0;
	this.timer;
	this.width;
	this.height;
	this.cDiv;
	this.duration = 30;
	this.step = 1;
	this.delay = 1000;
	this.opc;
	//this.ie = browser.ie;
}


NewsScroller.prototype.run = function () {
	
	if(this.read()) {
	
		switch(this.transition) {
			case 'SCROLL2TOP':
				this.scroll2top();
			break;
			case 'SCROLL2LEFT':
				this.scroll2left();
			break;
			case 'FADE':
				this.fade();
			break;
			default:
				alert("HATALI GEÇY?");
		}
	}
}


NewsScroller.prototype.read = function () {
	var i, j;
	var cont = document.getElementById(this.contDivID);
	var data = cont.childNodes;
	
	cont.style.overflow = 'hidden';
	cont.style.position = 'relative';
	
	this.width	= cont.offsetWidth;
	this.height	= cont.offsetHeight;
	
	this.news = new Array();
	
	j = 0;
	for(i=0; i < data.length; i++) {
		if(data[i].nodeName != '#text') {
			this.news[j] = data[i];
			j++;
		}
	}
	
	return true;
}


NewsScroller.prototype.scroll2top = function () {
	if(this.cIndex == this.news.length) {
		this.cIndex = 0;
	}
	
	if(this.cDiv) {
		this.cDiv.style.display = 'none';
	}
	
	this.cDiv = this.news[this.cIndex];
	this.cDiv.style.marginTop = this.height + "px";
	this.cDiv.style.display = 'block';
	this.cDiv.style.position = 'absolute';
	
	this.timer = setInterval(this.name + ".scrollTop()", this.duration);
	
	this.cIndex++;
}


NewsScroller.prototype.scrollTop = function () {
	var dist = parseInt(this.cDiv.style.marginTop);
	
	if(dist < -this.cDiv.offsetHeight) {
		clearInterval(this.timer);
		this.scroll2top();
	} else if(dist > 0 && dist <= this.step) {
		clearInterval(this.timer);
		this.cDiv.style.marginTop = "0px";
		this.timer = setTimeout(this.name+".goOn('scrollTop')", this.delay);
	} else {
		this.cDiv.style.marginTop = (dist - this.step) + "px";
	}
}


NewsScroller.prototype.scroll2left = function () {
	if(this.cIndex == this.news.length) {
		this.cIndex = 0;
	}
	
	if(this.cDiv) {
		this.cDiv.style.display = 'none';
	}
	
	this.cDiv = this.news[this.cIndex];
	this.cDiv.style.marginLeft = this.width + "px";
	this.cDiv.style.display = 'block';
	
	
	this.timer = setInterval(this.name + ".scrollLeft()", this.duration);
	
	this.cIndex++;
}


NewsScroller.prototype.scrollLeft = function () {
	var dist = parseInt(this.cDiv.style.marginLeft);
	
	if(dist < -this.cDiv.offsetWidth) {
		clearInterval(this.timer);
		this.scroll2left();
	} else if(dist > 0 && dist <= this.step) {
		clearInterval(this.timer);
		this.cDiv.style.marginLeft = "0px";
		this.timer = setTimeout(this.name+".goOn('scrollLeft')", this.delay);
	} else {
		this.cDiv.style.marginLeft = (dist - this.step) + "px";
	}
}


NewsScroller.prototype.fade = function () {
	if(this.cIndex == this.news.length) {
		this.cIndex = 0;
	}
	
	this.cDiv = this.news[this.cIndex];
	if(is.IE) {
		this.cDiv.filters.alpha.opacity = 0;
	} else {
		this.cDiv.style.MozOpacity = 0;
	}
	this.cDiv.style.display = 'block';
	this.opc = 0;
	this.timer = setInterval(this.name + ".fadeIN()", this.duration);
	this.cIndex++;
}


NewsScroller.prototype.fadeIN = function () {
	if(this.opc >= 100) {
		clearInterval(this.timer);
		this.opc = 100;
		this.timer = setTimeout(this.name + ".goOn('fadeOUT')", this.delay);
	} else {
		this.opc += this.step;
		if(is.IE) {
			this.cDiv.filters.alpha.opacity = this.opc;
		} else {
			this.cDiv.style.MozOpacity = this.opc/100;
		}
	}
}


NewsScroller.prototype.fadeOUT = function () {
	if(this.opc <= 0) {
		clearInterval(this.timer);
		this.cDiv.style.display = 'none';
		this.fade();
	} else {
		this.opc -= this.step;
		if(is.IE) {
			this.cDiv.filters.alpha.opacity = this.opc;
		} else {
			this.cDiv.style.MozOpacity = this.opc/100;
		}
	}
}



NewsScroller.prototype.goOn = function (func) {
	this.timer = setInterval(this.name + "." + func + "()", this.duration);
}
