


function nKep(id, x, y, nev, srcmin, srcminbw,  srcmed, srcmax, poz){
 this.id = id;
	this.x = x;
	this.y = y;
	this.nev = nev;
	this.srcmin = srcmin;
	this.srcminbw = srcminbw;
	this.srcmed = srcmed;
	this.srcmax = srcmax;
	this.poz = poz;
	}
	
var nKepek = Array();

function nFotokBetesz()
 {
	 h = "<table cellpadding=\"0\" cellspacing=\"0\"><tr>";
		tmp = 0;
	 for(i=0; i<nKepek.length; i++)
		 {
			 h += "\r\n<td><a href=\"javascript:;\" onClick=\"nBetesz(" + i + ", false);\"><img id=\"nkiskep" + i + "\" class=\"nkiskep\" src=\"" + nKepek[i].srcminbw + "\"></a></td>";
			 if(i<nKepek.length-1) h += "<td><img src=\"images/empty.gif\" width=8 height=0></td>";
				nKepek[i].poz = tmp;
				tmp += nKepek[i].x + 8;
			}
			
			h += "</tr></table>";
			$('#nav-sav').html(h);
			
		for(i=0; i<nKepek.length; i++)
		 {
			 kepAdd(nKepek[i].srcmed, '');
		 }	
			
			
 	return true;

	}

	function nScrollBarInit()
	{
	 v = document.getElementById('nav-cont').offsetWidth;  // tartalom div lathato hossza
		w = document.getElementById('nav-sav').offsetWidth;    // tartalom effektiv hossza
		y = document.getElementById('nscroll').offsetWidth;    // scroll terulet hossza
  if(v<w)  // ha a tartalom nagyobb, jeleitse meg a scroll bart (#npoz)
		 {
			 xw = v * y / w;                            // scrollbar hossza / scrool terulet hossza = tartalom lathato resze / tartalom effektiv hossza 
				xw = Math.round(xw);
			 $('#npoz').css('width', xw);
			}	
	}
	
function nBetesz(i, init)
  {
		$('#big').stop(1,1);
  $('#big').hide();
		h = "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"633\" height=\"403\" align=\"center\"><a href=\"javascript:;\" onClick=\"$('#kepmax" + nKepek[i].id + "').trigger('click');\"><img src=\"" + nKepek[i].srcmed + "\"></a></td></tr></table>";
		$('#big').html(h);
		
		$('#big').fadeIn(1200);
		var x = document.getElementById('nkiskep'+i);
			for(j=0; j<nKepek.length; j++)
				{
					$('#nkiskep' + j).attr('src', nKepek[j].srcminbw);
				}
			$('#nkiskep' + i).attr('src', nKepek[i].srcmin);
			
		
		 AktKep = i;
			
		 tmp1 = nKepek[AktKep].poz + nKepek[AktKep].x;
			tmp2 = nKepek[AktKep].poz; 
			
		if(tmp1 > v - AktPoz * Math.ceil(w/y)) { nScrollTo(nKepek[AktKep].poz - Math.ceil(y) + nKepek[AktKep].x +5);}
		 else 
			 if(tmp2 < (-1) * AktPoz * Math.ceil(w/y)) {   nScrollTo(nKepek[AktKep].poz - nKepek[AktKep].x	 ); }
			
			
		//	$('#po').html('nKepek[AktKep].poz: ' + nKepek[AktKep].poz + ', nKepek[AktKep].x:' + nKepek[AktKep].x + ', AktPoz: ' + AktPoz + ',v: ' + v );

			
			
			
	}



function nMozgat(event)
 {
	 if(!sbe) return false; // ha nincs lenyomva az eger gomb
		euj = event.clientX; // eger uj pozicioja mozgatas kozben
		nScrollAmount(euj-ex);
 }

function nScrollAmount(amount)
{
		mf = (-1)*(amount) + AktPoz;  
		
		if(mf>0) mf = 0; 
		if (xw>=mf+v) mf = xw - v;
		
		pf = (-1) * mf ;
		
  if(mf<=0 && y-xw>(-1)*mf)	 // a scroll fogantyu ferjen ne menjen ki a scrol teruletbol
		 {
			 $('#nav-sav').css('margin-left', mf * Math.ceil(w/y) +'px');
		  $('#npoz').css('margin-left', pf +'px');
			}
		//$('#po').html('v: ' + v + ', w:' + w + ', xw: ' + xw + ',euj: ' + euj + ', ex: ' + ex + ', mf: ' + mf + ', pf: ' + pf + ', AktPoz: ' + window.AktPoz );
	}


function nScrollTo(coord)
{
  
		mf = (-1) * (coord) / (w/y);  
		mf = Math.ceil(mf);
		
		if(mf>0) mf = 0; 
		if (xw>=mf+v) mf = xw - v;
		
		pf = (-1) * mf ;
		
  if(mf<=0)	 // a scroll fogantyu ferjen ne menjen ki a scrol teruletbol
		 {
			 $('#nav-sav').css('margin-left', mf * Math.ceil(w/y) +'px');
		  $('#npoz').css('margin-left', pf +'px');
				AktPoz = mf;
			} else alert('nem lehet');
		//	$('#po').html('v: ' + v + ', w:' + w + ', xw: ' + xw + ',euj: ' + euj + ', ex: ' + ex + ', mf: ' + mf + ', pf: ' + pf + ', AktPoz: ' + window.AktPoz );
	  
	
	
	}



