
	/*
		Kezeli a bal oldali ajánlót, figyelembe véve, hogy melyik nyílra kattintott a felhasználó
	*/
	
	function leftScroll(m,p)
	{
		// képek száma
		this.maxThumbNails = m;
		
		// td azonosító
		this.prefix = p;
		
		// aktuális irány
		this.direction = '';
		
		// folyamatban van-e a lapozás
		this.process = 0;
		
		// automatikus lapozás timeout
		this.timeout = 10000;
		
		//elindult-e a loop
		this.loopStarted = false;
		
		// manuálisan lapoz-e a felhasználó
		this.manualPaging = false;
		
		// aktuális objektum
		this.currObj;
		
		// beállítja, hogy melyik elemről induljon a scrollozás, illetve reset-el is
		this.reset = function()
		{
			this.currObj = (this.direction == 'up') ? this.maxThumbNails : 1;
		};
		
		// léptet a következő ajánlóelemre 
		this.nextElement = function()
		{
			if (this.direction == 'up') this.currObj--; else this.currObj++;
		};
		
		// melyik oldalon vagyunk
		this.setDirection = function(direction)
		{
			this.direction = direction;
		};
		
		// elindítja az xhr-t
		this.getContent = function()
		{
			var url = "programs/ajax.php?xhr=leftscroll&languageID=" + languageID + "&direction=" + this.direction;
			var post = dojo.xhrPost(
			{
				url: url,
				sync: true,
				mimetype: "text/json-comment-filtered",
				encoding: "utf-8",
				load: function (data) { lSI.parseResponse(data); },
		        error: function(data) { this.showHTML(dict['xhrError']); }
			});
			this.fadeIn();
		};
		
		// feldolgozza a kérést
		
		this.parseResponse = function(data)
		{
			var pData = eval(data); // json adattömb
			var temp = "";

			for (var i = 0; i < pData.length; i++) // feltöltjük a cuccal
			{
				temp += "<table style=\"opacity: 0;\" class=\"lstable strip\" id=\"t_" + (i + 1) + "\">\n";
				temp += "<tr>\n";
				temp += "\t<td class=\"top\"></td>\n";
				temp += "</tr>\n";
				temp += "<tr>\n";
				temp += "\t<td class=\"cont\"><a href=\"" + pData[i]["url"] + "\" title=\"" + pData[i]["name"] + "\"><img src=\"" + pData[i]["image"] + "\" alt=\"" + pData[i]["name"] + "\" />" + pData[i]["name"] + "</a></td>\n";
				temp += "</tr>\n";
				temp += "<tr>\n";
				temp += "\t<td class=\"bottom\"></td>\n";
				temp += "</tr>\n";
				temp += "</table>\n\n";
			}
			this.showHTML(temp);
		};
		
		// loader mutatása a művelet alatt
		this.showHTML = function(message)
		{
			document.getElementById("sc").innerHTML = message;
		};
		
		// következő elem
		this.next = function()
		{
			this.manualPaging = true;
			this.setDirection('down');
			this.nav();
		};
		
		// előző elem
		this.previous = function()
		{
			this.manualPaging = true;
			this.setDirection('up');
			this.nav();
		};
		
		// fő nav metódus
		this.nav =  function()
		{
			if (this.process == 0)
			{
				this.showHTML(dict['loading']);
				this.process = 1;
				this.reset();	
				this.fadeOut();	
			} else return;
		};
		
		// eltűnteti az elemet
		this.fadeOut = function()
		{
			obj = document.getElementById(this.prefix + this.currObj);
			if (obj) // van ilyen?
			{	
				dojo.fadeOut({ node: this.prefix + this.currObj, duration: 150 }).play();
				this.nextElement();
				setTimeout("lSI.fadeOut()", 150);
			} else if (this.currObj > 0 && this.currObj <= this.maxThumbNails)
			{
				this.nextElement();
				this.fadeOut();
			} else 
			{
				this.reset();
				this.getContent();
				return;
			}
		};
		
		// előtűnteti az elemet
		this.fadeIn = function()
		{
			obj = document.getElementById(this.prefix + this.currObj);
			
			if (obj) // van ilyen?
			{
				dojo.fadeIn({ node: this.prefix + this.currObj, duration: 500 }).play();
				this.nextElement();
				setTimeout("lSI.fadeIn()", 150);
			} else if (this.currObj > 0 && this.currObj <= this.maxThumbNails)
			{
				this.nextElement();
				this.fadeIn();
			} else 
			{
				this.reset();
				this.process = 0;
				return;
			}
		};
		
		// automatikus lapozás indítása
		this.startLoop = function()
		{
			if (this.loopStarted == true)
			{
				this.loopNext();
			}
			setTimeout('lSI.startLoop()', this.timeout);
			this.loopStarted = true;
		};
		
		// loop next, ha nem lapoz még a felhasználó
		this.loopNext = function()
		{
			if (this.manualPaging == false)
			{
				this.setDirection('down');
				this.nav();
			}
		};
	}
	

