var price1= []; var price2= []; var price3= []; var array1 = []; var kosik = new Array(0,0,0); price1['CZK']=4990; price2['CZK']=[2990,5990]; price3['CZK']=[2490,4490]; price1['USD']=249; price2['USD']=[159,299]; price3['USD']=[129,229]; price1['EUR']=219; price2['EUR']=[139,269]; price3['EUR']=[109,199]; //plugin bootstrap minus and plus //http://jsfiddle.net/laelitenetwork/puJ6G/ $('.btn-numberwidth').click(function(e){ e.preventDefault(); fieldName = $(this).attr('data-field'); type = $(this).attr('data-type'); var input = $("input[name='"+fieldName+"']"); var currentVal = parseInt(input.val()); if (!isNaN(currentVal)) { if(type == 'minus') { if (currentVal==100) zmena=50; else zmena=100 ; if(currentVal > input.attr('min')) { input.val(currentVal - zmena).change(); } if(parseInt(input.val()) == input.attr('min')) { $(this).attr('disabled', true); } } else if(type == 'plus') { if (currentVal==50) zmena=50; else zmena=100 ; if(currentVal < input.attr('max')) { input.val(currentVal + zmena).change(); } if(parseInt(input.val()) == input.attr('max')) { $(this).attr('disabled', true); } } } else { input.val(0); } }); $('.input-numberwidth').focusin(function(){ $(this).data('oldValue', $(this).val()); }); $('.input-numberwidth').change(function() { minValue = parseInt($(this).attr('min')); maxValue = parseInt($(this).attr('max')); valueCurrent = parseInt($(this).val()); name = $(this).attr('name'); if(valueCurrent >= minValue) { $(".btn-numberwidth[data-type='minus'][data-field='"+name+"']").removeAttr('disabled') } else { alert('Bylo překročeno minimum'); $(this).val($(this).data('oldValue')); } if(valueCurrent <= maxValue) { $(".btn-numberwidth[data-type='plus'][data-field='"+name+"']").removeAttr('disabled') } else { alert('Bylo překročeno maximum'); $(this).val($(this).data('oldValue')); } valuelen = parseInt($('.input-numberlen').val()); valuewidth = parseInt($('.input-numberwidth').val()); pocet = parseInt($('.pocet1').val()); document.getElementById("price").innerHTML=parseInt(price1[mena]*valuewidth/100*valuelen/100); document.getElementById("price_sum").innerHTML=pocet*parseInt((price1[mena]*valuewidth/100*valuelen/100)); }); $('.btn-numberwidth2').click(function(e){ e.preventDefault(); fieldName = $(this).attr('data-field'); type = $(this).attr('data-type'); var input = $("input[name='"+fieldName+"']"); var currentVal = parseInt(input.val()); if (!isNaN(currentVal)) { if(type == 'minus') { zmena=1 ; if(currentVal > input.attr('min')) { input.val(currentVal - zmena).change(); } if(parseInt(input.val()) == input.attr('min')) { $(this).attr('disabled', true); } } else if(type == 'plus') { zmena=1 ; if(currentVal < input.attr('max')) { input.val(currentVal + zmena).change(); } if(parseInt(input.val()) == input.attr('max')) { $(this).attr('disabled', true); } } } else { input.val(0); } }); $('.input-numberwidth2').focusin(function(){ $(this).data('oldValue', $(this).val()); }); $('.input-numberwidth2').change(function() { minValue = parseInt($(this).attr('min')); maxValue = parseInt($(this).attr('max')); valueCurrent = parseInt($(this).val()); name = $(this).attr('name'); if(valueCurrent >= minValue) { $(".btn-numberwidth2[data-type='minus'][data-field='"+name+"']").removeAttr('disabled') } else { alert('Bylo překročeno minimum'); $(this).val($(this).data('oldValue')); } if(valueCurrent <= maxValue) { $(".btn-numberwidth2[data-type='plus'][data-field='"+name+"']").removeAttr('disabled') } else { alert('Bylo překročeno maximum'); $(this).val($(this).data('oldValue')); } }); $('.btn-numberlen').click(function(e){ e.preventDefault(); fieldName = $(this).attr('data-field'); type = $(this).attr('data-type'); var input = $("input[name='"+fieldName+"']"); var currentVal = parseInt(input.val()); zmena=10; if (!isNaN(currentVal)) { if(type == 'minus') { if(currentVal > input.attr('min')) { input.val(currentVal - zmena).change(); } if(parseInt(input.val()) == input.attr('min')) { $(this).attr('disabled', true); } } else if(type == 'plus') { if(currentVal < input.attr('max')) { input.val(currentVal + zmena).change(); } if(parseInt(input.val()) == input.attr('max')) { $(this).attr('disabled', true); } } } else { input.val(0); } }); $('.input-numberlen').focusin(function(){ $(this).data('oldValue', $(this).val()); }); $('.input-numberlen').change(function() { minValue = parseInt($(this).attr('min')); maxValue = parseInt($(this).attr('max')); valueCurrent = parseInt($(this).val()); name = $(this).attr('name'); if(valueCurrent >= minValue) { $(".btn-numberlen[data-type='minus'][data-field='"+name+"']").removeAttr('disabled') } else { alert('Sorry, the minimum value was reached'); $(this).val($(this).data('oldValue')); } if(valueCurrent <= maxValue) { $(".btn-numberlen[data-type='plus'][data-field='"+name+"']").removeAttr('disabled') } else { alert('Sorry, the maximum value was reached'); $(this).val($(this).data('oldValue')); } valuelen = parseInt($('.input-numberlen').val()); valuewidth = parseInt($('.input-numberwidth').val()); pocet = parseInt($('.pocet1').val()); document.getElementById("price").innerHTML=parseInt(price1[mena]*valuewidth/100*valuelen/100); document.getElementById("price_sum").innerHTML=pocet*parseInt((price1[mena]*valuewidth/100*valuelen/100)); }); $('.pocet1').change(function() { valuelen = parseInt($('.input-numberlen').val()); valuewidth = parseInt($('.input-numberwidth').val()); pocet = parseInt($('.pocet1').val()); document.getElementById("price").innerHTML=parseInt(price1[mena]*valuewidth/100*valuelen/100); document.getElementById("price_sum").innerHTML=pocet*parseInt((price1[mena]*valuewidth/100*valuelen/100)); }); $('.pocet2').change(function() { valuesize = parseInt($('.size1:checked').val()); if (valuesize==2) {price=price2[mena][1]; } else {price=price2[mena][0]; } pocet = parseInt($('.pocet2').val()); document.getElementById("price2").innerHTML=parseInt(price); document.getElementById("price_sum2").innerHTML=parseInt(pocet*price); }); $('.pocet3').change(function() { valuesize = parseInt($('.size2:checked').val()); if (valuesize==2) {price=price3[mena][1]; } else {price=price3[mena][0] ; } pocet = parseInt($('.pocet3').val()); document.getElementById("price3").innerHTML=parseInt(price); document.getElementById("price_sum3").innerHTML=parseInt(pocet*price); }); $('.obr').change(function() { value1 = parseInt($('.vzor:checked').val()); value2 = parseInt($('.trasne:checked').val()); value3 = parseInt($('.size1:checked').val()); value4 = parseInt($('.vzor2:checked').val()); value5 = parseInt($('.size2:checked').val()); if (value1==1 && value2==1 )$("#koberec").attr("src","images/kob1.jpg"); if (value1==1 && value2==2 )$("#koberec").attr("src","images/kob3.jpg"); if (value1==2 && value2==1 )$("#koberec").attr("src","images/kob2.jpg"); if (value1==2 && value2==2 )$("#koberec").attr("src","images/kob4.jpg"); if (value3==1 && value4==1 )$("#polstar").attr("src","images/kob10.jpg"); if (value3==1 && value4==2 )$("#polstar").attr("src","images/kob11.jpg"); if (value3==2 && value4==1 )$("#polstar").attr("src","images/kob12.jpg"); if (value3==2 && value4==2 )$("#polstar").attr("src","images/kob13.jpg"); if (value5==1 )$("#podhlavnik").attr("src","images/kob20.jpg"); if (value5==2 )$("#podhlavnik").attr("src","images/kob21.jpg"); }); (function($,W,D) { var JQUERY4U = {}; JQUERY4U.UTIL = { setupFormValidation: function() { //form validation rules $("#form1").validate({ rules: { jmeno: "required", email: { required: true, email: true }, adress: "required", city: "required", zip: "required", telefon: "required", souhlas: "required", payment: "required" }, messages: { jmeno: "Enter your name and surname/Company name", telefon: "Enter your telephone number", email: "Enter your e-mail", adress: "Enter address", city: "Enter your city", zip: "Enter your postcode", souhlas: "You must agree to the Terms & Conditions", payment: "Choose the payment method
", }, errorPlacement: function(error, element) { if (element.attr("name") == "payment" ) { error.insertAfter("#payment"); } else { error.insertAfter(element); } }, submitHandler: function(form) { $("#reservate").prop( "disabled", true ); form.submit(); } }); } } //when the dom has loaded setup form validation rules $(D).ready(function($) { JQUERY4U.UTIL.setupFormValidation(); }); })(jQuery, window, document); $(window).load(function(){ $("#zakaznik").sticky({ topSpacing: 0 }); idmain=0; mena=$('.mena').val(); $( "" ).cena2(); $('.mena2').val(mena); $('.mena').val(mena); $( ).precenit(); sum=0; }); $('.addtocart').click(function() { valuelen = parseInt($('.input-numberlen').val()); valuewidth = parseInt($('.input-numberwidth').val()); price=document.getElementById("price").innerHTML=parseInt(price1[mena]*valuewidth/100*valuelen/100); valuevzor = parseInt($('.vzor:checked').val()); valuetrasne = parseInt($('.trasne:checked').val()); pocet = parseInt($('.pocet1').val()); idmain++; kosik[idmain] = new Array( [1,valuelen, valuewidth, price,valuevzor,valuetrasne,pocet,idmain]); text='

'+pocet+'x Carpets/covers '+valuewidth+'x'+valuelen+' cm

'; if (valuevzor==1) text=text+'striped pattern, '; else text=text+'full pattern, '; if (valuetrasne==1) text=text+' with fringe

'; else text=text+' without fringe

'; text=text+'PRICE: '+(pocet*price)+' '+mena+''; text=text+'


'; $( ""+ text + " " ).appendTo( "#kosik" ); sum=sum+(pocet*price); document.getElementById("doprava").innerHTML="

1 x Free shipping

PRICE: 0"+' '+mena+'
'; document.getElementById("sum").innerHTML="

TOTAL AMOUNT: "+sum+' '+mena+"


"; $('').attr({ type: 'hidden', id: 'polozkaform'+idmain, value: 'koberec'+'|'+valuewidth+'|'+valuelen+'|'+valuevzor+'|'+valuetrasne+'|'+mena+'|'+pocet+'|'+idmain, name: 'polozka[]' }).appendTo('#form1'); }); $('.addtocart2').click(function() { valuevzor = parseInt($('.vzor2:checked').val()); valuesize = parseInt($('.size1:checked').val()); pocet = parseInt($('.pocet2').val()); idmain++; if (valuesize==2) {price=price2[mena][1]; rozemry='90x50';} else {price=price2[mena][0]; rozemry='45x40'; } kosik[idmain] = new Array( [2,valuesize,price,valuevzor,pocet,idmain]); text='

'+pocet+'x Cushion '+rozemry+' cm

'; if (valuevzor==1) text=text+'striped pattern

'; else text=text+'full pattern

'; text=text+'PRICE: '+(pocet*price)+' '+mena+' '; text=text+'


'; $( ""+ text + " " ).appendTo( "#kosik" ); sum=sum+pocet*price; document.getElementById("doprava").innerHTML="

1 x Free shipping

PRICE: 0"+' '+mena+'
'; document.getElementById("sum").innerHTML="

TOTAL AMOUNT: "+sum+' '+mena+"


"; $('').attr({ type: 'hidden', id: 'polozkaform'+idmain, value: 'polstar'+'|'+valuesize+'|'+valuevzor+'|'+mena+'|'+pocet+'|'+idmain, name: 'polozka[]' }).appendTo('#form1'); }); $('.addtocart3').click(function() { valuesize = parseInt($('.size2:checked').val()); pocet = parseInt($('.pocet3').val()); idmain++; if (valuesize==2) {price=price3[mena][1]; rozemry='18×100';} else {price=price3[mena][0]; rozemry='18×50';} kosik[idmain] = new Array( [3,valuesize,price,pocet,idmain]); text='

'+pocet+'x Headrest '+rozemry+' cm

'; text=text+'PRICE: '+(pocet*price)+' '+mena+'
'; text=text+'


'; $( ""+ text + " " ).appendTo( "#kosik" ); sum=sum+(pocet*price); document.getElementById("doprava").innerHTML="

1 x Free shipping

PRICE: 0"+' '+mena+'
'; document.getElementById("sum").innerHTML="

TOTAL AMOUNT: "+sum+' '+mena+"


"; $('').attr({ type: 'hidden', id: 'polozkaform'+idmain, value: 'podhlavnik'+'|'+valuesize+'|'+mena+'|'+pocet+'|'+idmain, name: 'polozka[]' }).appendTo('#form1'); }); $(document).on('click','.remove',function() { var j= $(this).attr('id'); $("#polozka"+j).remove(); $("#polozkaform"+j).remove(); sum=0; idmain--; kosik.splice(j,1); console.log(kosik ); $( ).precenit(); }); $(document).on('click','.plus',function() { var j= $(this).attr('id'); pom = kosik[j].toString().split(","); if (pom[0]==1) {pocet=parseInt(pom[6])+1;kosik[j] = new Array( [pom[0],pom[1],pom[2], pom[3], pom[4],pom[5],pocet,pom[7]]);} else if (pom[0]==2) {pocet=parseInt(pom[4])+1;kosik[j] = new Array( [pom[0],pom[1],pom[2], pom[3], pocet ,pom[5]]); } else if (pom[0]==3) { pocet=parseInt(pom[3])+1; kosik[j] = new Array( [pom[0],pom[1],pom[2],pocet, pom[4]]); } $( ).precenit(); }); $(document).on('click','.minus',function() { var j= $(this).attr('id'); pom = kosik[j].toString().split(","); if (pom[0]==1) {pocet=parseInt(pom[6])-1; if (pocet>0){kosik[j] = new Array( [pom[0],pom[1],pom[2], pom[3], pom[4],pom[5],pocet,pom[7]]);}} else if (pom[0]==2) {pocet=parseInt(pom[4])-1;if (pocet>0){kosik[j] = new Array( [pom[0],pom[1],pom[2], pom[3], pocet ,pom[5]]); }} else if (pom[0]==3) { pocet=parseInt(pom[3])-1; if (pocet>0){kosik[j] = new Array( [pom[0],pom[1],pom[2],pocet, pom[4]]); } } $( ).precenit(); }); $('.size1').change(function() { pocet = parseInt($('.pocet2').val()); valuesize = parseInt($('.size1:checked').val()); if (valuesize==2) {price=price2[mena][1]; } else {price=price2[mena][0]; } document.getElementById("price2").innerHTML=parseInt(price); document.getElementById("price_sum2").innerHTML=parseInt(pocet*price); }); $('.size2').change(function() { pocet = parseInt($('.pocet3').val()); valuesize = parseInt($('.size2:checked').val()); if (valuesize==2) {price=price3[mena][1]; } else {price=price3[mena][0] ; } document.getElementById("price3").innerHTML=parseInt(price); document.getElementById("price_sum3").innerHTML=parseInt(pocet*price); }); $('.mena').change(function() { mena=$('.mena').val(); document.getElementById("curency").innerHTML=mena document.getElementById("curency1").innerHTML=mena document.getElementById("curency2").innerHTML=mena document.getElementById("curency_sum").innerHTML=mena document.getElementById("curency_sum2").innerHTML=mena document.getElementById("curency_sum3").innerHTML=mena document.getElementById("doprava").innerHTML=""; document.getElementById("sum").innerHTML=""; document.getElementById("formval").innerHTML=""; document.getElementById("kosik").innerHTML=""; sum=0; $("mena").remove(); $('').attr({ type: 'hidden', id: 'mena', value: mena, name: 'mena' }).appendTo('#form1'); $( "" ).cena2(); $('.mena2').val(mena); $('.mena3').val(mena); $( ).precenit(); }); $('.mena2').change(function() { mena=$('.mena2').val(); document.getElementById("curency").innerHTML=mena document.getElementById("curency1").innerHTML=mena document.getElementById("curency2").innerHTML=mena document.getElementById("curency_sum").innerHTML=mena document.getElementById("curency_sum2").innerHTML=mena document.getElementById("curency_sum3").innerHTML=mena document.getElementById("doprava").innerHTML=""; document.getElementById("sum").innerHTML=""; document.getElementById("formval").innerHTML=""; document.getElementById("kosik").innerHTML=""; sum=0; $("mena").remove(); $('').attr({ type: 'hidden', id: 'mena', value: mena, name: 'mena' }).appendTo('#form1'); $( "" ).cena2(); $('.mena3').val(mena); $('.mena').val(mena); $( ).precenit(); }); $('.mena3').change(function() { mena=$('.mena3').val(); document.getElementById("curency").innerHTML=mena document.getElementById("curency1").innerHTML=mena document.getElementById("curency2").innerHTML=mena document.getElementById("curency_sum").innerHTML=mena document.getElementById("curency_sum2").innerHTML=mena document.getElementById("curency_sum3").innerHTML=mena document.getElementById("doprava").innerHTML=""; document.getElementById("sum").innerHTML=""; document.getElementById("formval").innerHTML=""; document.getElementById("kosik").innerHTML=""; sum=0; $("mena").remove(); $('').attr({ type: 'hidden', id: 'mena', value: mena, name: 'mena' }).appendTo('#form1'); $( "" ).cena2(); $('.mena2').val(mena); $('.mena').val(mena); $( ).precenit(); }); jQuery.fn.extend({ cena2: function () { var price; valuesize = parseInt($('.size2:checked').val()); if (valuesize==2) {price=price3[mena][1]; } else {price=price3[mena][0] ; } pocet = parseInt($('.pocet3').val()); document.getElementById("price3").innerHTML=parseInt(price); document.getElementById("price_sum3").innerHTML=parseInt(pocet*price); valuelen = parseInt($('.input-numberlen').val()); valuewidth = parseInt($('.input-numberwidth').val()); price=document.getElementById("price").innerHTML=parseInt(price1[mena]*valuewidth/100*valuelen/100); pocet = parseInt($('.pocet1').val()); document.getElementById("price").innerHTML=parseInt(price); document.getElementById("price_sum").innerHTML=pocet*parseInt(price); valuesize = parseInt($('.size1:checked').val()); if (valuesize==2) {price=price2[mena][1]; } else {price=price2[mena][0] ; } pocet = parseInt($('.pocet2').val()); document.getElementById("price2").innerHTML=parseInt(price); document.getElementById("price_sum2").innerHTML=pocet*parseInt(price); } }); jQuery.fn.extend({ precenit: function () { sum=0; $.each(kosik , function(key1, value1) { if(value1[0]){ res = value1[0].toString().split(","); id=key1; if(res[0]==1){ id2 = res[7]; pocet = res[6]; valuelen = res[1]; valuewidth = res[2]; price=pocet*parseInt((price1[mena]*valuewidth/100*valuelen/100)); valuevzor = res[4]; valuetrasne = res[5]; kosik[id] = new Array( [res[0],res[1],res[2], res[3], res[4],res[5],res[6],id]); $("#polozka"+id2).remove(); text='

'+pocet+'x Carpets/covers '+valuewidth+'x'+valuelen+' cm

'; if (valuevzor==1) text=text+'striped pattern, '; else text=text+'full pattern, '; if (valuetrasne==1) text=text+' with fringe

'; else text=text+' without fringe

'; text=text+'PRICE: '+price+' '+mena+' '; text=text+'


'; $( ""+ text + " " ).appendTo( "#kosik" ); sum=sum+price; $("#polozkaform"+id2).remove(); $('').attr({ type: 'hidden', id: 'polozkaform'+id, value: 'koberec'+'|'+valuewidth+'|'+valuelen+'|'+valuevzor+'|'+valuetrasne+'|'+mena+'|'+pocet+'|'+id, name: 'polozka[]' }).appendTo('#form1'); } if(res[0]==2){ id2 = res[5]; pocet = res[4]; valuevzor = res[3]; valuesize = res[1]; $("#polozka"+id2).remove(); if (valuesize==2) {price=price2[mena][1]; rozemry='90x50';} else {price=price2[mena][0]; rozemry='45x40'; } price=price*pocet; kosik[id] = new Array( [res[0],res[1],res[2], res[3], res[4] ,id]); text='

'+pocet+'x Cushion '+rozemry+' cm

'; if (valuevzor==1) text=text+'striped pattern

'; else text=text+'full pattern

'; text=text+'PRICE: '+price+' '+mena+' '; text=text+'


'; $( ""+ text + " " ).appendTo( "#kosik" ); sum=sum+price; $("#polozkaform"+id2).remove(); $('').attr({ type: 'hidden', id: 'polozkaform'+id, value: 'polstar'+'|'+valuesize+'|'+valuevzor+'|'+mena+'|'+pocet+'|'+id, name: 'polozka[]' }).appendTo('#form1'); } if(res[0]==3){ id2 = res[4]; pocet = res[3]; valuesize = res[1]; $("#polozka"+id2).remove(); if (valuesize==2) {price=price3[mena][1]; rozemry='18×100';} else {price=price3[mena][0]; rozemry='18×50';} price=price*pocet; kosik[id] = new Array( [res[0],res[1],res[2], res[3],id]); text='

'+pocet+'x Headrest '+rozemry+' cm

'; text=text+'PRICE: '+price+' '+mena+'
'; text=text+'


'; $( ""+ text + " " ).appendTo( "#kosik" ); sum=sum+price; $("#polozkaform"+id2).remove(); $('').attr({ type: 'hidden', id: 'polozkaform'+id, value: 'podhlavnik'+'|'+valuesize+'|'+mena+'|'+pocet+'|'+id, name: 'polozka[]' }).appendTo('#form1'); } } document.getElementById("doprava").innerHTML="

1 x Free shipping

PRICE: 0"+' '+mena+'
'; document.getElementById("sum").innerHTML="

TOTAL AMOUNT: "+sum+' '+mena+"


"; }); } });