function userData(context) {
	$('.filtrAndOrder').make('filtrAndOrder');
	$('div.productItemQuote div.buy input[type=submit]').make('quoteForm');
};

$(document).ready(function() {
	userData();
	
	//$('input.nhFilled').hide();
	
	/*********************************/
	/*       ESHOP    */
	
	//množstevní ceny
	$('#productDetail tr.priceGross').hover(function () {
		$('#amountPrices').fadeIn(300);
	}, function () {
		$('#amountPrices').fadeOut(300);
	});
	
	//kontrola zadání atributů
	$('div.attributeArea').closest('form').submit(function () {
		notFilled = 0;
		$('select', this).each(function () {
			if ($('option:selected', this).length == 0 || $('option:selected', this).attr('value') == '0') {
				notFilled++;
			}
		});
		var names = [];
		var count = 0;
		$('input:radio', this).each(function() { // find unique names
			//names = true;
			names[$(this).attr('name').replace('[', '').replace(']', '')] = true;
		});
		for (var i in names) {
			count = count + 1;
		}
		if (count > $('input[type=radio]:checked', this).length) {
			notFilled++;
		}
		if (notFilled > 0) {
			alert(lang.eshop_ProductCouldNotBeAdded_missingAttr);
			return false;
		}
	});
	
	//samoodesílací select
	$('select.autoSubmit').change(function () {
		$(this).closest('form').submit();
	});
	
	//odebrání z košíku
	$('#eshopOrderForm input.countRemove').click(function () {
		$(this).closest('tr').find('input[type=number]').val(0)
	});
	
	//zavírací tlačítko
	$('a.close').click(function () {
		$(this).closest('.toClose').hide();
		return false;
	});
	
	//otvírací tlačítko
	$('.clickOpen').click(function () {
		this.xopen = $(this).data('open');
		if ( $('#'+ this.xopen).css('display') == 'block' ) {
			$('#'+ this.xopen).hide();
		}
		else {
			$('#'+ this.xopen).show();
		}
		
	});
	
	//galerie - detail produktu
	$('#thumbMover .mover').bind('click',function () {
		this.xcontext = $('#thumbMover');
		this.xtoBeMoved = $('div.inner', this.xcontext);
		this.xdirection = $(this).attr('rel');
		this.xmultiplier = this.xdirection == 'left' ? -1 : 1;
		$(this.xtoBeMoved).scrollLeft( $(this.xtoBeMoved).scrollLeft() + this.xmultiplier * 50 );
		return false;
	});
	
	//obecné taby
	$('div.tabs').each(function () {
		this.xhash = window.location.href.replace(/^(.*)#(.*)$/,'$2');
		this.xcontextMenu = $('div.tabList', this);
		if ( $('#tab_'+ this.xhash, this).length == 1 ) {
			this.xcurrent = 'tab_'+ this.xhash;
		}
		else {
			this.xcurrent = $('div.tab', this).eq(0).attr('id');
			this.xhash = this.xcurrent.replace(/tab_/,'');
		}
		//deaktivovat v menu
		$('a', this.xcontextMenu).removeClass('active');
		//aktivovat v menu
		$('a[href=#'+ this.xhash +']', this.xcontextMenu).addClass('active');
		//schovat všechny taby
		$('div.tab', this).hide().removeClass('active');
		//aktivovat aktuální tab
		$('#'+ this.xcurrent, this).show().addClass('active');
		
	});
	$('div.tabList a').click(function () {
		this.xcontext = $(this).closest('div.tabs');
		this.xcontextMenu = $(this).closest('div.tabList');
		this.xcurrent = $(this).attr('href').replace(/(.*)#(.*)/,'$2');
		//deaktivovat v menu
		$('a', this.xcontextMenu).removeClass('active');
		//aktivovat v menu
		$(this).addClass('active');
		//schovat všechny taby
		$('div.tab', this.xcontext).hide().removeClass('active');;
		//aktivovat aktuální tab
		$('#tab_'+ this.xcurrent, this.xcontext).show().addClass('active');
	});
	
	//platební metody v objednávce, doručení
	$('input.radioLike').live('change', function () {
		$('input.radioLike[name='+ this.name +']').not(this).removeAttr('checked');
	});
	
	$('#eshopOrderPaymentMethods input[type=checkbox]').live('change', function () {
		this.xclosure = $(this).closest('div');
		this.xselectedVal = $('#eshopOrderDeliveryMethods input[name=delivery_method_id]:checked').val();
		this.xvalue = $('input[name=payment_method_id]:checked', this.xclosure).val() == undefined ? 0 : $('input[name=payment_method_id]:checked', this.xclosure).val();
		this.orderListTable = $('#orderListTable');
		
		$(this).next().after('<img src="/images/loading.gif" class="xloading" />');
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: langURL +'ajax/eshop/delivery_for_payment/',
			data: {payment_id: Number(this.xvalue)}, 
			context: this, 
			success: function (data) {
				$('#eshopOrderDeliveryMethods').empty().append(data.data).find('input[value='+ this.xselectedVal +']').attr('checked', 'checked');
			}
		});
		//přidat řádek do objednávky
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: langURL +'ajax/eshop/payment_info/',
			data: {payment_id: Number(this.xvalue)}, 
			context: this, 
			success: function (data) {
				$('tr.payment', this.orderListTable).html(data.data)
				$('tr.sum', this.orderListTable).find('td.sumValue').html(data.sum);
				$('tr.sumVat', this.orderListTable).find('.value').html(data.vat);
				$('img.xloading', this.xclosure).remove();
			}
		});
	});
	
	//způsoby doručení
	$('#eshopOrderDeliveryMethods input[type=checkbox]').live('change', function () {
		this.xclosure = $(this).closest('div');
		this.xselectedVal = $('#eshopOrderPaymentMethods input[name=payment_method_id]:checked').val();
		this.xvalue = $('input[name=delivery_method_id]:checked', this.xclosure).val() == undefined ? 0 : $('input[name=delivery_method_id]:checked', this.xclosure).val();
		this.orderListTable = $('#orderListTable');
		
		$(this).next().after('<img src="/images/loading.gif" class="xloading" />');
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: langURL +'ajax/eshop/payment_for_delivery/',
			data: {delivery_id: Number(this.xvalue)}, 
			context: this, 
			success: function (data) {
				$('#eshopOrderPaymentMethods').empty().append(data.data).find('input[value='+ this.xselectedVal +']').attr('checked', 'checked');
			}
		});
		//přidat řádek do objednávky
		$.ajax({
			type: 'POST',
			dataType: 'json',
			url: langURL +'ajax/eshop/delivery_info/',
			data: {delivery_id: Number(this.xvalue)}, 
			context: this, 
			error: function (a,b,c) {//alert(b)
			},
			success: function (data) {
				$('tr.delivery', this.orderListTable).html(data.data);
				$('tr.sum', this.orderListTable).find('td.sumValue').html(data.sum);
				$('tr.sumVat', this.orderListTable).find('.value').html(data.vat);
				$('img.xloading', this.xclosure).remove();
			}
		});
	});
	
	//fakturační adresa?
	$('#billingAddressSwitch input[type=radio]').change(function () {
		switch ( this.value ) {
			case '0': {
				$('#eshopOrderBillingAddress').hide(0);
				break;
			}
			case '1': {
				$('#eshopOrderBillingAddress').show(0);
				break;
			}
		}
	});
	
	//typ uživatele v objednávce
	$('#eshopOrderFormUserVariant input[type=radio]').change(function () {
		$('fieldset.userVariantForm').hide(0);
		
		switch ( this.value ) {
			case '0': {
				$('#eshopOrderNoUserForm').show(0);
				break;
			}
			case '1': {
				$('#eshopOrderLoginForm').show(0);
				break;
			}
			case '2': {
				$('#eshopOrderRegisterForm').show(0);
				break;
			}
		}
	});
	
	//kategorie - rozbalování
	$('#eshopSideCategory span.trigger').live('click', function () {
		this.closure = $(this).closest('li');
		//pokud již je podkategorie načtena, zobrazit ji
		if ( $('ul', this.closure).length > 0 && $('ul:first', this.closure).css('display') == 'none' ) {
			$('ul:first', this.closure).show();
			$(this).removeClass('closed').addClass('open');
			$(this.closure).addClass('active');
		}
		//pokud již je podkategorie načtena, skrýt ji
		else if ( $('ul', this.closure).length > 0 && $('ul:first', this.closure).css('display') != 'none' ) {
			$('ul:first', this.closure).hide();
			$(this).removeClass('open').addClass('closed');
			$(this.closure).removeClass('active');
		}
		//načíst podkategorie, zobrazit
		else if ( !$(this).hasClass('noplus') ) {
			$(this.closure).append('<div class="loading"></div>');
			$.ajax({
				type: 'get', 
				url: langURL +'ajax/category/',
				async: false, 
				data: ({category_id: $(this).data('xid')}),
				context: this, 
				error: function (a,b,c) {
					alert(c)
				},
				success: function (data) {
					$('div.loading', this.closure).remove();
					$(this.closure).addClass('active').append(data);
					$(this).removeClass('closed').addClass('open');
				}
			})
		}
		return false;
	})
	/*  END ESHOP */
	/*************************************/

});
