/*
 * Kaizen-Soft Shop
 * Copyright(c) 2009-2010 Roland Schütz
 * 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");Element.hide("paymentPrice");Element.hide("shippingPrice");Element.hide("totalPrice");loading=true}function endLoading(){var a=document.getElementById("json_data").innerHTML.evalJSON();totalPriceWithTaxes=a.totalPriceWithTaxes;totalPriceWithoutTaxes=a.totalPriceWithoutTaxes;document.getElementById("totalProductPriceWithTaxes").innerHTML=a.totalProductPriceWithTaxes;document.getElementById("totalProductPriceWithoutTaxes").innerHTML=a.totalProductPriceWithoutTaxes;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");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}};