var GiftRegistry={Title:"",Description:"",Url:"",Password:"",Password2:"",Page_Load:function(){$j("#title").hide();$j("#grdescription").hide();$j("#password").hide();$j("#verifypassword").hide();$j("#comparepassword").hide();GiftRegistry.BindEvents()},BindEvents:function(){$j("#hypCreateRegistry").live("click",GiftRegistry.Create);$j(".registryPurchased").live("click",GiftRegistry.Purchase_OnClick);$j(".addToGiftRegistry").live("click",GiftRegistry.AddProduct)},Create:function(){$j("#title").hide();$j("#grdescription").hide();$j("#password").hide();$j("#verifypassword").hide();$j("#comparepassword").hide();GiftRegistry.Title=$j("[id$='txtTitle']").val();GiftRegistry.Description=$j("[id$='txtDescription']").val();GiftRegistry.Password=$j("[id$='txtPassword']").val();GiftRegistry.Password2=$j("[id$='txtPassword2']").val();if(GiftRegistry.Validate()){$j.ajax({type:"POST",url:"/layouts/Ecommerce/Ajax.aspx/CreateGiftRegistry",contentType:"application/json; charset=utf-8",data:"{'title': '"+GiftRegistry.Title+"','description': '"+GiftRegistry.Description+"','password': '"+GiftRegistry.Password+"'}",dataType:"json",success:function(a){if(a!=null&&a.d!=null){GiftRegistry.CreateSuccess(a.d)}},error:function(a){}})}else{}return false},AddProduct:function(d){var c=$j(this).attr("registryid");var a=$j(this).attr("productid");var b=($j(".hidIsRegistered").val()=="true");if(b){SetCurrentTab("GiftRegistry","EcProfileTabName");location.href="/My_page.aspx"}else{$j.ajax({type:"POST",url:"/layouts/Ecommerce/Ajax.aspx/AddToGiftRegistry",contentType:"application/json; charset=utf-8",data:"{'productId': '"+a+"'}",dataType:"json",success:function(e){if(e!=null&&e.d!=null){GiftRegistry.AddProduct_Success(e.d)}},error:function(e){$j("#loader").hide()}})}},AddProduct_Success:function(a){$j(".hidIsRegistered").val("true");$j(".registryText").text("View Registry")},Purchase_OnClick:function(d){var a=$j(this).parents("tr:first");var c=$j(this).attr("registryid");var b=$j(this).attr("registryitemid");$j("#loader").show();$j.ajax({type:"POST",url:"/layouts/Ecommerce/Ajax.aspx/ChangeRegistryItemStatus",contentType:"application/json; charset=utf-8",data:"{'registryId': '"+c+"','registryItemId': '"+b+"','status': 'true'}",dataType:"json",success:function(e){if(e!=null&&e.d!=null){GiftRegistry.PurchaseSuccess(e.d,a)}},error:function(e){$j("#loader").hide()}});return false},PurchaseSuccess:function(b,a){$j(".imgPurchased",a).show();$j(".roundButtonLarge",a).hide();$j("#loader").hide()},RemoveItem:function(c){var b=$j(c);var a=b.attr("pId");$j.ajax({type:"POST",url:"/layouts/Ecommerce/Ajax.aspx/RemoveFromRegistry",data:"{'productId':'"+a+"'}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(d){if(d!=null&&d.d!=null){GiftRegistry.RemoveItem_Success(b)}},error:function(d){}});return false},RemoveItem_Success:function(a){var b=a.parent().parent().parent();b.fadeOut(500,function(){b.remove()})},Validate:function(){var a=true;var d=true;var c=true;var b=true;if(GiftRegistry.Title==""){a=false;$j("#title").show()}else{$j("#title").hide()}if(GiftRegistry.Description==""){d=false;$j("#grdescription").show()}else{$j("#grdescription").hide()}if(GiftRegistry.Password==""){c=false;$j("#password").show()}else{$j("#password").hide()}if(GiftRegistry.Password2==""){$j("#verifypassword").show();b=false}else{$j("#verifypassword").hide()}if(GiftRegistry.Password!=""&&GiftRegistry.Password2!=""){if(GiftRegistry.Password!=GiftRegistry.Password2){$j("#comparepassword").show();b=false}else{$j("#comparepassword").hide()}}else{b=false}if(a&&d&&c&&b){return true}else{return false}},CreateSuccess:function(a){LoadSublayout("CF/Modules/UserManagement/GiftRegistry",$j(".tabContent"),null)}};var Wishlist={IsLoggedIn:false,Page_Load:function(){if($j(".hidIsLoggedIn").val()=="true"){Wishlist.BindEvents()}},BindEvents:function(){$j(".addToWishList").click(Wishlist.AddItem)},AddItem:function(c){var b=$j(this).attr("productid");var a=($j(".hidIsWished").val()=="true");if(a){SetCurrentTab("Wishlist","EcProfileTabName");location.href="/My_page.aspx"}else{$j.ajax({type:"POST",url:"/layouts/Ecommerce/Ajax.aspx/AddToWishList",data:"{'productid': '"+b+"'}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(d){if(d!=null&&d.d!=null){Wishlist.AddItem_Success(d.d);$j(".hidIsWished").val("true");$j(".wishlistText").text("View Wishlist")}},error:function(d){}})}return false},AddItem_Success:function(a){},RemoveItem:function(c){var b=$j(c);var a=b.attr("pId");$j.ajax({type:"POST",url:"/layouts/Ecommerce/Ajax.aspx/RemoveFromWishlist",data:"{'productId':'"+a+"'}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(d){if(d!=null&&d.d!=null){Wishlist.RemoveItem_Success(b)}},error:function(d){}});return false},RemoveItem_Success:function(a){a.parent().parent().remove();if($j(".CFWishlist").children("ul").length<=0){$j(".tabContent").append("<span>There are no items in your Wishlist</span>")}}};
