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ÇİŞ");
		}
	}
}


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(browser.isIE) {
		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(browser.isIE) {
			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(browser.isIE) {
			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);
}


function BrowserDetect(){
var ua=navigator.userAgent.toLowerCase(); 
	this.isGecko=(ua.indexOf('gecko')!=-1 && ua.indexOf('safari')==-1);
	this.isAppleWebKit=(ua.indexOf('applewebkit')!=-1);

	this.isSafari=(ua.indexOf('safari')!=- 1);
	this.isIE=(ua.indexOf('msie')!=-1 && !this.isOpera && (ua.indexOf('webtv')==-1)); 
	this.isMozilla=(this.isGecko && ua.indexOf('gecko/')+14==ua.length);
	this.isFirebird=(ua.indexOf('firebird/')!=-1);
	this.isNS=((this.isGecko)?(ua.indexOf('netscape')!=-1):((ua.indexOf('mozilla')!=-1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible')==-1) && (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1)));

	this.isIECompatible=((ua.indexOf('msie')!=-1) && !this.isIE);

	this.geckoVersion=((this.isGecko)?ua.substring((ua.lastIndexOf('gecko/')+6), (ua.lastIndexOf('gecko/')+14)):-1);
	this.equivalentMozilla=((this.isGecko)?parseFloat(ua.substring(ua.indexOf('rv:')+3)):-1);
	this.appleWebKitVersion=((this.isAppleWebKit) ? parseFloat(ua.substring(ua.indexOf('applewebkit/')+12)):-1);

	this.versionMinor=parseFloat(navigator.appVersion); 

	if(this.isGecko && !this.isMozilla) this.versionMinor=parseFloat(ua.substring(ua.indexOf('/', ua.indexOf('gecko/')+6)+1));
	else if(this.isMozilla) this.versionMinor=parseFloat(ua.substring(ua.indexOf('rv:')+3));
	else if(this.isIE && this.versionMinor>=4) this.versionMinor=parseFloat(ua.substring(ua.indexOf('msie ')+5));
	else if(this.isSafari) this.versionMinor=parseFloat(ua.substring(ua.lastIndexOf('safari/')+7));

	this.versionMajor=parseInt(this.versionMinor); 

	this.isDOM1=(document.getElementById);
	this.isDOM2Event=(document.addEventListener && document.removeEventListener);

	this.mode=document.compatMode?document.compatMode:'BackCompat';

	this.isWin=(ua.indexOf('win')!=-1);
	this.isMac=(ua.indexOf('mac')!=-1);

	this.isNS6x=(this.isNS && this.versionMajor==6);
	this.isNS6up=(this.isNS && this.versionMajor>= 6);
	this.isNS7x=(this.isNS && this.versionMajor==7);
	this.isNS7up=(this.isNS && this.versionMajor>= 7);
	this.isIE5x=(this.isIE && this.versionMajor==5);
	this.isIE55=(this.isIE && this.versionMinor==5.5);
	this.isIE5up=(this.isIE && this.versionMajor>= 5);
	this.isIE6x=(this.isIE && this.versionMajor==6);
	this.isIE6up=(this.isIE && this.versionMajor>= 6);
}
var browser=new BrowserDetect();




function Browser() {
		var b=navigator.appName;
		if (b=="Netscape") this.b="ns";
		else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
		else if (b=="Microsoft Internet Explorer") this.b="ie";
		if (!b) alert('Unidentified browser./nThis browser is not supported,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6=(this.version.indexOf('MSIE 6')>0);
	this.opera=(this.b=="opera");
	this.dom=(document.createElement && document.appendChild && document.getElementsByTagName)?true:false;
	this.def=(this.ie||this.dom); // most used browsers, for faster if loops
	var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win32";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";
}

is = new Browser();


