var pi = 4.0*Math.atan(1.0);
var tmp_left = 250;
var tmp_top = 0;
var tmp_bottom = 60;
var tmp_z = 100;
var tmp_op = 100;
var tmp_a = 0;
var drawing = 0;
var t;
var ItemList = new Array();
var div_width = 0;

var moving=0;
var tempX, tempY;
var futas = 0;
var atlagido = 0;

  function BemutatkozoItem(_id, _nev, _lead, _name, w_s, h_s, _link) {
  	this.id = _id;
  	this.nev = _nev;
  	this.name = _name;
  	this.width_small = w_s;
  	this.height_small = h_s;
  	this.lead = _lead;
  	this.link = _link;
	this.left = (_id*205)+Math.round((205-this.width_small)/2);
	this.top = Math.round((128-this.height_small)/2);
  }
  
  BemutatkozoItem.prototype.Show = function() {
  	if(!document.getElementById('bemutatkozo_'+this.id+'_Img')) {
  		document.getElementById("bemutatkozo_alap").innerHTML+='<img id="bemutatkozo_'+this.id+'_Img" src="'+url+this.name+'" style="left: 0px; z-index: 55; opacity:1.0; filter:alpha(opacity=100); cursor: pointer;" class="bemutatkozo" title="'+this.nev+'" onClick="document.location.href=\''+this.link+'\'">\n';
  	}

  	var div1 = document.getElementById('bemutatkozo_'+this.id+'_Img');
	
	if((this.left>=-205) && (this.left<205)) {
		div1.style.display='';
		div1.style.left = this.left+'px';
		div1.style.top = this.top+'px';
		div1.style.width = this.width_small+'px';
		div1.style.height = this.height_small+'px';
	}
	else div1.style.display='none';
	
	if(this.left==Math.round((205-this.width_small)/2)) {
		document.getElementById('bemutatkozo_nev').innerHTML="Bemutatkozik: <a href=\""+this.link+"\"><span>"+this.nev+"</span></a>";
		document.getElementById('bemutatkozo_szoveg').innerHTML=this.lead+'<a href="'+this.link+'">Tovább...</a>';
		ShowHideBemutatkozo(0,100,'bemutatkozo_nev');
		ShowHideBemutatkozo(0,100,'bemutatkozo_szoveg');
	}
  }
  
  BemutatkozoItem.prototype.CreatePos = function(_dif) {
  	if(_dif) {
  		var tmp = new Number(this.left);
  		tmp+=_dif;
  		this.left=tmp;
  	}
	this.Show();
	return this.left;
  }
  
  Array.prototype.ShowBemutatkozo = function(irany,tav) {
	this.moving=1;
	var def_dif = 0;
	var akt_left, akt_right, class_left, class_right;

	if(!tav) {
		if((irany>0) && (this[this.length-1].left>205)) {
			tav = 205;
		}
		else if (irany<0) {
			if(this[0].left>=(Math.round((205-this[0].width_small)/2))) {
				tav = 0;
			}
			else {
				tav = 205;
			}
		}
		else {
			tav=0;
		}
	}

	if(tav) {
		def_dif = Math.ceil(tav/8);
		tav = tav-def_dif;
	}
	else {
		def_dif = 0;
	}

  	for(var i=0; i<this.length; i++) {
		if(irany>0) {
			this[i].CreatePos(0-def_dif);		// Balra megy
		}
		else if (irany<0) {
			this[i].CreatePos(def_dif);	// Jobbra megy
		}
		else this[i].CreatePos(0);
		if(this[i].left==(Math.round((205-this[i].width_small)/2))) van_null=1;
  	}

	if(this[0].left>=0) {
		akt_left = 0;
		class_left = 'mozgatas_inaktiv';
		document.getElementById('bemutatkozo_balra').style.display='none';
	}
	else {
		akt_left = 70;
		class_left = 'mozgatas';
		document.getElementById('bemutatkozo_balra').style.display='';
	}

	if(this[this.length-1].left<205) {
		akt_right = 0;
		class_right = 'mozgatas_inaktiv';
		document.getElementById('bemutatkozo_jobbra').style.display='none';
	}
	else {
		akt_right = 70;
		class_right = 'mozgatas';
		document.getElementById('bemutatkozo_jobbra').style.display='';
	}

	if(isIE) {
		document.getElementById('bemutatkozo_balra').filters.alpha.opacity = akt_left;
		document.getElementById('bemutatkozo_jobbra').filters.alpha.opacity = akt_right;
	}
	else {
		document.getElementById('bemutatkozo_balra').style.opacity = akt_left/100;
		document.getElementById('bemutatkozo_jobbra').style.opacity = akt_right/100;
	}
	document.getElementById('bemutatkozo_balra').className = class_left;
	document.getElementById('bemutatkozo_jobbra').className = class_right;
	if(tav) {
		setTimeout("BemutatkozoList.ShowBemutatkozo("+irany+","+tav+")",'30');
	} 
	else {
		this.moving=0;
		return true;
	}
  }
  
  Array.prototype.ShowBig = 0;

  function ChangeBemutatkozo(_irany) {
  	if(!BemutatkozoList.moving) {
		ShowHideBemutatkozo(100,0,'bemutatkozo_nev');
		ShowHideBemutatkozo(100,0,'bemutatkozo_szoveg');
  		BemutatkozoList.ShowBemutatkozo(_irany);
  	}
  }
  
  function ShowHideBemutatkozo(_akt, _cel, _div) {
	var div = document.getElementById(_div);
//  	var div2 = document.getElementById('galeria_text');
	
	if(_cel==0) var akt=_akt-10;
	else var akt=_akt+10;
	if(isIE) {
		div.filters.alpha.opacity = akt;
//		div2.filters.alpha.opacity = akt;
	}
	else {
		div.style.opacity = (akt/100);
//		div2.style.opacity = (akt/100);
	}
	if(akt==_cel) {
		if(_cel==0) {
//			div.innerHTML = "";
		}
	}
	else {
		if(_cel==0)	setTimeout("ShowHideBemutatkozo("+akt+", "+_cel+", '"+_div+"')",'40');
		else setTimeout("ShowHideBemutatkozo("+akt+", "+_cel+", '"+_div+"')",'20');
	}	
  }

