var EffectEx={
	TimerId:null,
	Options:{
		From:0,
		To:1,
		X:0,
		Y:0,
		Delay:0,
		Duration:1
	},
	Transitions:{
		sinoidal: function(pos) {
			return (-Math.cos(pos*Math.PI)/2) + 0.5;
		},
		reverse: function(pos) {
			return 1-pos;
		},
		flicker: function(pos) {
			return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
		},
		wobble: function(pos) {
			return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
		},
		pulse: function(pos, pulses) {
			pulses = pulses || 5;
			return (
				Math.round((pos % (1/pulses)) * pulses) == 0 ? 
					((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : 
					1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
			);
		},
		none: function(pos) {
			return 0;
		},
		full: function(pos) {
			return 1;
		}
	},
	Scroll:function(element,x,y) {
		if(this.TimerId!=null) return;//Дабы не было нескольких нажатий. В MSIE отвратно выглядит...
		this.Element=document.getElementById(element);
		this.Position=0;
		this.Options.X=x;
		this.Options.Y=y;
		
		var timestamp = new Date().getTime();
		this.StartOn=this.Options.Delay*1000;
		this.FinishOn=this.StartOn + (this.Options.Duration*1000);
		this.StartOn+=timestamp;
		this.FinishOn+=timestamp;
		this.OriginalLeft=this.Element.scrollLeft;
		this.OriginalTop=this.Element.scrollTop;
		this.TimerId=window.setInterval(this.OnTimer.bind(this),15);
	},
	OnTimer:function() {
		var timestamp=new Date().getTime();
		if(timestamp>=this.StartOn)
		{
			if(timestamp>=this.FinishOn)
			{
				window.clearInterval(this.TimerId);
				this.TimerId=null;
			}
			else
			{
				var timePos=(timestamp - this.StartOn) / (this.FinishOn - this.StartOn);//TODO:Без точки с запятой код работает, а после Cruncher'а не работает
				var pos=this.Transitions.sinoidal(timePos);
				pos*=this.Options.To-this.Options.From;
				pos+=this.Options.From;
				this.Element.scrollLeft = this.Options.X * pos + this.OriginalLeft;
				this.Element.scrollTop  = this.Options.Y * pos + this.originalTop;
			}
		}
	}
};
