var operationPage = ''; var leftCartPage = ''; var imagesRoot = ''; var selectedBasketId = ""; var permanentSelectedBasketId = ""; var inquiryPage = ''; function AddBasket(t) { if (uId != '0') { b_amount = $F('ctl00_ContentBody_txtQuantity'); var b_quality = FindQualityValue($RF('aspnetForm', 'ctl00$ContentBody$ddProductParameters')); var b_printing = FindPrintingValue($RF('aspnetForm', 'ctl00$ContentBody$ddlPrintingType')); var b_pricing = $('strPrice').innerHTML; //if (console) // console.log("b_amount=" + b_amount + " b_quality=" + b_quality + " b_printing=" + b_printing); if (numericControl(b_amount) && b_quality != 0 && b_printing != 0) { fillBasket(); if (selectedBasketId != null && selectedBasketId != "" && selectedBasketId != 0) { AddNewBasketItems(selectedBasketId, b_productId, b_variationId, b_amount, b_quality, b_printing, b_pricing); } $('btnAddBasket').hide(); $('divMyBasket').show(); $('divbasketdirection_links').hide(); } else { alert("WARNING : Please check your values!"); } } else alert('You need to login in order to create baskets...'); } function numericControl(val) { return !isNaN(val) || val == ""; } function FindQualityValue(quality) { var code = 0; switch (quality) { case 'Standard Printing': code=1; break; case 'Featured Printing': code = 2; break; case 'Premium Printing': code = 3; break; } return code; } function FindPrintingValue(printing) { var code = 0; switch (printing.substring(0,1)) { case 'D': code = 1; break; case 'O': code = 2; break; } return code; } function observeRadioButonList() { $$('#rblBasketList input').each(function(o) { o.observe('click', function(rb) { var id = rb.target.value; //alert(id); selectedBasketId = id; permanentSelectedBasketId = selectedBasketId; AddBasket(); selectedBasketId = ""; hideBasket(); }); }); $$('#rblBasketList label').each(function(o) { o.observe('click', function(rb) { var id = rb.target.previous('input').value; //alert(id); selectedBasketId = id; permanentSelectedBasketId = selectedBasketId; AddBasket(); selectedBasketId = ""; hideBasket(); }); }); } function fillBasket() { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'list' } , onComplete: function() { observeRadioButonList(); } }); } function newBasket() { var newName = prompt('Namnge varukorgen:', 'Min Kundvagn'); if (newName != null && newName != "") { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'add', basketName: newName } , onComplete: function() { observeRadioButonList(); if (updateLeftCart) updateLeftCart(); } }); } } function editBasket(basketid) { var newName = prompt('Basket name:'); if (newName != null && newName != "") { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'edit', basketid: basketid, basketName: newName } , onComplete: function() { fillBasket(); } }); } } function DeleteBasket(basketid) { if (confirm('Fortsätt?')) { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'delete', basketid: basketid } , onComplete: function() { var dvNm = 'divBasket_' + basketid; $(dvNm).hide(); if (updateLeftCart) updateLeftCart(); } }); } } function ListBasketItems(basketid) { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'listBasketItem', basketid: basketid } , onComplete: function() { } }); } function AddNewBasketItems(basketid, productid, variationid, amount, quality, printing, price) { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'addBasketItem', basketid: basketid, productid: productid, variationid: variationid, amount: amount, quality: quality, printing: printing, price: price } , onComplete: function() { if (updateLeftCart) updateLeftCart(); //alert('Kundvagn är uppdaterad'); $('divbasketdirection_links').show(); } }); } function DeleteBasketItem(basketitemid) { if (confirm('Fortsätt?')) { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'deleteBasketItem', basketitemid: basketitemid } , onComplete: function() { var dvNm = 'divBasketItem_' + basketitemid; $(dvNm).hide(); if (updateLeftCart) updateLeftCart(); } }); } } function hideBasket() { $('divMyBasket').hide(); $('btnAddBasket').show(); } function showBasket() { $('btnAddBasket').hide(); $('divMyBasket').show(); } function $RF(el, radioGroup) { if ($(el).type && $(el).type.toLowerCase() == 'radio') { var radioGroup = $(el).name; var el = $(el).form; } else if ($(el).tagName.toLowerCase() != 'form') { return false; } var checked = $(el).getInputs('radio', radioGroup).find( function(re) { return re.checked; } ); return (checked) ? $F(checked) : null; } function updateLeftCart() { new Ajax.Updater('ctl00_Login1_pnlLeftBasketArea', leftCartPage, { onComplete: function() { $$('#ctl00_Login1_pnlLeftBasketArea img').each(function(img) { var src = img.src; src = '/icons' + src.substring(src.lastIndexOf('/')); img.src = imagesRoot+src; }); } }); } function GoInquiryWithBasketId(basketid) { //alert(basketid); if (basketid == null) basketid = permanentSelectedBasketId; document.location.href = inquiryPage + '?basketId=' + basketid; } function DefaultBasket() { var newName = '<%= Resource.GetString("gnNewBasketText") %>'; if (newName != null && newName != "") { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'add', basketName: newName } , onComplete: function() { observeRadioButonList(); if (updateLeftCart) updateLeftCart(); } }); } } function defaultBasket() { new Ajax.Updater('divBasketList', operationPage, { parameters: { mode: 'createDefaultBasket' } , onComplete: function() { observeRadioButonList(); if (updateLeftCart) updateLeftCart(); } }); }