function search_shop(){ if(document.form.search_str.value == ''){ alert('[lang_search2]'); }else{ location.href = 'http://www.uph.nu/sv/katalog/?act=search&search_str=' + document.form.search_str.value + '&lang_id=0'; } } function login(){ document.form.action = 'inc/user/login.php'; document.form.submit(); } function send_password_retrieval(act){ if (document.form.email.value == ''){ alert('Skriv in din e-postadress!'); } else { document.form.page.value = 'user/password_retrieval'; document.form.ext_link.value = 'user/password_retrieval'; document.form.act.value = act; document.form.submit(); } } function remove_product(id, type){ if(confirm('Vill du ta bort produkten från varuvagnen?')){ if(type == '0'){ location.href = 'http://www.uph.nu/sv/varuvagn/?pid='+id+'&act=add_to_cart&q=0' + '&lang_id=0'; }else if(type == '1'){ location.href = 'http://www.uph.nu/sv/kassa/?pid='+id+'&act=add_to_cart&q=0' + '&lang_id=0'; } } } function add_to_cart(product_id,variation){ document.form.page.value = 'shop/product_list'; document.form.ext_link.value = 'shop/product_list'; document.form.act.value = 'add_to_cart'; document.form.pid.value = product_id; document.form.v.value = variation; var bla = 'q_' + product_id; document.form.q.value = document.form[bla].value; document.form.action = 'index.php#cartposition'; document.form.submit(); } function update_cart(){ document.form.page.value = 'shop_cart0'; document.form.act.value = 'update_cart'; document.form.submit(); } function empty_cart(){ if(confirm('Vill du tömma hela varuvagnen?')){ document.form.page.value = 'shop/index'; document.form.ext_link.value = 'shop/index'; document.form.act.value = 'empty_cart'; document.form.submit(); } } function cart(){ location.href = 'index.php?page=shop/cart&ext_link=shop/cart'; } function checkout(x){ if(x == 1){ alert('Du har artiklar som inte finns i lager eller inte är aktiva i varuvagnen. Dessa rättas till i kassan.'); }else if(x == 2){ alert('Lagersaldot på en eller flera artiklar är mindre än antalet beställda. Ändra antal på dessa.'); } if(x != 2){ location.href = 'http://www.uph.nu/sv/kassa/?act=checkout'+ '&lang_id=0'; } } function checkout_attach_files(){ if(document.form.shipping_id[document.form.shipping_id.selectedIndex].value == '0'){ alert('Du har inte valt fraktsätt.'); }else if(document.form.payment_id[document.form.payment_id.selectedIndex].value == '0'){ alert('Du har inte valt betalsätt.'); }else{ location.href = 'index.php?page=shop/checkout_attach_files&ext_link=shop/checkout_attach_files'; } } function attach_file_open(id){ document.form.chosen_prod.value = id; document.getElementById('user_files').style.visibility = 'visible'; } function attach_file_close(){ document.getElementById('user_files').style.visibility = 'hidden'; } function attach_file(id,name){ var prod = 'prod_file_'+document.form.chosen_prod.value; var a_prod = 'attached_file_'+document.form.chosen_prod.value; var td_prod = 'td_'+document.form.chosen_prod.value; document.form[prod].value = id; document.getElementById(a_prod).innerHTML = name; document.getElementById(td_prod).style.backgroundColor = '#90E98C'; document.getElementById('user_files').style.visibility = 'hidden'; } function remove_attached_file(id){ var prod = 'prod_file_'+id; var a_prod = 'attached_file_'+id; var td_prod = 'td_'+id; document.form[prod].value = ''; document.getElementById(a_prod).innerHTML = 'Ingen bifogad fil'; document.getElementById(td_prod).style.backgroundColor = '#FF6060'; } function checkout_confirm(x){ shipping_selected_value = $("#shipping_drop").val(); payment_selected_value = $("#payment_drop").val(); if (shipping_selected_value == 0 || payment_selected_value == 0) { alert('Du måste välja frakt- och betalsätt!'); } else { var reg_ok = 1; if(document.getElementById('form').unreg_checkout.value == 'true'){ var reg_ok = 0; if(document.getElementById('form').user_vat_nr_ok_hidden.value == '0' || document.getElementById('form').user_email_ok_hidden.value == '0' || document.getElementById('form').user_vatnr.value == '' || document.getElementById('form').user_fname.value == '' || document.getElementById('form').user_lname.value == '' || document.getElementById('form').user_email.value == '' || document.getElementById('form').user_address_1.value == '' || document.getElementById('form').user_postnr.value == '' || document.getElementById('form').user_city.value == ''){ alert('Du har inte fyllt i alla obligatoriska fält'); }else if(document.getElementById('form').accept_policy.checked == false){ var reg_ok = 0; alert('Du måste godkänna villkoren'); }else{ reg_ok = 1; } }else if(document.getElementById('form').accept_policy.checked == false){ var reg_ok = 0; alert('Du måste godkänna villkoren'); }else{ reg_ok = 1; } if(reg_ok == 1){ if(x == 1){ alert('Du har artiklar som inte finns i lager eller inte är aktiva i varuvagnen. Dessa rättas till i kassan.'); }else if(x == 2){ alert('Lagersaldot på en eller flera artiklar är mindre än antalet beställda. Ändra antal på dessa.'); } if(x != 2){ document.form.page.value = 'shop_checkout_conf0'; document.form.act.value = 'checkout'; checkout_confirm_final(); } } } } function shipping_selection(){ document.form.payment_id.disabled = true; $("#loading_shipping_payment").fadeIn(100); var shipping_id = document.form.shipping_id[document.form.shipping_id.selectedIndex].value; location.href = 'http://www.uph.nu/sv/kassa/?act=shipping_selection&shipping_id='+shipping_id+'&lang_id=0'; } function payment_selection(){ document.form.shipping_id.disabled = true; $("#loading_shipping_payment").fadeIn(100); var payment_id = document.form.payment_id[document.form.payment_id.selectedIndex].value; location.href = 'http://www.uph.nu/sv/kassa/?act=payment_selection&payment_id='+payment_id+'&lang_id=0'; } function kreditor_part_payment(){ var pclass = document.form.pclass[document.form.pclass.selectedIndex].value; location.href = 'http://www.uph.nu/sv/kassa/?act=kreditor_selection&pclass='+pclass+'&lang_id=0'; } function add_voucher_code(){ if(document.form.voucher_code.value == ''){ alert('Fyll i rabattkod.'); }else{ document.form.page.value = 'shop_checkout0'; document.form.act.value = 'voucher_code'; document.form.submit(); } } function payment_invoice(x){ if(x == 1){ alert('Du har artiklar som inte finns i lager eller inte är aktiva i varuvagnen. Dessa rättas till i kassan.'); }else if(x == 2){ alert('Lagersaldot på en eller flera artiklar är mindre än antalet beställda. Ändra antal på dessa.'); } if(x != 2){ if(confirm('Nu skickas ordern!')){ document.form.page.value = 'shop_order_complete0'; document.form.act.value = 'send_order_invoice'; document.form.submit(); } } } function send_order(x){ if(x == 1){ alert('Du har artiklar som inte finns i lager eller inte är aktiva i varuvagnen. Dessa rättas till i kassan.'); }else if(x == 2){ alert('Lagersaldot på en eller flera artiklar är mindre än antalet beställda. Ändra antal på dessa.'); } if(x != 2){ if(confirm('Nu skickas ordern!')){ document.form.page.value = 'shop_order_complete0'; document.form.act.value = 'send_order'; document.form.submit(); } } } function update_order_status(){ document.form.page.value = 'shop/supplier_order'; document.form.ext_link.value = 'shop/supplier_order'; document.form.act.value = 'update_order_status'; document.form.submit(); } function upload_file(){ if(document.form.user_file.value == ''){ alert('Har du valt dokuemnt/fil?'); }else{ document.form.page.value = 'shop/user_files'; document.form.ext_link.value = 'shop/user_files'; document.form.act.value = 'upload_file'; document.form.submit(); } } function del_user_file(id){ if(confirm('Vill du radera detta dokument/fil?')){ document.form.page.value = 'shop/user_files'; document.form.ext_link.value = 'shop/user_files'; document.form.act.value = 'del_user_file'; document.form.user_file_id.value = id; document.form.submit(); } } function supplier_login(){ document.form.act.value = 'supplier_login'; document.form.page.value = 'shop/supplier_order_list'; document.form.ext_link.value = 'shop/supplier_order_list'; document.form.act.value = 'supplier_login'; document.form.submit(); } function switchDiv(parent, child) { $("#" + parent + " > *").hide(100); $("#" + child).show(); } function getVariationData(data, product_id, num) { $.ajax({ type: "POST", url: "inc/shop/getVariationData.php", data: "data=" + data + "&product_id=" + product_id + '&num=' + num, success: function(msg){ msg_split = msg.split("::"); vari_id = msg_split[0]; vari_name = msg_split[1]; vari_art_no = msg_split[2]; vari_price = msg_split[3]; vari_spec = msg_split[4]; vari_file = msg_split[5]; $("#product_id").attr("value", vari_id); $("#product_name").html(vari_name); $("#product_art_no").html(vari_art_no); $("#product_price").html(vari_price); $("#product_image").attr("src", vari_file); } }); } function addToCart(product_id, q, subscription) { subscription = (typeof subscription == 'undefined') ? 0 : subscription; $.ajax({ type: "POST", url: "inc/shop/addToCart.php", data: "act=add_to_cart&pid=" + product_id + '&q=' + q + '&subscription=' + subscription, success: function(msg){ msg_split = msg.split("::"); $("#cart_text").html(msg_split[0]) .show(); msg2 = msg_split[1]; if (subscription == 1) { msg2 = "Du har lagt en ny produkt i varuvagnen
Pris: " + $("#price_optional").html(); } $("#addToCartSlide").html(msg2); } }); $("#checkout_button_special").show(); } function toggleTechSpec(objects, icon) { $obj = $("tr." + objects); if ($obj.is(":hidden")) { $(icon).attr('src', 'img/icons/remov_10.png'); $obj.show(); } else { $(icon).attr('src', 'img/icons/add_10.png'); $obj.hide(); } } $(document).ready( function() { $("input.addToCart").click( function(){ div = "addToCartSlide"; win_height = $(window).height(); win_width = $(window).width(); pos_top = ((win_height / 2) - ($("#" + div).height() / 2) - 100) + $(document).scrollTop(); pos_left = (win_width / 2) - ($("#" + div).width() / 2); $("#" + div).css("top", pos_top); $("#" + div).css("left", pos_left); $("#" + div).fadeIn(300) .animate({opacity: 1.0}, 3000); button_pos = $(this).position(); button_pos_top = button_pos.top; button_pos_left = button_pos.left; pos = $("#cart_link").offset(); top_p = pos.top; left_p = pos.left; $("#" + div).show( function() { $("#" + div).animate({ top: top_p, left: left_p }, 200, function(){ $("#" + div).fadeOut(300); }) }); }); }); function switchProductImage(new_src) { $("#productMainImage").hide() .attr("src", new_src) .fadeIn(); } function selectSubscription(product_id, main_id, template_id, head_id) { var parent_id = document.getElementById('form')['sub_' + head_id][document.getElementById('form')['sub_' + head_id].selectedIndex].value; $.ajax({ type: "POST", url: "inc/shop/getSubscriptionData.php", data: "product_id=" + product_id + "&main_id=" + main_id + "&template_id=" + template_id + "&head_id=" + head_id + "&parent_id=" + parent_id, success: function(msg) { if(msg != '') { msg_split_data_price = msg.split("|||||||"); $("#price_optional").html(msg_split_data_price[1]) msg_split_headers = msg_split_data_price[0].split("|||||"); for(i = 0; i < msg_split_headers.length; i++) { msg_split_select = msg_split_headers[i].split("|||"); if(msg_split_select.length > 1) { var targetObj = document.getElementById('form')[msg_split_select[0]]; targetObj.length = 0; msg_split_options = msg_split_select[1].split("||"); var n = 0; var arr_length = msg_split_options.length / 3; for(v = 0; v < arr_length; v++) { targetObj.options[v] = new Option(msg_split_options[n+1], msg_split_options[n]); if(msg_split_options[n+2] == '1') { targetObj.options[v].selected = true; } else { targetObj.options[v].selected = false; } n = n + 3; } } } } } }); } function check_shipping_billing() { if ($("#payment_drop").val() == "0" || $("#shipping_drop").val() == "0") { $('#shipping_billing_warning').show(); } } function ajax_check(act, value, div, error_msg) { $.ajax({ type: "POST", url: "inc/shop/ajax_check.php", data: "act=" + act + "&value=" + value, success: function(msg){ if (msg == 1) { $("#" + div).css("color", "#00ff00"); $("#" + div).html(" OK"); $("#" + div + "_hidden").val("1"); } else { $("#" + div).css("color", "#fff000"); $("#" + div).html(" " + error_msg); $("#" + div + "_hidden").val("0"); } } }); }