function show_address_box(){ $("#address_box").css("display","inline"); } function hide_address_box(){ $("#address_box").css("display","none"); } function sel_radio(radio){ $("#" + radio + "").attr("checked", true); } function addToCart(prod){ var amount; amount = document.getElementById('prod_' + prod).value; var url = document.URL; var site_url = url.substring(0,url.lastIndexOf("/")) + '/'; $.ajax({ type: "POST", url: site_url + "index.php?file=ajax&action=addToCart&prod=" + prod + "&amount=" + amount, data: "ajax=1", success: function(msg){ var cartBox; cartBox = document.getElementById('cart_box').innerHTML = msg; document.getElementById('cart_added_product_' + prod).innerHTML = document.getElementById('prod_added_text').value; $('#cartbox').show(); } }); } function addToCart2(prod){ var url = document.URL; var site_url = url.substring(0,url.lastIndexOf("/")) + '/'; var query_string = ''; var query_string = 'file=ajax&action=addToCart&' + $('#add_to_cart_' + prod).formSerialize(); $.ajax({ type: "POST", url: site_url + "index.php?" + query_string, data: "ajax=1", success: function(msg){ var cartBox; cartBox = document.getElementById('cart_box').innerHTML = msg; document.getElementById('cart_added_product_' + prod).innerHTML = document.getElementById('prod_added_text').value + ' Vaata ostukorvi.'; } }); } var cart_contact_fields = new Array('firstname','lastname','email','phone','city','index','street','country'); function update_cart_contacts(checked){ var cbox = document.getElementById(checked); if(cbox != null){ var cbox1 = document.getElementById('only_one_address1'); cbox1.checked = cbox.checked; if(cbox.checked == true){ copy_cart_contacts(); disable_cart_contacts2(); }else{ enable_cart_contacts2(); } } } function disable_cart_contacts2(){ var i = 0; var cols = cart_contact_fields; while(cols[i]){ document.getElementById(cols[i] + '_2').readOnly = true; i = i + 1; } } function enable_cart_contacts2(){ var i = 0; var cols = cart_contact_fields; while(cols[i]){ document.getElementById(cols[i] + '_2').readOnly = false; i = i + 1; } } function copy_cart_contacts(){ var i = 0; var cols = cart_contact_fields; while(cols[i]){ document.getElementById(cols[i] + '_2').value = document.getElementById(cols[i] + '_1').value; i = i + 1; } //document.getElementById('region_2').selectedIndex = document.getElementById('region_1').selectedIndex; } function cart_contacts_change(){ var cbox1 = document.getElementById('only_one_address1'); if(cbox1.checked == true){ copy_cart_contacts() } } update_cart_contacts('only_one_address1');