	$(document).ready(function() {
		$(".language > a").mouseenter(function() {
			var position = $(this).position();
			position.top -= 6;
			position.left -= 9;
			$(".languages").css(position).show();
		});
		$(".catalog > a").mouseenter(function() {
			if (list = sections($(this).attr("rel"))) {
				var pos = $(this).position();
				pos.top += 12;
				$(".sections").html(list).css(pos).fadeIn();
			}
		});
		$(".selector").mouseleave(function() {
			$(this).hide();
		});
		if( !$('div.search > form input[name="query"]').val() )
			$('div.search > form button').attr('disabled', 1);
		$('div.search > form input[name="query"]').keyup(function(){
			if( $(this).val() )
				$('div.search > form button').removeAttr('disabled');
			else
				$('div.search > form button').attr('disabled', 1);
		});
		//var total_width = $(".header").width() - 40;
		//var item_width = 220;
		//var c = Math.floor(total_width / item_width);
		/*$(".carousel").width(c * item_width + 40);
		$(".carousel > .scrollable, .carousel .items > div").width(c * item_width);
		var list = "<div>";
		var i = 0;
		for (id in special) {
			if (i > 0 && i % c == 0) {
				list += "</div><div>";
			}
			list += special[id];
			i++;
		}*/
		//$(".carousel .items").append(list + "</div>");
		//$(".carousel .scrollable").scrollable({"circular": true}).autoscroll(8000);
		$("select#sort").change(function(){
			if( $(this).val() )
				location.href = $(this).val();
		});
		
		$("ul#navmenu-v > li > a").bind('click', function(){
			if( $(this).hasClass('opened') )
			{
				$(this).removeClass('opened');
				$(this).next('ul').hide();
			}
			else
			{
				$('.opened').next().hide();
				$('.opened').removeClass('opened');
				$(this).addClass('opened');
				$(this).next('ul').show();
			}
			return false;
		});
		$.get('/imonline.php');
		setInterval("$.get('/imonline.php');", 120000);
	});
	max_specials = 0;
	function load_hor_spec(width)
	{
		var size = Math.floor(width/184);
		$.ajax({
		   type: "GET",
		   url: "/retrievespecials",
		   data: "size=" + size,
		   success: function(data){
			 $('div.specials').prepend(data);
			 if( navigator.userAgent.match(/iPad/i) )
			 {
				 $('div.specials a.special-offer').css('margin','0px 1px 0px 1px');
			 }
			 else
			{
				 var css = Math.floor((width-(184*max_specials))/(max_specials*2));
				 css -= 3;
				 $('div.specials a.special-offer').css('margin','0px ' + css + 'px 0px ' + css + 'px');
			}
		   }
		 });
	}
	
