jQuery(function(){
	jQuery('nav a')
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400, complete:function(){
				jQuery(this).css({backgroundPosition: "0 0"});
			}});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-250px 0)"}, {duration:1});
		});
	jQuery('#in-stores a')
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400, complete:function(){
				jQuery(this).css({backgroundPosition: "0 0"});
			}});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-250px 0)"}, {duration:1});
		});
	jQuery('#links a')
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400, complete:function(){
				jQuery(this).css({backgroundPosition: "0 0"});
			}});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-250px 0)"}, {duration:1});
		});
	jQuery('#media a')
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400, complete:function(){
				jQuery(this).css({backgroundPosition: "0 0"});
			}});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-250px 0)"}, {duration:1});
		});
	jQuery('.widgets a.active')
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:400, complete:function(){
				jQuery(this).css({backgroundPosition: "0 0"});
			}});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:1});
		});
});

jQuery(document).ready(function() {
	var containter_height = "";
	var pic_height = "";
	var container_height = jQuery(window).height() - 226;
	var container_width = jQuery(".main-picture .picture").width();
	var pic_width = jQuery(".main-picture .picture img").width();
	jQuery(".main-picture #gallery li").css({'width' : container_width});
	// jQuery(".main-picture img").load(function() {
		var pic_height = jQuery(this).height();
		if (pic_height > container_height) {
			jQuery(".main-picture .picture").css({'height' : container_height});
			jQuery(".main-picture img").css({'width' : 'auto', 'height' : '97%'});
		}
		if ((pic_height < container_height) && (pic_width > container_width)) {
			jQuery(".main-picture img").css({'width' : '97%', 'height' : 'auto' });
		}
	// });
});

jQuery(document).ready(function(){
	jQuery('#gallery').jcarousel({auto: 4, animation: 'slow', scroll: 1});
	// Counting pixels for carousel
		//Pictures carousel
			jQuery(".for-carousel").css({ 'width' : '50%' });
			var carousel_wrap_width = jQuery(".for-carousel").width();
			var items_count = Math.floor(carousel_wrap_width / 83);
			var carousel_width = items_count * 83;
			var carousel_container_width = carousel_width + 50;
			jQuery(".for-carousel").css({ 'width' : carousel_container_width });
			jQuery(".for-carousel .widgets").css({ 'width' : carousel_container_width });
			jQuery(".for-carousel .carousel").css({ 'width' : carousel_container_width });
			jQuery(".for-carousel .jcarousel-container").css({ 'width' : carousel_container_width });
			jQuery(".for-carousel .jcarousel-clip").css({ 'width' : carousel_width });
		// Appearing at carousel
			jQuery(".app-carousel").css({ 'width' : '60%' });
			var carousel_app_wrap_width = jQuery(".app-carousel").width();
			var widgets_switch_width = jQuery(".app-carousel .widgets-switch").width();
			var get_carousel_width = carousel_app_wrap_width - widgets_switch_width - 30;
			var items_app_count = Math.floor((get_carousel_width - 50) / 126);
			var carousel_app_width = items_app_count * 126;
			var carousel_app_container_width = carousel_app_width + 60;
			jQuery(".app-carousel .widgets").css({ 'width' : carousel_app_wrap_width });
			jQuery(".app-carousel .tab-container").css({ 'width' : get_carousel_width });
			jQuery(".app-carousel .jcarousel-container").css({ 'width' : carousel_app_container_width });
			jQuery(".app-carousel .jcarousel-clip").css({ 'width' : carousel_app_width });
});
