﻿_ecshopOkButton = ecTranslate("common-buttons.common-ok"); _ecshopCancelButton = ecTranslate("common-buttons.common-cancel"); _ecshopCloseWindow = ecTranslate("common-buttons.common-close-window"); _ecshopRemoveLastProdHeading = ecTranslate("checkout-headings.checkout-remove-last-product-from-basket-heading"); _ecshopRemoveLastProdMessage = ecTranslate("checkout-labels.checkout-remove-last-product-from-basket-message"); _ecshopYouJustAddedHeader = ecTranslate("basket-labels.basket-just-added"); _ecshopShowSearchResult = ecTranslate("product-labels.product-back-to-search"); _ecshopHideSearchResult = ecTranslate("product-labels.product-search-hide-result"); function ecShopGoToCheckout(loginLink, checkoutLink) { var cookieValue = readCookie(_ecshopUserLoggedInCookie); if(cookieValue == 'undefined' || cookieValue == '' || cookieValue == null) { cookieValue = "0";}
if(cookieValue == "1"){ link = checkoutLink;} else { link = loginLink;}
var dontRegister = ecShopReturnFieldFromCookie("dontregister"); var checkoutStep = 1; var updateLink = (link.indexOf('sign_in') > 0) ? link : (link + "#step" + checkoutStep); ecShopGoogleTrackCheckout(checkoutStep); if(dontRegister == "true" && checkoutLink.length > 0) { location.replace(checkoutLink + '#step' + checkoutStep);} else { var currentUrl = document.location.href; if(currentUrl.indexOf('#step4') > 0) { location.replace(link + "#step1"); if (navigator.appName == 'Microsoft Internet Explorer') { history.go(0);} else { window.location.reload();}
} else { location.replace(updateLink);}
}
}
function ecShopLoadCheckout() { _ecshopInOrderProcess = true; ecShopChangeSelectedTab(1); window.onbeforeunload = ecShopLeaveCheckout; if(_ecshopUserId.length > 0) { ecShopGetAddresses("webshop", _ecshopUserId, "ecshopfx_address_list", true);}
else { if(_ecshopAddressFormat != null) { ecShopLoadStep1NotRegistered(_ecshopAddressFormat);} else { ecShop.Web.Soap.ecShopWS.GetAddressForm(ecShopLoadStep1NotRegistered, OnError);}
}
}
function ecShopLeaveCheckout() { _ecshopInOrderProcess = false; clearInterval(_ecshopObserveTimer); if(_ecshopUseCookiesInCheckout) { ecShopAddOrUpdateArray("leftcheckout", true);}
}
function ecShopUpdateCheckoutUrl(step) { if(location.hash != "#step" + step) { }
}
function ecShopLoadStep1Registered() { if(_ecshopUseCookiesInCheckout) { var leftCheckout = ecShopReturnFieldFromCookie("leftcheckout"); if(leftCheckout == "true") { var selectedBilling = ecShopReturnFieldFromCookie("selectedbilling"); var selectedShipping = 0; if(selectedBilling == null || selectedBilling == "") { selectedBilling = 0;} else { var selectedBillingOption = document.getElementById("ecshopfx_billing_radio_" + selectedBilling); if(selectedBillingOption) { selectedBillingOption.checked = true;}
}
var showShipping = ecShopReturnFieldFromCookie("showshipping"); if(showShipping == "true") { var shippingAddressContainer = document.getElementById("ecshopfx_other_shipping_address"); selectedShipping = ecShopReturnFieldFromCookie("selectedshipping"); if(selectedShipping == null || selectedShipping == "") { selectedShipping = 0;} else { var selectedShippingOption = document.getElementById("ecshopfx_shipping_radio_" + selectedBilling); if(selectedShippingOption) { selectedShippingOption.checked = true;}
}
if(shippingAddressContainer) { shippingAddressContainer.checked = true; toggleObject("ecshopfx_shipping_address");}
}
var step = ecShopReturnFieldFromCookie("step"); if(step.length > 0) { if(step == 2 || step == 3) { goStep2(); ecShopUpdateCheckoutUrl(2);}
}
ecShopAddOrUpdateArray("leftcheckout", false);}
}
}
function ecShopLoadStep1NotRegistered(results) { if(_ecshopAddressFormat == null) { _ecshopAddressFormat = results;}
ecShopCreateAddressForm(results, "ecshopfx_billing_box", _ecshopShopParam, "billing"); if(_ecshopUseCookiesInCheckout) { var leftCheckout = ecShopReturnFieldFromCookie("leftcheckout"); if(leftCheckout == "true") { ecShopUpdateAddressFromCookie("billing"); var showShipping = ecShopReturnFieldFromCookie("showshipping"); if(showShipping == "true") { var shippingAddressContainer = document.getElementById("ecshopfx_other_shipping_address"); if(shippingAddressContainer) { shippingAddressContainer.checked = true; ecShopShowShippingAddress();}
}
var email = ecShopReturnFieldFromCookie("email"); var container = document.getElementById(_ecshopShopParam + "email"); if(container) { if(container.value == "") { container.value = email;}
}
var step = ecShopReturnFieldFromCookie("step"); if(step.length > 0) { if(step == 2 || step == 3) { goStep2(); ecShopUpdateCheckoutUrl(2);}
}
ecShopAddOrUpdateArray("leftcheckout", false);}
}
}
function ecShopCreateAddressForm(results, elementId, param, prefix) { if(prefix == undefined)
prefix = ""; var html = ''; for(var i = 0; i < results.length; i++) { var collection = "common-labels."; var word = "common-field-" + results[i].Xml; var translation = ecTranslate(collection + word); var name = (translation.indexOf(word) > -1) ? results[i].Name : translation; html += '<div class="clear">'; html += '   <label for="' + param + prefix + results[i].Xml + '">' + (results[i].Validation.indexOf("validate") > -1 ? '* ' : '') + ' ' + name + '</label>'; if(results[i].IsReadOnly) { html += '   <input id="' + param + prefix + results[i].Xml + '" name="' + param + results[i].Xml + '" class="' + results[i].Validation + '" size="20" maxlength="' + results[i].MaxLength + '" value="' + results[i].DefaultValue + '" readonly="readonly"></input>';} else { html += '   <input id="' + param + prefix + results[i].Xml + '" name="' + param + results[i].Xml + '" class="' + results[i].Validation + '" size="20" maxlength="' + results[i].MaxLength + '" value=""></input>';}
html += '</div>';}
ReplaceContent(elementId, html);}
function ecShopShowShippingAddress() { var shippingAddress = document.getElementById("ecshopfx_shipping_address"); if(shippingAddress) { toggleObject("ecshopfx_shipping_address"); if(shippingAddress.className.indexOf("ecshop_hide") < 0) { var shippingBox = document.getElementById("ecshopfx_shipping_box"); if(shippingBox) { ecShopCreateAddressForm(_ecshopAddressFormat, "ecshopfx_shipping_box", _ecshopShopParam, "shipping"); if(_ecshopUseCookiesInCheckout) ecShopUpdateAddressFromCookie("shipping");}
}
}
var shippingCheckBox = document.getElementById("ecshopfx_other_shipping_address"); if(shippingCheckBox) { ecShopAddOrUpdateArray("showshipping", shippingCheckBox.checked);}
}
function ecShopLoadAddressesFromStep1(billingOption, shippingOption) { if(_ecshopAddressFormat == null) { ecShopGetAddressFormatArray(); setTimeout("ecShopLoadAddressesFromStep1('" + billingOption + "', '" + shippingOption + "')", 500);} else { if(billingOption == undefined) billingOption = 0; if(shippingOption == undefined) shippingOption = 0; if(billingOption > 0) { var billingRadio = document.getElementById("ecshopfx_billing_radio_" + billingOption); if(billingRadio) { billingRadio.checked = true;}
ecShopAddOrUpdateArray("selectedbilling", billingOption);}
var billingHTML = ecShopLoadAddress("billing", billingOption); ReplaceContent("ecshopfx_billing_from_step_1", billingHTML); var shippingAddressContainer = document.getElementById("ecshopfx_other_shipping_address"); if(shippingAddressContainer.checked) { if(shippingOption > 0) { var shippingRadio = document.getElementById("ecshopfx_shipping_radio_" + shippingOption); if(shippingRadio) { shippingRadio.checked = true;}
ecShopAddOrUpdateArray("selectedshipping", shippingOption);}
var shippingHTML = ecShopLoadAddress("shipping", shippingOption); ReplaceContent("ecshopfx_shipping_from_step_1", shippingHTML); hideObject("ecshopfx_same_as_billing");} else { ReplaceContent("ecshopfx_shipping_from_step_1", billingHTML); showObject("ecshopfx_same_as_billing");}
}
}
function ecShopLoadAddress(prefix, option) { var html = ''; var array = _ecshopCookieArray; if(option == undefined) { option = 0;}
if(_ecshopUseCookiesInCheckout && option == 0) { ecShopUpdateAddressFromCookie(prefix);}
for(var i = 0; i < _ecshopAddressFormat.length; i++) { var value = ""; var container = ""; if(option > 0) { var id = "ecshopfx_" + prefix + "_option_" + option + "_" + _ecshopAddressFormat[i].Xml; container = document.getElementById(id); if(container) { value = container.innerHTML;}
} else { container = document.getElementById(_ecshopShopParam + prefix + _ecshopAddressFormat[i].Xml); if(container) { value = container.value;}
}
if(value == "" || value == undefined || value == "undefined") { value = array[prefix + _ecshopAddressFormat[i].Xml];}
if(value != "" && value != undefined) { html += value; if(_ecshopAddressFormat[i].LineBreak) { html += '<br/>';} else { html += ' ';}
}
}
return html;}
function ecShopChooseAddress(option, prefix) { for(var i = 0; i < _ecshopXmlAttributes.length; i++) { var id = "ecshopfx_" + prefix + "_option_" + option + "_" + _ecshopXmlAttributes[i]; var container = document.getElementById(id); if(container) { var value = container.innerHTML; ecShopAddOrUpdateArray(prefix + _ecshopXmlAttributes[i], value);}
}
}
function ecShopLoadMethods(method, type) { var value = ecShopReturnFieldFromCookie(method); var name = ecShopReturnFieldFromCookie(type); if(value.length > 0) { var radioOptions = document.getElementsByName(_ecshopShopParam + method); if(radioOptions) { for(var i = 0; i < radioOptions.length; i++) { if(radioOptions[i].value == (name + "|" + value)) { radioOptions[i].checked = true; return true;}
}
}
}
return false;}
function ecShopCreateOrderAddressXml(prefix) { var xml = ""; if(prefix == "shipping") { var showShipping = ecShopReturnFieldFromCookie("showshipping"); var shippingAddressExists = ecShopReturnFieldFromCookie("shippingfirstname"); if(showShipping == "false" || shippingAddressExists == undefined || shippingAddressExists == "") { prefix = "billing";}
}
for(var i = 0; i < _ecshopXmlAttributes.length; i++) { var value = ecShopReturnFieldFromCookie(prefix + _ecshopXmlAttributes[i]); if(value != undefined) { xml += "<attribute><name>" + _ecshopXmlAttributes[i] + "</name><value>" + value + "</value></attribute>";}
}
return xml;}
function ecShopTrackIdleTime() { var obj = document.body; if (obj.attachEvent) { obj.attachEvent('onmousemove',ecShopCallResetCounter); obj.attachEvent('onkeydown',ecShopCallResetCounter);}
else if (obj.addEventListener) { try { emulateAttachEvent(); obj.attachEvent('mousemove',ecShopCallResetCounter); obj.attachEvent('keydown',ecShopCallResetCounter);} catch (err) { obj.onmousemove = ecShopCallResetCounter; obj.onkeydown = ecShopCallResetCounter;}
}
ecShopStartCounter();}
function ecShopLogout() { createCookie('ecwebuserid' + _ecshopWebsiteId + 'd', '', 0); createCookie(_ecshopUserLoggedInCookie, '', 0);}
function ecShopIncreaseCounter() { var x = readCookie(_ecshopTimeoutCookie); var currentCount = parseInt(x); var delay = 60000; var pageTimeout = parseInt(_ecshopIdleTimeout); if(currentCount < pageTimeout) { currentCount = currentCount+1; createCookie(_ecshopTimeoutCookie,currentCount,1); _ecshopTimeoutObject = setTimeout(ecShopIncreaseCounter,delay);} else { clearTimeout(_ecshopTimeoutObject); createCookie(_ecshopTimeoutCookie,'-1',-1); ecShopDeleteAllCookies(); var currentUrl = document.location.href; if(currentUrl.toLowerCase().indexOf('checkout') > -1 || currentUrl.toLowerCase().indexOf('account') > -1) { document.location.href = ecShopReturnHost();}
}
}
function ecShopStartCounter() { createCookie(_ecshopTimeoutCookie,'0',1); ecShopIncreaseCounter();}
function ecShopResetCounter() { clearTimeout(_ecshopTimeoutObject); ecShopStartCounter();}
function ecShopCallResetCounter() { ecShopResetCounter();}
ecShopAddLoadEvent(ecShopTrackIdleTime); function ecShopSaveNodesInCookie() { var arrayValues = ""; for(var i = 0; i < _ecshopNodeArray.length; i++) { arrayValues += _ecshopNodeArray[i] + "|";}
createCookie(_ecshopNodeCookie, arrayValues, 1);}
function ecShopReturnNodesFromCookie(cookie) { var arrayValues = readCookie(cookie); var nodeCount = 0; var nodes = new Array(); if(arrayValues == null) { arrayValues = "";}
if(arrayValues.length > 0) { var tmpArray = arrayValues.split("|"); for(var i = 0; i < tmpArray.length; i++) { if(tmpArray[i] != "") { nodes[nodeCount] = tmpArray[i]; nodeCount++;}
}
}
return nodes;}
function ecShopReturnArray(type) { if(type == undefined) { type = "";}
if(type == "nodes") { if(_ecshopNodeArray.length == 0) { _ecshopNodeArray = ecShopReturnNodesFromCookie(_ecshopNodeCookie);}
return _ecshopNodeArray;} else { if(_ecshopCookieArray["billingfirstname"] == undefined || _ecshopCookieArray["billingfirstname"] == "") { _ecshopCookieArray = ecShopReturnArrayFromCookie(_ecshopCheckoutCookie);}
return _ecshopCookieArray;}
}
function ecShopAddOrUpdateArray(node, value) { _ecshopCookieArray = ecShopReturnArray(); _ecshopNodeArray = ecShopReturnArray("nodes"); var check = _ecshopCookieArray[node]; if(check == null || check == undefined) { _ecshopNodeArray[_ecshopNodeArray.length] = node; ecShopSaveNodesInCookie();}
_ecshopCookieArray[node] = value; if(_ecshopUseCookiesInCheckout) { ecShopSaveArrayInCookie(_ecshopCheckoutCookie, _ecshopCookieArray);}
}
function ecShopSaveArrayInCookie(cookie, array) { var arrayValues = ""; for(var i = 0; i < _ecshopNodeArray.length; i++) { arrayValues += _ecshopNodeArray[i] + ":ecsplit:" + array[_ecshopNodeArray[i]] + "^ecsplit^";}
createCookie(cookie, arrayValues, 1);}
function ecShopReturnArrayFromCookie(cookie) { var cookieValue = readCookie(cookie); var cookieArray = new Array(); if(cookieValue == null) { cookieValue = "";}
if(cookieValue.length > 0) { var elements = cookieValue.split("^ecsplit^"); for(var i = 0; i < elements.length; i++) { if(elements[i].length > 0) { var values = elements[i].split(":ecsplit:"); if(values[0] != null && values[1] != null) { cookieArray[values[0]] = values[1];}
}
}
}
return cookieArray;}
function ecShopReturnFieldFromCookie(field) { _ecshopCookieArray = ecShopReturnArray(); var value = _ecshopCookieArray[field]; if(value != null) { return value;} else { return "";}
}
function ecShopUpdateAddressFromCookie(prefix) { _ecshopCookieArray = ecShopReturnArray(); for(var i = 0; i < _ecshopXmlAttributes.length; i++) { var container = document.getElementById(_ecshopShopParam + prefix + _ecshopXmlAttributes[i]); if(container) { var value = _ecshopCookieArray[prefix + _ecshopXmlAttributes[i]]; if(value != null && container.value == "") { container.value = value;}
}
}
}
function ecShopSaveAddressInArray(prefix) { for(var i = 0; i < _ecshopXmlAttributes.length; i++) { var container = document.getElementById(_ecshopShopParam + prefix + _ecshopXmlAttributes[i]); if(container) { ecShopAddOrUpdateArray(prefix + _ecshopXmlAttributes[i], container.value);}
}
}
function ecShopHistoryStep(step, goingback) { var returnToCheckoutStep = false; _ecshopInOrderProcess = true; if(step == 1) { goBackToStep1();} else { if(_ecshopUseCookiesInCheckout) { var leftCheckout = ecShopReturnFieldFromCookie("leftcheckout"); if(leftCheckout == "true") { returnToCheckoutStep = true;}
}
if(!returnToCheckoutStep) { ecShopCheckoutStep(step, goingback);}
}
}
function ecShopCheckoutStep(step, goingback) { if(goingback == undefined) goingback = false; if(goingback) { if(step == 1) goBackToStep1(); else if(step == 2) goBackToStep2();} else { if(step == 2) goStep2(); else if(step == 3) goStep3(); else if(step == 4) goStep4();}
}
var _ecshopHistoryInterval = null; function ecShopCheckHistory() { }
function ecShopGoToStepFromHistory(step) { }
if(_ecshopInOrderProcess || location.href.toLowerCase().indexOf("checkout") > -1) { if (navigator.appName == 'Microsoft Internet Explorer') { } else { }
}
function goBackToStep1() { ecShopCheckoutTransform(1);}
function goStep2() { var userId = _ecshopUserId; var missingText = ecTranslate("common-labels.common-form-validate-ismissing"); var incorrectText = ecTranslate("common-labels.common-form-validate-notvalid"); var shippingAddressContainer = document.getElementById("ecshopfx_other_shipping_address"); if(shippingAddressContainer) { ecShopAddOrUpdateArray("showshipping", shippingAddressContainer.checked);}
if(userId == "") { if(validateForm("ecshopfx_billingAddressForm", missingText, "", incorrectText, "")) { ecShopSaveAddressInArray("billing"); var emailContainer = document.getElementById(_ecshopShopParam + "email"); ecShopAddOrUpdateArray("email",emailContainer.value); if(shippingAddressContainer.checked) { if(validateForm("ecshopfx_shipping_address", missingText, "", incorrectText, "")) { ecShopSaveAddressInArray("shipping");} else { ecShopUpdateStepUrl(2, 1); ecShopUpdateCheckoutUrl(1); return;}
}
} else { return;}
ecShopLoadAddressesFromStep1();} else { var selectedShippingAddress = 0; var selectedBillingAddress = getSelectedValue("billing_options"); ecShopAddOrUpdateArray("email", _ecshopUserEmail); ecShopAddOrUpdateArray("userid", userId); if(selectedBillingAddress > 0) { ecShopChooseAddress(selectedBillingAddress, "billing"); if(shippingAddressContainer.checked) { selectedShippingAddress = getSelectedValue("shipping_options"); if(selectedShippingAddress > 0) { ecShopChooseAddress(selectedShippingAddress, "shipping");} else { CreateError(ecTranslate("checkout-errors.checkout-address-select-shipping-address")); ecShopUpdateStepUrl(2, 1); ecShopUpdateCheckoutUrl(1); return;}
}
} else { CreateError(ecTranslate("checkout-errors.checkout-address-select-billing-address")); ecShopUpdateStepUrl(2, 1); ecShopUpdateCheckoutUrl(1); return;}
ecShopLoadAddressesFromStep1(selectedBillingAddress, selectedShippingAddress);}
var selectedShippingPostcode = ecShopReturnFieldFromCookie("shippingpostalcode"); var selectedBillingPostcode = ecShopReturnFieldFromCookie("billingpostalcode"); _ecshopDynamicRatePostalcode = (selectedShippingPostcode != "") ? selectedShippingPostcode : selectedBillingPostcode; ecShopSelectShippingMethod(); ecShopCheckoutTransform(2);}
function ecShopSelectShippingMethod() { var selected_shipping_obj = getSelectedObj('ec_webshop_page_6_shippingmethod'); var selected_shipping_pos = (selected_shipping_obj) ? selected_shipping_obj.getAttribute("id").replace("ship","") : 1; var selected_shipping = getSelectedValue('ec_webshop_page_6_shippingmethod'); var shippingValue = selected_shipping.split('|'); var shippingMethod = (shippingValue.length > 0) ? shippingValue[0] : ""; var shippingGuid = (shippingValue.length > 1) ? shippingValue[1] : ""; var inpShippingRestriction = document.getElementById("ecshopfx_shipping_restriction_" + shippingGuid); var orderPrice = document.getElementById("ecshopfx_total_product_price").value; if(inpShippingRestriction && inpShippingRestriction.value == "dynamic-rate") { var txtShippingRestrictions = document.getElementById("ecshopfx_shipping_dynamic_" + shippingGuid); _ecshopDynamicRateSelected = true; ecShopFillDynamicShippingRate(txtShippingRestrictions, false, 'ecshopfx_shipping_price', 'ecshopfx_totalprice', selected_shipping_pos, orderPrice);} else if(inpShippingRestriction && inpShippingRestriction.value == "dynamic-rate-orderprice") { _ecshopDynamicRateSelected = true; ecShopGetDynamicShippingRate('ecshopfx_shipping_price', 'ecshopfx_totalprice', selected_shipping_pos, orderPrice);} else { _ecshopDynamicRateSelected = false;}
}
function goBackToStep2() { ecShopCheckoutTransform(2, true);}
function goStep3() { 
    var step3Container = document.getElementById("ecshopfx_container_step3"); 
    if(step3Container) { step3Container.innerHTML = "";}
    if(_ecshopCheckoutComplete) { }
    else { 
        var isWebpayment = false; var typeOfWebpayment = ""; var ecshop_err = ""; var selected_shipping = getSelectedValue('ec_webshop_page_6_shippingmethod'); var selected_payment = getSelectedValue('ec_webshop_page_6_paymentmethod'); var selected_payment_obj = getSelectedObj('ec_webshop_page_6_paymentmethod'); 
        if(selected_shipping != -1 && selected_payment != -1) { 
            var paymentValue = selected_payment.split('|'); var paymentMethod = (paymentValue.length > 0) ? paymentValue[0] : ""; var paymentGuid = (paymentValue.length > 1) ? paymentValue[1] : ""; var paymentInputId = selected_payment_obj.getAttribute("id"); 
            var paymentDescription = ""; 
            if(paymentInputId != null) { var paymentDescriptionObj = document.getElementById("ecshopfx_" + paymentInputId); 
                if(paymentDescriptionObj) { paymentDescription = paymentDescriptionObj.innerHTML;}
            }
            ecShopAddOrUpdateArray("paymentmethod", paymentGuid); ecShopAddOrUpdateArray("paymentname", paymentMethod); var shippingValue = selected_shipping.split('|'); 
            var shippingMethod = (shippingValue.length > 0) ? shippingValue[0] : ""; var shippingGuid = (shippingValue.length > 1) ? shippingValue[1] : ""; 
            ecShopAddOrUpdateArray("shippingmethod", shippingGuid); ecShopAddOrUpdateArray("shippingname", shippingMethod); 
            if(selected_payment != -1) { 
                if(paymentDescription.toLowerCase() == 'credit card'){ 
                    var selected_cardType = getSelectedValue('credit_card_type'); ecShopAddOrUpdateArray("ecshopcardtype", selected_cardType); 
                    var missingText = ecTranslate("common-labels.common-form-validate-ismissing"); var notValidText = ecTranslate("common-labels.common-form-validate-notvalid"); var expiredText = ecTranslate("common-labels.common-form-validate-ccexpired"); 
                    if(!validateForm("ecshopfx_paydesc1", missingText, "", notValidText, expiredText)) { 
                        ecShopUpdateStepUrl(3, 2); ecShopUpdateCheckoutUrl(2); return;
                    }
                } 
                else if(paymentDescription.toLowerCase().indexOf("webpayment") > -1) { isWebpayment = true; typeOfWebpayment = paymentDescription.toLowerCase().replace("webpayment-","");
                }
            }
            var shippingRestriction = document.getElementById("ecshopfx_shipping_restriction_" + shippingGuid); var shippingAgent = document.getElementById("ecshopfx_shipping_agent"); 
            if(shippingRestriction && shippingRestriction.value == "dynamic-rate" && !_ecshopDynamicRateValid) { 
                ecshop_err = ecTranslate("checkout-errors.checkout-select-valid-shipping"); CreateError(ecshop_err); ecShopUpdateStepUrl(3, 2); ecShopUpdateCheckoutUrl(2); return;
            }
            if(shippingAgent && _ecshopSelectedDeliveryAgent == "") { ecshop_err = ecTranslate("checkout-errors.checkout-select-valid-shippingtime"); CreateError(ecshop_err); ecShopUpdateStepUrl(3, 2); ecShopUpdateCheckoutUrl(2); return;}
        } 
        else { 
            if(selected_shipping == -1) { ecshop_err = ecTranslate("checkout-errors.checkout-select-shipping") + "<br/>";}
            if(selected_payment == -1) { ecshop_err += ecTranslate("checkout-errors.checkout-select-payment") + "\n";}
            CreateError(ecshop_err); ecShopUpdateStepUrl(3, 2); ecShopUpdateCheckoutUrl(2); return;
        }
        hideObject("ecshopfx_container_step1"); hideObject("ecshopfx_container_step2"); showObject("ecshopfx_container_step3"); var ecshop_orderXML = ""; 
        if(_ecshopDynamicRateSelected) { ecshop_orderXML += '<orderinfo><paymentmethod>' + paymentGuid + '</paymentmethod><shippingmethod updaterate="' + _ecshopDynamicRate + '">' + shippingGuid + '</shippingmethod><attributes><attribute><name>deliverydate</name><value>' + _ecshopSelectedDeliveryTime + '|' + _ecshopSelectedDeliveryDate + '</value></attribute>';} 
        else { ecshop_orderXML += '<orderinfo><paymentmethod>' + paymentGuid + '</paymentmethod><shippingmethod>' + shippingGuid + '</shippingmethod><attributes>';}
        ecshop_orderXML += ecShopCreateOrderAddressXml("shipping"); ecshop_orderXML += "<attribute><name>email</name><value>" + ecShopReturnFieldFromCookie("email") + "</value></attribute>"; 
        if(getSelectedValue('ec_webshop_page_6_paymentmethod') != -1){ 
            var ecshop_selectedPayment = getSelectedValue('ec_webshop_page_6_paymentmethod'); 
            if(paymentDescription.toLowerCase() == 'credit card'){ 
                var objCreditCardMonth = document.getElementById('exp_month'); var objCreditCardYear = document.getElementById('exp_year'); var objCVC = document.getElementById('cvc'); 
                var objNameOnCard = document.getElementById('name_on_card'); ecshop_orderXML += "<attribute><name>credit_card_expire</name><value>" + objCreditCardMonth.options[objCreditCardMonth.selectedIndex].value + "/" + objCreditCardYear.options[objCreditCardYear.selectedIndex].value + "</value></attribute>"; 
                ecshop_orderXML += "<attribute><name>credit_card_number</name><value>" + document.getElementById('card_number').value + "</value></attribute>"; ecshop_orderXML += "<attribute><name>cardtype</name><value>" + getSelectedValue('credit_card_type') + "</value></attribute>"; 
                ecshop_orderXML += "<attribute><name>cvc</name><value>" + objCVC.value + "</value></attribute>"; ecshop_orderXML += "<attribute><name>name_on_card</name><value>" + objNameOnCard.value + "</value></attribute>";
            }
        }
        if(_ecshopUserComments == "true") { var ecshopUserComments = document.getElementById("ecshopfx_usercomments"); 
            if(ecshopUserComments && ecshopUserComments.value.length > 0) {ecshop_orderXML += "<attribute><name>notes</name><value>" + HtmlEncode(ecshopUserComments.value) + "</value></attribute>";}
            else if(ecshopUserComments) {ecshop_orderXML += "<attribute><name>notes</name><value>N/A</value></attribute>";}
        }
        ecshop_orderXML += "</attributes><queryparams><querystring><name>confirm</name><value>false</value></querystring>"; ecshop_orderXML += "<querystring><name>infostage</name><value>confirm</value></querystring></queryparams></orderinfo>"; 
        ecShopCheckoutTransform(3); ecShopUpdateOrder('confirm', 'false', HtmlEncode(ecshop_orderXML), 'ecshopfx_container_step3', 'orderprocess', isWebpayment, typeOfWebpayment);
    }
}
function goStep4(refId) { var err = ''; if(refId == undefined)
{ refId = "";}
clearTimeout(_ecshopHistoryInterval); disable('ecshopfx_gostep4'); var privacyPolicy = document.getElementById('privacy_policy'); var terms = document.getElementById('terms_and_conditions'); if(privacyPolicy && terms) { if( (!privacyPolicy.checked) || (!terms.checked) ){ if( !(privacyPolicy.checked) && !(terms.checked) ){ err = ecTranslate("checkout-errors.checkout-accept-both-policyandterms");}
else if( !(terms.checked) ){ err = ecTranslate("checkout-errors.checkout-accept-termsandconditions");}
else if(!privacyPolicy.checked) { err = ecTranslate("checkout-errors.checkout-accept-privacyandpolicy");}
}
if(err != '') { CreateError(err); enable('ecshopfx_gostep4'); ecShopUpdateStepUrl(4, 3); return;}
}
var ecshop_orderXML = ""; if(_ecshopDynamicRateSelected) { ecshop_orderXML += '<orderinfo><paymentmethod>' + ecShopReturnFieldFromCookie("paymentmethod") + '</paymentmethod><shippingmethod updaterate="' + _ecshopDynamicRate + '">' + ecShopReturnFieldFromCookie("shippingmethod") + '</shippingmethod><attributes><attribute><name>deliverydate</name><value>' + _ecshopSelectedDeliveryTime + '|' + _ecshopSelectedDeliveryDate + '</value></attribute>';} else { ecshop_orderXML += '<orderinfo><paymentmethod>' + ecShopReturnFieldFromCookie("paymentmethod") + '</paymentmethod><shippingmethod>' + ecShopReturnFieldFromCookie("shippingmethod") + '</shippingmethod><attributes>';}
ecshop_orderXML += ecShopCreateOrderAddressXml("shipping"); ecshop_orderXML += "<attribute><name>email</name><value>" + ecShopReturnFieldFromCookie("email") + "</value></attribute>"; var selected_payment = getSelectedValue('ec_webshop_page_6_paymentmethod'); var selected_payment_obj = getSelectedObj('ec_webshop_page_6_paymentmethod'); if(selected_payment != -1) { var paymentInputId = selected_payment_obj.getAttribute("id"); var paymentDescription = ""; if(paymentInputId != null) { var paymentDescriptionObj = document.getElementById("ecshopfx_" + paymentInputId); if(paymentDescriptionObj) { paymentDescription = paymentDescriptionObj.innerHTML;}
}
var ecshop_selectedPayment = getSelectedValue('ec_webshop_page_6_paymentmethod'); if(paymentDescription.toLowerCase() == 'credit card'){ var objCreditCardMonth = document.getElementById('exp_month'); var objCreditCardYear = document.getElementById('exp_year'); var objCVC = document.getElementById('cvc'); ecshop_orderXML += "<attribute><name>credit_card_expire</name><value>" + objCreditCardMonth.options[objCreditCardMonth.selectedIndex].value + "/" + objCreditCardYear.options[objCreditCardYear.selectedIndex].value + "</value></attribute>"; ecshop_orderXML += "<attribute><name>credit_card_number</name><value>" + document.getElementById('card_number').value+"</value></attribute>"; ecshop_orderXML += "<attribute><name>cardtype</name><value>" + getSelectedValue('credit_card_type') +"</value></attribute>"; ecshop_orderXML += "<attribute><name>cvc</name><value>" + objCVC.value + "</value></attribute>"; ecshop_orderXML += "<attribute><name>name_on_card</name><value>" + ecShopReturnFieldFromCookie("billingfirstname") + ' ' + ecShopReturnFieldFromCookie("billinglastname") + "</value></attribute>";}
}
if(_ecshopUserComments == "true") { var ecshopUserComments = document.getElementById("ecshopfx_usercomments"); 
    if(ecshopUserComments && ecshopUserComments.value.length > 0) { ecshop_orderXML += "<attribute><name>notes</name><value>" + HtmlEncode(ecshopUserComments.value) + "</value></attribute>";}
    else if(ecshopUserComments) { ecshop_orderXML += "<attribute><name>notes</name><value>N/A</value></attribute>"; }
}
ecshop_orderXML += "</attributes><queryparams><querystring><name>confirm</name><value>true</value></querystring></queryparams></orderinfo>"; ecShopCheckoutTransform(4); ecShopUpdateOrder('confirm', 'true', HtmlEncode(ecshop_orderXML), 'ecshop_checkout_container', 'orderreceipt', false, "", refId);}
function ecShopCheckoutTransform(step, goingback) { if(goingback == undefined) { goingback = false;}
ecShopChangeSelectedTab(step); if(!goingback) ecShopGoogleTrackCheckout(step); if(step < 4) ecShopAddOrUpdateArray("step", step); for(var i = 1; i < 5; i++) { if(i == step) { showObject("ecshopfx_container_step" + i);} else { hideObject("ecshopfx_container_step" + i);}
}
}
function ecShopUpdateStepUrl(current, wanted) { ecShopAddOrUpdateArray("step", wanted);}
function ecShopChangeSelectedTab(currentStep) { var title = ecTranslate("checkout-headings.checkout-map"); for(var i = 1; i < 5; i++) { var step = document.getElementById("step" + i + "_tab_lbl"); var separate = document.getElementById("step" + i + "_sep"); if(i == currentStep) { separate.className = "sep current"; step.className = "current";} else if(i < currentStep) { separate.className = "sep completed"; step.className = "completed";} else { separate.className = "sep"; step.className = "";}
if(i <= currentStep) { title += " > " + step.innerHTML.replace("&amp;","&");}
}
document.title = title;}
function ecShopUpdateOrder(stage, createOrder, orderxml, elementID, entity, isWebpayment, typeOfWebpayment, webpaymentRefId)
{ if(createOrder == "true") { CreateUpdate(ecTranslate("checkout-labels.checkout-submitting-order"));} else if(createOrder == "false" && stage != "info") { CreateUpdate(ecTranslate("checkout-labels.checkout-preparing-order"));}
if(entity == undefined)
entity = "orderprocess"; if(isWebpayment == undefined)
isWebpayment = false; if(typeOfWebpayment == undefined)
typeOfWebpayment = ""; if(webpaymentRefId == undefined)
webpaymentRefId = ""; var _pageId = _ecshopOrderPageId; var _positionId = _ecshopOrderPositionId; var _pageType = "1"; var _stage = stage; var _createorder = createOrder; var _orderXML = orderxml; var soapBodyOrderProcess = new SOAPObject("orderProcess"); soapBodyOrderProcess.ns = "http://tempuri.org/"; soapBodyOrderProcess.appendChild(new SOAPObject("pageId")).val(_pageId); soapBodyOrderProcess.appendChild(new SOAPObject("positionId")).val(_positionId); soapBodyOrderProcess.appendChild(new SOAPObject("pageType")).val(_pageType); soapBodyOrderProcess.appendChild(new SOAPObject("stage")).val(_stage); soapBodyOrderProcess.appendChild(new SOAPObject("createorder")).val(_createorder); soapBodyOrderProcess.appendChild(new SOAPObject("orderInfoXml")).val(_orderXML); var OrderSR = new SOAPRequest("http://tempuri.org/orderProcess", soapBodyOrderProcess); OrderSR.addNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance"); OrderSR.addNamespace("xsd","http://www.w3.org/2001/XMLSchema"); SOAPClient.Proxy = ecShopReturnHost() + "/editor/soap/ecbusiness.asmx"; SOAPClient.SOAPServer = ecShopReturnHost() + "/editor/soap/ecbusiness.asmx"; SOAPClient.SendRequest(OrderSR,orderProcessResponse); _ecshopOrderXML = ""; function orderProcessResponse(orderRespObj, orderRespText, orderRespXml)
{ try
{ var responseMessage = orderRespObj.Body[0].orderProcessResponse[0].orderProcessResult[0].root[0]; var orderHtmlData = responseMessage.htmldata[0].Text; var orderXmlData = orderRespText; var orderHtmlStart = orderHtmlData.indexOf('<!--'+ entity + '-starts-->'); var orderHtmlEnd = orderHtmlData.indexOf('<!--' + entity + '-ends-->'); var orderShippingStart = orderHtmlData.indexOf('<!--shipping-starts-->'); var orderShippingEnd = orderHtmlData.indexOf('<!--shipping-ends-->'); var orderShipping = orderHtmlData.substring(orderShippingStart,orderShippingEnd); var orderErrorStart = orderHtmlData.indexOf('<!--ordererror-starts-->'); var orderErrorEnd = orderHtmlData.indexOf('<!--ordererror-ends-->'); var orderError = orderHtmlData.substring(orderErrorStart,orderErrorEnd); var container = document.getElementById(elementID); if(createOrder == "true") { if(orderError.length > 0) { CreateError(orderError); enable('ecshopfx_gostep4');} else { if(container) { container.innerHTML = orderHtmlData.substring(orderHtmlStart,orderHtmlEnd);}
ecShopResetBasketHtml(); var receiptStarts = "<!--receiptxml-starts-->"; var receiptXmlStartsHere = orderHtmlData.indexOf(receiptStarts); var receiptXmlStart = receiptXmlStartsHere + receiptStarts.length; var receiptXmlEnd = orderHtmlData.indexOf('<!--receiptxml-ends-->'); var receiptXml = orderHtmlData.substring(receiptXmlStart,receiptXmlEnd); _ecshopSaveInvoiceXml = receiptXml; ecShopDeleteAllCookies(); window.onbeforeunload = null; clearInterval(_ecshopObserveTimer); ecShopHideAndShow('ecshopfx_container_step',4); var relatedProductContainer = document.getElementById("related_products_container"); if (relatedProductContainer) { relatedProductContainer.innerHTML = "";}
var googleAnalyticsStarts = "<!--googleanalytics-starts-->"; var googleHtmlStartsHere = orderHtmlData.indexOf(googleAnalyticsStarts); var googleHtmlStart = googleHtmlStartsHere + googleAnalyticsStarts.length; var googleHtmlEnd = orderHtmlData.indexOf('<!--googleanalytics-ends-->'); var googleAnalytics = orderHtmlData.substring(googleHtmlStart,googleHtmlEnd); if(googleAnalytics.length > 0) { ecShopGoogleTrackOrder(googleAnalytics);}
}
var orderId = responseMessage.information[0].orders[0].order[0].guid[0].Text; var shopId = responseMessage.information[0].shop[0].guid[0].Text; var shipmentComment = '<p><strong>Sendingarmáti</strong><br/>'; shipmentComment += 'Sendingartími: ' + _ecshopSelectedDeliveryTime + '<br/>'; shipmentComment += 'Sendingardagur: ' + _ecshopSelectedDeliveryDate + '<br/>'; shipmentComment += '</p>'; if(webpaymentRefId != "" && _ecshopDynamicRateSelected) { ecShopUpdateWebpaymentOrder(orderId, shopId, webpaymentRefId, shipmentComment);} else if(webpaymentRefId != "" && !_ecshopDynamicRateSelected) { ecShopUpdateWebpaymentOrder(orderId, shopId, webpaymentRefId);} else if(_ecshopDynamicRateSelected) { ecShopUpdateOrderComments(orderId, shopId, shipmentComment);}
try { _ecShopPostStep3();} catch (e){ }
} else if(stage == "confirm") { ecShopHideAndShow('ecshopfx_container_step',3); _ecshopSaveInvoiceCookie = readCookie(_ecshopCheckoutCookie); if(isWebpayment) { var iframeHtml = '<form id="webpayment_form" method="post" target="webpayment" action="' + ecShopReturnHost() + '/upload/files/templates/controls/' + typeOfWebpayment + '.aspx">'; iframeHtml += '<input id="ecshopfx_webpayment_xml" name="OrderXmlVal" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_process" name="process" value="1" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_shippingdate" name="shippingdate" value="" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_shippingtime" name="shippingtime" value="" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_currency" name="currency" value="' + ecTranslate("basket-labels.basket-currency") + '" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_ftext" name="failuretext" value="' + ecTranslate("checkout-errors.checkout-webpayment-failure") + '" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_stext" name="successtext" value="' + ecTranslate("checkout-labels.checkout-webpayment-success") + '" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_shipping" name="shippingtext" value="' + ecTranslate("basket-labels.basket-shipping-cost") + '" type="hidden"/>'; iframeHtml += '<input id="ecshopfx_webpayment_md5" name="md5" value="' + ecTranslate("checkout-errors.checkout-webpayment-md5") + '" type="hidden"/>'; iframeHtml += '</form>'; iframeHtml += '<iframe name="webpayment" id="webpayment" src="about:blank" height="100%" width="100%" class="ecshop_webpayment_iframe" frameborder="0" scrolling="0"></iframe>'; container.innerHTML = iframeHtml; document.getElementById("ecshopfx_webpayment_xml").value = orderXmlData; if(_ecshopDynamicRateSelected) { document.getElementById("ecshopfx_webpayment_shippingtime").value = _ecshopSelectedDeliveryTime; document.getElementById("ecshopfx_webpayment_shippingdate").value = _ecshopSelectedDeliveryDate;}
document.getElementById("webpayment_form").submit(); hideObject("ecshopfx_container_step1"); hideObject("ecshopfx_container_step2"); showObject("ecshopfx_container_step3"); try { _ecShopPostStep2Webpayment();} catch (e){ }
} else { if(container) { container.innerHTML = orderHtmlData.substring(orderHtmlStart,orderHtmlEnd);}
var addressPreview = document.getElementById("ecshopfx_address_preview"); if(addressPreview) { ReplaceContent("ecshopfx_address_confirmation",addressPreview.innerHTML);}
var cardType = ecShopReturnFieldFromCookie("ecshopcardtype"); var cardTypeContainer = document.getElementById('ecshopfx_cardtype'); if(cardType == "" || cardType == 'undefined' || cardType == null)
cardType = ""; if(cardType.length > 0) { if(cardTypeContainer)
cardTypeContainer.innerHTML = ecShopReturnFieldFromCookie("ecshopcardtype");}
try { _ecShopPostStep2();} catch (e){ }
}
} else { if(container) { container.innerHTML = orderHtmlData.substring(orderHtmlStart,orderHtmlEnd);}
var shippingContainer = document.getElementById("ecshopfx_shipping_methods"); if(shippingContainer) { shippingContainer.innerHTML = orderShipping; ecShopUpdateShippingCollection();}
try { _ecShopPostStep1();} catch (e){ }
}
DeleteUpdate();}
catch(e)
{ CreateError(e); DeleteUpdate();}
}
}
function ecShopDeleteAllCookies() { createCookie(_ecshopShopParamCookie,'',0); createCookie(_ecshopSelectedShippingGuidCookie,'',0); createCookie(_ecshopSelectedShippingPositionCookie,'', 0); createCookie(_ecshopCheckoutCookie,'',0); createCookie(_ecshopNodeCookie,'',0); _ecshopCookieArray = new Array(); _ecshopNodeArray = new Array();}
function ecShopSaveInvoice()
{ document.getElementById("ecshopfx_SaveInvoiceVal").value = _ecshopSaveInvoiceXml; document.getElementById("ecshopfx_Addrs_Cookie").value = _ecshopSaveInvoiceCookie; document.ecshopfx_saveinvoice.submit();}
function ecShopUpdateWebpaymentOrder(orderId, shopId, refId, comments) { if(comments == undefined) { comments = "";}
ecShop.Web.Soap.ecShopWS.UpdateWebpaymentOrderComments(shopId, orderId, refId, comments, OnOrderCommentsUpdated, OnError);}
function ecShopUpdateOrderComments(orderId, shopId, comments) { ecShop.Web.Soap.ecShopWS.UpdateOrderComments(shopId, orderId, comments, OnOrderCommentsUpdated, OnError);}
function OnOrderCommentsUpdated() { }
function ecShopAddProduct(prod_id, quantity, imageUrl, imageName, version, productName, stock, optionString, productType)
{ if(productType == undefined) { productType = "";}
if (optionString == null || optionString == '')
{ var option = 1; var options = '<options><option prodid="' + prod_id + '">'; if (document.getElementById('ecshopfx_' + prod_id + "_1") != null)
{ options = options + '<attribs>'; while(document.getElementById('ecshopfx_' + prod_id + '_' + option))
{ var selectObj = document.getElementById('ecshopfx_' + prod_id + '_' + option); var selectedOption = selectObj.options[selectObj.selectedIndex]; var value = selectedOption.value; var name = selectedOption.getAttribute("title"); options = options + '<attrib><name>' + name + '</name><value>' + value + '</value></attrib>'; option++;}
var ecshopColor = document.getElementById("ecshopfx_color_selection"); if(ecshopColor != null && ecshopColor.value.length > 0) { options = options + ecshopColor.value + '</attribs>';} else { options = options + '</attribs>';}
} else if(document.getElementById("ecshopfx_color_selection")) { options = options + '<attribs>'; var ecshopColor = document.getElementById("ecshopfx_color_selection"); if(ecshopColor != null && ecshopColor.value.length > 0) { options = options + ecshopColor.value + '</attribs>';} else { options = options + '</attribs>';}
}
options = options + '</option></options>';} else { options = optionString;}
if(document.getElementById('prod_image')) { var imagePath = document.getElementById('prod_image').src; var imagePathSplit = imagePath.split("ecshop_detail_"); imageUrl = imagePathSplit[0]; imageName = imagePathSplit[1];}
try { ecShopJustAddedToBasket(productName, imageUrl, imageName, version);} catch(err){ }
try { ecShopAddProductToBasket(prod_id, quantity, HtmlEncode(options), productType);} catch(err){ }
}
function ecShopJustAddedToBasket(product, imageUrl, imageName, version) { var container = document.getElementById("ecshopfx_small_cart"); var html = '<div id="ecshop_added_to_basket" class="ecshop_basket ecshop_hide">'; html += '<div class="content just_added">'; html += '<h3>' + _ecshopYouJustAddedHeader + '</h3>'; if(imageUrl.length > 0) { var imgSrc = imageUrl + version + imageName; html += '<div class="product_img"><img src="' + imgSrc + '" /></div>';}
html += '<h2>' + product + '</h2>'; html += '</div>'; html += '</div>'; if(container) { container.innerHTML = html; floatingMenu.menu = document.getElementById("ecshop_added_to_basket"); floatingMenu.computeShifts(); var locationY = (floatingMenu.shiftY + parseInt(_ecshopFloatingMenuYAdjustment)); var locationX = (floatingMenu.shiftX + parseInt(_ecshopFloatingMenuXAdjustment)); if(floatingMenu.shiftY > 170) { if (document.layers)
{ floatingMenu.menu.left = locationX; floatingMenu.menu.top = locationY;}
else
{ floatingMenu.menu.style.left = locationX + 'px'; floatingMenu.menu.style.top = locationY + 'px';}
}
showObject("ecshop_added_to_basket");}
if(_ecshopAddedBasketTimer != null) { clearTimeout(_ecshopAddedBasketTimer);}
_ecshopAddedBasketTimer = setTimeout("ecShopHideJustAdded()",2000);}
function ecShopHideJustAdded() { FadeItem('ecshop_added_to_basket','out',2000, true);}
function ecShopShowBasket() { if(_ecshopDropdownBasketTimer != null) { clearTimeout(_ecshopDropdownBasketTimer);}
hideObject("ecshop_added_to_basket"); showObject("ecshop_small_basket_dropdown"); showObject("ecshopfx_dropdown_basket");}
function ecShopHideBasket() { _ecshopDropdownBasketTimer = setTimeout("ecShopFadeBasket()",2000);}
function ecShopFadeBasket() { FadeItem('ecshopfx_dropdown_basket','out',3000, false);}
function ecShopAddProductToBasket(productId, quantity, option, productType)
{ _ecshopAddingProduct = true; var action = "add"; var elementID = "ecshop_small_basket"; var comments = productType; var pageId = _ecshopBasketPageId; var positionId = _ecshopBasketPositionId; var pageType = "2"; var Url = document.location.href; try { if(Url.indexOf("?ec_webshop_page") > 0) { ecShopUpdateBasketInfoStage(productId, quantity, action, option, elementID);} else { ecShopUpdateBasket(productId, quantity, action, comments, option, elementID, pageId, positionId, pageType);}
} catch(err) { }
}
function quantityCheck(pos, customField)
{ var enteredQty = document.getElementById('product_qty' + pos).value; var existingStock = document.getElementById('ecshopfx_product_stock_hidden' + pos).value; if(parseInt(existingStock) < parseInt(enteredQty))
{ if(customField == 'zero-stock' || customField == '') { CreateError(ecTranslate("product-messages.product-limitedstock-zero-stock"));} else if(customField == 'no-stock' || customField == 'hide-stock') { CreateError(ecTranslate("product-messages.product-limitedstock-no-stock")); if(!existingStock > 0) { document.getElementById('product_qty' + pos).value = "1";} else { document.getElementById('product_qty' + pos).value = existingStock;}
}
}
}
function redirectPackageProducts(prodId, detailUrl)
{ _ecshopLastOpenedProduct = prodId; var header = ecTranslate("product-labels.product-package-alert"); var text = ecTranslate("product-labels.product-package-redirect"); CreateUpdate(text); window.setTimeout("closePackagePopup('" + detailUrl + "')",2000);}
function closePackagePopup(detailUrl)
{ DeleteUpdate(); ecShopGoToProductDetail(detailUrl)
}
function UpdateProductCount(prodID, qty, action, option, operation)
{ var elementID = 'ecshop_checkout_container'; if(typeof(operation) == 'undefined')
operation = 'empty'; if(operation == 'dec')
{ if(qty == 1)
{ action = "remove"; qty = 1;}
else { qty--;}
}
if(operation == 'inc')
qty++; ecShopUpdateLargeBasket(prodID, qty, action, HtmlEncode(option), elementID);}
function UpdateProductQuantity(obj, oldQty, prodID, action, option)
{ var elementID = 'ecshop_checkout_container'; validateNumber(obj); var qty = obj.value; if(qty == 0) { action = "remove"; qty = 1;}
if(obj.value != "" && oldQty != qty) { ecShopUpdateLargeBasket(prodID, qty, action, HtmlEncode(option), elementID);}
}
var _ecshopFirstVariation = true; var _ecshopPreviousVariationText = null; var _ecshopPreviousVariationMenu = null; var _ecshopPreviousLink = null; var _ecshopPreviousFunction = null; function ecShopCancelVariation() { if(_ecshopPreviousVariationMenu != null) { hideObject(_ecshopPreviousVariationMenu);}
if(_ecshopPreviousVariationText != null) { showObject(_ecshopPreviousVariationText);}
if(_ecshopPreviousLink != null) { _ecshopPreviousLink.innerHTML = ecTranslate("basket-buttons.basket-modify"); _ecshopPreviousLink.onclick = _ecshopPreviousFunction;}
var cancelObject = document.getElementById("ecshopfx_cancel_variation"); if(cancelObject) { cancelObject.parentNode.removeChild(cancelObject);}
}
function ecShopChangeVariation(obj, qty, objPropDisplay, objPropSelect, prodRow, optionXML, inOrderProcess){ if(inOrderProcess == undefined) { inOrderProcess = false;}
var variationText = objPropDisplay; var variationMenu = objPropSelect; if(_ecshopFirstVariation) { _ecshopFirstVariation = false;} else { if(_ecshopPreviousVariationMenu != null) { hideObject(_ecshopPreviousVariationMenu);}
if(_ecshopPreviousVariationText != null) { showObject(_ecshopPreviousVariationText);}
if(_ecshopPreviousLink != null) { _ecshopPreviousLink.innerHTML = ecTranslate("basket-buttons.basket-modify"); _ecshopPreviousLink.onclick = _ecshopPreviousFunction;}
}
_ecshopPreviousVariationMenu = variationMenu; _ecshopPreviousVariationText = variationText; _ecshopPreviousLink = obj; _ecshopPreviousFunction = obj.onclick; hideObject(objPropDisplay); showObject(objPropSelect); obj.innerHTML = ecTranslate("basket-buttons.basket-variation-save"); var cancelObject = document.getElementById("ecshopfx_cancel_variation"); if(cancelObject) { cancelObject.parentNode.removeChild(cancelObject);}
cancelObject = document.createElement("span"); cancelObject.setAttribute("id","ecshopfx_cancel_variation"); cancelObject.setAttribute("title",ecTranslate("common-buttons.common-cancel")); cancelObject.innerHTML = " (x)"; cancelObject.onclick = function() { ecShopCancelVariation();}
cancelObject.style.cursor = "pointer"; obj.parentNode.appendChild(cancelObject); obj.onclick = function() { var selectedProperty = objPropSelect.options[objPropSelect.selectedIndex].value.split('|'); var reg = new RegExp(">" + selectedProperty[0] + "</name><value>[^>]*</value>", "i"); var replaceStr = ">" + selectedProperty[0] + "</name><value>" + selectedProperty[1] + "</value>"; var oldOptionStr = optionXML; _ecshopOldOptions = HtmlEncode(optionXML); var newOptionStr = optionXML.replace(reg,replaceStr); _ecshopNewOptions = HtmlEncode(newOptionStr); obj.innerHTML = ecTranslate("basket-buttons.basket-variation-updating"); if(!inOrderProcess) { ecShopUpdateLargeBasket(_ecshopVariationParam[prodRow][0], qty, 'remove', HtmlEncode(oldOptionStr), 'ecshop_checkout_container', false, false, true);} else { var ecshop_orderXML = "<orderinfo>"
var selected_payment = getSelectedValue('ec_webshop_page_6_paymentmethod'); var selected_shipping = getSelectedValue('ec_webshop_page_6_shippingmethod'); if(selected_payment!=-1){ paymentValue = selected_payment.split('|'); ecshop_orderXML += "<paymentmethod>"+paymentValue[1]+"</paymentmethod>";}
if(selected_shipping!=-1){ shippingValue = selected_shipping.split('|'); if(_ecshopDynamicRateSelected) { ecshop_orderXML += '<shippingmethod updaterate="' + _ecshopDynamicRate + '">' + shippingValue[1] + '</shippingmethod><attributes><attribute><name>deliverydate</name><value>' + _ecshopSelectedDeliveryTime + '|' + _ecshopSelectedDeliveryDate + '</value></attribute></attributes>';} else { ecshop_orderXML += '<shippingmethod>' + shippingValue[1] + '</shippingmethod>';}
}
ecshop_orderXML += "</orderinfo>"; var elementId = "ecshop_small_basket"; ecShopUpdateOrderBasket(_ecshopVariationParam[prodRow][0], qty, 'remove', HtmlEncode(oldOptionStr), HtmlEncode(ecshop_orderXML), elementId, false, true, true);}
};}
function ecShopEmptyBasketConfirmation(productID, qty, action, option, divID) { var html = '<div class="ecshop_form_container">'; html += '<p>' + _ecshopRemoveLastProdMessage + '</p>'; html += '<div class="buttons"><button onclick="ecShopUpdateBasketInfoStage(\'' + productID + '\',\'' + qty + '\',\'' + action + '\',\'' + escape(option) + '\',\'' + divID + '\',true);removePopup(\'last_product\')" class="ecshop_send">' + _ecshopOkButton + '</button><button onclick="removePopup(\'last_product\')" class="ecshop_cancel">' + _ecshopCancelButton + '<br/><span>' + _ecshopCloseWindow + '</span></button></div>'; html += '<div class="clear"></div></div>'; CreateConfirmation(_ecshopRemoveLastProdHeading, html, "last_product");}
function checkUpdateBasket(productID, qty, action, option, operation, divID, noOfProductsInBasket)
{ if(noOfProductsInBasket == 1 || noOfProductsInBasket == "clear") { ecShopEmptyBasketConfirmation(productID, qty, action, option, operation, divID);} else { ecShopUpdateBasketInfoStage(productID, qty, action, escape(option), divID);}
}
function ecShopUpdateBasketInfoStage(productID, qty, action, option, divID, redirect) { if(action == "clear") { ecShopDeleteAllCookies();}
if(redirect == undefined)
redirect = false; option = unescape(option); var ecshop_orderXML = "<orderinfo>"
var selected_payment = getSelectedValue('ec_webshop_page_6_paymentmethod'); var selected_shipping = getSelectedValue('ec_webshop_page_6_shippingmethod'); if(selected_payment!=-1){ paymentValue = selected_payment.split('|'); ecshop_orderXML += "<paymentmethod>"+paymentValue[1]+"</paymentmethod>";}
if(selected_shipping!=-1){ shippingValue = selected_shipping.split('|'); if(_ecshopDynamicRateSelected) { ecshop_orderXML += '<shippingmethod updaterate="' + _ecshopDynamicRate + '">' + shippingValue[1] + '</shippingmethod><attributes><attribute><name>deliverydate</name><value>' + _ecshopSelectedDeliveryTime + '|' + _ecshopSelectedDeliveryDate + '</value></attribute></attributes>';} else { ecshop_orderXML += '<shippingmethod>' + shippingValue[1] + '</shippingmethod>';}
}
ecshop_orderXML += "</orderinfo>"; if(redirect) { _ecshopRedirect = _ecshopRedirectTo;} else { _ecshopRedirect = "";}
ecShopUpdateOrderBasket(productID, qty, action, HtmlEncode(option), HtmlEncode(ecshop_orderXML), divID);}
function updateBasketInfoStage(productID, qty, action, option, operation, divID, noOfProductsInBasket)
{ option = unescape(option); if(typeof(operation) == undefined || operation == '')
operation='empty'; if(operation=='dec')
{ if(qty==1)
{ if(noOfProductsInBasket == 1) { ecShopEmptyBasketConfirmation(productID, qty, "remove", option, divID); return;}
else { action = "remove";}
}
else { qty--;}
}
if(operation=='inc')
qty++; ecShopUpdateBasketInfoStage(productID, qty, action, option, divID)
}
function updateQuantityInfoStage(obj, oldQty, productID, option, divID, noOfProductsInBasket)
{ option = unescape(option); var action = "update"; var qty = obj.value; if(qty == 0) { if(noOfProductsInBasket == 1) { ecShopEmptyBasketConfirmation(productID, oldQty, "remove", option, divID); return;} else { action = "remove";}
}
if(obj.value != "" && oldQty != qty) { ecShopUpdateBasketInfoStage(productID, qty, action, option, divID)
}
}
function ecShopResetShippingArrays() { _ecshopShippingRates = new Array(); _ecshopShippingRatesFormatted = new Array(); _ecshopOrderTotal = new Array(); _ecshopOrderTotalFormated = new Array(); _ecshopOrderFormatted = new Array(); _ecshopShippingName = new Array(); _ecshopShippingDescription = new Array(); _ecshopShippingTime = new Array(); _ecshopShippingGuid = new Array();}
function ecShopAddToShippingArrays(position, shippingRates, shippingRatesFormatted, orderTotal, orderTotalFormated, orderFormatted, shippingName, shippingDescription, shippingTime, shippingGuid) { _ecshopShippingRates[position] = shippingRates; _ecshopShippingRatesFormatted[position] = shippingRatesFormatted; _ecshopOrderTotal[position] = orderTotal; _ecshopOrderTotalFormated[position] = orderTotalFormated; _ecshopOrderFormatted[position] = orderFormatted; _ecshopShippingName[position] = shippingName; _ecshopShippingDescription[position] = shippingDescription; _ecshopShippingTime[position] = shippingTime; _ecshopShippingGuid[position] = shippingGuid;}
function ecShopLoadShippingRates() { var selectedShippingRate = 1; var shipCookie = readCookie(_ecshopSelectedShippingGuidCookie); if(shipCookie != "") { for(var i = 1; i < _ecshopShippingGuid.length; i++) { if(shipCookie == _ecshopShippingGuid[i]) { selectedShippingRate = i;}
}
}
ecShopShowShippingRates(selectedShippingRate, 'ecshopfx_shipping_rate', 'ecshopfx_order_total', 'ecshopfx_current_shipping_description', ecTranslate('basket-labels.basket-shipping-sentwith'),ecTranslate('basket-labels.basket-shipping-time'),ecTranslate('basket-labels.basket-shipping-days'),ecTranslate('basket-labels.basket-currency'));}
function ecShopShowShippingRates(position, shippingTotalContainerId, orderTotalContainerId, shippingDescriptionContainerId, shippingPrefix, averagePrefix, daysText) { var shippingDescriptionContainer = document.getElementById(shippingDescriptionContainerId); var orderTotalContainer = document.getElementById(orderTotalContainerId); var shippingTotalContainer = document.getElementById(shippingTotalContainerId); _ecshopShippingTotalContainer = shippingTotalContainerId; _ecshopOrderTotalContainer = orderTotalContainerId; _ecshopShippingDescriptionContainer = shippingDescriptionContainerId; _ecshopShippingPrefix = shippingPrefix; _ecshopAveragePrefix = averagePrefix; _ecshopDaysText = daysText; if(_ecshopShippingRetainCookie == '1') { createCookie(_ecshopSelectedShippingGuidCookie, _ecshopShippingGuid[position], 1); createCookie(_ecshopSelectedShippingPositionCookie, position, 1); _ecshopShippingRetainCookie = "0";}
if(shippingDescriptionContainer) { var html = '<p><strong>' + shippingPrefix + ': ' + _ecshopShippingName[position] + '</strong><br/>'; html += replaceBreaks(unescape(decodeURI(_ecshopShippingDescription[position]))) + '</p>'; html += '<p><small>' + averagePrefix + ': ' + _ecshopShippingTime[position] + ' ' + daysText + '</small></p>'; shippingDescriptionContainer.innerHTML = html;}
if(shippingTotalContainer) { shippingTotalContainer.innerHTML = _ecshopShippingRatesFormatted[position];}
if(orderTotalContainer) { var orderPrice = orderTotalContainer.className; if(orderPrice != null && orderPrice != _ecshopOrderTotal[position]) { var totalOrder = (orderPrice * 1) + (_ecshopShippingRates[position] * 1); var decimaldigits = "0"; orderTotalContainer.innerHTML = ecShopFormatPrice(_ecshopPriceFormatCulture, totalOrder, decimaldigits);} else { orderTotalContainer.innerHTML = _ecshopOrderFormatted[position];}
}
}
function ecShopFormatPrice(culture, price, decimaldigits){ ecShop.Web.Soap.ecShopWS.FormatNumberByCulture(culture, price, decimaldigits, OnFormatePrice, OnError);}
function OnFormatePrice(results) { var orderTotalContainer = document.getElementById('ecshopfx_order_total'); orderTotalContainer.innerHTML = results;}
function ecShopChangeShippingRates(shippingTotalContainerId, orderTotalContainerId, shippingDescriptionContainerId, shippingPrefix, averagePrefix, daysText, cost, courier, orderCost) { _ecshopShippingRetainCookie = "1"; var html = '<h3>Available shipping rates</h3>'; html += '<table cellpadding="3" cellspacing="0" width="100%">'; html += '<thead>'; html += '<tr><th>' + courier + '</th><th>' + averagePrefix + '</th><th>' + cost + '</th></tr>'; html += '</thead>'; html += '<tbody>'; for(var i = 1; i < _ecshopShippingRates.length; i++) { html += '<tr onclick="ecShopDoChangeShippingRates(\'' + i + '\', \'' + shippingTotalContainerId + '\', \'' + orderTotalContainerId + '\', \'' + shippingDescriptionContainerId + '\', \'' + shippingPrefix + '\', \'' + averagePrefix + '\', \'' + daysText + '\')">'; html += '<td>' + _ecshopShippingName[i] + '</td>'; html += '<td>' + _ecshopShippingTime[i] + ' ' + daysText + '</td>'; html += '<td>' + _ecshopShippingRatesFormatted[i] + '</td>'; html += '</tr>';}
html += '</tbody>'; html += '</table>'; createPopup(html, "ecshop_shipping_rates", "shippingrates");}
function ecShopDoChangeShippingRates(position, shippingTotalContainerId, orderTotalContainerId, shippingDescriptionContainerId, shippingPrefix, averagePrefix, daysText) { ecShopShowShippingRates(position, shippingTotalContainerId, orderTotalContainerId, shippingDescriptionContainerId, shippingPrefix, averagePrefix, daysText); removePopup("shippingrates");}
function ecShopUpdateShippingRates() { var shippingPosition = readCookie(_ecshopSelectedShippingPositionCookie); if(shippingPosition == null || shippingPosition == "") { shippingPosition = 1;}
ecShopShowShippingRates(shippingPosition, _ecshopShippingTotalContainer,_ecshopOrderTotalContainer,_ecshopShippingDescriptionContainer,_ecshopShippingPrefix, _ecshopAveragePrefix,_ecshopDaysText,_ecshopCurrency); var container = document.getElementById(_ecshopOrderTotalContainer); if(container) { var orderPrice = container.getAttribute("price"); if(orderPrice != null) { var totalOrder = (orderPrice * 1) + (_ecshopShippingRates[shippingPosition] * 1); container.innerHTML = formatNumber(totalOrder) + ' ' + _ecshopCurrency;}
}
}
function ecShopUpdateShippingCollection() { if(_ecshopSelectedShippingPosition != null && _ecshopSelectedShippingPosition != '') { ecShopHideAndShow('ecshopfx_shipDesc',_ecshopSelectedShippingPosition); ecShopSelectShippingMethod();}
}
function ecShopAddToShippingCollection(position, guid, price, formattedPrice, orderPrice, orderPriceFormatted) { _ecshopShippingGuidCollection[position] = guid; _ecshopShippingPricesCollection[position] = price; _ecshopShippingPricesCollectionFormatted[position] = formattedPrice; _ecshopOrderTotalPrice[position] = orderPrice; _ecshopOrderTotalPriceFormatted[position] = orderPriceFormatted;}
function ecShopSetSelectedShippingCollection(position, guid, price, formattedPrice) { _ecshopSelectedShippingPosition = position; _ecshopSelectedShippingGuid = guid; _ecshopSelectedShippingPrice = price; _ecshopSelectedShippingPriceFormatted = formattedPrice;}
function ecShopLoadSelectedShippingCollection() { var totalPriceContainer = document.getElementById("ecshopfx_totalprice"); var shippingPriceContainer = document.getElementById("ecshopfx_shipping_price"); if(_ecshopSelectedShippingPosition != null) { if(totalPriceContainer) { totalPriceContainer.innerHTML = _ecshopOrderTotalPriceFormatted[_ecshopSelectedShippingPosition];}
if(shippingPriceContainer) { shippingPriceContainer.innerHTML = _ecshopSelectedShippingPriceFormatted;}
}
}
function ecShopProcessShipping(objShippingDesc, objShippingPrice, objTotalPrice, pos, totalOrderPrice){ ecShopHideAndShow(objShippingDesc,pos); createCookie(_ecshopSelectedShippingGuidCookie, _ecshopShippingGuidCollection[pos], 1); _ecshopSelectedShippingPosition = pos; document.getElementById(objShippingPrice).innerHTML = _ecshopShippingPricesCollectionFormatted[pos]; document.getElementById(objTotalPrice).innerHTML = totalOrderPrice; ecShopSelectShippingMethod();}
function ecShopShowDescription(objGroupName, objToShow){ var objCollections = document.getElementsByName(objGroupName); for(i=0; i < objCollections.length; i++){ if(objCollections[i].checked)
ecShopHideAndShow(objToShow,(i+1));}
}
function ecShopGetDynamicShippingRate(objShippingPrice, objTotalPrice, pos, orderPrice) { var selected_shipping = getSelectedValue('ec_webshop_page_6_shippingmethod'); var shippingValue = selected_shipping.split('|'); var shippingMethod = (shippingValue.length > 0) ? shippingValue[0] : ""; var shippingGuid = (shippingValue.length > 1) ? shippingValue[1] : ""; var inpShippingRestriction = document.getElementById("ecshopfx_shipping_restriction_" + shippingGuid); var ecshopProductsInBasketGuid = document.getElementById("ecshopfx_products_in_basket_guid_array").value; var ecshopProductsInBasketQuantity = document.getElementById("ecshopfx_products_in_basket_quantity_array").value; _ecshopProductsInBasketGuidArray = ecshopProductsInBasketGuid.split("|"); _ecshopProductsInBasketQuantityArray = ecshopProductsInBasketQuantity.split("|"); if(_ecshopProductsInBasketGuidArray.length > 0) { var agentObj = document.getElementById("ecshopfx_shipping_agent"); var defaultAgent = (agentObj) ? agentObj.value : ""; var agent = (_ecshopSelectedDeliveryAgent.length > 0) ? _ecshopSelectedDeliveryAgent : defaultAgent; var postcodeObj = document.getElementById("ecshopfx_shipping_postcode"); var postcode = (postcodeObj) ? postcodeObj.value : ""; if(postcode == "" && _ecshopDynamicRatePostalcode != "") { postcode = _ecshopDynamicRatePostalcode;}
var products = new Array(); products[0] = ""; var quantities = new Array(); quantities[0] = 0; for(var i = 1; i < _ecshopProductsInBasketGuidArray.length; i++) { products[i] = _ecshopProductsInBasketGuidArray[i]; quantities[i] = _ecshopProductsInBasketQuantityArray[i];}
if (inpShippingRestriction && inpShippingRestriction.value == 'dynamic-rate-orderprice'){ postcode = 0;}
if(validateForm("ecshopfx_shipping_dynamic_" + shippingGuid, ecTranslate("common-labels.common-form-validate-ismissing"), "", ecTranslate("common-labels.common-form-validate-notvalid"))) { CreateUpdate(ecTranslate("basket-labels.basket-updating")); ecShop.Web.Soap.ecShopWS.GetShippingRate(agent, postcode, products, quantities, orderPrice, OnShowShippingCost, OnShippingCostError);}
}
function OnShowShippingCost(results) { DeleteUpdate(); _ecshopDynamicRateValid = true; document.getElementById(objShippingPrice).innerHTML = results.FormattedCost; document.getElementById(objTotalPrice).innerHTML = results.FormattedTotal; document.getElementById("ecshopfx_dynamicrate_" + shippingGuid).innerHTML = results.FormattedCost; _ecshopDynamicRate = results.Cost;}
function OnShippingCostError(error) { _ecshopDynamicRateValid = false; OnError(error);}
}
function ecShopFillDynamicShippingRate(obj, showPostCode, objShippingPrice, objTotalPrice, pos, orderPrice) { if(showPostCode == undefined) { showPostCode = true;}
var html = ''; if (showPostCode) { html += '<div>'; html += ' <label for="ecshopfx_shipping_postcode">' + ecTranslate("checkout-labels.checkout-shipping-selectpostcode") + ' *</label>'; html += ' <input id="ecshopfx_shipping_postcode" class="validate number" />'; html += ' </div>';}
if(ecShopIsShortDistance(_ecshopDynamicRatePostalcode)) { html += ' <div>'; html += ' <label for="ecshopfx_shipping_agent">' + ecTranslate("checkout-labels.checkout-shipping-selectdeliverytime") + ' *</label>'; html += ' <input id="ecshopfx_shipping_agent" type="hidden" value="H10-12"/>'; html += ecShopCreateDynamicRateTable(pos); html += ' </div>';}
if(showPostCode) { html += ' <button onclick="ecShopGetDynamicShippingRate(\'' + objShippingPrice + '\', \'' + objTotalPrice + '\', \'' + pos + '\', \'' + orderPrice + '\')" class="ecshop_send">Sjá sendingarkostnað</button>';}
if(obj) { obj.innerHTML = html;}
if(!showPostCode) { ecShopGetDynamicShippingRate(objShippingPrice, objTotalPrice, pos, orderPrice);}
}
function ecShopCreateDynamicRateTable(pos) { var html = '<table cellpadding="3" cellspacing="0" class="clear dynamic-rate" id="ecshopfx_dynamicrate_table_' + pos + '">'; var today = new Date(); var weekday = new Array(7); weekday[0] = ecTranslate("common-labels.common-day-sunday"); weekday[1] = ecTranslate("common-labels.common-day-monday"); weekday[2] = ecTranslate("common-labels.common-day-tuesday"); weekday[3] = ecTranslate("common-labels.common-day-wednesday"); weekday[4] = ecTranslate("common-labels.common-day-thursday"); weekday[5] = ecTranslate("common-labels.common-day-friday"); weekday[6] = ecTranslate("common-labels.common-day-saturday"); var agentArray = new Array("H11-13", "H13-15", "H14-16", "H17-19", "H18-21"); var slotsArray = new Array("11 - 13", "13 - 15", "14 - 16", "17 - 19", "18 - 21"); var availableOnWeekdaysArray = new Array(true, false, true, false, true); var availableOnSaturdayArray = new Array(true, false, true, true, false); var availableOnSundayArray = new Array(false, true, false, true, false); html += '<tr>'; var currentDate = ""; var savedDate = ""; var currentWeekday = ""; for(var j = 0; j < 4; j++) { currentDate = new Date(); currentDate.setDate(currentDate.getDate()+(1+j)); savedDate = currentDate.toDateString(); currentWeekday = currentDate.getDay(); html += '<th>' + weekday[currentWeekday] + '</th>';}
html += '</tr>'; for(var i = 0; i < agentArray.length; i++) { html += '<tr>'; for(var j = 0; j < 4; j++) { currentDate = new Date(); currentDate.setDate(currentDate.getDate()+(1+j)); savedDate = currentDate.toDateString(); currentWeekday = currentDate.getDay(); if((currentWeekday == 0 && availableOnSundayArray[i]) || (currentWeekday == 6 && availableOnSaturdayArray[i]) || ((currentWeekday > 0 && currentWeekday < 6) && availableOnWeekdaysArray[i])) { html += '<td onclick="ecShopSetSelectedDeliveryTime(this,\'ecshopfx_dynamicrate_table_' + pos + '\',\'' + agentArray[i] + '\',\'' + slotsArray[i] + '\', \'' + savedDate + '\')" class="click-me">' + slotsArray[i] + '</td>';} else { html += '<td class="na">&nbsp;</td>';}
}
html += '</tr>';}
html += '</table>'; return html;}
function ecShopSetSelectedDeliveryTime(obj, table, agent, time, date) { var agentObj = document.getElementById("ecshopfx_shipping_agent"); if(agentObj) { agentObj.value = agent;}
_ecshopSelectedDeliveryAgent = agent; _ecshopSelectedDeliveryTime = time; _ecshopSelectedDeliveryDate = date; var tableObj = document.getElementById(table); var tableCells = tableObj.getElementsByTagName("td"); for(var i = 0; i < tableCells.length; i++) { if(tableCells[i].className == "selected") { tableCells[i].className = "click-me"
}
}
obj.className = "selected";}
function ecShopIsShortDistance(postalCode) { var isShortDistance = false; if(postalCode == "") { isShortDistance = true;} else if(postalCode >= 101 && postalCode <= 113) { isShortDistance = true;} else if(postalCode >= 116 && postalCode <= 172) { isShortDistance = true;} else if(postalCode >= 200 && postalCode <= 225) { isShortDistance = true;} else if(postalCode == 270) { isShortDistance = true;}
return isShortDistance;}
function TransformBasketXml(xml, array, containers) { _ecshopTransformContainers = containers; ecShop.Web.Soap.ecShopWS.TransformBasketXml(xml, array, OnTransformBasket, OnError);}
function OnTransformBasket(results) { if(results.length > 0) { var containers = _ecshopTransformContainers; _ecshopTransformContainers = new Array(); for(var i = 0; i < containers.length; i++) { var container = document.getElementById(containers[i]); ReplaceHtml(containers[i], results[i], i);}
ecShopUpdateShippingRates();}
}
function ecShopUpdateLargeBasket(productId, quantity, action, option, elementID, updateOrder, updateHtml, changeVariation) { var pageId = _ecshopBasketPageId; var positionId = _ecshopBasketPositionId; var pageType = "2"; if(updateHtml == undefined)
updateHtml = true; if(updateOrder == undefined)
updateOrder = false; if(changeVariation == undefined)
changeVariation = false; ecShopUpdateBasket(productId, quantity, action, "", option, elementID, pageId, positionId, pageType, updateHtml, updateOrder, changeVariation)
}
function ecShopUpdateOrderBasket(productId, quantity, action, option, orderXML, elementID, updateHtml, updateOrder, changeVariation) { if(updateHtml == undefined)
updateHtml = true; if(changeVariation == undefined)
changeVariation = false; if(updateOrder == undefined)
updateOrder = true; _ecshopOrderXML = orderXML; ecShopUpdateLargeBasket(productId, quantity, action, option, elementID, updateOrder, updateHtml, changeVariation);}
function ecShopUpdateBasket(productId, quantity, action, comments, option, elementID, pageId, positionId, pageType, updateHtml, updateOrder, changeVariation)
{ if(updateHtml == undefined)
updateHtml = true; if(updateHtml) { CreateUpdate(ecTranslate("basket-labels.basket-updating"));}
if(updateOrder == undefined)
updateOrder = false; if(changeVariation == undefined)
changeVariation = false; _ecshopShippingRetainCookie = '0'; var soapBody = new SOAPObject("processBasket"); soapBody.ns = "http://tempuri.org/"; soapBody.appendChild(new SOAPObject("pageId")).val(pageId); soapBody.appendChild(new SOAPObject("positionId")).val(positionId); soapBody.appendChild(new SOAPObject("pageType")).val(pageType); soapBody.appendChild(new SOAPObject("productId")).val(productId); soapBody.appendChild(new SOAPObject("quantity")).val(quantity); soapBody.appendChild(new SOAPObject("comments")).val(comments); soapBody.appendChild(new SOAPObject("action")).val(action); soapBody.appendChild(new SOAPObject("option")).val(option); var sr = new SOAPRequest("http://tempuri.org/processBasket", soapBody); sr.addNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance"); sr.addNamespace("xsd","http://www.w3.org/2001/XMLSchema"); SOAPClient.Proxy = ecShopReturnHost() + "/editor/soap/ecbusiness.asmx"; SOAPClient.SOAPServer = ecShopReturnHost() + "/editor/soap/ecbusiness.asmx"; SOAPClient.ContentType = "text/xml"; SOAPClient.SendRequest(sr, processResponse); function processResponse(respObj, respText, respXml)
{ try
{ var responseMessage = respObj.Body[0].processBasketResponse[0].processBasketResult[0].root[0]; var htmlData = responseMessage.htmldata[0].Text; if(changeVariation) { ecShopUpdateBasket(productId, quantity, 'add', comments, _ecshopNewOptions, elementID, pageId, positionId, pageType, true, updateOrder, false);}
else { if(updateHtml) { var transformXsltArray = new Array(); var transformContainerArray = new Array(); var allContainerArray = new Array("ecshop_small_basket", "ecshop_large_cart"); var allXsltNameArray = new Array("ecShop - Small cart v2.0", "ecShop - Large cart v2.0"); var arrayCounter = 0; var transform = false; for(var i = 0; i < allContainerArray.length; i++) { var container = document.getElementById(allContainerArray[i]); if(container) { if(allContainerArray[i] == elementID) { ReplaceHtml(elementID, htmlData, i);} else { transformXsltArray[arrayCounter] = allXsltNameArray[i]; transformContainerArray[arrayCounter] = allContainerArray[i]; arrayCounter++; transform = true;}
}
}
if(transform) { var currentUrl = document.location.href; if(currentUrl.indexOf("?ec_webshop_page") < 0) { TransformBasketXml(respText, transformXsltArray, transformContainerArray);}
}
}
if(updateOrder) { var currentLocation = document.location.href; if(_ecshopRedirect != "") { var redirect = _ecshopRedirect; _ecshopRedirect = ""; if(currentLocation.indexOf("?ec_webshop_page") > 0) { document.location.href = redirect;}
else { DeleteUpdate();}
} else if(currentLocation.indexOf("?ec_webshop_page") > 0) { var currentStep = ecShopReturnFieldFromCookie("step"); if (currentStep == '3') { ecShopUpdateOrder("info", "false", _ecshopOrderXML, "ecshop_basket_container_step3", "basketinfostep3");} else { ecShopUpdateOrder("info", "false", _ecshopOrderXML, "ecshop_basket_container", "basketinfo");}
} else { DeleteUpdate();}
} else { DeleteUpdate();}
}
}
catch(err)
{ CreateError(err.description + "<br/><br/>" + respText); DeleteUpdate();}
}
}
function ecShopResetBasketHtml() { var smallCart = document.getElementById("ecshop_small_cart"); var dropdownCart = document.getElementById("ecshop_small_basket_dropdown"); if(smallCart) { var basketText = ecTranslate("basket-labels.basket-is-empty"); smallCart.innerHTML = ' <span class="basket_center"><span class="basket_center_content">' + basketText + '</span></span>';}
if(dropdownCart) { dropdownCart.innerHTML = "";}
}
function ecShopBottomPagingDisplay(toDivId, fromDivId){ if(toDivId == undefined) { toDivId = "ecshop_bottom_paging";}
if(fromDivId == undefined){ fromDivId = "ecshop_top_paging";}
toContainer = document.getElementById(toDivId); fromContainer = document.getElementById(fromDivId); if(toContainer && fromContainer) { toContainer.innerHTML = fromContainer.innerHTML;}
}
function ecShopSaveColorSelection(obj, name, value) { var ecshopColorXml = document.getElementById("ecshopfx_color_selection"); if(ecshopColorXml) { var option = '<attrib><name>' + name + '</name><value>' + value + '</value></attrib>'; ecshopColorXml.value = HtmlEncode(option);}
var parent = obj.parentNode; for(var i = 0; i < parent.childNodes.length; i++) { var child = parent.childNodes[i]; child.className = child.className.replace(" selected","").replace("selected","");}
obj.className += " selected"; var ecshopColorPackage = document.getElementById("ecshopfx_color_package"); if(ecshopColorPackage) { ecshopColorPackage.value = name + ":" + value + "|";}
ecShopUpdatePackagePrice();}
function ecShopShowProductDetail(id) { var oldContainer = null; if(_ecshopLastOpenedProduct == "") { _ecshopLastOpenedProduct = readCookie("ecshoptable" + _ecshopWebsiteId);}
if(_ecshopLastOpenedProduct != "" && _ecshopLastOpenedProduct != id) { oldContainer = document.getElementById("ecshopfx_detail_" + _ecshopLastOpenedProduct); var lineContainer = document.getElementById("ecshopfx_table_line_" + _ecshopLastOpenedProduct); if(oldContainer) { hideObject(oldContainer); lineContainer.className = "line";}
}
var rowContainer = document.getElementById("ecshopfx_detail_" + id); var lineContainer = document.getElementById("ecshopfx_table_line_" + id); if(rowContainer) { if(rowContainer.className.indexOf("ecshop_hide") > -1) { showObject(rowContainer); lineContainer.className = "line with_bkg";} else { hideObject(rowContainer); lineContainer.className = "line";}
}
_ecshopLastOpenedProduct = id;}
function ecShopGoToProductDetail(url) { createCookie("ecshoptable" + _ecshopWebsiteId, _ecshopLastOpenedProduct, 1); document.location.href = url;}
function ecShopResetPackagePricing(stockType) { _ecshopPackagePriceArray = new Array(); _ecshopPriceLabel = ecTranslate("product-labels.product-price"); _ecshopStockLabel = ecTranslate("product-labels.product-stock"); _ecshopImageLabel = ecTranslate("product-labels.product-noimage"); _ecshopStockType = stockType; _ecshopNoStockMsg = ecTranslate("product-labels.product-nostock");}
function ecShopUpdatePackagePrice() { var priceLabel = _ecshopPriceLabel; var stockLabel = _ecshopStockLabel; var noImage = _ecshopImageLabel; var stockType = _ecshopStockType; var container = document.getElementById("ecshopfx_product_variations"); var selectBoxes = container.getElementsByTagName("select"); var currentPackage = ''; for(var i = 0; i < selectBoxes.length; i++) { var index = selectBoxes[i].selectedIndex; var value = selectBoxes[i].options[index].value; var name = selectBoxes[i].options[index].getAttribute("title"); currentPackage += name + ":" + value + "|";}
var ecshopColorPackage = document.getElementById("ecshopfx_color_package"); if(ecshopColorPackage) { currentPackage += ecshopColorPackage.value;}
for(var i = 1; i < _ecshopPackagePriceArray.length; i++) { if(_ecshopPackagePriceArray[i][0] == currentPackage) { var priceContainer = document.getElementById("ecshopfx_product_price"); var priceHiddenContainer = document.getElementById("ecshopfx_product_price_hidden"); if(priceContainer)
priceContainer.innerHTML = '<span class="label">' + priceLabel + ':</span> <span class="value">' + _ecshopPackagePriceArray[i][1] + '</span>'; if(priceHiddenContainer)
priceHiddenContainer.value = _ecshopPackagePriceArray[i][1]; if((_ecshopPackagePriceArray[i][1] != _ecshopPackagePriceArray[i][6]) && document.getElementById("strike")) { document.getElementById("strike").innerHTML = '<span class="label">' + priceLabel + ':</span> <span class="value">' + _ecshopPackagePriceArray[i][6] + '</span>';}
if(_ecshopPackagePriceArray[i][3] <= 0){ var displayStock = "0";} else { displayStock = _ecshopPackagePriceArray[i][3];}
var stockContainer = document.getElementById("ecshopfx_product_stock"); var stockHiddenContainer = document.getElementById("ecshopfx_product_stock_hidden"); if(stockContainer)
stockContainer.innerHTML = '<span class="label">' + stockLabel + ':</span> <span class="value">' + displayStock + '</span>'; if(stockHiddenContainer)
stockHiddenContainer.value = displayStock; if(_ecshopManageStock) { if(stockType == 'zero-stock') { if(_ecshopPackagePriceArray[i][3] < _ecshopReOrderLevel && _ecshopPackagePriceArray[i][3] > parseInt(_ecshopStockLowestLevel)) { showObject("ecshopfx_product_out_of_stock_addtobasket"); showObject("ecshopfx_buy_button");} else if(_ecshopPackagePriceArray[i][3] <= parseInt(_ecshopStockLowestLevel)) { hideObject("ecshopfx_product_out_of_stock_addtobasket"); showObject("ecshopfx_product_out_of_stock"); hideObject("ecshopfx_buy_button");} else { hideObject("ecshopfx_product_out_of_stock"); hideObject("ecshopfx_product_out_of_stock_addtobasket"); showObject("ecshopfx_buy_button");}
} else if((stockType == 'no-stock')||(stockType == 'hide-stock')) { if(_ecshopPackagePriceArray[i][3] <= 0) { hideObject("ecshopfx_buy_button"); showObject("ecshopfx_product_out_of_stock");} else { hideObject("ecshopfx_product_out_of_stock"); showObject("ecshopfx_buy_button");}
}
}
var imageContainer = document.getElementById("ecshopfx_image_viewer"); var largeImage = document.getElementById("ecshopfx_large_image"); if(imageContainer && _ecshopPackageImage.length == 0) { _ecshopPackageImage = imageContainer.innerHTML; _ecshopPackageLink = largeImage.href;}
if(imageContainer) { if(_ecshopPackagePriceArray[i][4].length == 0) { if(_ecshopPackageImage.length > 0) { imageContainer.innerHTML = _ecshopPackageImage; if(largeImage) { largeImage.href = _ecshopPackageLink;}
} else { imageContainer.innerHTML = noImage;}
} else { var imageObj = new Image(); imageObj.src = _ecshopPackagePriceArray[i][4]; var height = imageObj.height; if(height < 5)
height = ""; var width = imageObj.width; if(width < 5)
width = ""; imageContainer.innerHTML = '<img alt="' + _ecshopPackagePriceArray[i][1] + '" height="' + height + '" width="' + width + '" src="' + imageObj.src + '" id="prod_image" jqimg="' + _ecshopPackagePriceArray[i][5] + '"/>'; if(largeImage) { largeImage.href = _ecshopPackagePriceArray[i][5];}
}
}
}
}
}
function ecShopAddToPackagePricing(pos, package, price, image, imageName, imagePath, stock, totalPrice, manageStock, reOrderLevel, stockLowestLevel) { var imageVersion = (imagePath.length > 0 && imageName.length > 0) ? (imagePath + 'ecshop_detail_' + imageName) : ""; var imageOriginal = (imagePath.length > 0 && imageName.length > 0) ? (imagePath + 'ecshop_zoom_' + imageName) : ""; _ecshopPackagePriceArray[pos] = []; _ecshopPackagePriceArray[pos][0] = package; _ecshopPackagePriceArray[pos][1] = price; _ecshopPackagePriceArray[pos][2] = image; _ecshopPackagePriceArray[pos][3] = stock; _ecshopPackagePriceArray[pos][4] = imageVersion; _ecshopPackagePriceArray[pos][5] = imageOriginal; _ecshopPackagePriceArray[pos][6] = totalPrice; _ecshopManageStock = manageStock; _ecshopReOrderLevel = reOrderLevel; _ecshopStockLowestLevel = stockLowestLevel;}
function ecShopShowImageViewer(fixedImgPath, fixedImgName, version) { var fixedOriginalImg = fixedImgPath + "ecshop_zoom_" + fixedImgName; var fixedVariationImg = fixedImgPath + version + fixedImgName; var imageViewer = document.getElementById('ecshopfx_image_viewer'); var largeViewer = document.getElementById('ecshopfx_large_image'); if(imageViewer) { var imageObj = new Image(); imageObj.src = fixedVariationImg; var height = imageObj.height; if(height < 5)
height = ""; var width = imageObj.width; if(width < 5)
width = ""; imageViewer.innerHTML = '<img src="' + imageObj.src + '" height="' + height + '" width="' + width + '" id="prod_image" jqimg="' + fixedOriginalImg + '" alt=""/>';}
if(largeViewer) { largeViewer.href = fixedOriginalImg;}
}
function ecShopAddProductImages(name, version, thumbnail, original) { _ecshopImageNameArray[_ecshopImageCounter] = name; _ecshopImageVersionArray[_ecshopImageCounter] = version; _ecshopImageThumbnailArray[_ecshopImageCounter] = thumbnail; _ecshopImageOriginalArray[_ecshopImageCounter] = original; _ecshopImageCounter++;}
function ecShopLoadProductImages() { if(_ecshopImageNameArray.length > 0) { var imageVersionObj = new Image(); var imageZoomObj = new Image(); for(var i = 0; i < _ecshopImageVersionArray.length; i++) { imageVersionObj.src = _ecshopImageVersionArray[i]; imageZoomObj.src = _ecshopImageOriginalArray[i];}
var container = document.getElementById("ecshopfx_image"); if(container) { var firstImageObj = new Image(); firstImageObj.src = _ecshopImageVersionArray[0]; var height = firstImageObj.height; if(height > 5)
height = ' height="' + height + '"'; else
height = ''; var width = firstImageObj.width; if(width > 5)
width = ' width="' + width + '"'; else
width = ''; var html = '<div class="image_container">'; html += '   <div class="product_img">'; html += '       <div class="jqzoom" id="ecshopfx_image_viewer">'
html += '           <img jqimg="' + _ecshopImageOriginalArray[0] + '"' + height + width + ' src="' + firstImageObj.src + '" alt="' + _ecshopImageNameArray[0] + '" />'; html += '       </div>'; html += '</div>'; html += '<div class="image_options">'; html += _ecshopZoomText; html += '   <div class="product_larger_view">'; html += '       <a id="ecshopfx_large_image" href="' + _ecshopImageOriginalArray[0] + '" rel="lightbox">' + _ecshopLargeText + '</a>'; html += '   </div>'; html += '</div></div>'; html += '<div class="clear"></div>'; if(_ecshopImageNameArray.length > 1) { html += '<div class="more_images">'; for(var i = 0; i < _ecshopImageNameArray.length; i++) { html += '<a href="javascript:void(0)" onclick="ecShopSwapImageInViewer(' + i + ');">'; html += '<img class="image" src="' + _ecshopImageThumbnailArray[i] + '" border="0" id="img_1" alt="' + _ecshopImageNameArray[i] + '" />'; html += '</a>';}
html += '</div><div class="clear"></div><p class="ecshop_hide"></div>';}
container.innerHTML = html; initLightbox();}
}
}
function ecShopSwapImageInViewer(pos) { var imageViewer = document.getElementById("ecshopfx_image_viewer"); var largeViewer = document.getElementById("ecshopfx_large_image"); if(imageViewer) { var imageVersionObj = new Image(); imageVersionObj.src = _ecshopImageVersionArray[pos]; var height = imageVersionObj.height; if(height < 5)
height = ""; var width = imageVersionObj.width; if(width < 5)
width = ""; var imageZoomObj = new Image(); imageZoomObj.src = _ecshopImageOriginalArray[pos]; var html = '<img jqimg="' + imageZoomObj.src + '" width="' + width +'" height="' + height +'" src="' + imageVersionObj.src + '" alt="' + _ecshopImageNameArray[pos] + '" />'; imageViewer.innerHTML = html;}
if(largeViewer) { largeViewer.href = _ecshopImageOriginalArray[pos];}
}
function ecShopAddLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function'){ window.onload = func;} else { window.onload = function(){ oldonload(); func();}
}
}
function ecShopGetFrameContent(id, html) { var divObj = document.getElementById(id); if(divObj) { ReplaceContent(id, html);}
}
function ecShopReturnHost() { return _ecshopHost;}
function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString();} else var expires = ""; document.cookie = name+"="+value+expires+"; path=/";}
function readCookie(cookieName)
{ var cookieVal = ""; if(document.cookie.length > 0)
{ cookieStart = document.cookie.indexOf(cookieName+"="); if(cookieStart != -1)
{ cookieStart = cookieStart+cookieName.length+1; cookieEnd = document.cookie.indexOf(";",cookieStart); if(cookieEnd == -1) cookieEnd = document.cookie.length; cookieVal = unescape(document.cookie.substring(cookieStart,cookieEnd));}
}
if(cookieVal == null || cookieVal == "null")
cookieVal = ""; return cookieVal;}
function emulateAttachEvent() { HTMLDocument.prototype.attachEvent = HTMLElement.prototype.attachEvent = function (eventName, eventHandler) { var shortTypeName = eventName.replace(/on/, ""); eventHandler._ieEmuEventHandler = function (e) { window.event = e; return eventHandler();}; this.addEventListener(shortTypeName, eventHandler._ieEmuEventHandler, false);}; HTMLDocument.prototype.detachEvent = HTMLElement.prototype.detachEvent = function (eventName, eventHandler) { var shortTypeName = eventName.replace(/on/, ""); if (typeof eventHandler._ieEmuEventHandler == "function")
this.removeEventListener(shortTypeName, eventHandler._ieEmuEventHandler, false); else
this.removeEventListener(shortTypeName, eventHandler, true);};}
function formatNumber(number) { var isCulture = Sys.CultureInfo._parse('{"name":"","numberFormat":{"CurrencyDecimalDigits":0,"CurrencyDecimalSeparator":",","IsReadOnly":true,"CurrencyGroupSizes":[3],"NumberGroupSizes":[3],"PercentGroupSizes":[3],"CurrencyGroupSeparator":".","CurrencySymbol":"\u00A4","NaNSymbol":"NaN","CurrencyNegativePattern":0,"NumberNegativePattern":1,"PercentPositivePattern":0,"PercentNegativePattern":0,"NegativeInfinitySymbol":"-Infinity","NegativeSign":"-","NumberDecimalDigits":0,"NumberDecimalSeparator":",","NumberGroupSeparator":".","CurrencyPositivePattern":0,"PositiveInfinitySymbol":"Infinity","PositiveSign":"+","PercentDecimalDigits":2,"PercentDecimalSeparator":",","PercentGroupSeparator":".","PercentSymbol":"%","PerMilleSymbol":"\u2030","NativeDigits":["0","1","2","3","4","5","6","7","8","9"],"DigitSubstitution":1},"dateTimeFormat":{"AMDesignator":"AM","Calendar":{"MinSupportedDateTime":"@-62135568000000@","MaxSupportedDateTime":"@253402300799999@","AlgorithmType":1,"CalendarType":1,"Eras":[1],"TwoDigitYearMax":2029,"IsReadOnly":true},"DateSeparator":"/","FirstDayOfWeek":0,"CalendarWeekRule":0,"FullDateTimePattern":"dddd, dd MMMM yyyy HH:mm:ss","LongDatePattern":"dddd, dd MMMM yyyy","LongTimePattern":"HH:mm:ss","MonthDayPattern":"MMMM dd","PMDesignator":"PM","RFC1123Pattern":"ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'","ShortDatePattern":"MM/dd/yyyy","ShortTimePattern":"HH:mm","SortableDateTimePattern":"yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss","TimeSeparator":":","UniversalSortableDateTimePattern":"yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'","YearMonthPattern":"yyyy MMMM","AbbreviatedDayNames":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"ShortestDayNames":["Su","Mo","Tu","We","Th","Fr","Sa"],"DayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"AbbreviatedMonthNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthNames":["January","February","March","April","May","June","July","August","September","October","November","December",""],"IsReadOnly":true,"NativeCalendarName":"Gregorian Calendar","AbbreviatedMonthGenitiveNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthGenitiveNames":["January","February","March","April","May","June","July","August","September","October","November","December",""]}}'); return Math.round(number)._toFormattedString('n0', isCulture)
}
function HtmlEncode(text)
{ return text.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')
}
function ecShopHideAndShow(objName, pos){ var obj; var clsName; for(var i = 1; document.getElementById(objName+i)!= null; i++){ obj = document.getElementById(objName+i); if(pos == i) { showObject(obj);}
else { hideObject(obj)
}
}
}
function getSelectedValue(radioObjName){ var objR = document.getElementsByName(radioObjName); for(i=0;i<objR.length;i++){ if (objR[i].checked)
return objR[i].value;}
return -1;}
function getSelectedObj(radioObjName){ var objR = document.getElementsByName(radioObjName); for(i=0;i<objR.length;i++){ if (objR[i].checked)
return objR[i];}
return -1;}
function replaceBreaks(str) { var regExpLt = /(&lt;)/g; var regExpGt = /(&gt;)/g; return str.replace(regExpGt, ">").replace(regExpLt, "<");}
function ReplaceHtml(containerId, html, pos) { var container = document.getElementById(containerId); if(pos == undefined) { pos = 0;}
if(container) { var parent = container.parentNode; var tempElement = document.createElement("div"); tempElement.setAttribute("id","temp_replacement_" + pos); tempElement.style.display = "none"; tempElement.innerHTML = html.replace(containerId, containerId + "_temp_" + pos); parent.appendChild(tempElement); var cleanHtml = document.getElementById(containerId + "_temp_" + pos).innerHTML; container.innerHTML = cleanHtml; parent.removeChild(tempElement);}
}
function ecShopGetStyle(el,styleProp)
{ var x = document.getElementById(el); if (x.currentStyle)
var y = x.currentStyle[styleProp]; else if (window.getComputedStyle)
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y;}
function LoadCaptcha() { ecShop.Web.Soap.ecShopWS.GetCaptcha(OnSuccessCaptcha,OnError);}
function OnSuccessCaptcha(results) { var s1 = results[0]; var s2 = results[1]; var s3 = results[2]; var captcha = document.getElementById("captchaimg"); if(captcha) { captcha.src = s3 + '/upload/files/templates/controls/CaptchaImage.aspx?height=100&width=200&text=' + s1; document.getElementById("captchahash").value = s2;}
}
function OnError(error) { if(error.get_message().indexOf("ecshop-error:") > -1) { var word = error.get_message().replace("ecshop-error:",""); CreateError(ecTranslate(word));} else { CreateError(error.get_message());}
DeleteUpdate();}
function ecTranslate(word) { var lang = readCookie(_ecshopLangCookie); if(lang == "" || lang == null)
lang = _ecshopDefaultLang; try { return _ecTranslate(word + "." + lang);} catch(err) { return word + "[JSERR]";}
}
function ecShopGetCurrentLang() { var lang = readCookie(_ecshopLangCookie); if(lang == "" || lang == null)
lang = _ecshopDefaultLang; return lang;}
function disable(id)
{ hideObject(id);}
function enable(id)
{ showObject(id);}
function ReplaceContent(elementId, html) { var container = document.getElementById(elementId); if(container != null) { container.innerHTML = html;}
}
function LoadPartialRender() { var render = readCookie("ecshoppartialrender" + _ecshopWebsiteId); if(render != null && render.length > 0) { var rendering = render.split("|"); if(rendering.length > 2) { var anchors = document.getElementsByTagName("a"); var currentUrl = document.location.href; var currentLang = ecShopGetCurrentLang(); var href = rendering[1]; var languageIndex = href.indexOf("lang="); var startIndex = languageIndex + 5; var endIndex = languageIndex + 7; if(href.length < endIndex) { endIndex = href.length;}
var selectedLang = href.substring(startIndex,endIndex); if(selectedLang != currentLang) { href = href.replace("lang=" + selectedLang,"lang=" + currentLang);}
var previousUrl = ""; if(rendering[2].indexOf("&category_name=") > -1 || currentUrl.indexOf("&category_name=") > -1) { var removeCatNamePrev = rendering[2].split("&category_name="); var removeCatNameCrnt = currentUrl.split("&category_name="); previousUrl = removeCatNamePrev[0]; currentUrl = removeCatNameCrnt[0];} else { var previousUrl = rendering[2];}
if(currentUrl == previousUrl) { var divId = "pr_225_130_" + rendering[0]; var divObj = document.getElementById(divId); webSite = divObj.getAttribute("webSite"); siteName = divObj.getAttribute("siteName"); handlerPage = "/" + siteName + staticHandlerPath; tagId = divId; getContent("", href, divId, "");} else { createCookie("ecshoppartialrender" + _ecshopWebsiteId, "", 0); showObject("ecshop_product_container");}
} else { showObject("ecshop_product_container");}
} else { showObject("ecshop_product_container");}
}
function PrePartialRender(anchor, modulePosition) { var ahref = anchor.href; createCookie("ecshoppartialrender" + _ecshopWebsiteId, modulePosition + "|" + ahref + "|" + document.location.href, 1);}
function partialRenderLoading() { if(!_ecshopPreLoading) { CreateUpdate(ecTranslate("product-messages.product-updating-list")); _ecshopPreLoading = false;}
}
function partialRenderLoaded() { DeleteUpdate(); var lastOpenedProduct = readCookie("ecshoptable" + _ecshopWebsiteId); if(lastOpenedProduct != "") { oldContainer = document.getElementById("ecshopfx_detail_" + lastOpenedProduct); lineContainer = document.getElementById("ecshopfx_table_line_" + lastOpenedProduct); if(oldContainer) { showObject(oldContainer); lineContainer.className = "line with_bkg";}
_ecshopLastOpenedProduct = lastOpenedProduct; createCookie("ecshoptable" + _ecshopWebsiteId, "", 0);}
showObject("ecshop_product_container");}
function trim(text) { return text.replace(/^\s*|\s*$/g, "");}
var _zIndex = 500; function createPopup(html, nameOfClass, id) { var container = document.getElementById("ecshop-hover_" + id); if(container == null) { container = document.createElement("div");} else { container.innerHTML = "";}
container.className = "ecshop_hover_window"; container.setAttribute("id","ecshop-hover_" + id); container.style.zIndex = _zIndex++; var popup = document.createElement("div"); popup.className = "ecshop_hover_content " + nameOfClass; popup.setAttribute("id","ecshop-content_" + id); var closeWindow = document.createElement("div"); closeWindow.className = "ecshop_hover_close"; closeWindow.innerHTML = '<a href="javascript:removePopup(\'' + id + '\')" class="img_replace" title="' + ecTranslate("common-buttons.common-close-window") + '"><span>' + ecTranslate("common-buttons.common-close-window") + '</span></a>'; var content = document.createElement("div"); content.innerHTML = html; popup.appendChild(content); popup.appendChild(closeWindow); container.appendChild(popup); var parent = document.body; parent.insertBefore(container, parent.firstChild);}
function removePopup(id) { var popup = document.getElementById("ecshop-hover_" + id); if(popup) { popup.parentNode.removeChild(popup);}
}
function CreateError(error) { var html = '<h2>' + ecTranslate("common-headings.common-error") + '</h2><p>' + error + '</p>'; createPopup(html, "ecshop_error", "ecshoperror");}
function CreateConfirmation(header, content, id) { var html = '<h2>' + header + '</h2>' + content; createPopup(html, "ecshop_confirmation", id);}
function CreateMessage(header, text, id) { var html = '<h2>' + header + '</h2><p>' + text + '</p>'; createPopup(html, "ecshop_message", id); setTimeout("FadeItem('ecshop-content_" + id + "','out',1000)",3000, true); setTimeout("removePopup('" + id + "')",5000);}
function FadeItem(id, direction, speed, deleteItem) { if(speed == undefined)
speed = 1000; if(direction == undefined)
direction = "out"; if(direction == "in") { $("#" + id).fadeIn(speed);} else if(direction == "out") { $("#" + id).fadeOut(speed);}
}
function CreateUpdate(text) { var html = '<p>' + text + '</p>'; createPopup(html, "ecshop_update", "ecshop_update");}
function DeleteUpdate() { removePopup("ecshop_update");}
function showObject(elementId) { var object = null; if(typeof(elementId) == "string") { object = document.getElementById(elementId);} else { object = elementId;}
if(object) { if(object.className.indexOf(" ecshop_hide") > -1) { object.className = object.className.replace(" ecshop_hide","");} else if(object.className.indexOf("ecshop_hide") > -1) { object.className = object.className.replace("ecshop_hide","");} else if(object.className.indexOf(" ecshop_obscure") > -1) { object.className = object.className.replace(" ecshop_obscure","");} else if(object.className.indexOf("ecshop_obscure") > -1) { object.className = object.className.replace("ecshop_obscure","");}
if(object.style.display == 'none') { object.style.display = '';}
if(object.style.visibility == 'hidden') { object.style.visibility = '';}
}
}
function obscureObject(elementId) { var object = null; if(typeof(elementId) == "string") { object = document.getElementById(elementId);} else { object = elementId;}
if(object) { if(object.className.indexOf("ecshop_obscure") == -1) { if(object.className.length > 0) { object.className += " ecshop_obscure";} else { object.className = "ecshop_obscure";}
}
}
}
function hideObject(elementId) { var object = null; if(typeof(elementId) == "string") { object = document.getElementById(elementId);} else { object = elementId;}
if(object) { if(object.className.indexOf("ecshop_hide") == -1) { if(object.className.length > 0) { object.className += " ecshop_hide";} else { object.className = "ecshop_hide";}
}
}
}
function deleteObject(elementId) { var object = document.getElementById(elementId); if(object) { var parent = object.parentNode; if(parent) { object.parentNode.removeChild(object);}
}
}
function toggleObject(elementId) { var object = document.getElementById(elementId); if(object) { if(object.className.indexOf("ecshop_hide") == -1) { hideObject(elementId);} else { showObject(elementId);}
}
}
function overwriteInnerHTML(elementObj,oldText,newText) { if(elementObj) { if(elementObj.innerHTML.indexOf(oldText) > -1) { elementObj.innerHTML = newText;} else { elementObj.innerHTML = oldText;}
}
}
function ecShopCaptureMouse(e) { if (!document.all) { _ecshopTempX = e.pageX
_ecshopTempY = e.pageY
}
}
function ecShopCaptureHistory(e) { if (document.all) { _ecshopTempX = event.clientX
_ecshopTempY = event.clientY
}
if(_ecshopTempY < 1) { return ecTranslate("checkout-errors.checkout-navigate-back");}
}
function GetComments(productId) { var userComments = document.getElementById("ecshop_product_reviews"); if(userComments) { var elementStyle = ecShopGetStyle("ecshop_product_reviews","display").toLowerCase(); if(elementStyle != "none") { if(productId != undefined) { ecShop.Web.Soap.ecShopWS.GetPosts(productId, OnComments, OnError);}
}
}
}
function getForumForm(prodId, productSerial, catName)
{ var results = ""; var productSerial = (productSerial.indexOf("\'") > -1) ? productSerial.replace("\'","\\'") : productSerial; var header = ecTranslate("product-headings.product-review-product"); var name = ecTranslate("common-labels.common-field-name"); var message = ecTranslate("common-labels.common-field-message"); var imgVerification = ecTranslate("common-labels.common-field-verification"); var imgTooltip = ecTranslate("common-tooltips.common-field-verification"); var imgRegenerate = ecTranslate("common-tooltips.common-field-imgregenerate"); var sendButton = ecTranslate("common-buttons.common-send"); var cancelButton = ecTranslate("common-buttons.common-cancel"); var closeButton = ecTranslate("common-buttons.common-close-window"); results += '<h2>' + header + '</h2>'; results += '<div class="ecshop_form_container" id="comment_container">'; results += '<div>'; results += '<label for="comment_author">' + name + ' *</label>'; results += '<input id="comment_author" maxlength="30" size="30" class="validate"/>'; results += '</div>'; results += '<div>'; results += '<label for="comment_content">' + message + ' *</label>'; results += '<textarea id="comment_content" rows="3" cols="30" class="validate"></textarea>'; results += '</div>'; results += '<div>'; results += '<input type="hidden" id="captchahash" value=""/>'; results += '<div class="ecshop_captcha"><img id="captchaimg" src="' + ecShopReturnHost() + '/upload/files/templates/controls/captcha.gif" onclick="return LoadCaptcha();" height="100" width="200" alt="Image verification" title="' + imgRegenerate + '" /></div>'; results += '</div>'; results += '<div>'; results += '<label for="captcha_input" title="' + imgTooltip + '">' + imgVerification +' *</label>'; results += '<input type="text" id="captcha_input" size="20" class="validate" maxlength="20" />'; results += '</div>'; results += '<div class="ecshop_form_buttons">'; results += '<button onclick="postComment(\'' + prodId + '\',\'' + productSerial + '\',\''+ catName + '\')" class="ecshop_send">' + sendButton + '</button><button onclick="removePopup(\'forum-form\')" class="ecshop_cancel">' + cancelButton + '<br/><span>' + closeButton + '</span></button>'; results += '<div class="clear"></div>'; results += '</div>'; results += '</div>'; LoadCaptcha(); createPopup(results,"ecshop_create-address","forum-form");}
function postComment(productId, productSerial, catName)
{ var name = document.getElementById('comment_author').value; var email = ""; var postText = document.getElementById('comment_content').value; var captchaInput = document.getElementById('captcha_input').value; var captchaHash = document.getElementById('captchahash').value; var firstPost = document.getElementById("ecshopfx_first_post").value; var status = 0; var customProperties = "<root/>"; var fromEditor = "true"; if(validateForm("comment_container",ecTranslate("common-labels.common-form-validate-ismissing"),"",ecTranslate("common-labels.common-form-validate-notvalid"),""))
{ CreateUpdate(ecTranslate("product-messages.product-comment-posting")); ecShop.Web.Soap.ecShopWS.PostComment(productId, catName, productSerial, postText, name, email, customProperties, fromEditor, status, firstPost, captchaHash, captchaInput, OnPostComments, OnError);}
}
function OnPostComments() { DeleteUpdate(); CreateMessage(ecTranslate("common-headings.common-success"),ecTranslate("product-labels.product-comment-posted"),"postedcomment"); removePopup("forum-form"); document.getElementById("ecshopfx_first_post").value = "false";}
function OnComments(results) { DeleteUpdate(); if(results.indexOf("class=\"ecshop_forum\"") > -1) { ReplaceContent("ecshopfx_product_comments", results); document.getElementById("ecshopfx_first_post").value = "false";} else if(results.indexOf("class=\"ecshop_forum_empty\"") > -1) { ReplaceContent("ecshopfx_product_comments", ecTranslate("product-labels.product-nocomments")); document.getElementById("ecshopfx_first_post").value = "false";} else if(results.indexOf("<threaderror>") > -1 || results == "") { ReplaceContent("ecshopfx_product_comments", ecTranslate("product-labels.product-nocomments")); document.getElementById("ecshopfx_first_post").value = "true";}
}
var _ecshopRedirectParamIndex = _ecshopCurrentUrl.indexOf("?noredirect=true&from="); if(_ecshopRedirectParamIndex > -1) { var redirectTo = _ecshopCurrentUrl.substring(_ecshopRedirectParamIndex, _ecshopCurrentUrl.length); document.location.href = _ecshopSignInPage;}
function ecShopAccountLoadAddress() { ecShopGetAddresses(_ecshopPageType, _ecshopAccountUser, 'ecshopfx_address_list');}
function ecShopGetAddresses(pageType, userId, addressContainer, webshop) { if(webshop == undefined)
webshop = false; _ecshopPageType = pageType; _ecshopAccountUser = userId; _ecshopAddressContainer = addressContainer; _ecshopGetWebshop = webshop; if(userId == 0 || userId == null) { document.getElementById(addressContainer).innerHTML = ecTranslate("account-labels.account-order-message-anonymoususer");}
else if(userId != null) { CreateUpdate(ecTranslate("account-labels.account-address-loading")); ecShop.Web.Soap.ecShopWS.GetAddresses(userId, pageType, OnListAddresses, OnError);}
}
function OnListAddresses(results) { if(results.length > 0 ) { ReplaceContent(_ecshopAddressContainer, results);}
else if(results.length == 0) { var html = '<div class="ecshop_form_container" id="ecshop_form_container">'; html += '<h3>'+ ecTranslate("account-headings.account-address-create") + '</h3>'; html += '<button class="ecshop_send" value="add_address" onclick="addAddress(\'' + _ecshopAccountUser + '\')">' + ecTranslate("account-buttons.account-address-create") + '</button>'; html += '</div><div class="clear"></div>'; ReplaceContent(_ecshopAddressContainer, html);}
DeleteUpdate(); if(_ecshopGetWebshop) { ecShopLoadStep1Registered(); _ecshopGetWebshop = false;}
}
function ecShopAddAddress() { ecShopGetAddressForm();}
function ecShopGetAddressForm() { if(_ecshopAddressFormat != null) { OnAddressForm(_ecshopAddressFormat);} else { ecShop.Web.Soap.ecShopWS.GetAddressForm(OnAddressForm, OnError);}
}
function OnAddressForm(results) { if(_ecshopAddressFormat == null) { _ecshopAddressFormat = results;}
var html = '<div class="ecshop_form_container" id="ecshop_address_form">'; html += '<h3>' + ecTranslate("account-headings.account-address-create") + '</h3>'; for(var i = 0; i < results.length; i++) { var collection = "common-labels."; var word = "common-field-" + results[i].Xml; var translation = ecTranslate(collection + word); var name = (translation != undefined && translation.indexOf(word) > -1) ? results[i].Name : translation; html += '<div><label for="infoId_' + results[i].Id + '">' + name + ((results[i].Validation.indexOf("validate") > -1) ? ' *' : '') + '</label>'; if(results[i].IsReadOnly) { html += '<input id="infoId_' + results[i].Id + '" maxlength="50" size="30" class="' + results[i].Validation + '" value="' + results[i].DefaultValue + '" readonly="readonly"/></div>';} else { html += '<input id="infoId_' + results[i].Id + '" maxlength="50" size="30" class="' + results[i].Validation + '" /></div>';}
}
html += '<div class="buttons">'; html += '<button onclick="ecShopCreateAddress()" class="ecshop_send">' + ecTranslate("common-buttons.common-save") + '</button>'; html += '<button onclick="removePopup(\'create-address\')" class="ecshop_cancel">' + ecTranslate("common-buttons.common-cancel") + '<br/><span>' + ecTranslate("common-buttons.common-close-window") + '</span></button>'; html += '</div>'; html += '<div class="clear"></div></div>'; createPopup(html,"ecshop_create-address","create-address");}
function ecShopCreateAddress() { var addressContainer = document.getElementById("ecshop_address_form"); var inputs = addressContainer.getElementsByTagName("input"); var inputIdArray = new Array(); var inputValueArray = new Array(); var isPrimary = 0; for(var i = 0; i < inputs.length; i++) { var name = inputs[i].getAttribute("id"); if(name.indexOf("infoId") > -1) { var id = name.replace("infoId_",""); var value = inputs[i].value; inputIdArray[i] = id; inputValueArray[i] = value;}
}
if(validateForm("ecshop_address_form",ecTranslate("common-labels.common-form-validate-ismissing"),"",ecTranslate("common-labels.common-form-validate-notvalid"))) { removePopup("create-address"); CreateUpdate(ecTranslate("account-labels.account-address-saving")); ecShop.Web.Soap.ecShopWS.CreateAddress(_ecshopAccountUser, inputIdArray, inputValueArray,_ecshopPageType, isPrimary, OnCreateAddress, OnError);}
}
function OnCreateAddress(results) { CreateMessage(ecTranslate("common-headings.common-success"),ecTranslate("account-labels.account-address-created"),"addaddress_message"); OnListAddresses(results);}
function ecShopShowAddress(addressId) { ecShop.Web.Soap.ecShopWS.GetAddress(addressId, OnShowAddress);}
function OnShowAddress(results) { if(results != null) { var html = '<div class="ecshop_form_container" id="ecshop_form_container">'; html += '<h3>' + ecTranslate("account-headings.account-address-edit") + '</h3>'; for(var i = 0; i < results.Details.length; i++) { if(results.Details[i].Info.Deleted == 0) { var collection = "common-labels."; var word = "common-field-" + results.Details[i].Info.Xml; var translation = ecTranslate(collection + word); var name = (translation.indexOf(word) > -1) ? results.Details[i].Info.Name : translation; html += '<div><label for="infoId_' + results.Details[i].InfoID + '">' + name + ((results.Details[i].Info.Validation.indexOf("validate") > -1) ? ' *' : '') + '</label> '; if(results.Details[i].Info.IsReadOnly) { html += '<input readonly="readonly" id="infoId_' + results.Details[i].InfoID + '" maxlength="50" size="30" value="' + results.Details[i].Info.DefaultValue + '" /></div>';} else { html += '<input class="' + results.Details[i].Info.Validation + '" id="infoId_' + results.Details[i].InfoID + '" maxlength="50" size="30" value="' + results.Details[i].InfoValue + '" /></div>';}
}
}
html += '<div class="buttons"><button onclick="ecShopUpdateAddress(\'' + results.AddressId + '\',\'' + results.UserId + '\')" class="ecshop_send">' + ecTranslate("common-buttons.common-save-changes") + '</button>'; html += '<button onclick="removePopup(\'edit-address\')" class="ecshop_cancel">' + ecTranslate("common-buttons.common-cancel") + '<br/><span>' + ecTranslate("common-buttons.common-close-window") + '</span></button></div>'; html += '<div class="clear"></div></div>'; createPopup(html,"ecshop_create-address","edit-address");}
}
function ecShopUpdateAddress(addressId) { var addressContainer = document.getElementById("ecshop_form_container"); var inputs = addressContainer.getElementsByTagName("input"); var inputIdArray = new Array(); var inputValueArray = new Array(); var isPrimary = 0; for(var i = 0; i < inputs.length; i++) { var name = inputs[i].getAttribute("id"); if(name.indexOf("infoId") > -1) { var id = name.replace("infoId_",""); var value = inputs[i].value; inputIdArray[i] = id; inputValueArray[i] = value;}
}
if(validateForm("ecshop_form_container", ecTranslate("common-labels.common-form-validate-ismissing"), "", ecTranslate("common-labels.common-form-validate-notvalid"))) { removePopup("edit-address"); CreateUpdate(ecTranslate("account-labels.account-address-updating")); ecShop.Web.Soap.ecShopWS.EditAddress(addressId, _ecshopAccountUser, inputIdArray, inputValueArray,_ecshopPageType, isPrimary, OnUpdateAddress, OnError);}
}
function OnUpdateAddress(results) { CreateMessage(ecTranslate("common-headings.common-success"), ecTranslate("account-labels.account-address-created"), "addaddress_message"); OnListAddresses(results);}
function ecShopDeleteAddress(addressId) { var html = '<div class="ecshop_form_container">'; html += '<p>' + ecTranslate("account-labels.account-address-delete") + '</p>'; html += '<div class="buttons"><button onclick="ecShopDoDeleteAddress(\'' + addressId + '\')" class="ecshop_send">' + ecTranslate("common-buttons.common-ok") + '</button>'; html += '<button onclick="removePopup(\'confirm-delete\')" class="ecshop_cancel">' + ecTranslate("common-buttons.common-cancel") + '<br/><span>' + ecTranslate("common-buttons.common-close-window") + '</span></button></div>'; html += '<div class="clear"></div></div>'; CreateConfirmation(ecTranslate("account-headings.account-address-delete"),html,"confirm-delete");}
function ecShopDoDeleteAddress(addressId) { removePopup("confirm-delete"); ecShop.Web.Soap.ecShopWS.DeleteAddress(addressId, _ecshopPageType, OnListAddresses, OnError); CreateMessage(ecTranslate("common-headings.common-success"), ecTranslate("account-labels.account-address-deleted"),"deleteaddress_message"); window.setTimeout("removePopup('deleteaddress_message')",1000);}
function ecShopGetAddressFormatArray() { if(!_ecshopGettingFormat) { _ecshopGettingFormat = true; ecShop.Web.Soap.ecShopWS.GetAddressForm(ecShopOnGetAddressFormatArray, OnError);}
}
function ecShopOnGetAddressFormatArray(results) { _ecshopAddressFormat = results; _ecshopGettingFormat = false;}
function ecShopFilterOrder(objTable,objSelect,selectedIndex1,selectedIndex2,selectedIndex3,selectedIndex4) { var selectedIndex = objSelect.selectedIndex; var selectedYear = objSelect.options[selectedIndex].value; if(selectedYear == selectedIndex1) { CreateError(ecTranslate("account-labels.account-order-filter-alert"));}
else if(selectedYear == selectedIndex2) { CreateUpdate(ecTranslate("account-messages.account-updating-the-orderlist")); ecShopFilter(objTable,selectedPeriod,2);}
else if(selectedYear == selectedIndex3) { CreateUpdate(ecTranslate("account-messages.account-updating-the-orderlist")); var date = new Date(); var now = new Date(date.getTime() - (14*24*60*60*1000)); seletedMonth = now.getMonth() + 1; var selectedPeriod = now.getFullYear().toString() + (seletedMonth < 10 ? "0" + seletedMonth.toString() : seletedMonth.toString()) + (now.getDate() < 10 ? "0" + now.getDate().toString() : now.getDate().toString()); ecShopFilter(objTable,selectedPeriod,1);}
else if(selectedYear == selectedIndex4) { CreateUpdate(ecTranslate("account-messages.account-updating-the-orderlist")); var date = new Date(); var now = new Date(date.getTime() - (182*24*60*60*1000)); seletedMonth = now.getMonth() + 1; var selectedPeriod = now.getFullYear().toString() + (seletedMonth < 10 ? "0" + seletedMonth.toString() : seletedMonth.toString()) + (now.getDate() < 10 ? "0" + now.getDate().toString() : now.getDate().toString()); ecShopFilter(objTable,selectedPeriod,1);}
else { CreateUpdate(ecTranslate("account-messages.account-updating-the-orderlist")); ecShopFilter(objTable,selectedYear,0);}
}
function ecShopFilter(table,selectedValue,cell) { var hideRow; for (var i = 0 ; i < table.rows.length;i++) { hideRow = false; var cels = table.rows[i].getElementsByTagName('td'); if(cell == 0 && cels[cell].innerHTML != selectedValue) { hideRow = true;} else if(cell == 1 && cels[cell].innerHTML < selectedValue) { hideRow = true;} else { hideRow=false;}
if (hideRow) { table.rows[i].style.display = 'none';} else { table.rows[i].style.display = '';}
}
setTimeout("DeleteUpdate()", 2000);}
function validateForm(formId, missingText, passwordText, incorrectText, expiredText, singleChar) { if(!missingText)
missingText = ""; if(!passwordText)
passwordText = ""; if(!incorrectText)
incorrectText = ""; if(!expiredText)
expiredText = ""; if(!singleChar) { singleChar = "";}
var form = document.getElementById(formId); var inputs = form.getElementsByTagName("input"); var textareas = form.getElementsByTagName("textarea"); var selects = form.getElementsByTagName("select"); var validatedInputs = validateElements(inputs, missingText, passwordText, incorrectText, expiredText, singleChar); var validatedTextareas = validateElements(textareas, missingText, passwordText, incorrectText, expiredText, singleChar); var validatedSelects = validateElements(selects, missingText, passwordText, incorrectText, expiredText, singleChar); return (validatedInputs && validatedTextareas && validatedSelects);}
function validateElements(inputs, missingText, passwordText, incorrectText, expiredText, singleChar) { var validated = true; for(var i = 0; i < inputs.length; i++)
{ var currInput = inputs[i]; var parent = currInput.parentNode; var label; var missing; var smallText; var checkEmail = (currInput.className.indexOf("email") > -1 && !validateEmail(currInput.value)); var checkAlphabet = (currInput.className.indexOf("alphabet") > -1 && !validateAlphabet(currInput.value)); var checkAlphanumeric = (currInput.className.indexOf("alphanumeric") > -1 && !validateAlphaNumerics(currInput.value)); var checkNumerics = (currInput.className.indexOf("number") > -1 && !validateNumerics(currInput.value)); var checkCVC = (currInput.className.indexOf("cvc") > -1 && !validateCVCNumber(currInput.value)); var checkCCN = (currInput.className.indexOf("ccn") > -1 && !validateCreditCardNumber(currInput.value)); var checkCEXP = (currInput.className.indexOf("cexp") > -1 && !validateCCExpires(currInput.value,currInput.className)); var checkSSN = (currInput.className.indexOf("ssn") > -1 && !validateSSN(currInput.value)); var checkEmailConfirm = (currInput.className.indexOf("cmail_") > -1 && !validateEmailConfirm(currInput.value, currInput.className)); var checkPassword = (currInput.className.indexOf("password_") > -1 && !validatePassword(currInput.value, currInput.className)); var checkSelectList = (currInput.className.indexOf("select") > -1 && !validateSelect(currInput)); var checkSingle = (currInput.className.indexOf("single") > -1 && !validateSingle(currInput.value)); if(currInput.className.indexOf("validate") > -1 || currInput.className.indexOf("required") > -1) { currInput.className = currInput.className.replace("required","validate"); label = parent.getElementsByTagName("label")[0]; if(label != null) { var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML; label.innerHTML = origLabel; label.className = label.className.replace(" error","").replace("error","");}
if(trim(currInput.value) == "" ||checkEmail || checkSSN || checkPassword || checkEmailConfirm || checkCVC || checkCCN || checkCEXP || checkSelectList || checkAlphabet || checkAlphanumeric || checkNumerics || checkSingle)
{ validated = false; currInput.className = currInput.className.replace("validate","required"); label = parent.getElementsByTagName("label")[0]; if(label) { var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML; var errorLabel = ""; label.setAttribute("orig", origLabel); if(trim(currInput.value) == "") {var originallabel = origLabel.replace(" *",""); errorLabel = origLabel.replace(" *","") + " " + missingText;if(trim(originallabel) == "Öryggislykill"){errorLabel = "Öryggislykil" + " " + missingText;}} else if (checkPassword || checkEmailConfirm) { errorLabel = passwordText;} else if(checkCCN || checkCVC || checkEmail || checkSSN || checkAlphabet || checkAlphanumeric || checkNumerics) { errorLabel = origLabel.replace(" *","") + " " + incorrectText;} else if(checkCEXP) { errorLabel = expiredText;} else if(checkSingle) { errorLabel = origLabel.replace(" *","") + " " + singleChar;} else if(checkSelectList){ errorLabel = origLabel.replace(" *","") + " " + missingText;}
label.innerHTML = errorLabel; if(label.className == "") { label.className = "error";} else { label.className += " error";}
}
}
} else if((currInput.className.indexOf("optional") > -1 || currInput.className.indexOf("incorrect") > -1) && trim(currInput.value) != "") { currInput.className = currInput.className.replace("incorrect","optional"); label = parent.getElementsByTagName("label")[0]; if(label) { var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML; label.innerHTML = origLabel; label.className = label.className.replace(" error","").replace("error",""); if(checkEmail || checkSSN || checkPassword || checkEmailConfirm || checkCVC || checkCCN || checkCEXP || checkAlphabet || checkAlphanumeric || checkNumerics || checkSingle)
{ validated = false; currInput.className = currInput.className.replace("optional","incorrect"); label = parent.getElementsByTagName("label")[0]; origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML; errorLabel = ""; label.setAttribute("orig", origLabel); if(incorrectText == "") { incorrectText = missingText;}
if(checkSSN || checkCCN || checkCVC || checkAlphabet || checkAlphanumeric || checkNumerics) { errorLabel = origLabel.replace(" *","") + " " + incorrectText;} else if(checkCEXP) { errorLabel = expiredText;} else if(checkSingle) { errorLabel = origLabel.replace(" *","") + " " + singleChar;} else { errorLabel = origLabel.replace(" *","") + " " + missingText;}
label.innerHTML = errorLabel; if(label.className == "") { label.className = "error";} else { label.className += " error";}
}
}
}
}
return validated;}
function validateSingle(value) { if(value.length > 1)
return true; else
return false;}
function validateSelect(objSelect){ if(objSelect.options[objSelect.selectedIndex].value == '0')
return false; return true;}
function validateName(str){ var reg = new RegExp("[\\[\\]{}%*`~^$#@&()|!=(0-9)]","gi"); if (reg.test(str))
return false; return true;}
function validatePassword(value, compareValueObj) { var tmp1 = compareValueObj.replace("validate ",""); var tmp2 = tmp1.replace("required ",""); var compareValue = document.getElementById(tmp2.replace("password_","")).value; if(value != compareValue)
return false; else
return true;}
function validateSSN(src)
{ var regex = /[0-9]/g; if(src.length != 10) { return false;} else { if(regex.test(src))
{ return true;}
else { return false;}
}
}
function validateEmail(src)
{ var regex=/([a-zA-Z0-9_-])+(\.{0,1})+([a-zA-Z0-9_-])+([\.][a-zA-Z0-9_-]+){0,1}@{1}([a-zA-Z0-9_-])+(\.{1})+([a-zA-Z0-9]{0,4})+(\.{0,1})+[a-zA-Z]{2,4}$/; if(regex.test(src)) { return true;} else { return false;}
}
function validateEmailConfirm(value, compareValueObj) { var tmp1 = compareValueObj.replace("validate ",""); var tmp2 = tmp1.replace("required ",""); var compareValue = document.getElementById(tmp2.replace("cmail_","")).value; if(value != compareValue)
return false; else
return true;}
function validateNumerics(src) { var allowed = /^-{0,1}\d+$/; if(allowed.test(src)) { return true;}else { return false;}
}
function validateAlphaNumerics(src) { var allowed = /[a-z0-9]/g; if(allowed.test(src)) { return true;}else { return false;}
}
function validateAlphabet(src) { var allowed = /[a-z]/g; if(allowed.test(src)) { return true;}else { return false;}
}
function validateNumber(obj) { var allowed = /[^0-9]/g; var value = obj.value; obj.value = value.replace(allowed,'');}
function validateCreditCardNumber(CCN)
{ var Valid_Numbers = "0123456789"; var CreditCard_Numbers = ""; for (var i=0; i < CCN.length; i++)
{ Temp = CCN.charAt(i); if (Valid_Numbers.indexOf(Temp,0) != -1) { CreditCard_Numbers += Temp;}
}
var Sum_CreditCard = CreditCard_Numbers.length / 2; if (Sum_CreditCard < 6.5 || Sum_CreditCard > 8 || Sum_CreditCard == 7)
return false; var CreditCard_Even = Math.floor(Sum_CreditCard); var CreditCard_Odd = Math.ceil(Sum_CreditCard) - CreditCard_Even; var Temp2 = 0; for (var i=0; i<CreditCard_Even; i++)
{ a = CreditCard_Numbers.charAt(i*2+CreditCard_Odd) * 2; Temp2 += a > 9 ? Math.floor(a/10 + a%10) : a;}
for (var i=0; i<CreditCard_Even+CreditCard_Odd; i++) { Temp2 += CreditCard_Numbers.charAt(i*2+1-CreditCard_Odd) * 1;}
return (Temp2%10 == 0); return false;}
function validateCVCNumber(src) { var cv=/^\d{3}$/; if (src.length > 3)
{ return false;}
else if (src.length < 3)
{ return false;}
else if (src.search(cv)==-1)
{ return false;}
else { return true;}
}
function validateCCExpires(month, yearClass) { var yearId = yearClass.replace("validate ","").replace("required ","").replace("cexp_",""); var yearObj = document.getElementById(yearId); var year = yearObj.options[yearObj.selectedIndex].text; var today = new Date(); var currentMonth = (today.getMonth() + 1); var currentYear = today.getFullYear(); if(month.substring(0,1) == 0) { month = month.substring(1,2);}
if(currentYear < year) { return true;} else if (currentYear == year && currentMonth <= month) { return true;}
else { return false;}
}
function makeMandatory(fieldToChangeId, nameOfClass) { var fieldToChange = document.getElementById(fieldToChangeId); fieldToChange.className = nameOfClass; var label = fieldToChange.parentNode.getElementsByTagName("label")[0]; if(label != null) { if(label.innerHTML.indexOf("*") < 0) { label.innerHTML = label.innerHTML + " *";}
}
}
function makeOptional(fieldToChangeId) { var fieldToChange = document.getElementById(fieldToChangeId); var parent = fieldToChange.parentNode; fieldToChange.className = ""; var label = parent.getElementsByTagName("label")[0]; if(label != null) { label.innerHTML = label.innerHTML.replace(" *","");}
if(parent.getElementsByTagName("small").length > 0) { var smallText = parent.getElementsByTagName("small")[0]; parent.removeChild(smallText);}
}
function limitCharacters(obj,limit) { var text = obj.value; if(text.length > limit) { obj.value = text.substring(0,limit);}
}
function clearForm(form) { var formContainer = document.getElementById(form); var formValues = formContainer.getElementsByTagName("input"); for(var i = 0; i < formValues.length; i++) { var input = formValues[i]; if(input.type == "text" || input.type == "hidden" || input.type == "password") { input.value = "";} else if(input.type == "checkbox") { input.checked = false;}
}
}
function ecShopAddToBreadCrumbs(containerId, name, url, isLast, webTreePathLength) { _ecshopBreadCrumbContainer = containerId; if(isLast) { _ecshopBreadCrumbs += '<span class="location">' + name + '</span>';} else { _ecshopBreadCrumbs += '<a href="' + url + '">' + name + '</a><span class="sep"> > </span>';}
}
function ecShopLoadBreadCrumbs() { 
	var container = document.getElementById(_ecshopBreadCrumbContainer); 
	if(container) { container.innerHTML += _ecshopBreadCrumbs;}
	ecShopChangePageTitle();
}
function ecShopChangePageTitle() { 
	var ie = document.all; 
	var breadCrumbContainer = document.getElementById("breadcrumb_container"); 
	var lastPage = (_ecshopLastPage.length > 0) ? _ecshopLastPage + " - " : ""; 
	if(breadCrumbContainer) { 
		if(ie) { document.title = lastPage + ecShopReverseBreadcrumbs(breadCrumbContainer.innerText);} 
		else { document.title = lastPage + ecShopReverseBreadcrumbs(breadCrumbContainer.textContent);}
	}
}
function ecShopReverseBreadcrumbs(breadcrumbs) { 
	var breadcrumbsList = breadcrumbs.split(" > "); 
	var reversedBreadcrumbs = ""; 
	//for(var i = breadcrumbsList.length-1; i >= 0; i--) { 
	for(var i = breadcrumbsList.length-1; i > 0; i--) { 
		if(breadcrumbsList[i] != "") { 
			reversedBreadcrumbs += breadcrumbsList[i]; 
			if(i > 0) { 
				reversedBreadcrumbs += " - ";
			}
		}
	}
	reversedBreadcrumbs += "A4 Vefverslun";
	return reversedBreadcrumbs;
}
function ecShopHideCategoryTree() { var area = document.getElementById("content_area"); var container = document.getElementById("content_container"); if(area) { area.className = "right_sidebar";}
if(container) { container.className = "product";}
}
//function sendToFriend() { if(validateForm("ecshop_send_to_friend_popup",ecTranslate("common-labels.common-form-validate-ismissing"),"",ecTranslate("common-labels.common-form-validate-notvalid"))) { var productPrice = document.getElementById("ecshopfx_product_price_hidden"); if(productPrice) { document.getElementById("item_price").value = productPrice.value;}
//document.getElementById("buy_link").value = document.location.href; document.getElementById("ecshopfx_send_to_friend").submit();}
//}

function sendToFriend() { 
    if(validateForm("ecshop_send_to_friend_popup",ecTranslate("common-labels.common-form-validate-ismissing"),"",ecTranslate("common-labels.common-form-validate-notvalid"))) 
    { 
        var productPrice = document.getElementById("ecshopfx_product_price_hidden");
        if(productPrice) { document.getElementById("item_price").value = productPrice.value;}        
        var a = document.getElementById('verify').value;
        var b = document.getElementById('captchahash').value;
        validateCaptcha("captchaimg",a,b);
        
        //document.getElementById("buy_link").value = document.location.href;
        //document.getElementById("ecshopfx_send_to_friend").submit();
    }
}

function validateCaptcha(b,c,d){
    if(c.length>0){
        ecShop.CaptchaValidation.CaptchaValidation.ValidateCaptcha(b,c,d,OnSuccessCaptchaVerification,OnError);
    }
    
    function OnSuccessCaptchaVerification(r){
        if(r){
            var a = document.getElementById("ecshopfx_product_price_hidden");
            if(a){
                document.getElementById("item_price").value = a.value;
            }
            document.getElementById("buy_link").value = document.location.href;
            document.getElementById("ecshopfx_send_to_friend").submit();
        }
        else{
            CreateError(ecTranslate("common-errors.common-error-captcha"));
        }
    }
}


function OnSendToFriend(buttonType) { if (buttonType == 'undefined') { buttonType = "sent";}
hideObject("ecshop_send_to_friend_popup"); document.getElementById("friend_name").value = ""; document.getElementById("friend_email").value = ""; document.getElementById("your_email").value = ""; document.getElementById("message").value = ""; if(!(buttonType == 'clear')) { CreateMessage(ecTranslate("common-headings.common-success"),ecTranslate("common-headings.common-login-mail-sent"),'send-to-friend');}
}
function showProductRating(totalRating, totalVotes, productId, containerId) { if(totalRating == "")
totalRating = 0; if(totalVotes == "")
totalVotes = 0; var ratingContainer = document.getElementById(containerId); _ecshopRatingContainerId = containerId; _ecshopRatingProductId = productId; if(ratingContainer) { var ratingCookie = readCookie(_ecshopProductRatingCookie); var alreadyVoted = false; if(ratingCookie == null){ ratingCookie = "";}
if(ratingCookie.length > 0 && ratingCookie.indexOf(productId + "|") > -1) { alreadyVoted = true; var msgContainer = document.getElementById("ecshopfx_rating_status"); if(msgContainer) { msgContainer.innerHTML = ecTranslate("product-labels.product-rated");}
}
var averageRating = (totalVotes > 0) ? Math.round(totalRating/totalVotes) : 0; var html = ''; for(var i = 1; i <= 5; i++) { var star = (averageRating != 0 && averageRating >= i) ? "full" : "empty"; if(alreadyVoted) { html += '<div title="' + ecTranslate("product-labels.product-already-rated") + '" class="star ' + star + '"></div>';} else { html += '<div title="' + ecTranslate("product-labels.product-rate-prefix") + ' ' + i + ' ' + ecTranslate("product-labels.product-rate-appendix") + '" class="star ' + star + ' vote" onclick="updateProductRating(\'' + totalRating + '\',\'' + totalVotes + '\',\'' + i + '\',\'' + productId + '\')"></div>';}
}
html += '<span>' + averageRating + '/5</span>'; ratingContainer.innerHTML = html;}
}
function updateProductRating(totalRating, totalVotes, vote, productId) { _ecshopUserRating = vote; ecShop.Web.Soap.ecShopWS.UpdateProductRating(totalRating, totalVotes, vote, productId, OnProductRatingUpdated, OnError);}
function OnProductRatingUpdated(results) { if(results.length > 1) { var ratingCookie = readCookie(_ecshopProductRatingCookie); var ratingCookieValue = ""; if(ratingCookie != null && ratingCookie != "") { ratingCookieValue = ratingCookie + _ecshopRatingProductId + "|";} else { ratingCookieValue = _ecshopRatingProductId + "|";}
createCookie(_ecshopProductRatingCookie, ratingCookieValue, 365); showProductRating(_ecshopUserRating, 1, _ecshopRatingProductId, _ecshopRatingContainerId); var msgContainer = document.getElementById("ecshopfx_rating_status"); if(msgContainer) { msgContainer.innerHTML = ecTranslate("product-labels.product-rated"); msgContainer.className += " high-light"; setTimeout("removeHighLight('ecshopfx_rating_status')",3000);}
_ecshopRatingContainerId = null; _ecshopRatingProductId = null; _ecshopUserRating = null;}
}
function removeHighLight(containerId) { var container = document.getElementById(containerId); if(container) { var oldClass = container.className; if(oldClass.indexOf(" high-light") > -1) { container.className = oldClass.replace(" high-light","");} else { container.className = oldClass.replace("high-light","");}
}
}
function ecShopSearch(rowFrom, rowTo, sortBy1, sortBy2, columns, key, category) { var defaultValue = document.getElementById("ecshopfx_search_default").value; if(columns == undefined) { var columnField = document.getElementById("ecshopfx_search_columns"); if(columnField != null && columnField.value.length > 0) { columns = columnField.value;} else { columns = _ecshopSearchColumns;}
}
if(key == undefined) { var keyField = document.getElementById("ecshopfx_search_word"); if(keyField != null) { key = keyField.value;} else { key = "";}
}
if(category == undefined) { var categoryField = document.getElementById("ecshopfx_search_cat"); if(categoryField != null) { category = categoryField.value;} else { category = "";}
}
if(rowFrom == undefined) { rowFrom = null;}
if(rowTo == undefined) { rowTo = null;}
if(sortBy1 == undefined) { sortBy1 = null;}
if(sortBy2 == undefined) { sortBy2 = null;}
if(key != defaultValue && key != "") { ecShopCloseSearch(); ecShopGoogleTrackSearch(key, category); CreateUpdate(ecTranslate("common-messages.common-searching")); ProductSearchList.ProductsFrom = rowFrom; ProductSearchList.ProdctsTo = rowTo; ProductSearchList.SortBy1 = sortBy1; ProductSearchList.SortBy2 = sortBy2; ProductSearchList.Key = key; ProductSearchList.Cat = category; ProductSearchList.Columns = columns; ProductSearchList.Reset(); ecShopSaveSearch(); ecShop.Web.Soap.ecShopWS.SearchProducts(rowFrom, rowTo, sortBy1, sortBy2, category, key, columns, OnProductSearch, OnError);} else { CreateError(ecTranslate("common-errors.common-search-novalue"));}
}
function ecShopSaveSearch() { var searchValues = "key:" + ProductSearchList.Key + "|cat:" + ProductSearchList.Cat + "|columns:" + ProductSearchList.Columns + "|currentPage:" + ProductSearchList.CurrentPage; createCookie(_ecshopSearchValuesCookie, searchValues, 1);}
function ecShopGetSearch() { var searchValues = readCookie(_ecshopSearchValuesCookie); if((searchValues != null || searchValues != undefined) && searchValues.length > 0) { var values = searchValues.split("|"); return values;}
}
/*function ecShopSearchEvent(e) { var keycode; var browser = navigator.userAgent; if(browser.toLowerCase().indexOf('firefox') < 0) { if (window.event)
{ keycode = window.event.keyCode;}
else if (e)
{ keycode = e.keyCode;}
if (keycode == 13)
{ ecShopSearch();}
}
}*/

function ecShopSearchEvent(e) {
    var keycode;
    var b = navigator.appName;
    if(b == 'Microsoft Internet Explorer'){
        if (window.event) {
            keycode = window.event.keyCode;
        }
        else if (e) {
            keycode = e.keyCode;
        }
        if (keycode == 13) {
            ecShopSearch();
        }
    }
}
function OnProductSearch(results) { 
	DeleteUpdate(); 
	ecShopOnSearchResult(results); 
	$('div#ecshop_search').slideToggle("slow");
}
function ecShopCheckSavedSearch() { 
	var searchResultsCookie = readCookie(_ecshopSearchCookie); 
	if(searchResultsCookie == "1") { 
		ecShopCreateSearchButton(_ecshopShowSearchResult, "ecshop_search_toggle"); 
		var values = ecShopGetSearch(); 
		if((values != null || values != undefined) && values.length > 2) { 
			if(values[3].split(":")[1] > 1) { 
				ProductSearchList.CurrentPage = values[3].split(":")[1];
			}
		}
		ecShopLoadSavedSearch();
	}
}
function ecShopCreateSearchButton(html, nameOfclass) { 
	var container = document.getElementById("ecshop_search_toogle"); 

	if(container == null) { 
		container = document.createElement("div");
	} else { 
		container.innerHTML = "";
	}

	container.className = nameOfclass; 
	container.setAttribute("id","ecshop_search_toogle"); 
	container.style.zIndex = _zIndex++; 

	var content = document.createElement("div"); 
	content.setAttribute("id","ecshop_search_toogle_text"); 
	content.innerHTML = html; 

	var closeWindow = document.createElement("div"); 
	closeWindow.className = "ecshop_hover_close"; 
	closeWindow.innerHTML = '<a href="javascript:ecShopCloseSearch()" class="img_replace" title="' + ecTranslate("common-buttons.common-close-window") + '"><span>' + ecTranslate("common-buttons.common-close-window") + '</span></a>'; 

	container.appendChild(content); 
	container.appendChild(closeWindow); 

	var parent = document.body; 
	parent.insertBefore(container, parent.firstChild); 

	$('div#ecshop_search_toogle_text').click(function () { 
		ecShopPositionToggle(true); 
		$('div#ecshop_search').slideToggle("slow", ecShopPositionToggle);
	});
}

function ecShopPositionToggle(start) { 
	if(start == undefined)
		start = false; 

	var toggle = document.getElementById("ecshop_search_toogle"); 
	var search = document.getElementById("ecshop_search"); 
	var changeTextObj = document.getElementById("ecshop_search_toogle_text"); 

	if(start) { 
		if(search.style.display == 'none') { 
			toggle.style.position = 'relative';
		}
	} else { 
		if(search.style.display == 'none') { 
			toggle.style.position = 'absolute';
		}
	}
	if(start && changeTextObj) { 
		overwriteInnerHTML(changeTextObj,_ecshopShowSearchResult,_ecshopHideSearchResult);
	}
}
function ecShopCloseSearch() { var popup = document.getElementById("ecshop_search_toogle"); var searchContainer = document.getElementById("ecshop_search"); if(popup) { popup.parentNode.removeChild(popup);}
if(searchContainer)
searchContainer.parentNode.removeChild(searchContainer); createCookie(_ecshopSearchCookie, "", 0); createCookie(_ecshopSearchValuesCookie, "", 0);}
function ecShopLoadSavedSearch() { var values = ecShopGetSearch(); if((values != null || values != undefined) && values.length > 2) { ProductSearchList.Key = values[0].replace("key:",""); ProductSearchList.Cat = values[1].replace("cat:",""); ProductSearchList.Columns = values[2].replace("columns:","");}
ecShop.Web.Soap.ecShopWS.GetSearchFromSession(ecShopOnSearchResult, OnError);}
function ecShopOnSearchResult(results) { var searchContainer = document.getElementById("ecshop_search"); if(searchContainer) { searchContainer.innerHTML = "";} else { searchContainer = document.createElement("div");}
searchContainer.setAttribute("id", "ecshop_search"); searchContainer.className = "ecshop_search_results"; searchContainer.style.display = 'none'; searchContainer.style.zIndex = _zIndex++; var searchHTML = '<div class="ecshop_hover_close"><a href="javascript:ecShopCloseSearch()" class="img_replace" title="' + ecTranslate("common-buttons.common-close-window") + '"><span>' + ecTranslate("common-buttons.common-close-window") + '</span></a></div>'; searchHTML += results; searchHTML += '<div class="clear"></div>'; searchContainer.innerHTML = searchHTML; document.body.insertBefore(searchContainer, document.body.firstChild);}
ecShopAddLoadEvent(ecShopCheckSavedSearch); var ProductSearchList = { ProductsPerPage : _ecshopSearchProductsPerPage, ProductsFrom : null, ProductsTo: null, CurrentPage : 1, SortBy1 : 1, SortBy2 : 3, View : 'grid', Key : '', Cat : '', Columns : 3, PrevPage: function()
{ if(this.CurrentPage > 1)
{ this.CurrentPage--; this.ProductsTo = (this.ProductsPerPage * this.CurrentPage); this.ProductsFrom = (this.ProductsPerPage * this.CurrentPage) - this.ProductsPerPage + 1; this.Update();}
}, NextPage: function()
{ this.ProductsFrom = (this.ProductsPerPage * this.CurrentPage) + 1; this.CurrentPage++; this.ProductsTo = (this.ProductsPerPage * this.CurrentPage); this.Update();}, ChangeView: function(view)
{ this.View = view; this.Update();}, SetPage: function(PageNo)
{ this.ProductsFrom = (this.ProductsPerPage * (PageNo - 1)) + 1; this.ProductsTo = (this.ProductsPerPage * PageNo); this.CurrentPage = PageNo; this.Update();}, SortProduct: function(SortOrder)
{ this.SortBy1 = SortOrder; this.Update();}, Reset: function()
{ this.ProductsPerPage = _ecshopSearchProductsPerPage; this.ProductsFrom = 1; this.ProductsTo = _ecshopSearchProductsPerPage; this.CurrentPage = 1; this.SortBy1 = 1;}, Update: function() { ecShopSaveSearch(); ecShop.Web.Soap.ecShopWS.SearchProducts(this.ProductsFrom, this.ProductsTo, this.SortBy1, this.SortBy2, this.Cat, this.Key, this.Columns, OnProductSearchUpdated, OnError);}
}
function OnProductSearchUpdated(results) { var container = document.getElementById("ecshop_search"); if(container) { var searchHTML = '<div class="ecshop_hover_close"><a href="javascript:ecShopCloseSearch()" class="img_replace" title="' + ecTranslate("common-buttons.common-close-window") + '"><span>' + ecTranslate("common-buttons.common-close-window") + '</span></a></div>'; searchHTML += results; searchHTML += '<div class="clear"></div>'; container.innerHTML = searchHTML;}
}
function ecShopPrintInvoice() { var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; disp_setting+="scrollbars=yes,height=800,width=800;top=100"; var content_value = document.getElementById("ecshop_printinvoice_container").innerHTML; var docprint = window.open("","",disp_setting); docprint.document.open(); docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:asp><head><title>PrintInvoice</title>'); docprint.document.write('<link href="' + ecShopReturnHost() + '/webpages/templates/css/global.css" media="all" rel="stylesheet" type="text/css">'); docprint.document.write('<link href="' + ecShopReturnHost() + '/webpages/templates/css/webshop.css" media="all" rel="stylesheet" type="text/css" />'); docprint.document.write('<link href="' + ecShopReturnHost() + '/webpages/templates/css/font.css" media="all" rel="stylesheet" type="text/css" />'); docprint.document.write('</head><body id="print" onload="window.print()">'); docprint.document.write('<div id="ecshop_product_container" class="basket_view">' + content_value + '</div>'); docprint.document.write('</body></html>'); docprint.document.close(); docprint.focus();}
function ecShopGoogleTrackOrder(order) { if(pageTracker != null) { try { eval(order);} catch(err) { }
}
}
function ecShopGoogleTrackCheckout(step) { if(pageTracker != null) { pageTracker._trackPageview("/checkout/step" + step + ".html");}
}
function ecShopGoogleTrackSearch(key, cat) { if(pageTracker != null) { pageTracker._trackPageview("/quicksearch/search.html?search=" + key + "&cat=" + cat);}
}

