$(document).ready(function() {    
	$('form table tr.required label').append("<span class='required'>*</span>");

	// empty values na nette formulare
    $('input[type="text"]').emptyNetteValue();

    $("a.ajax").live('click', function() {
        $.get(this.href);
        return false;
    });

	$("form.ajax").submit(function() {
		$(this).ajaxSubmit();
		return false;
	});

	$('.lightbox a.lbitem').lightBox({
		imageLoading: '/components/lightbox/images/lightbox-ico-loading.gif',
		imageBtnClose: '/components/lightbox/images/lightbox-btn-close.gif',
		imageBtnPrev: '/components/lightbox/images/lightbox-btn-prev.gif',
		imageBtnNext: '/components/lightbox/images/lightbox-btn-next.gif'
	});	

	$(".banner").click(function() {
		var id = this.id.replace('banner_', '');
		$.ajax({url:'/banners/clicked/', data:{id: id}, type:'post'});
	});

	// v mainproducts je inicializacia dnu v produkte
	$("#rightmenu div.product select, #introproducts div.product select").selectBox({
		'menuTransition': 'fade',
		'menuSpeed' : 'fast'
	});

	$("a.addToCart").live('click', function(event){
		event.preventDefault();
		var selected = $(this).parent().parent().find('select.addToCartSize option:selected');//.selected();
		var idvariant = selected.val();
		var href = $(this).attr('href') + '&idv='+idvariant;
		document.location = href;
		return false;
	});

	$("#brands ul").addClass('smallsize');
	$("#brands ul").hoverClass('scrollable');

	$("#BrandRelegOptions a").click(function() {
		setMode(this.rel, true);
		return false;
	});	
});

function setMode(mode, member) {
	if(member) $.cookie('mode', mode, {path: '/'});
	var id = mode+'Options';
	$("#brands ul").hide();
	$("#"+id).show();

	$("#BrandRelegOptions a").removeClass('active');
	$("#BrandRelegOptions a.c"+mode).addClass('active');
}

