var azs04 = { params: params, coreimg: 'images/azscroll04/', xmlsrc: 'azscroll04_loader.php', loading1: 'images/azscroll04/ajax_loader.gif', imgpath: null, noimage: 'noimage.gif', view: 0, // 0:new_products, 1:specials, 2:featured dimension: ['',120], // width | height dimension2: new Array(), // temp var (just leave unset) scaleby: 20, sortby: 'latest', sort_order: 'desc', limitstart: 0, limit: 5, total: 0 }; var azs04_desc = false; var azs04_data = new Array(); function azs04_loadItem(gallery, state) { azs04.limitstart = gallery.first-1; var data_params = azs04.params+"&task=showproducts&view="+azs04.view+"&sort="+azs04.sortby+"&sortorder="+azs04.sort_order+"&limitstart="+azs04.limitstart+"&limit="+azs04.limit; // Check if the requested items already exist if (gallery.has(gallery.first, gallery.last)) { return; } jQuery.ajax({ url: azs04.xmlsrc, type: "get", dataType: "xml", data: data_params, error: function(){ $(".azscroll04-container").prepend($azs04_label['ERROR1']); }, success: function(xml){ azs04_addItem(gallery, gallery.first, gallery.last, xml); } }); }; function azs04_addItem(gallery, first, last, xml) { var gal = $(xml).find("gallery"); azs04_data = new Array(); azs04.limitstart = gal.attr("limitstart"); azs04.total = gal.attr("total"); azs04.imgpath = gal.attr("path"); gallery.size(parseInt(azs04.total)); $("product", xml).each(function(i){ azs04_data[i] = new Array(); azs04_data[i]['id'] = $("id", this).text() ? $("id", this).text() : 0; azs04_data[i]['title'] = $("title", this).text() ? $("title", this).text() : null; azs04_data[i]['image'] = $("image", this).text() ? $("image", this).text() : azs04.noimage; azs04_data[i]['price'] = $("price", this).text() ? $("price", this).text() : 0; azs04_data[i]['sprice'] = $("sprice", this).text() ? $("sprice", this).text() : 0; gallery.add(first + i, azs04_getItemHTML(azs04_data[i], i)); }); jQuery('div.azs04_pbox').hover( function () { $(this).addClass('selected') $('.azs04_button2',this).css({'display':'inline'}) $('.azs04_button',this).css({'display':'none'}) if(azs04.dimension[0]){ $('img', this).width(parseInt(azs04.dimension[0]+azs04.scaleby)+'px').height('auto') }else{ $('img', this).width('auto').height(parseInt(azs04.dimension[1]+azs04.scaleby)+'px') } }, function () { $(this).removeClass('selected') $('.azs04_button',this).css({'display':'inline'}) $('.azs04_button2',this).css({'display':'none'}) if(azs04.dimension[0]){ $('img', this).width(azs04.dimension[0]+'px').height('auto') }else{ $('img', this).width('auto').height(azs04.dimension[1]+'px') } } ); if(azs04.total < azs04.limit){ $('.azscroll04-item-temp').css({'background' : 'none'}) } }; function azs04_getItemHTML(data, id) { var imgpath = data['image']; imgDimension = azs04_desc ? (azs04.dimension[0] ? 'width="'+parseInt(azs04.dimension[0]+azs04.scaleby)+'" ' : '') + (azs04.dimension[1] ? 'height="'+parseInt(azs04.dimension[1]+azs04.scaleby)+'" ' : '') : (azs04.dimension[0] ? 'width="'+azs04.dimension[0]+'" ' : '') + (azs04.dimension[1] ? 'height="'+azs04.dimension[1]+'" ' : ''); ptitle = data['title'].length > 10 ? data['title'].substr(0,9)+'...' : data['title']; buttonText = azs04_desc ? $azs04_label['BACK'] : $azs04_label['MORE'] ; var html = '
' + '
' + ptitle + '
' + '' + '' + '
' + getPrice(data['price'], data['sprice']) + '
' + '
'; return html; }; function azs04_getDescriptionHTML(id) { var html = '
' + '' + '
'; return html; }; function showDescription(id) { if(azs04_desc == false) { var data_params = azs04.params+"&task=viewproductinfo&pid="+azs04_data[id]['id']; azs04_desc = true jQuery('.azscroll04_descContainer').show(1).html(azs04_getDescriptionHTML(id)) jQuery('.azscroll04-clip').hide(1) jQuery('.azs04_button2','.azscroll04_descContainer').css({'display':'inline'}) jQuery('.azs04_button','.azscroll04_descContainer').css({'display':'none'}) jQuery.ajax({ url: azs04.xmlsrc, type: "get", dataType: "html", data: data_params, error: function(){ $('#azs04_descWrapper').html($azs04_label['ERROR1']) }, success: function(response){ $('#azs04_descWrapper').html(response) } }); }else{ azs04_desc = false jQuery('.azscroll04-clip').show(1) jQuery('.azscroll04_descContainer').hide(1).empty() $('img', '.azs04_pbox').height(azs04.dimension2[1]+'px').width(azs04.dimension2[0]+'px') } }; function azs04AddtoCart(obj, pid) { var id = '&' + $("form#az_popForm").serialize() var data_params = azs04.params + '&task=addtocart' + (id ? id : '&pid='+pid); obj.blur() $(".azs04_cartItems").hide(1); $.ajax({ url: azs04.xmlsrc, type: "get", dataType: "xml", data: data_params, beforeSend: function(){ $("#azs04_cart_loading").show(1); }, error: function(){ $("#azs04_cart_loading").show(1, function(){ $(this).html($azs04_label['ERROR1']); }).fadeOut(4000, function(){ $(this).html(''); $(".azs04_cartItems").show(1) }); }, success: function(xml){ var result = parseInt($(xml).find("result").text()); var azcart_top = $(xml).find("carttext").text(); if(result > 0){ $(".azs04_cartItems").show(1).html('('+result + ') ' + $azs04_label['IN_CART']); $("#azs04_cart_loading").hide(1); $("#az_cart_top").html(azcart_top); }else{ $("#azs04_cart_loading").html($azs04_label['ERROR2']); } $("#azs04_cart_loading").fadeOut(4000, function(){ $(this).html(''); $(".azs04_cartItems").show(1) }); } }); }; function azButton(alt, bnum, size) { var buttonW = size ? ' style="width:'+size+'px;"' : ''; var image_button = '  ' + alt +'  '; return image_button; }; function getPrice(price, sprice){ if(!sprice == 0){ price = '' + price + ' ' + sprice; } return price; }; jQuery(document).ready(function() { jQuery('#myscroll ul').html(''); jQuery('#myscroll').azscroll04({ scroll: azs04.limit, itemVisibleOutCallback: {onAfterAnimation: function(gallery, item, i, state, evt) { gallery.remove(i); }}, itemLoadCallback: azs04_loadItem }); });