




// termekkep popup
function prodpic_popupwindow()
{
	var p = $('termek_pic');
	p.addEvent('click', function()
	{
		//alert(p.getProperty('href'));
		var img = p.getProperty('href');
		pw = window.open('', 'pw', 'height=510,width=510,left=100,resizable=no');
		pw.document.write('<html><body style="margin: 0px; padding: 0px;"><div style="text-align: center;"><img src="'+img+'" /></div></body></html>');
		pw.document.close();
	});
}
//










// sajtobejelentes megejelnites
function show_press()
{
	// hozzarendeljuk a gombhoz
	$$('a[name=pressLink]').addEvent('click', function() {
		$('pressContainer').setStyle('display', 'block');
		//alert('a');
	});
}
//










// lista szempontok valtoztatasa legordulok
function propFilter_bindbuttons()
{
	$$('.propFiler').getElements('select').each
	(
		function(sel)
		{
			sel.addEvent( 'change', function(){$('propFilerForm').submit()} );
		}
	)
}










// tabok kapcsolgatasa
var Tabber = new Class
({
	//
	initialize: function(ezu)
	{
		// termek id el van rejtve faszan a kodban
		var s = $('termekPageTabContainer').getProperty('name').split('|');
		this.termek_id = s[1];
		this.activeTab = '';

		// tab fulek (ears, hahaha, ez nagyonjo!)
		this.ears = $A( $('termekPageTabHeaders').getElements('a') );
		this.ears.each
		(
			function(button)
			{
				tabN = button.getProperty('name');
				button.addEvent( 'click', this.switchTab.bindAsEventListener(this, tabN) );
			}.bind(this)
		);
	},


	//
	switchTab: function(dis, tabName)
	{
		//alert(tabName);
		dis.activeTab = tabName;

		// leszipkazza a cuccost
		new Ajax('/ajaxz/product_tabs.php',
		{
			method: 'post',
			data: 'termek=' + this.termek_id + '&tab=' + tabName,
			update: $('termekPageTabContent'),
			evalScripts: true
		}).request();


		// tab allitgatas
		this.ears.each
		(
			function(button)
			{
				tabN = button.getProperty('name');
				if (dis.activeTab==tabN)
					button.addClass('active');
				else
					button.removeClass('active');
			}
		);

		// print view link beallitas
		if ($('printview_link'))
		{
			var pvl = $('printview_link').getProperty('href');
			var pvl_A = pvl.split('/');
			var curT = pvl_A.getLast();
			var newLink = pvl.replace(curT, tabName);
			$('printview_link').setProperty('href', newLink);
		}

	}

});










// cuccok
window.addEvent('domready', function()
{
	// lista szempontok valtoztatasa legordulok
	if ( $$('.propFiler') )
		propFilter_bindbuttons();


	// tabok
	if ( $('termekPageTabContainer') )
	{
		myCoolTabber = new Tabber( $('termekPageTabContainer') );
	}

	// sajtolink ha van
	if ($$('a[name=pressLink]'))
	{
		show_press();
	}

	// termek pic pop
	if ($('termek_pic'))
	{
		prodpic_popupwindow();
	}
}
);
