var svetskriniUI = function() {
	return {

		init : function() {
			this.fixFormLabels();
			this.homepageBubble();
			this.searchFieldStyling();
			this.switchEstablishments();
			this.zoomIcon();
			this.disableModules();
			this.notes();
			this.purchaseBubbles();
			this.purchaseHideParts();
		},
		
		

		fixIEOverflow : function(el) {
			if (!/*@cc_on!@*/0) return; // only apply to IE
			
			if (!el) {
				var el = document.getElementsByTagName('*'), i = el.length;
			} else {
				var el = [el], i = 1;
			}
			
			while (i--) {
				if (el[i].scrollWidth > el[i].offsetWidth) {
					el[i].style['paddingBottom'] = '20px';
					el[i].style['overflowY'] = 'hidden';
				}
			}
		},



		fixFormLabels : function() {
			$('label img').click(function() {
				$(this).parent().trigger('click');
			});
		},
		


		homepageBubble : function() {
			$('#logo a').bind('mouseenter', function() {
				$('#homepage-title').text('domovská stránka');
			}).bind('mouseleave', function() {
				$('#homepage-title').html('&nbsp;');
			});
		},



		searchFieldStyling : function() {
			$('#q').attr('value', 'Hledat…')
				.css('color', '#777')
				.bind('focus', function() {
					if ($(this).attr('value') != 'Hledat…')
						return;
					$(this).attr('value', '').css('color', '#000');
				})
				.bind('blur', function() {
					if ($(this).attr('value'))
						return;
					$(this).attr('value', 'Hledat…').css('color', '#777');
				});
			$('#search form').bind('submit', function() {
				if ($('#q').attr('value') == '' || $('#q').attr('value') == 'Hledat…') {
					alert('Zadejte hledaný výraz…');
					return false;
				}
			});
		},
		
		
		
		switchEstablishments : function() {
			$('#showRybare, #showJenisov').click(function() {
				if ($(this).hasClass('active')) return;
				$('#showRybare, #showJenisov').toggleClass('active');
				$('#visit-us .rybare, #visit-us .jenisov').toggleClass('hidden');
				$(this).blur();
				return false;
			});
		},
		
		
		
		zoomIcon : function() {
			$('.zooming').bind('mouseenter', function() {
				$(this).append('<span class="zoom"></span>');
			}).bind('mouseleave', function() {
				$('.zoom', this).remove();
			});
		},
		
		
		
		disableModules : function() {
			$('#modul-tabs > ul > li > a').click(function() {
				var className = $(this).parent().attr('class');
				if (className == 'nabytek' || className == 'kovani')
				{
					alert('Vážení návštěvníci, oddělení Nábytek a Kování právě připravujeme. Navštivte nás, prosíme, později. Děkujeme za pochopení.');
					return false;
				}
			});
		},



		notes : function() {
			$('.showNote').click(function()
			{
				var noteId = '#' + $(this).attr('rel');
				var noteOffset = 0;
				var trim = /(auto|px)$/; 
				noteOffset += ($(this).css('margin-bottom').replace(trim, '') * 1) + ($(this).parent().css('margin-bottom').replace(trim, '') * 1);
				noteOffset -= 10;
				$(noteId).css('margin-top', '-' + noteOffset + 'px');
				if ($(noteId).css('display') == 'none') {
					$(noteId).show();
				} else {
					$(noteId).slideUp(50);
				}
				$(this).trigger('blur');
				return false;
			});
		},
		
		
		
		purchaseBubbles : function() {
			$('.koncepce-skrine label').bind('mouseenter', function(e) {
				$('img', this).clone().attr('class', 'floatimg').appendTo('body').css('display', 'block').css('position', 'absolute').css('top', e.pageY).css('left', e.pageX + 25);
			}).bind('mousemove', function(e) {
				$('img.floatimg').css('top', e.pageY).css('left', e.pageX + 25);
			}).bind('mouseleave', function() {
				$('img.floatimg').remove();
			});
			$('.koncepce-skrine label img').parent().css('border-bottom', '1px dashed #aaa');
		},
		
		
		
		purchaseHideParts : function() {
			$('form.std fieldset.hide legend').bind('mouseenter', function(e) {
				$(this).css('color', '#54990f');
			}).bind('mouseleave', function(e) {
				$(this).css('color', '');
			}).bind('click', function() {
				$('table', $(this).parent()).slideDown(50);
				$(this).parent().removeClass('hide');
			});
		}

	};
}();
