function loadupCategories() { var htmlBlock = ""; $.ajax({ dataType: 'xml', data: 'fetch=categories_names&id=1', url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { stringData = '
  • PRESENTKORT
  • '; htmlBlock = htmlBlock + stringData; $('row', xml).each(function() { stringData = '
  • ' + $('cell:eq(1)',this).text() + '
  • '; htmlBlock = htmlBlock + stringData; }); }, error: function(xml) { //alert('XML Error'); }, complete: function() { $('.menuItemholder').html(htmlBlock); } }); } function loadupFrontcats() { var htmlBlock = ""; $.ajax({ dataType: 'xml', data: 'fetch=categories_pictures&id=2', url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { var count = 0; $('row', xml).each(function() { img = new Image(); img.src = '/shop/bilder/cats/' + $('cell:eq(1)', this).text(); if(count == 4) { stringData = $('#frontContainer').html(); htmlBlock = htmlBlock + stringData; } string = '
    '+ $('cell:eq(1)', this).text() +'
    '; htmlBlock = htmlBlock + string; count++; }); }, error: function(xml) { //alert('XML Error'); }, complete: function() { string = '
    Presentkort
    '; htmlBlock = string + htmlBlock; $('#frontContainer').html(htmlBlock); } }); } function objectifyQuerystring(stringData) { var urlObject={}; stringData = stringData.replace(/#[\w\d]+/, ''); var qs=stringData.substring(stringData.indexOf('?') + 1, stringData.length).split('&'); for (var i in qs) { eval('urlObject.' + qs[i].split('=')[0] + '=\'' + qs[i].split('=')[1] + '\''); }; return urlObject; } function loadupProdcat(urlObject) { $.ajax({ dataType: 'xml', data: 'fetch=products&id=' + urlObject.id, url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { $('row', xml).each(function() { string = '
    '; string += '
    '; if($('cell:eq(5)', this).text() != "") { img = new Image(); img.src = 'bilder/prods/' + $('cell:eq(5)', this).text(); string += 'Product Item'; } else { string += 'Bild saknas'; } string += '
    '; string += '
    '; string += '' + $('cell:eq(1)', this).text() + ''; string += '' + $('cell:eq(2)', this).text() + ''; string += '' + $('cell:eq(3)', this).text() + ''; string += '' + $('cell:eq(4)', this).text() + 'kr'; string += '
    '; string += '
    '; string += ''; string += ''; string += '
    '; string += '
    '; $('#prodCont').append(string); }); }, error: function() {}, complete: function() { $('.prodBuy a').bind('click', function() { var qStr = $(this).attr('href'); qStr = qStr.substring(qStr.indexOf('?')+1); addThisproduct(qStr); return false; }); } }); } function loadupProdinfo(urlObject) { $('.prodTitle').html('Produktinformation'); $('.history a').attr('href','/shop/category.asp?id=' + urlObject.returnValue); $.ajax({ dataType: 'xml', data: 'fetch=productInfo&id=' + urlObject.id, url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { $('info:eq(0) row', xml).each(function() { $('.prodBuy a').attr('href', '/shop/shopHandler.asp?fetch=putProducts&id=' + $('cell:eq(0)', xml).text()); $('.prodTitle').html($('cell:eq(1)', xml).text()); var stringData = $('cell:eq(2)', xml).text(); stringData = stringData.replace(/\r?\n/g, '
    '); //stringData = stringData.replace(/(<).+(>);/g, "

    "); $('.prodDesc').html(stringData); $('.prodVol').html($('cell:eq(3)', xml).text() + ''); $('.prodPrice').html($('cell:eq(4)', xml).text() + 'kr'); tImg = new Image(); tImg.src = '/shop/bilder/prods/large/' + $('cell:eq(5)', xml).text().replace(/.gif/,'.jpg'); setTimeout("$('.prodImg img').attr('src', tImg.src)", 400); $('.prodBuy a').bind('click', function() { var qStr = 'fetch=putProduct&id=' + $('cell:eq(0)', xml).text() + '&qty=' + $('#__antal').val(); $(".pLeft fieldset input[type=checkbox]:checked").each(function(){ qStr += '&aid=' + $(this).val(); }); $('.prodBuy a').attr('href', '/shop/shopHandler.asp?' + qStr); addThisproduct(qStr); return false; }); }); $('info:eq(1) row', xml).each(function(xx) { switch(eval($('cell:eq(4)', this).text())) { case 0: break; case 1: stringBlock = '

    '; stringBlock += '
    '; stringBlock += ''; stringBlock += 'Vill du även lägga till:'; stringBlock += ''; stringBlock += ''; stringBlock += '

    '; stringBlock += '

    ' + $('cell:eq(1)', this).text() + '

    '; stringBlock += '

    Pris: ' + $('cell:eq(3)', this).text() + 'kr

    '; stringBlock += '
    '; $('.prodBuy').after(stringBlock); break; case 2: break; } }); }, error: function(xml) { //alert('XML Error'); } }); } function checkOutCart(delbutton) { randomDate = (new Date().getTime()); var totPrice = 0; $.ajax({ dataType: 'xml', data: 'fetch=getBasket×tamp=' + randomDate, url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { $('div.checkoutItems *').remove(); $('row', xml).each(function() { string = ''; $('div.checkoutItems').append(string); totPrice = totPrice + eval($('cell:eq(3)', this).text() + '*' + $('cell:eq(2)', this).text()); }); $('li.del, li.button').bind('click', function() { delProd($(this).attr('rel')); location.reload(); }).css({ cursor: 'pointer'}); }, error: function(xml) { //alert('Could not update webcart'); }, complete: function() { $('.c_psum').text(totPrice + ' SEK'); } }); } // Cart handling. function updateWebcart() { var randomDate = (new Date().getTime()); $.ajax({ dataType: 'xml', data: 'fetch=getBasket×tamp=' + randomDate, url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { $('div.webcart div:eq(0) p').remove(); $('row', xml).each(function() { stringData = '

    '; stringData += ''+$('cell:eq(2)', this).text()+''; stringData += ''+$('cell:eq(1)', this).text()+''; if($('cell:eq(5)', this).text() != '0') { stringData += 'Delete'; } stringData += ''+$('cell:eq(3)', this).text()+'kr'; stringData += '

    '; $('div.webcart div:eq(0)').append(stringData); }); $('.delbtn').bind('click', function() { $(this).parent().animate({ opacity: 0 }, 'slow',function() { delProd($(this).attr('id')); $(this).remove(); recount(); }); }); recount(); }, error: function(xml) { //alert('Could not update webcart'); } }); } function delProd(id) { $.get("/shop/shopHandler.asp", { "fetch": "delProduct", "id": id.substring(1)} ,function(xml) { updateWebcart(); /*if($('deleted', xml).text() == 0) { $('.cartItem').remove(); $('span.sum').text('0kr'); }*/ }); } function addThisproduct(tString) { var randomDate = (new Date().getTime()); $.ajax({ dataType: 'xml', data: tString + '×tamp=' + randomDate, url: '/shop/shopHandler.asp', timeout: 60000, type: 'GET', success: function(xml) { updateWebcart(); }, error: function(xml) { alert("Could not add product to cart."); } }); } function addExpeditionFee(){ $.get("/shop/shopHandler.asp", {"fetch": "addExpeditionFee"}, function(xml) { updateWebcart(); }); } function removeExpeditionFee(){ $.get("/shop/shopHandler.asp", {"fetch": "removeExpeditionFee"}, function(xml) { updateWebcart(); }); } function recount() { var count = 0; if($('.psum').is(':visible')) { $('.psum').each(function() { var myregexp = /([\.\,\d]+)/; var match = myregexp.exec($(this).text()); if (match != null) { result = match[0]; } else { result = 0; } var qty = $(this).siblings().filter('.qty').text(); count = eval(count) + (eval(result) * eval(qty)); $('span.sum').text(count + 'kr'); }); } else { $('span.sum').text(count + 'kr'); } qty = undefined; count = undefined; }