
$(document).ready(function(){
	
	var thisIndex = $("ul.left-tab>li>a.active").parent().index();
	$(".tabpane").hide();
	$(".tabpane:eq("+thisIndex+")").show();
	
	$("ul.left-tab>li>a").on("click",function(){
		$("ul.left-tab>li>a").removeClass("active");	
		$(this).addClass("active");	
		var thisIndex = $("ul.left-tab>li>a").index(this);
		$(".tabpane").hide();
		$(".tabpane:eq("+thisIndex+")").show();
		if($(this).attr('id')=="general")
		{
			$('.cropSection').addClass('cur_menu');
		}
		if($(this).attr('id')=="qtyPrice")
		{
			$('.cropSection').removeClass('cur_menu');
		}
	});
	
});
(function($){
	$.extend({
		ceFloatingBar: function() {
			var fb = this;
			if (!fb.fbToggle) {
				fb.fbToggle = function(scroll) {
					var toggle = this;
					var w = $.get_window_sizes();
					var elms;
					if (scroll && toggle.elms) {
						elms = toggle.elms.filter(':visible');
					} else {
						elms = toggle.elms = $('.tabpane').find('.buttons-bg');
					}

					$(elms).each(function() {

						var self = $(this);
						if (!self.has('input')) {
							return false;
						}

						if (!self.data('fbarInit'))	{
							self.wrapInner('<div class="cm-buttons-placeholder"></div>');
							self.append('<div class="cm-buttons-floating hidden"></div>');
							self.data('fbarInit', true);
						}

						var floating = self.find('.cm-buttons-floating');
						var offset = self.offset();

						if (self.is(':visible') && offset.top > w.offset_y + w.view_height - 70) { // 70 = bottom_menu height + cm-buttons-floating height
							if (!floating.children().length) {
								floating.append(self.find('.cm-buttons-placeholder'));
								floating.show();
							}
						} else {
							if (floating.children().length) {
								self.append(self.find('.cm-buttons-placeholder'));
								floating.hide();
							}
						}

						if($.isMobile()) {
							$(".cm-buttons-floating").css("position", "relative");
						}
					});
				};

				$(window).bind('scroll resize', function() {
					fb.fbToggle(true);
				});
			}

			fb.fbToggle();
		}
	});

})(jQuery);