





// termek kep kinagyito   #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
function termek_pics()
{
	var pics = $A($$('img.termek_foto_thumb'));

	pics.each
	(
		function(p)
		{
			p.addEvent('click', function()
			{
				// nagykep src
				var termek_id = p.getProperty('name').replace('tpic', '').toInt();

				//alert(termek_id);
				popwindow(625, 675, '/popup_content/termekgaleria.php?t='+termek_id);

/*
				// kep meretek a name properyben
				var psize = p.getProperty('name').split('|');
				var dwid = psize[0].toInt();
				var dhei = psize[1].toInt() + 21;
*/
				// popupba a kep

				// dialogba a kep
				/*
				var d = new PopDialog(true, dwid, dhei);
				d.clearbg();
				d.show('<img src="'+gal_pic+'" alt="" />');
				*/
			});
		}
	);
}
//










// kosar gombok  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
var Kosarbuttons = new Class
({

	initialize: function ()
	{
		// vegigszaladunk a kosargombokon
		var kosarA = $A($$('input.addToCart_btn'));
		//
		kosarA.each
		(
			function(k)
			{
				//k.addEvent('click', this.add_to_cart.bindAsEventListener(this, k));
				k.addEvent('click', function(){this.add_to_cart(k)}.bind(this));
			}.bind(this)
		);
	},



	//
	add_to_cart: function(k)
	{
		// termek id
		var termek_id = k.id.replace('addToCart_btn_', ''); //alert(termek_id);

		// termek szam
		var termek_num = $('addToCart_num_'+termek_id).getValue(); //alert(termek_num);


		// berakas siker ajax
		if (termek_num>0)
		{
			// kosar
			new Ajax('/remote/add_to_cart.php',
			{
				method: 'post',
				data: 'termek=' + termek_id + '&num=' + termek_num,
				//update: $('cartQuantity')//,
				onComplete: function(response)
				{//alert(response);

					var Addttocart_dialog = new PopDialog();
					Addttocart_dialog.show(response);

					$('addtocart_close').addEvent('click', function(){Addttocart_dialog.hide()});
				},
				evalScripts: true
			}).request();
		}
		// ha nem oke a termekszam, akkor figyelmeztetjuk
		else
		{
			var d = new PopDialog();
			d.show('<div class="add2cart_content"><div class="title add2cart_title "></div><div class="text"><br/><br/>Adja meg a darabszámot!</div></div>');
		}
	}
});










// subtermek adat berako fuggveny  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
function subtermek(id)
{
	// dropdown elem
	var drop = $(id);

	// valasztott subtermek id
	var sub_id = drop.getValue(); //alert(sub_id);

	// termek id
	var termek_id = drop.id.replace('sub_dropdown_', '');	//alert(termek_id);

	// data container
	var s1Cnt = $('dyn1_data_'+termek_id); //sCnt.setHTML('t:'+termek_id+'s'+sub_id);
	// ikon container
	var s2Cnt = $('dyn2_data_'+termek_id); //sCnt.setHTML('t:'+termek_id+'s'+sub_id);

	// adaokt ajaxbul
	new Ajax('/remote/subtermek_data.php',
	{
		method: 'post',
		data: 'blokk=' + termek_id + '&sub=' + sub_id,
		//update: s1Cnt
		onComplete: function(response)
		{
			var respS = response.split('|||');
			//alert(respS[1]);
			s1Cnt.setHTML(respS[0]);
			s2Cnt.setHTML(respS[1]);
		}
	}).request();

}










// betoltes utan lefut
window.addEvent('load', function(){

	// kosar gombok
	Kosarbuttons_obj = new Kosarbuttons();

	// termekfotok
	if ($$('img.termek_foto_thumb'))
		termek_pics();

/*
	// termek ajanlasok NINCS ITT
	if ($$('a.ajanlas'))
		Termek_ajanlas_obj = new Termek_ajanlas();
*/

/*
	// termek tooltips MAR NEMKELL
	if ($$('a.ajanlas'))
		TermekTooltips = new Termektooltip_();
*/

});
