/*global $*/
var URUMI = {};

$(function () { 
	
	URUMI.UI = function () {
		
		var IE6 = false;
		
		function setVerticalAlign(element) {
			
			// top 5 items vertical align middle	
			$(element).each(function () {
				$(this).find('a').css({'padding-top': Math.ceil(Math.abs((($(this).height() - $(this).find('a').height()) / 2) - 1))});	
			});
		
		}

		function handleSearchField() {
			
			var search = $('#search'),
				defaultValue = search.val();

			search.bind('focus', function () {
				
				if (search.val() === defaultValue) {
					search.val('');
				}
				
			}).bind('blur', function () {
				
				if (search.val() === '') {
					search.val(defaultValue);
				}
				
			});
		
		}
		
		function checkForIE6() {
		
			return ($.browser.msie && $.browser.version < 7) ? true : false;
			
		}
		
		function runIe6Fixes() {
			
			$('.section .list li:first-child, .section .list dt:first-child, .products-by-alphabets li:first-child, .brands-and-products .products-by-alphabets h2:first-child, .brands-and-products .products-by-alphabets h2:first-child + ul').css({'borderTop': 0});
			
			if ($('.products-decoration-1').length > 0 && $('.products').length > 0) { 
				$('.products-decoration-1').css({'height': $('.products').height() - 36, 'left': '282px'});
			}
			
		}
		
		function init() {
			
			IE6 = checkForIE6();
			
			if (IE6) {
				
				runIe6Fixes();
			
			} 
			
			setVerticalAlign('.list-of-top5-products li');
			handleSearchField();
		
		}
		
		return {
			Init: init
		};
	
	}();
	
	URUMI.UI.Init();
	
});


