
gState.GetShipMethodById=function(vShipMethodId){if(gState.CartShipMethodGetResponse.StatusCode=='200'){for(pIndex in gState.CartShipMethodGetResponse.ShipMethods){zShipMethod=gState.CartShipMethodGetResponse.ShipMethods[pIndex];if(zShipMethod.ShipMethodId==vShipMethodId){return zShipMethod;}}}
return{ShipMethodId:0};};function CartShipMethodGetRequest(vShipToCountryId,vCallBack){$('#shipmethod-loading').show();$('#ShipMethod').attr('disabled','true').emptySelect();gFunnel.Display.Block();var url=GetUniqueURL(CartService.ServicePath+'?Operation=CartShipMethodGet&Format=JSON&ShipToCountryId='+vShipToCountryId.toString());var callback=function(data){var zResponse=eval("("+data+")");vCallBack(zResponse);};$.get(url,callback,'text');}
function CartGetRequest(vShipToCountryId,vCallBack){gFunnel.Display.Block();var url=GetUniqueURL(CartService.ServicePath+'?Operation=CartGet&Format=JSON&ShipToCountryId='+vShipToCountryId.toString());var callback=function(data){var zResponse=eval("("+data+")");vCallBack(zResponse);};$.get(url,callback,'text');}
function CartModifyRequest(options,vCallBack){var settings=$.extend({'Email':'','ShipMethodId':0,'ShipToAddressId':0,'BillToAddressId':0,'ShipToCountryId':224,'CarbonOffset':(gState.CartGetResponse.Cart.IncludeCarbonOffset?1:0),'PromoCode':'','GiftCertificate':'','BlockUI':true},options||{});if(settings.BlockUI){gFunnel.Display.Block();}
var url=CartService.ServicePath+'?Operation=CartModify&Format=JSON';var callback=function(data){var zResponse=eval("("+data+")");vCallBack(zResponse);};$.post(url,settings,callback,'text');}
function AddToWishlistRequest(options,vCallBack){var settings=$.extend({'BlockUI':true},options||{});var url=CartService.ServicePath+'?Operation=AddToWishlist&Format=JSON';var callback=function(data){var zResponse=eval("("+data+")");vCallBack(zResponse);};$.post(url,settings,callback,'text');}
var CartService={ServicePath:'Services/Cart.aspx',ShipMethodGet:function(vShipToCountryId,vCallBack){CartShipMethodGetRequest(vShipToCountryId,vCallBack);},Get:function(vShipToCountryId,vCallBack){CartGetRequest(vShipToCountryId,vCallBack);},Modify:function(options,vCallBack){CartModifyRequest(options,vCallBack);},AddToWishlist:function(options,vCallBack){AddToWishlistRequest(options,vCallBack);}};