/* * © fancy.lv, 2010 */ $(document).ready(function(){ $("#thumbs a").click(function(){ return item.switchImage($(this).attr("href")); }); $("#order-form").parent().submit(function(){ return basket.add(this); });//.jqTransform(); $('input[name="size"]').change(function(){ if ($(this).attr('checked')) { if ($('#colors').children().children().children('input').length > 1) { $('#colors span.label span.value').html('Izvēlieties krāsu'); $('#colors').removeClass('disabled'); $('#colors').dropDown(); } } else { $('#colors').addClass('disabled'); } }); $('.dorpDownVal').not('.disabled').dropDown(); $('input[name="size"]').change(); item.popular.prepare(); }); var item = { cat: 0, size: "", color: "", switchImage: function(img){ $("#imgs")[0].href = img; if (img.match('^/images/storage/big_')) { img = img.substr(20); } else {// "/resize.php?pic=" img = img.substr(16); } $("#image").html(''); return false; }, popular: { data: {}, show: 10, prepare: function(){return false; if(item.cat < 1){ return false; } $.getJSON("/items/popular.php?cat="+item.cat, {}, function(data){ item.popular.data = data; return item.popular.draw(0); }); }, draw: function(start){ if(start < 0){ start = item.popular.data.count; } if(start > item.popular.data.count){ start = 0; } var end = start+item.popular.show; if(end > item.popular.data.count){ end = item.popular.data.count; } var showed = 0; var str = ''; if(start < end){ for(var i = start; i < end; i++){ var d = item.popular.data.items[i]; str+= '
'+d.title+'
'; showed++; } } if(showed < item.popular.show && item.popular.data.count >= item.popular.show){ end = item.popular.show-showed; for(var i = 0; i < end; i++){ var d = item.popular.data.items[i]; str+= '
'+d.title+'
'; } } str+= '
 
'; $("#items").html(str); return false; } } }