var cmsAjaxUrl = "/de/c27/index.html"; function reloadItemWithContent(elementId, contentUrl) { jq.post(contentUrl,"",function(result){ if (result != null){ jq("#" + elementId).html(result); jq("#" + elementId).css("visibility","visible"); } else { jq("#" + elementId).html("Error in AJAX Request, please contact the site administrator!"); } }); } function reloadWarenkorbItemWithContent(elementId, contentUrl, artikelId) { jq.post(contentUrl,"",function(result){ if (result != null){ jq("#" + elementId).html(result); visualWarenkorbButtonOk(artikelId); showAddWarenkorbConfirm(); } else { jq("#" + elementId).html("Error in AJAX Request, please contact the site administrator!"); } }); } // calls the callback function when ready (callback( bool success, string result) ) function loadWithCallback(contentUrl, callback) { jq.post(contentUrl,"",function(result){ if (result != null){ callback(true, trimString(result)); } else { callback(false, "Error in AJAX Request, please contact the site administrator!"); } }); } // calls the callback function when ready (callback( bool success, string result) ) function reloadItemWithCallbackAndContent(elementId, contentUrl, callback) { jq.post(contentUrl,"",function(result){ if (result != null){ jq("#" + elementId).html(result); if (callback) callback(true, trimString(result)); } else { if (callback) callback(false, "Error in AJAX Request, please contact the site administrator!"); } }); } function saveWerbung(elementId, parameters) { var url = appendParameter(cmsAjaxUrl, "aAction", "freundschaftsAnfrage"); url = url + "&" + parameters; reloadItemWithContent(elementId, url); } function saveBenutzer(elementId, parameters) { var url = appendParameter(cmsAjaxUrl, "aAction", "benutzer"); url = url + "&" + parameters; reloadItemWithContent(elementId, url); } function loadAuftragUebersicht(elementId) { var url = appendParameter(cmsAjaxUrl, "aAction", "auftragUebersicht"); reloadItemWithContent(elementId, url); } function loadBestelladresse(elementId, editMode) { var url = appendParameter(cmsAjaxUrl, "aAction", "bestellAdresse"); url = appendParameter(url, "editAdresse", "" + editMode); reloadItemWithContent(elementId, url); } function saveBestelladresse(elementId, parameters, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "bestellAdresse"); url = url + "&" + parameters; reloadItemWithCallbackAndContent(elementId, url, callback); } function loadLieferadresse(elementId, editMode) { var url = appendParameter(cmsAjaxUrl, "aAction", "lieferAdresse"); url = appendParameter(url, "editDeliveryAdresse", "" + editMode); reloadItemWithContent(elementId, url); } function saveLieferadresse(elementId, parameters, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "lieferAdresse"); url = url + "&" + parameters; reloadItemWithCallbackAndContent(elementId, url, callback); } function deleteLieferadresse(elementId, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "lieferAdresse"); url = url + "&deleteDeliveryAddress=true"; reloadItemWithCallbackAndContent(elementId, url, callback); } function loadAuftragZusatz(elementId) { var url = appendParameter(cmsAjaxUrl, "aAction", "auftragZusatz"); reloadItemWithContent(elementId, url); } function saveVersandart(elementId, versandartId, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "auftragZusatz"); url = appendParameter(url, "versandartId", "" + versandartId); reloadItemWithCallbackAndContent(elementId, url, callback); } function saveZahlungsart(elementId, zahlungsartId, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "auftragZusatz"); url = appendParameter(url, "zahlungsartId", "" + zahlungsartId); reloadItemWithCallbackAndContent(elementId, url, callback); } function saveHaendler(elementId, haendlerId, haendler, haendlerEmail, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "haendler"); url = appendParameter(url, "haendlerId", "" + haendlerId); url = appendParameter(url, "haendler", "" + haendler); url = appendParameter(url, "haendlerEmail", "" + haendlerEmail); reloadItemWithCallbackAndContent(elementId, url, callback); } function loadGutschein(elementId) { var url = appendParameter(cmsAjaxUrl, "aAction", "gutschein"); reloadItemWithContent(elementId, url); } function addGutscheinCode(elementId, gutscheinCode, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "gutschein"); url = appendParameter(url, "gutscheinCode", gutscheinCode); reloadItemWithCallbackAndContent(elementId, url, callback); } function getLoginToken(username, password, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "loginToken"); url = appendParameter(url, "username", username); url = appendParameter(url, "password", password); loadWithCallback(url, callback); } function doForgotPassword(email, callback) { var url = appendParameter(cmsAjaxUrl, "aAction", "forgotPassword"); url = appendParameter(url, "pEmail", email); loadWithCallback(url, callback); } function loadTextForWarengruppe(elementId, wgrpId) { var url = appendParameter(cmsAjaxUrl, "aAction", "prdListWgrpText"); url = appendParameter(url, "wgrp", wgrpId); reloadItemWithContent(elementId, url); } function loadPageSelectorForWarengruppe(elementIdTop, elementIdBottom, curPage, wgrpId, keywords, artikelTyp) { var url = appendParameter(cmsAjaxUrl, "aAction", "prdListPageSelector"); url = appendParameter(url, "wgrp", wgrpId); url = appendParameter(url, "q", keywords); url = appendParameter(url, "artikelTyp", artikelTyp); url = appendParameter(url, "curPage", curPage); reloadItemWithContent(elementIdTop, url); reloadItemWithContent(elementIdBottom, url); } function loadPageTopHeadlineForWarengruppe(elementIdTop, curPage, wgrpId, keywords, artikelTyp) { var url = appendParameter(cmsAjaxUrl, "aAction", "prdListTopHeadline "); url = appendParameter(url, "wgrp", wgrpId); url = appendParameter(url, "q", keywords); url = appendParameter(url, "artikelTyp", artikelTyp); url = appendParameter(url, "curPage", curPage); reloadItemWithContent(elementIdTop, url); } function loadPageListForWarengruppe(elementId, curPage, wgrpId, keywords, artikelTyp) { var url = appendParameter(cmsAjaxUrl, "aAction", "prdListPageProducts"); url = appendParameter(url, "wgrp", wgrpId); url = appendParameter(url, "q", keywords); url = appendParameter(url, "artikelTyp", artikelTyp); url = appendParameter(url, "curPage", curPage); reloadItemWithContent(elementId, url); } function loadPageListForBonusShop(elementId, curPage, warenkorbId) { var url = appendParameter(cmsAjaxUrl, "aAction", "prdListPageProducts"); url = appendParameter(url, "artikelTyp", "bonus_shop"); url = appendParameter(url, "curPage", curPage); url = appendParameter(url, "wkId", warenkorbId); reloadItemWithContent(elementId, url); } function loadTextForBonusShop(elementId, warenkorbId) { var url = appendParameter(cmsAjaxUrl, "aAction", "prdListWgrpText"); url = appendParameter(url, "artikelTyp", "bonus_shop"); url = appendParameter(url, "wkId", warenkorbId); reloadItemWithContent(elementId, url); } function loadArtikelDetail(elementId, artikelId) { var url = appendParameter(cmsAjaxUrl, "aAction", "artikelDetail"); url = appendParameter(url, "artikelId", artikelId); reloadItemWithContent(elementId, url); } function toWarenkorb(elementId, artikelId, warenkorbId) { toWarenkorb(elementId, artikelId, -1, "", warenkorbId); } function toWarenkorb(elementId, artikelId, vpeId, warenkorbId) { toWarenkorb(elementId, artikelId, vpeId, "", warenkorbId); } function toWarenkorb(elementId, artikelId, vpeId, variantenCsv, warenkorbId) { visualWarenkorbButtonWaiting(artikelId); var url = appendParameter(cmsAjaxUrl, "aAction", "hdrWarenkorb"); url = appendParameter(url, "addArtikelId", artikelId); if (vpeId >= 0) { url = appendParameter(url, "addVpeId", vpeId); } url = appendParameter(url, "wkId", warenkorbId); url = appendParameter(url, "variantenCsv", "" + variantenCsv); reloadWarenkorbItemWithContent(elementId, url, artikelId); } function updateWarenkorb(elementId) { var url = appendParameter(cmsAjaxUrl, "aAction", "hdrWarenkorb"); reloadItemWithContent(elementId, url); } function visualWarenkorbButtonWaiting(artikelId) { var elm = "artwkbtn_" + artikelId; jq("#" + elm).attr("src", "/tmp/w0h0m0_i32_.img"); } function visualWarenkorbButtonOk(artikelId) { var elm = "artwkbtn_" + artikelId; jq("#" + elm).attr("src", "/tmp/w0h0m0_i11_.img"); } function removeWarenkorbPosition(elementId, posId) { var url = appendParameter(cmsAjaxUrl, "aAction", "warenkorbEdit"); url = appendParameter(url, "deletePosId", posId); reloadItemWithContent(elementId, url); } function changeWarenkorbPosition(elementId, posId, menge) { var url = appendParameter(cmsAjaxUrl, "aAction", "warenkorbEdit"); url = appendParameter(url, "posId", posId); url = appendParameter(url, "menge", menge); reloadItemWithContent(elementId, url); } function appendParameter(url, parameter, value) { if(url.indexOf('?') > -1) { url += "&" + parameter + "=" + encodeURIComponent(value); } else { url += "?" + parameter + "=" + encodeURIComponent(value); } return url; } function trimString(str) { return str.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' '); }; function showAddWarenkorbConfirm() { jSuccess( '  Der Artikel wurde in Ihren Warenkorb gelegt!', { autoHide : true, // added in v2.0 clickOverlay : true, // added in v2.0 MinWidth : 300, TimeShown : 2000, ShowTimeEffect : 200, HideTimeEffect : 200, LongTrip :20, HorizontalPosition : 'center', VerticalPosition : 'center', ShowOverlay : true, ColorOverlay : '#000', OpacityOverlay : 0.5, onClosed : function(){ // added in v2.0 }, onCompleted : function(){ // added in v2.0 } }); }