var Cart = { Increase: function(pid) { var container = $("articles.container"); AjaxInitializeAnimation(container); AjaxStartAnimation(container); var opt = { method: "get", parameters: { ajax: "Cart.Increase", pid: pid }, onComplete: function(transport) { AjaxStopAnimation(container); }, onSuccess: function(response) { var status = response.responseJSON; if (status && status.status == 1) { Cart.Refresh(); } Shop.UpdateTopMenu(); } } var Request = new Ajax.Request('cart.php', opt); }, Decrease: function(pid) { var container = $("articles.container"); AjaxInitializeAnimation(container); AjaxStartAnimation(container); var opt = { method: "get", parameters: { ajax: "Cart.Decrease", pid: pid }, onComplete: function(transport) { AjaxStopAnimation(container); }, onSuccess: function(response) { var status = response.responseJSON; if (status && status.status == 1) { Cart.Refresh(); } Shop.UpdateTopMenu(); } } var Request = new Ajax.Request('cart.php', opt); }, Update: function(pid) { var container = $("articles.container"); var count = document.forms.cart[pid].value; AjaxInitializeAnimation(container); AjaxStartAnimation(container); var opt = { method: "get", parameters: { ajax: "Cart.Update", pid: pid, count: count }, onComplete: function(transport) { AjaxStopAnimation(container); }, onSuccess: function(response) { var status = response.responseJSON; if (status && status.status == 1) { Cart.Refresh(); } Shop.UpdateTopMenu(); } } var Request = new Ajax.Request('cart.php', opt); }, Remove: function(pid) { var container = $("articles.container"); AjaxInitializeAnimation(container); AjaxStartAnimation(container); var opt = { method: "get", parameters: { ajax: "Cart.Remove", pid: pid }, onComplete: function(transport) { AjaxStopAnimation(container); }, onSuccess: function(response) { var status = response.responseJSON; if (status && status.status == 1) { Cart.Refresh(); } Shop.UpdateTopMenu(); } } var Request = new Ajax.Request('cart.php', opt); }, Add: function(pidaid) { var pids = pidaid.match(/(.*)\-/); if (pids) { var note = $("cart-add-note-" + pids[1]); note.setOpacity(1.0) note.setStyle({display: "block"}); var e = note.select("div.cart-add-failed"); if (e.length > 0) { e[0].setStyle({display: ""}); } var e = note.select("div.cart-add-success"); if (e.length > 0) { e[0].setStyle({display: ""}); } } AjaxInitializeAnimation(note); AjaxStartAnimation(note); var opt = { method: "get", parameters: { ajax: "Cart.Add", pid: pidaid }, onFailure: function(response) { var e = note.select("div.cart-add-failed"); if (e.length > 0) { e[0].setStyle({display: "block"}); } var e = note.select("div.cart-add-success"); if (e.length > 0) { e[0].setStyle({display: "none"}); } }, onComplete: function(response) { AjaxStopAnimation(note); }, onSuccess: function(response) { var status = response.responseJSON; if (note.iid) { note.opacityIndex = 0.0; note.opacity = 1.0; } else { note.opacity = 1.0; note.opacityIndex = 0.0; note.iid = setInterval(function() { note.opacity = Math.cos(note.opacityIndex); note.setOpacity(note.opacity); note.opacityIndex += (3.1416 / 2) / 25; /* in 7° Schritten hochzählen */ if (note.opacity < 0.0) { clearInterval(note.iid); note.iid = null; note.opacity = null; note.opacityIndex = null; note.setStyle({display : "none"}); } }, 100); } Shop.UpdateTopMenu(); } } var Request = new Ajax.Request('cart.php', opt); }, AddClickHandler: function(event, pidaid) { var pids = pidaid.match(/(.*)\-/); if (pids) { var note = $("cart-add-note-" + pids[1]); var target = (event.target) ? event.target : event.srcElement; //var offs = target.positionedOffset(); var coords = GetCoords(target); var offs = {left: coords[0], top: coords[1]}; note.setOpacity(1.0); note.absolutize(); note.setStyle({display: "block", left: (coords[0] + coords[2] - note.getWidth()) + "px", top: (coords[1] + coords[3]) + "px"}); Cart.Add(pidaid); } }, Delete: function() { var container = $("articles.container"); AjaxInitializeAnimation(container); AjaxStartAnimation(container); var opt = { method: "get", parameters: { ajax: "Cart.Delete" }, onComplete: function(transport) { AjaxStopAnimation(container); }, onSuccess: function(response) { var status = response.responseJSON; if (status && status.status == 1) { Cart.Refresh(); } Shop.UpdateTopMenu(); } } var Request = new Ajax.Request('cart.php', opt); }, Order: function() { document.location.assign("pay.php"); }, Refresh: function(pid) { var container = $("articles.container"); var oldtable = $("articles"); if (container) { AjaxInitializeAnimation(container); AjaxStartAnimation(container); var opt = { method: "get", parameters: { ajax: "Cart.Refresh" }, onComplete: function(transport) { AjaxStopAnimation(container); }, onSuccess: function(response) { var html = response.responseText; var newtable = ''; if (oldtable.tHead) { newtable += "" + oldtable.tHead.innerHTML + ""; } if (oldtable.tFoot) { newtable += "" + oldtable.tFoot.innerHTML + ""; } newtable += "" + html + "
"; container.innerHTML = newtable; } } var Request = new Ajax.Request('cart.php', opt); } } }