var oldpic = '';
function sadOn(url){
	var o = $('blogoimg');
	if(!o){
		return;
	}
	if(oldpic == ''){
		oldpic = o.src;
	}
	o.src = '/sadiki/img/'+url+'/blogo.jpg';
}
function sadOff(url){
	var o = $('blogoimg');
	if(!o){
		return;
	}
	o.src = oldpic
}

window.onload=function() {
	setTicker();	
}

function setTicker() {
	if ($('nttext')!=null) {
		var ticker = new marqueeText('nttext','roller');
		ticker.run();
	//	Event.observe($('nttext'), 'mouseover', function(){ticker.stoper()});
		Event.observe($('roller'), 'mouseover', ticker.stoper.bindAsEventListener(ticker));
		Event.observe($('roller'), 'mouseout', ticker.run.bindAsEventListener(ticker));
	}
	
}

var marqueeText = Class.create();
marqueeText.prototype = {
	initialize: function(obj,text,params) {
		/**Настраиваемые параметры*/
		this.textspeed = 37;
		this.period = 50;
		
		
		this.speed=this.textspeed
		
		this.obj = $(obj); //объект, (в котором все движется)
		$(text).style.display='none';
		this.ow = this.obj.offsetWidth; //ширина объекта
		this.text = $(text); //то что движется
		/**накладываем стили и делаем объект релативным*/
		this.obj.style.overflow="hidden";
		this.obj.style.height = '2em';
		this.obj.style.position='relative';
		
		/**накладываем стили и делаем текст абсолютным*/
		this.text.style.whiteSpace='nowrap';
		this.text.show();
		this.tw = this.text.offsetWidth;
		//alert(this.tw);
		this.text.style.display='block';
		this.text.style.position='absolute';
		
		/**сдвигаем текст почти в самый конец объекта*/
		this.ctl = this.ow-100;
		this.text.style.left=this.ctl+'px';
		this.isrun=false;
	},
	
	stoper: function() {
		this.speed = 0;
		
	},
	
	positioned: function(pe) {
		this.pe=pe;
		this.ctl = this.ctl-this.speed*(this.period/1000);
		if (this.ctl<-this.tw) {
			this.ctl=this.ow;
		}
		this.text.style.left=this.ctl+'px';
	},
	
	run: function(pe) {
		this.speed = this.textspeed;
		if (this.isrun) {
			return;
		}
		this.isrun = true;
		new PeriodicalExecuter(this.positioned.bind(this),this.period/1000);
	}
	
}

