/**
	params:
		- win_id : window id
		- objName : obj példány neve

*/

function sliderwindow_class(params) {
	this.objName = params['objName']
	this.obj = document.getElementById(params['win_id']);
	this.obj.op = 100;
	this.xPos = -this.obj.offsetWidth;
	this.speed = 20;
	this.gyorsulas = 0.4;
	this.maxSpeed = 20;
	var size = getPageSize();
	this.centerPos = Math.round(size[0]/2-this.obj.offsetWidth/2);
	this.fadeOut = sliderwindow_fadeOut;
	this.setOpacity = sliderwindow_setOpacity;
	this.sliding = sliderwindow_sliding;
	this.sliding();
}

function sliderwindow_sliding() {
	var irany = 0;
	if (this.centerPos>this.xPos) irany = 1;
	else irany = -1;

	var fek = 0;
	if (Math.abs(this.xPos-this.centerPos)<100) {
		fek = this.gyorsulas*-0.5;
	}

	if ( ( (this.speed>0) && (irany<0) ) ||
		 ( (this.speed<0) && (irany>0) ) ) {
		this.speed += this.gyorsulas*irany*3;
	} else {
		this.speed += this.gyorsulas*irany*fek;
	}
	this.speed += this.gyorsulas*irany;
	if (Math.abs(this.speed)>this.maxSpeed) this.speed = (this.speed>0?this.maxSpeed:-this.maxSpeed);
	this.xPos += this.speed;
	this.obj.style.left = this.xPos+'px';
	if ( (Math.round(this.xPos)!=Math.round(this.centerPos)) || (Math.abs(this.speed)>1) )
		setTimeout(this.objName+'.sliding()',10);
}

function sliderwindow_fadeOut() {
	this.obj.op -= 4;
	if (this.obj.op<0) this.obj.op = 100;
	this.setOpacity(this.obj);
	if (this.obj.op>0)
		setTimeout(this.objName+'.fadeOut()',10);
	else this.obj.style.display = 'none';
}

function sliderwindow_setOpacity(obj) {
	obj.style.filter = 'alpha(opacity='+obj.op+')';
	obj.style.mozOpacity = obj.op/100.0;
	obj.style.opacity = obj.op/100.0;
}