var jillylenauUI = function() {
	return {

		init : function() {
			this.fixFormLabels();
			this.homepageBubble();
			this.articlesHover();
			this.searchFieldStyling();
			this.addInCartDone();
			this.colours();
			this.storeRegions();

			// hvezdicka za povinne polozky ve form
			$('form label.required').each(function () {
				$(this).html($(this).text() + '<span>*</span>');
			});
			
			$('label[for=frmorder-platba-1]').each(function () {
				$(this).append($('<span class="cards-icon"><img src="/images/mask/icon-visa.png" alt="VISA" /><img src="/images/mask/icon-mastercard.png" alt="MC" /></span>'));
			});
		},
		
		

		storeRegions : function() {

			$('#stores h4.switcher, #company h3.switcher').click(function() {
				$(this).parent('.region, #company').toggleClass('collapsed');
				/*if (region.hasClass('collapsed')) {
					$('dl', region).slideDown(5000, function() {
						region.removeClass('collapsed');
					});
				}*/
			});
			
			$('#stores-map area').click(function() {
				$('#company').addClass('collapsed');
				$('.region').addClass('collapsed');
				$('.region[title=' + $(this).attr('alt') + ']').toggleClass('collapsed');
				return false;
			});
		},



		colours : function() {
			$('#colour-card .classic').click(function() {
				$('#colour-card a').removeClass('active');
				$('a', this).addClass('active').trigger('blur');
				$('.classic-scheme').addClass('hidden');
				$('div[title="' + $(this).text() + '"]').removeClass('hidden');
			});

			$('#colour-card .classic, #colour-card .trend').click(function() {
				$('select[name=colour]').val($(this).attr('title')).after(
					$('<div id="ajax-spinner"></div>').css({
						position: 'absolute',
						right: -22,
						top: 2
					})
				);
				$('#ajax-spinner').fadeOut(1200, function() { $(this).remove(); });
			});
		},
		


		fixFormLabels : function() {
			$('label img').click(function() {
				$(this).parent().trigger('click');
			});
		},
		


		homepageBubble : function() {
			$('#logo a').bind('mouseenter', function() {
				$('#homepage-title').text('úvodní stránka');
			}).bind('mouseleave', function() {
				$('#homepage-title').html('&nbsp;');
			});
		},



		articlesHover : function() {
			$('.product').bind('mouseover', function() {
				$('.small-photo', this).addClass('hover');
			}).bind('mouseout', function() {
				$('.small-photo', this).removeClass('hover');
			});
		},



		searchFieldStyling : function() {
			$('#q').attr('value', 'Hledaný výraz…')
				.css('color', '#777')
				.bind('focus', function() {
					if ($(this).attr('value') != 'Hledaný výraz…')
						return;
					$(this).attr('value', '').css('color', '#000');
				})
				.bind('blur', function() {
					if ($(this).attr('value'))
						return;
					$(this).attr('value', 'Hledaný výraz…').css('color', '#777');
				});
			$('#search form').bind('submit', function() {
				if ($('#q').attr('value') == '' || $('#q').attr('value') == 'Hledaný výraz…') {
					alert('Zadejte hledaný výraz…');
					return false;
				}
			});
		},



		addInCartDone : function() {
			$('li.basket a.ajax').bind('click', function() {
				$(this).bind('ajaxSuccess', function() {
					$(this).attr('href', jQueryData.link)
						.attr('class', '')
						.addClass('done')
						.html('v&nbsp;košíku')
						.attr('title', 'Přejít do košíku');
				}).trigger('blur');
			});
		}

	};
}();
