function Objectraktar() {
  this.cnt = 0;
  this.objects = new Array();
}
Objectraktar.prototype.add = function(obj){
	this.cnt++;
	this.objects[this.cnt] = obj;
	return this.cnt;
}
Objectraktar.prototype.del = function(obj){

}

var ObjectHolder = new Objectraktar();

function Effect(){
	this.vegeredmeny = 0;
	this.speed = 3;
	this.framePerSec = 60;
	this.intervalID = null;
	this.allapot = "zarva";
	this.obj = "";
	this.irany = "left";
	this.meret = 100;
	this.szam = 0;
	this.id = ObjectHolder.add(this);
	this.fadeObj;
	this.fadeState = false;
	this.browser = (document.all) ? "ie" : "moz";
}

//objektum id, irany, meret(%)-ban
Effect.prototype.show = function(objid,irany,meret) {
   var id = this.id;
   this.objid = objid;
   this.irany = irany;
   if (this.allapot == "nyitva") {
  	 this.vegeredmeny = -meret;
	 this.intervalID = window.setInterval("ObjectHolder.objects["+id+"].mozgat('"+objid+"','be')", this.getFramePerSec());
   } else {
     this.vegeredmeny = 0;
  	 this.intervalID = window.setInterval("ObjectHolder.objects["+id+"].mozgat('"+objid+"','ki')", this.getFramePerSec());
   }

}
Effect.prototype.fade = function(objid,opacity){
	this.fadeObj = document.getElementById(objid);
	if(this.fadeStat == false){
		this.opacity -= 10;
	}
	if (opacity >= 0) {
       obj.style.MozOpacity = opacity/100;
       
       window.setTimeout("ObjectHolder.objects["+id+"].fadeShow()", 1000);
    }
}
Effect.prototype.mozgat = function(objid,type) {
	var vege = false;
	var obj = document.getElementById(this.objid);
	var kezdes = this.getPosition(obj);
	var tavolsag = this.vegeredmeny - kezdes;
	var ut = tavolsag / this.speed;
	if (type == "ki") {
		ut /= 1.5;
	}
	if (tavolsag == Math.abs(tavolsag)) {
		if (ut < 1) {
			ut = 1;
		}
		if (kezdes + ut > this.vegeredmeny) {
			ut = this.vegeredmeny - kezdes;
		}
	} else {
		if (ut > -1) {
			ut = -1;
		}
		if (kezdes + ut < this.vegeredmeny) {
			ut = this.vegeredmeny - kezdes;
		}
	}
	if (kezdes + ut == this.vegeredmeny) {
		vege = true;
	}
	this.setPosition(obj,String(kezdes + ut) + "px");
	if (vege) {
		window.clearInterval(this.intervalID);
		if (this.allapot == "nyitva") {
			this.allapot = "zarva";
		} else {
			this.allapot = "nyitva";
		}
	}
}
Effect.prototype.fadeShow = function(objId,opacity) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
       obj.style.MozOpacity = opacity/100;
       opacity -= 10;
       window.setTimeout("Effect.fadeOut('"+objId+"',"+opacity+")", 1000);
    }
}
Effect.prototype.fadeOut = function(objId,opacity) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
       var opa = opacity/100;
       obj.style.MozOpacity = opa;
       //opacity -= 10;
       //window.setTimeout("Effect.fadeOut('"+objId+"',"+opacity+")", 1000);
    }
}
Effect.prototype.getFramePerSec = function() {
	return Math.round(1000 / this.framePerSec);
}
Effect.prototype.setSpeed = function(value){
	this.speed = value;
}
Effect.prototype.setFramePerSec = function(value){
	this.framePerSec = value;
}
Effect.prototype.Alert = function(msg){
	if(this.szam == 0){
		alert(msg);
		this.szam = 1;
	}
}
Effect.prototype.getPosition = function(obj){
	switch(this.irany){
		case 'top' : return parseInt(obj.style.top);break;
		case 'left' : return parseInt(obj.style.left);break;
		case 'right' : return parseInt(obj.style.right);break;
		case 'bottom' : return parseInt(obj.style.bottom);break;		
	}
}
Effect.prototype.setPosition = function(obj,pos){
	switch(this.irany){
		case 'top' : obj.style.top = pos;break;
		case 'left' : obj.style.left = pos;break;
		case 'right' : obj.style.right = pos;break;
		case 'bottom' : obj.style.bottom = pos;break;		
	}
}
var Effect = new Effect();
//var Effect1 = new Effect;
