winWrapper={redirectParent:function(){parent.window.location="/store/home.jsp";
}};
$(function(){$(".openLoginBox").click(function(){openLoginBox();
});
$(".closeLoginBox").click(function(){closeLoginBox("XXgoBack");
});
$(".openForgotBox").click(function(){openForgotBox();
});
$(".closeForgotBox").click(function(){closeForgotBox();
});
});
function random_string(){var time=String((new Date()).getTime()).replace(/\D/gi,"");
return time;
}function openLoginBox(){if(location.protocol=="https:"){$("#loginFormIframe").attr("src","/store/registration/inc/my_account_login.jsp");
}else{$("#loginFormIframe").attr("src","/store/common/inc/my_account_login.jsp");
}$("#loginFormDiv").jqmShow();
}function closeLoginBox(){if(parent.location.href.indexOf("/checkout/")>0){parent.window.location="/store/cart/shoppingCart.jsp";
}else{if(parent.location.href.indexOf("/account/")>0){parent.window.location="/store/home.jsp";
}else{parent.$("#loginFormDiv").jqmHide();
}}}function closeCommonLoginBox(){if(location.href.toLowerCase().indexOf("lauramercier.com")!=-1){parent.$("#loginFormDiv").jqmHide();
}else{if(parent.location.href.indexOf("/checkout/")>0){parent.window.location="/store/cart/shoppingCart.jsp";
}else{if(parent.location.href.indexOf("/account/")>0){parent.window.location="/store/home.jsp";
}else{parent.$("#loginFormDiv").jqmHide();
}}}}function openForgotBox(){if(($(this).parent().find("iframe")[0])!=0){parent.$("#signinForgotIframe").attr("src","/store/registration/inc/my_account_forgotPassword.jsp");
parent.$("#signinForgotDiv").jqmShow();
}else{$("#signinForgotDiv").jqmShow();
}}function closeForgotBox(){if(($(this).parent().find("iframe")[0])!=0){parent.$("#signinForgotDiv").jqmHide();
}else{$("#signinForgotDiv").jqmHide();
}}function submitSingleForm(formId,skuId){$("#pleaseWait").jqmShow();
if(typeof (skuId)=="undefined"||skuId.length==0){skuId="";
}var submitParams="?from="+formId;
var isError=false;
$.ajax({type:"post",url:"/store/common/inc/formSubmits.jsp"+submitParams,data:$("#"+formId+" input").serialize(),dataType:"json",async:false,error:function(){if(formId=="forgotPwdForm"){$("#forgotPasswordSuccess").hide();
$("#forgotPasswordErrors").html("There was a problem with the e-mail address provided.<br />Please double check your e-mail and try again.");
$("#forgotPasswordErrors").show();
$("#pleaseWait").jqmHide();
return false;
}else{$("#pleaseWait").jqmHide();
alert("Error loading document: "+formId);
return false;
}},success:function(data){$("#loginErrors, #createAccountErrors, #myProfileErrors, #myProfileSuccess, #myAddressErrors, #myAddressSucces, #contactUsFormErrors").hide();
$("#contactUsFormSuccess, #forgotPasswordErrors, #forgotPasswordSuccess, #replenishmentErrors, #replenishmentSuccess, #wishlistSuccessErrors, #wishlistSuccessSuccess").hide();
var resultObj=data;
if(resultObj==null||typeof (resultObj)=="undefined"){if(formId=="forgotPwdForm"){$("#forgotPasswordSuccess").hide();
$("#forgotPasswordErrors").html("There was a problem with the e-mail address provided.<br />Please double check your e-mail and try again.");
$("#forgotPasswordErrors").show();
$("#pleaseWait").jqmHide();
return false;
}else{alert("No response was provided by the server.");
$("#pleaseWait").jqmHide();
return false;
$.stopPropagation();
}}var loginBoxClose=0;
if(resultObj.result=="true"&&(resultObj.form=="maLoginForm"||resultObj.form=="maSignupForm")){loginBoxClose=1;
}else{if(resultObj.result=="true"){if(resultObj.form=="forgotPwdForm"){$("#forgotPasswordSuccess p").html("We will send you a new password to your email address shortly.");
$("#forgotPasswordSuccess").show();
setTimeout("closeForgotBox()",5555);
}else{if(resultObj.form=="updateProfileForm"){$("#myProfileSuccess p").html("Successfully updated.");
$("#myProfileSuccess").show();
}else{if(resultObj.form=="addressForm"||resultObj.form=="defaultShippingForm"){$("#myAddressSuccess p").html("Successfully updated.");
$("#myAddressSuccess").show();
}else{if(resultObj.form=="shippingForm"){$("#myAddressSuccess p").html("Successfully added.");
$("#myAddressSuccess").show();
$("#addressBookSelect").load("/store/registration/inc/my_account_address_select.jsp");
}else{if(resultObj.form=="newShippingForm"){$("#myAddressSuccess p").html("Successfully updated.");
$("#myAddressSuccess").show();
$("#addressBookSelect").load("/store/registration/inc/my_account_address_select.jsp");
}else{if(resultObj.form.indexOf("deleteForm_")>=0){$("#myAccountActiveTab").load("/store/common/inc/getMyAccountActiveTab.jsp?ma=3");
location.href="/store/account/";
$("#pleaseWait").jqmHide();
return false;
}else{if(resultObj.form=="contactUsForm"){$("#contactUsFormSuccess p").html("Form successfully submitted.");
$("#contactUsFormSuccess").show();
}else{if(resultObj.form.indexOf("subscribeOpts")>=0){$("#myAccountActiveTab").load("/store/common/inc/getMyAccountActiveTab.jsp?ma=2");
$("#myAccountContent").load("/store/registration/inc/my_account_communications.jsp?opt="+skuId,function(){if(skuId=="optIn"){$("#subscribeOptsFormSuccess p").html("Thank you. You have successfully opted-in to receive email marketing messaging from Laura Mercier.");
}else{if(skuId=="optOut"){$("#subscribeOptsFormSuccess p").html("Thank you. You have successfully opted-out from receiving email marketing messaging.");
}}$("#subscribeOptsFormSuccess").show();
});
$(".myActive").removeClass("myActive").addClass("myActiveNon");
$("#myAccountUlLi li:eq(2)").removeClass("myActiveNon").addClass("myActive");
$("#pleaseWait").jqmHide();
return false;
}else{if((resultObj.form=="form_add_to_cart"&&formId=="form_add_to_cart")||resultObj.form=="form_add_all_to_cart"||resultObj.form=="form_add_all_failed_to_cart"){$("#miniCartTop").load("/store/common/inc/minicartload.jsp");
$("#replenishmentSuccess p").html("Successfully added to shopping cart.");
$("#replenishmentSuccess").show();
window.location.href="#top";
}else{if(resultObj.form=="form_replenishment_program"){if(skuId.length>0){$("#wish_"+skuId).html('<img alt="This item has been added to Replenishment program already" title="This item has been added to Replenishment program already" src="/store/template/default/images/addToReplenishmentProgramStar_on.png" style="position:relative; z-index:15; top:0; left:0;" />');
$("#replenishmentSuccess p").html(skuId+" successfully added to replenishment program.");
$("#replenishmentSuccess").show();
window.location.href="#top";
}else{window.location.reload();
}}else{if(resultObj.form=="wishlistAll"){$("#miniCartTop").load("/store/common/inc/minicartload.jsp");
$("#wishlistSuccess p").html("Successfully added to shopping cart.");
$("#wishlistSuccess").show();
window.location.href="#top";
}else{if(resultObj.form=="form_add_to_cart"&&formId.indexOf("wishListFormAdd_")>=0){$("#miniCartTop").load("/store/common/inc/minicartload.jsp");
$("#wishlistSuccess p").html("Successfully added to shopping cart.");
$("#wishlistSuccess").show();
window.location.href="#top";
}else{if(resultObj.form.indexOf("wishListFormRemove_")>=0){$("#myAccountActiveTab").load("/store/common/inc/getMyAccountActiveTab.jsp?ma=4");
$("#myAccountContent").load("/store/account/inc/my_account_wishList.jsp?rs="+skuId);
window.location.href="#top";
}else{}}}}}}}}}}}}}}else{if(resultObj.form=="forgotPwdForm"){$("#forgotPasswordErrors").html(resultObj.errors.replace(/,/g,"<br />"));
$("#forgotPasswordErrors").show();
}else{if(resultObj.form=="maLoginForm"){$("#loginErrors").html(resultObj.errors.replace(/,/g,"<br />"));
$("#loginErrors").show();
}else{if(resultObj.form=="maSignupForm"){$("#createAccountErrors").html(resultObj.errors.replace(/,/g,"<br />"));
$("#createAccountErrors").show();
}else{if(resultObj.form=="updateProfileForm"){$("#myProfileErrors p").html(resultObj.errors.replace(/,/g,"<br />"));
$("#myProfileErrors").show();
}else{if(resultObj.form=="addressForm"||resultObj.form=="defaultShippingForm"||resultObj.form=="shippingForm"||resultObj.form=="newShippingForm"){$("#myAddressErrors p").html(resultObj.errors.replace(/,/g,"<br />"));
$("#myAddressErrors").show();
}else{if(resultObj.form=="contactUsForm"){$("#contactUsFormErrors p").html(resultObj.errors.replace(/,/g,"<br />"));
$("#contactUsFormErrors").show();
}else{if(resultObj.form=="subscribeOpts2Form"){$("#subscribeOpts2FormErrors p").html(resultObj.errors.replace(/,/g,"<br />"));
$("#subscribeOpts2FormErrors").show();
}else{if(resultObj.form=="subscribeOpts3Form"){$("#subscribeOpts3FormErrors p").html(resultObj.errors.replace(/,/g,"<br />"));
$("#subscribeOpts3FormErrors").show();
}else{if(resultObj.form=="form_add_to_cart"||resultObj.form=="form_replenishment_program"||resultObj.form=="form_add_all_to_cart"||resultObj.form=="form_add_all_failed_to_cart"){$("#replenishmentErrors p").html(resultObj.errors.replace(/,/g,"<br />"));
$("#replenishmentErrors").show();
window.location.href="#topOfProductsList";
}else{alert("result: "+resultObj.result+"\r\nform: "+resultObj.form+"\r\nerrors: "+resultObj.errors);
}}}}}}}}}}}if(loginBoxClose==1){if(location.href.indexOf("/common/")!=-1&&location.href.toLowerCase().indexOf("lauramercier.com")!=-1){winWrapper.redirectParent();
return true;
}else{$("#loginFormDiv").jqmHide();
if(/\/checkout\//.test(parent.window.location)){parent.document.location.replace("/store/checkout/shipping.jsp");
}else{parent.window.location.reload();
}return true;
}}else{$("#pleaseWait").jqmHide();
return false;
}}});
}
