jQuery().ready(function() { var bodyHeight = $('.sizes .line.body').height(); if(bodyHeight < 1) { bodyHeight = 23; } var result = null; var doneAnimating = false; finished = function() { if(result != null && doneAnimating) { $('.sizes .loader').remove(); $('.sizes .line.head').after(result); $('.sizes .line.body').css({ height: 0 }).animate({ height: bodyHeight }, 300, function() { $('.sizes .loader').remove(); }); $('.sizes .line .cell.quantity input').inputDefault({ text: '0' }); result = null; doneAnimating = false; } } loadData = function() { if($('.sizes .line.body').height() > 0) { $('.sizes .line.body').animate({ height: 0 }, 300, function() { $(this).remove(); if($('.sizes img.loader').length == 0 && result == null) { $('.sizes .line.head').after($('').attr('src', '/images/loadingproducts.gif').addClass('loader')); } doneAnimating = true; finished(); }); } else { doneAnimating = true; } $.post('/' + $('.languages ul li a.current.').html().toLowerCase() + '/colorchange', { article: $('input[name="article"]').val(), color: $('.selectcolor select[name="color"]').val() }, function(data) { result = data; finished(); }); } $('.colors a').click(function() { $('.colors a').removeClass('current'); $(this).addClass('current'); $('.selectcolor select[name="color"]').val($(this).attr('href').substr(1)); loadData(); return false; }); $('.selectcolor select[name="color"]').change(function() { $('.colors a').removeClass('current'); $('.colors a[href="#' + $(this).val() + '"]').addClass('current'); loadData(); }); });