﻿jQuery.noConflict();
(function(a){function e(){return window.location.hostname=="localhost"?"http://localhost/bgsAug08/":window.location.protocol+"//"+window.location.hostname+"/"}function h(b){b=a("#galleryHolder"+b+" .ajaxbuybtn");a('<span class="ajaxLoader"><img src='+e()+"images/template/loader.gif ></span>").insertAfter(b);b.hide()}function f(b){a("#galleryHolder"+b+" .ajaxLoader").remove();a("#galleryHolder"+b+" .ajaxbuybtn").show()}var d=null;this.addToBasket=function(b,i){a("#galleryHolder"+b+" .ajaxAddedToBasket").remove();
a("#galleryHolder"+b+" .ajaxFailedAddToBasket").remove();h(b);a.ajax({url:e()+"apps/ajax/addtobasket.ashx",type:"POST",cache:false,data:{p:b,q:i},dataType:"json",success:function(c){f(b);c.status==0?a('<div class="ajaxAddedToBasket">'+c.msg+"</div>").appendTo("#galleryHolder"+b):a('<div class="ajaxFailedAddToBasket">'+c.msg+"</div>").appendTo("#galleryHolder"+b);a("#headerBasketSummary").html(c.HeaderMessage);if(c.ShippingMessage!=null&&c.ShippingMessage.length>0)if(d==null||d!=c.ShippingMessage){a(".ajaxShippingMessage").remove();
var g=a("#galleryHolder"+b).offset(),j=a("<div></div>").css({left:g.left+20,top:g.top+20,display:"none"}).html(c.ShippingMessage).addClass("ajaxShippingMessage").click(function(){a(this).stop().fadeOut(200,function(){a(this).remove()})}).appendTo("body").fadeIn();setTimeout(function(){j.fadeOut(2E3,function(){a(this).remove()})},4E3);d=c.ShippingMessage}},error:function(){f(b);a('<div class="ajaxFailedAddToBasket">Could not add to basket</div>').appendTo("#galleryHolder"+b)}})};a(function(){a(".buy").hide();
a(".ajaxbuybtn").show()})})(jQuery);
