/* load document variables [ begin ] */
$(function(){
doc = function(){
if (self.innerHeight) {
doc.pageYOffset = self.pageYOffset;
doc.pageXOffset = self.pageXOffset;
doc.innerHeight = self.innerHeight;
doc.innerWidth = self.innerWidth;
} else if (document.documentElement && document.documentElement.clientHeight) {
doc.pageYOffset = document.documentElement.scrollTop;
doc.pageXOffset = document.documentElement.scrollLeft;
doc.innerHeight = document.documentElement.clientHeight;
doc.innerWidth = document.documentElement.clientWidth;
} else if (document.body) {
doc.pageYOffset = document.body.scrollTop;
doc.pageXOffset = document.body.scrollLeft;
doc.innerHeight = document.body.clientHeight;
doc.innerWidth = document.body.clientWidth;
}
return doc;
}
});
function getMouseCoord(e){
(!e) ? e = window.event : e = e;
objDoc = new doc();
(e.pageX) ? objDoc.pageX = e.pageX : objDoc.pageX = e.clientX + objDoc.scrollLeft;
(e.pageY) ? objDoc.pageY = e.pageY : objDoc.pageY = e.clientY + objDoc.scrollTop;
return [e.pageX,e.pageY];
}
/* load document variables [ end ] */
/* png transparency [ begin ] */
$(function(){
fixPNG($(".png_ie"));
});
function fixPNG(o) {
o.each(function(){
s = $(this).attr("src");
s = s.substr(0,s.lastIndexOf("/")) + "/" + $(this).attr("id") + ".png";
if (navigator.appName.indexOf("Microsoft") != -1) {
$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + s + "', sizingMethod='scale')");
} else {
$(this).attr("src",s);
}
});
}
/* png transparency [ end ] */
/* search [ begin ] */
$(function() {
$(".search_text_box").blur(function() {
valInput = $.trim($(this).val());
if (valInput == "") {
$(this).attr("value","enter keyword");
}
});
$(".search_text_box").focus(function() {
valInput = $.trim($(this).val());
if (valInput == "enter keyword" || valInput == "") {
$(this).attr("value","");
}
});
$(".endeca_search_form").submit(function() {
valInput = $.trim($(".search_text_box",this).val());
if (valInput == "enter keyword" || valInput == "") {
return false;
} else {
// replace multiple spaces inbetween words with single space
exp = / /g;
while (valInput.match(exp)) {
valInput = valInput.replace(exp," ");
}
endecaUrl = "catalog/search.jsp?N=0&Nty=1&Ns=PRODUCT_SEQUENCE_NO|0&Ntk=AllSearch&Ntx=mode+matchallpartial&Ntt=" + valInput;
location.href = "/" + endecaUrl + "?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997";
return false;
}
});
});
/* search [ end ] */
/* power reviews [ begin ] */
function pwrWriteReview(writeURL) {
showProductInfoTab($("#product_info_review_tab"));
$.get(
writeURL,
function(data) {
$("#pwr_review_tab").html(data);
}
);
}
function pwrReadReview(readURL) {
showProductInfoTab($("#product_info_review_tab"));
$.get(
readURL,
function(data) {
$("#pwr_review_tab").html(data);
}
);
}
/* power reviews [ begin ] */
/* epp message tool tip [ begin ] */
$(function(){ initEppMsg(); });
function initEppMsg() {
$(".epp_msg").hover(function(i){
msgTitle = $(this).attr("title");
$(this).attr("title","");
$("body").append("
");
xPos = getMouseCoord(i)[0] - $(".epp_msg_tt").width() - 5;
yPos = getMouseCoord(i)[1] - $(".epp_msg_tt").height() - 5;
$(".epp_msg_tt").css("left",xPos).css("top",yPos);
},function(){
$(this).attr("title",msgTitle);
$(".epp_msg_tt").remove();
});
}
/* epp message tool tip [ end ] */
/* global popup layer [ begin ] */
$(function(){
$(".phone_why").click(function(){
popGlobalLayer("Why do you ask?","Some states restrict electronic messages to persons under 18 that present products or services for which they would not qualify, such as special Meijer Credit Card promotions or sales on wine. Meijer ensures we are complying by asking you to confirm your age.");
return false;
});
$(".birth_date_why").click(function(){
popGlobalLayer("Why do you ask?","Some states restrict electronic messages to persons under 18 that present products or services for which they would not qualify, such as special Meijer Credit Card promotions or sales on wine. Meijer ensures we are complying by asking you to confirm your age.");
return false;
});
$(".birth_date_meijer1_why").click(function(){
popGlobalLayer("Why do you ask?","We're asking for your birth date to make sure we're accessing the correct account.");
return false;
});
$(".gift_card_legal").click(function(){
popGiftCardLegal("Meijer Gift Card Terms & Conditions");
return false;
});
$(".forgot_password").click(function(){
$("#global_layer").remove();
$("body").append("");
$.post(
"/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_forgot_password.jsp",
function(data) {
fixSelect(true);
$("#global_layer").html(data);
doc = new doc();
$("#global_layer").css("top",Math.round(doc.innerHeight/2) + doc.pageYOffset - Math.round($("#global_layer").height()/2));
$("#global_layer").css("left",Math.round(doc.innerWidth/2) + doc.pageXOffset - Math.round($("#global_layer").width()/2));
fixPNG($(".png_ie"));
$(".mid","#global_layer").height($(".inner","#global_layer").height());
$(".close/a","#global_layer").click(function(){
fixSelect('');
$("#global_layer").remove();
return false;
});
$.ajax({
type: "POST",
url: "/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_forgot_password.jsp",
dataType: "html"
});
}
);
});
});
function popGlobalLayer(paramTitle, paramContent) {
$("#global_layer").remove();
$("body").append("");
$.post(
"/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_global.jsp",
{ layerTitle: paramTitle, layerContent: paramContent },
function(data) {
fixSelect(true);
$("#global_layer").html(data);
doc = new doc();
$("#global_layer").css("top",Math.round(doc.innerHeight/2) + doc.pageYOffset - Math.round($("#global_layer").height()/2));
$("#global_layer").css("left",Math.round(doc.innerWidth/2) + doc.pageXOffset - Math.round($("#global_layer").width()/2));
fixPNG($(".png_ie"));
$(".mid","#global_layer").height($(".inner","#global_layer").height());
$(".close/a","#global_layer").click(function(){
fixSelect('');
$("#global_layer").remove();
return false;
});
}
);
}
/* global popup layer [ end ] */
/* popup layer with gift card legal cms [ start] */
function popGiftCardLegal(paramTitle) {
$("#popup_layer").remove();
$("body").append("");
$.post(
"/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "gift_card_legal.jsp",
{ layerTitle: paramTitle },
function(data) {
fixSelect(true);
$("#popup_layer").html(data);
doc = new doc();
$("#popup_layer").css("top",Math.round(doc.innerHeight/2) + doc.pageYOffset - Math.round($("#popup_layer").height()/2));
$("#popup_layer").css("left",Math.round(doc.innerWidth/2) + doc.pageXOffset - Math.round($("#popup_layer").width()/2));
fixPNG($(".png_ie"));
$(".mid","#popup_layer").height($(".inner","#popup_layer").height());
$(".close/a","#popup_layer").click(function(){
fixSelect('');
$("#popup_layer").remove();
return false;
});
}
);
}
/* popup layer with gift card legal cms [ end ] */
/* popup layer with ensemble product details [ start] */
$(function() {
$(".ensemble_product_details").each(function() {
$(this).click(function(){
var index = $(this).attr("id");
popEnsembleProdDetails("Ensemble Product Details",index);
return false;
});
});
});
function popEnsembleProdDetails(paramTitle,index) {
$("#popup_layer").remove();
$("body").append("");
$.post(
"/catalog/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "product_info_popup.jsp?productId=" + index,
{ layerTitle: paramTitle },
function(data) {
fixSelect(true);
$("#popup_layer").html(data);
doc = new doc();
$("#popup_layer").css("top",Math.round(doc.innerHeight/2) + doc.pageYOffset - Math.round($("#popup_layer").height()/2));
$("#popup_layer").css("left",Math.round(doc.innerWidth/2) + doc.pageXOffset - Math.round($("#popup_layer").width()/2));
fixPNG($(".png_ie"));
$(".mid","#popup_layer").height($(".inner","#popup_layer").height());
$(".close/a","#popup_layer").click(function(){
fixSelect('');
$("#popup_layer").remove();
return false;
});
}
);
}
/* popup layer with ensemble product details [ end ] */
/* persistent cart [ begin ] */
$(function(){
$(".add_to_cart").click(function(){
if ($("input[@name=fromProductOrEnsemble]") != null) {
var source = "fromProductOrEnsemble";
} else {
var source = "other";
}
var pid = $(this).attr("id");
var pVarId = $("input[@name=productVariantId]").val();
var pQuantity = $("input[@name=quantity]").val();
var pFlag = "N";
if ($("input[@name=protectionFlag]").checked) {
pFlag = "Y";
}
if (pVarId == null) { // We came from the thumbnail page.
pVarId = $(this).next().val(); // Hidden field in the DOM.
pQuantity = 1; // Default from thumbnail.
}
addToCart(pVarId,pid.substr(4,pid.length),$("input[@name=pCatId]").val(),$("input[@name=catId]").val(),$("input[@name=subCatId]").val(),pQuantity,this,source);
});
$(".add_from_comparison_to_cart").click(function(){
var message = $(this).next().val() +' is currently Out of Stock.';
addToCartFromComparison(this, message);
});
$(".add_from_gift_card").each(function(){
$(this).click(function(){
var index = $(this).attr("id").substr(4);
var productId = $("input[@name=product_id_" + index + "]").val();
var variantId = $("input[@name=product_variant_id_" + index + "]").val();
var quantity = $("input[@name=quantity_" + index + "]").val();
document.gift_card_index = index;
addToCart(variantId, productId, "", "", "", quantity, this, "fromGiftCard");
return false;
});
});
$(".add_to_wish_list").each(function(){
$(this).click(function(){
var index = $(this).attr("id").substr(4);
var productId = $("input[@name=product_id_" + index + "]").val();
var variantId = $("input[@name=product_variant_id_" + index + "]").val();
var style = $("input[@name=product_style_" + index + "]").val();
document.gift_card_index = index;
addToWishlist(variantId, productId, this, "fromGiftCard", style);
return false;
});
});
$(".add_from_theme").click(function(){
$("input[@name=addTo]").val("1");
buttonObj = this;
injectProcessing(buttonObj,"",true,"cb");
pVarId = [];
$(".pVarId").each(function(i){
pVarId[i] = $(this).val();
});
pId = [];
$(".pId").each(function(i){
pId[i] = $(this).val();
});
pQuantity = [];
$(".productQuantity").each(function(i){
pQuantity[i] = $(this).val();
});
$.post(
"/checkout/add_items_to_order.cmd?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{ addTo: $("input[@name=addTo]").val(), ensembleItemCount:pVarId.length, productId: pId, productVariantId: pVarId, quantity: pQuantity, ensembleId: $("input[@name=ensembleId]").val(), categoryId: $("input[@name=categoryId]").val(), parentCategoryId: $("input[@name=parentCategoryId]").val() },
function(data) {
var dataDiv = '';
$("body").append(dataDiv);
$("#datadiv").append(data);
if ($("#datadiv input[@name=cErrors]").val() == "true") {
var qtyErrs = $("#datadiv input[@name=cErrorHook_3]").val();
qtyErrs = qtyErrs.substr(1,qtyErrs.length - 2).split(",");
errMsgLen = $(".error_message").length;
$(".error_message").show();
$(".error_message").text("Please enter an amount");
injectProcessing(buttonObj,"",false,"");
for (i = 0; i < qtyErrs.length; i++) {
for (j = 0; j < errMsgLen; j++) {
if ($(".error_message").filter(":eq(" + j + ")").attr("id") == $.trim(qtyErrs[i].split("=")[0])) {
$(".error_message").filter(":eq(" + j + ")").html(qtyErrs[i].split("=")[1]).css("display","block");
}
}
}
} else {
$("#persistent_cart").html(data);
// note: remove hidden data div?
$("#datadiv").remove();
injectProcessing(buttonObj,"",false,"");
showPersistentCart();
}
}
);
});
$(".add_from_ensemble").click(function(){
$("input[@name=addTo]").val("1");
buttonObj = this;
injectProcessing(buttonObj,"",true,"cb");
pVarId = [];
$(".pVarId").each(function(i){
pVarId[i] = $(this).val();
});
pId = [];
$(".pId").each(function(i){
pId[i] = $(this).val();
});
pQuantity = [];
$(".productQuantity").each(function(i){
pQuantity[i] = $(this).val();
});
$.post(
"/checkout/add_items_to_order.cmd?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{ addTo: $("input[@name=addTo]").val(), ensembleItemCount:pVarId.length, productId: pId, productVariantId: pVarId, quantity: pQuantity, ensembleId: $("input[@name=ensembleId]").val(), categoryId: $("input[@name=categoryId]").val(), parentCategoryId: $("input[@name=parentCategoryId]").val() },
function(data) {
var dataDiv = '';
$("body").append(dataDiv);
$("#datadiv").append(data);
if ($("#datadiv input[@name=cErrors]").val() == "true") {
var qtyErrs = $("#datadiv input[@name=cErrorHook_3]").val();
qtyErrs = qtyErrs.substr(1,qtyErrs.length - 2).split(",");
errMsgLen = $(".error_message").length;
//alert(qtyErrs);
$(".error_message").show();
$(".error_message").text("Please enter an amount");
injectProcessing(buttonObj,"",false,"");
for (i = 0; i < qtyErrs.length; i++) {
for (j = 0; j < errMsgLen; j++) {
if ($(".error_message").filter(":eq(" + j + ")").attr("id") == $.trim(qtyErrs[i].split("=")[0])) {
$(".error_message").filter(":eq(" + j + ")").html(qtyErrs[i].split("=")[1]).css("display","block");
}
}
}
} else {
$("#persistent_cart").html(data);
// note: remove hidden data div?
$("#datadiv").remove();
injectProcessing(buttonObj,"",false,"");
showPersistentCart();
}
}
);
});
$(".add_from_wishlist").click(function(){
populateSelectedList = "";
$(".update_check").each(function(){
if (this.checked == true) {
populateSelectedList += "-" + $(this).val();
}
});
if (populateSelectedList.length <= 0) {
alert("Please select an item to send to your Cart.");
return false;
} else {
$("input[@name=selectedList]").val(populateSelectedList);
addToCartFromWishlist($("input[@name=selectedList]").val(),this);
}
return false;
});
$(".view_cart").click(function(){ viewPersistentCart();return false; });
});
function zipCodeVal() {
$("input[@name=zipCode]").blur(function() {
valInput = $.trim($(this).val());
if (valInput == "") {
$(this).attr("value","ZIP Code");
}
});
$("input[@name=zipCode]").focus(function() {
valInput = $.trim($(this).val());
if (valInput == "ZIP Code" || valInput == "") {
$(this).attr("value","");
}
});
}
function addToCart(pVarId,pId,pCatId,catId,subCatId,pQuantity,clickObject,source){
var pFlag = "N";
if ($("input[@name=protectionFlag]:checked").val() != null) {
pFlag = "Y";
}
injectProcessing(clickObject,"",true,"cb");
$.get(
"/checkout/add_item_to_order.cmd?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{ productVariantId: pVarId, productId: pId, parentCategoryId: pCatId, categoryId: catId, subCategoryId: subCatId, quantity: pQuantity, protectionFlag: pFlag, giftCardFlag: (source=="fromGiftCard"?"Y":"N"), time: (new Date().getTime()) },
function(data) {
try{
if ($("input[@name=cErrors]",data).val() == "true") {
if (source == "other") {
$("#quick_view").html(data);
renderQuickView(pId,pCatId,catId,subCatId,clickObject);
} else if(source == "fromGiftCard") {
var errorMessage = $(".error_messages",data).filter(":eq(0)").val();
if(errorMessage != null & errorMessage != "") {
var msg = $(".error_message").filter(":eq(" + document.gift_card_index + ")");
msg.removeClass("important").removeClass("messaging").addClass("important");
msg.css("display","block").html(errorMessage);
}
injectProcessing(clickObject,"",false,"");
} else {
$(".error_messages",data).each(function(i){
var thisValue = $(this).val();
$(".error_message").filter(":eq(" + i + ")").css("display","block").html(thisValue);
injectProcessing(clickObject,"",false,"");
});
}
} else if ($("input[@name=cErrors]",data).val() == null) {
var message = $("input[@name=confirmation_messages]",data).val();
$("#quick_view").remove();
$("#persistent_cart").html("");
injectLoader("#persistent_cart",true);
$.get(
"/includes/layer_cart.jsp?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{time: (new Date().getTime()), message: message},
function(data) {
injectProcessing(clickObject,"",false,"");
$("#persistent_cart").html(data);
showPersistentCart();
}
);
}
injectProcessing(clickObject,"",false,"");
}catch(err){
injectProcessing(clickObject,"",false,"");
}
}
);
}
function addToCartFromComparison(clickObject, message){
injectProcessing(clickObject,"",true,"cb");
injectLoader("#persistent_cart",true);
$.get(
"/includes/layer_cart.jsp?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{time: (new Date().getTime()), message: message },
function(data) {
injectProcessing(clickObject,"",false,"");
$("#persistent_cart").html(data);
showPersistentCart();
}
);
}
function addToWishlist(pVarId, pId, clickObject, source, style){
injectProcessing(clickObject,"",true,"cb");
$.get(
"/user/add_item_to_wishlist.cmd?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{ productVariantId: pVarId, productId: pId, time: (new Date().getTime()) },
function(data) {
try{
var msg = $(".error_message").filter(":eq(" + document.gift_card_index + ")");
msg.removeClass("important").removeClass("messaging");
var notMemberMessage = $("input[@name=add_to_wishlist_not_member]",data).val();
if (notMemberMessage != null && notMemberMessage != "") {
if(source == "fromGiftCard") {
msg.css("display","block").html(notMemberMessage).addClass("important");
}
}
var successMessage = $("input[@name=add_to_wishlist_success]",data).val();
if (successMessage != null && successMessage != "") {
if(source == "fromGiftCard") {
var msg = $(".error_message").filter(":eq(" + document.gift_card_index + ")");
msg.css("display","block").html(successMessage).addClass("messaging");
}
sendOmnitureWishlishEvent(style);
}
injectProcessing(clickObject,"",false,"");
}catch(err){
injectProcessing(clickObject,"",false,"");
}
}
);
}
function addToCartFromWishlist(itemsToAdd,clickObject) {
injectProcessing(clickObject,"inline",true,"vam");
$("#persistent_cart").html("");
injectLoader("#persistent_cart",true);
$.post(
"/user/add_all_wishlist_items_to_basket.cmd?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{ selectedList: itemsToAdd },
function(data) {
$("#persistent_cart").html(data);
showPersistentCart();
}
);
}
function estimateShippingCart() {
var paramOrderIndex = $("input[@name=orderIndex]","#persistent_cart").val();
var paramZipCode = $("input[@name=zipCode]","#persistent_cart").val();
$("#persistent_cart").html("");
injectLoader("#persistent_cart",true);
$.get(
"/checkout/update_items_in_cart.cmd?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{ zipCode: paramZipCode, orderIndex: paramOrderIndex, task: "estimate" },
function(data) {
$("#persistent_cart").html(data);
showPersistentCart();
}
);
}
function viewPersistentCart() {
if ($("#persistent_cart").html() == "") {
injectLoader("#persistent_cart",true);
$.get(
"/includes/layer_cart.jsp?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997",
{time: (new Date().getTime())},
function(data) {
$("#persistent_cart").html(data);
showPersistentCart();
}
);
}
}
function showPersistentCart(){
fixSelect(true);
location.href = "#";
arrItemsHeight = new Array();
itemsHeight = 0;
$(".item","#persistent_cart").each(function(i){
arrItemsHeight[i] = $(this).height() + 1; // 1 = border
if (i < 4) {
itemsHeight += $(this).height() + 1; // 1 = border
}
});
if (($(".added","#persistent_cart").length == $(".item","#persistent_cart").length) || ($(".added","#persistent_cart").length >= 4)) {
$(".items","#persistent_cart").height(itemsHeight);
} else {
$(".items","#persistent_cart").height(itemsHeight - 1); // - 1 for hide last border
}
$(".mid","#persistent_cart").height($(".inner","#persistent_cart").height());
fixPNG($(".png_ie"));
if (arrItemsHeight.length > 4) {
$(".view_less_items/img","#persistent_cart").wrap('');
$(".view_more_items/img","#persistent_cart").attr("src",'http://img.meijer.com/assets/site/images/buttons/btn_cart_layer_on_down.gif').wrap('');
}
animating = false;
sCount = 4;
$(".view_more_items/a","#persistent_cart").click(function() {
if (animating == false && (sCount + 1 <= arrItemsHeight.length)) {
animating = true;
curPos = parseInt($(".items_inner","#persistent_cart").css("top"));
animateTop = curPos - arrItemsHeight[sCount];
$(".items_inner","#persistent_cart").animate({top: animateTop},"normal",function(){
$(this).css("top",animateTop);
});
sCount++;
animating = false;
}
if (sCount > 4) {
$(".view_less_items >> img:eq(0)","#persistent_cart").attr("src",'http://img.meijer.com/assets/site/images/buttons/btn_cart_layer_on_up.gif');
}
if (sCount == arrItemsHeight.length) {
$(".view_more_items >> img:eq(0)","#persistent_cart").attr("src",'http://img.meijer.com/assets/site/images/buttons/btn_cart_layer_off_updown.gif');
}
});
$(".view_less_items/a","#persistent_cart").click(function() {
if (animating == false && (sCount - 1 > 3)) {
animating = true;
sCount--;
curPos = parseInt($(".items_inner","#persistent_cart").css("top"));
animateTop = curPos + arrItemsHeight[sCount];
$(".items_inner","#persistent_cart").animate({top: animateTop},"normal",function(){
$(this).css("top",animateTop);
animating = false;
});
}
if (sCount == 4) {
$(".view_less_items >> img:eq(0)","#persistent_cart").attr("src",'http://img.meijer.com/assets/site/images/buttons/btn_cart_layer_off_updown.gif');
}
if (sCount >= 4) {
$(".view_more_items >> img:eq(0)","#persistent_cart").attr("src",'http://img.meijer.com/assets/site/images/buttons/btn_cart_layer_on_down.gif');
}
});
$(".remove_from_cart").click(function(){
cmdPath = $(this).next().val();
$("#persistent_cart").html("");
injectLoader("#persistent_cart",true);
$.post(
cmdPath,
function(data) {
$("#persistent_cart").html(data);
showPersistentCart();
updateCartDisplay();
}
);
return false;
});
$(".estimate_shipping","#persistent_cart").click(function(){ estimateShippingCart();return false; });
$(".close_cart","#persistent_cart").click(function() {
$("#persistent_cart").html("");
fixSelect('');
sCount = 4;
return false;
});
zipCodeVal();
updateCartDisplay();
var timer = null;
$("#persistent_cart").mouseout( function() {
timer = setTimeout(function() {
$("#persistent_cart").html("");
fixSelect('');
sCount = 4;
return false;
}, 5000);
} );
$("#persistent_cart").mouseover( function() {
clearTimeout(timer);
} );
timer = setTimeout(function() {
$("#persistent_cart").html("");
fixSelect('');
sCount = 4;
return false;
}, 5000);
}
function updateCartDisplay() {
var uniqueItemTotal = parseInt($("input[@name=uniqueItemTotal]","#persistent_cart").val());
var getItemQuantityTotal = parseInt($("input[@name=getItemQuantityTotal]","#persistent_cart").val());
var checkoutURL = $("a[@name=btnCheckout]","#view_cart_contents").attr("href");
if (uniqueItemTotal > 0) {
if (getItemQuantityTotal > 1) {
$("#view_cart_contents").html("
");
} else {
$("#view_cart_contents").html("
");
}
} else {
$("#view_cart_contents").html("
");
}
$(".view_cart").click(function(){ viewPersistentCart();return false; });
}
/* persistent cart [ end ] */
/* quick view [ begin ] */
$(function(){
$(".preview").click(function(){
if ($("#quick_view")) {
$("#quick_view").remove();
}
injectProcessing(this,"",true,'');
var pid = $(this).attr("id");
showQuickView(pid.substr(4,pid.length),$("input[@name=pCatId]").val(),$("input[@name=catId]").val(),$("input[@name=subCatId]").val(),this);
return false;
});
});
function showQuickView(pId,pCatId,catId,subCatId,clickObject) {
if ($("#quick_view")) {
$("#quick_view").remove();
}
$("body").append("");
injectLoader("#quick_view",true);
doc = new doc();
$("#quick_view").css("top",Math.round(doc.innerHeight/2) + doc.pageYOffset - Math.round($("#quick_view").height()/2));
$("#quick_view").css("left",Math.round(doc.innerWidth/2) + doc.pageXOffset - Math.round($("#quick_view").width()/2));
$.ajax({
type: "POST",
url: "/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_quick_view.jsp",
data: { productId: pId, parentCategoryId: pCatId, categoryId: catId, subCategoryId: subCatId, time: (new Date().getTime()) },
success: function(r) {
fixSelect(true);
injectProcessing(clickObject,"inline",false,'');
injectLoader("#quick_view",false);
$("#quick_view").html(r);
renderQuickView(pId,pCatId,catId,subCatId,clickObject);
if ($.browser.msie) {
$.ajax({
type: "GET",
url: "/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_quick_view.jsp",
data: { productId: pId, parentCategoryId: pCatId, categoryId: catId, subCategoryId: subCatId, time: (new Date().getTime()) },
dataType: "html"
});
}
}
});
/*
if ($.browser.msie && parseInt(navigator.appVersion) < 7) {
$.ajax({
type: "POST",
url: "/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_quick_view.jsp",
data: { productId: pId, parentCategoryId: pCatId, categoryId: catId, subCategoryId: subCatId, time: (new Date().getTime()) },
dataType: "html",
success: function(r) {
alert("loaded");
}
});
}
$.get(
"/includes/?PIPELINE_SESSION_ID=e1ff44f8c0a8877c0f2c0e903f9c7997" + "layer_quick_view.jsp",
{ productId: pId, parentCategoryId: pCatId, categoryId: catId, subCategoryId: subCatId, time: (new Date().getTime()) },
function(data) {
fixSelect(true);
injectProcessing(clickObject,"inline",false,'');
injectLoader("#quick_view",false);
$("#quick_view").html(data);
renderQuickView(pId,pCatId,catId,subCatId,clickObject);
}
);
*/
sendOmnitureProductViewEvent(pId);
}
function renderQuickView(pId,pCatId,catId,subCatId,clickObject) {
$("#quick_view").css("top",Math.round(doc.innerHeight/2) + doc.pageYOffset - Math.round($("#quick_view").height()/2));
$("#quick_view").css("left",Math.round(doc.innerWidth/2) + doc.pageXOffset - Math.round($("#quick_view").width()/2));
fixPNG($(".png_ie"));
$(".mid","#quick_view").height($(".inner","#quick_view").height());
$(".view_alt_img","#quick_view").click(function(){
this.blur();
o = this;
$(".product_image","#quick_view").find("img").attr("src",$(o).next().val());
return false;
});
$(".add_to_cart","#quick_view").click(function(){
var pid = $(this).attr("id");
var pVarId = $("input[@name=productVariantId]").val();
if(pVarId == null || pVarId == "") pVarId = $("input[@name=defaultProductVariantId]").val();
addToCart(pVarId,pid.substr(4,pid.length),$("input[@name=pCatId]").val(),$("input[@name=catId]").val(),$("input[@name=subCatId]").val(),$("input[@name=quantity]").val(),this,"other");
});
$(".close/a","#quick_view").click(function(){
$("#quick_view").remove();
fixSelect('');
return false;
});
initEppMsg();
}
/* quick view [ end ] */
/* recently viewed items [ begin ] */
$(function(){
$(".action_hide","#rv_items").click(function(){
if ($(".action_hide","#rv_items").html() == "Hide") {
$(".to_hide","#rv_items").css("display","none");
$(".heading","#rv_items").css("border-bottom","1px solid #b7b7b7");
$(".action_hide","#rv_items").html("Show");
} else {
$(".to_hide","#rv_items").css("display","block");
$(".heading","#rv_items").css("border-bottom","none");
$(".action_hide","#rv_items").html("Hide");
}
return false;
});
arrRvItemsHeight = new Array();
rvItemsHeight = 0;
$(".item","#rv_items").each(function(i){
arrRvItemsHeight[i] = $(this).height() + 1; // 1 = border
if (i < 3) {
rvItemsHeight += $(this).height() + 1; // 1 = border
}
});
$(".items","#rv_items").height(rvItemsHeight - 1 + "px"); // - 1 for hide last border
$(".mid","#rv_items").height($(".inner","#rv_items").height() + "px");
if (arrRvItemsHeight.length > 3) {
$(".view_less_items/img","#rv_items").wrap("");
$(".view_more_items/img","#rv_items").attr("src",'../assets/site/images/buttons/btn_rv_on_down.gif').wrap("");
}
animating = false;
sCount = 3;
$(".view_more_items/a","#rv_items").click(function() {
if (animating == false && (sCount + 1 <= arrRvItemsHeight.length)) {
animating = true;
curPos = parseInt($(".items_inner","#rv_items").css("top"));
animateTop = curPos - arrRvItemsHeight[sCount];
$(".items_inner","#rv_items").animate({top: animateTop},"normal",function(){
$(this).css("top",animateTop);
});
sCount++;
animating = false;
}
if (sCount > 2) {
window.setTimeout('$(".view_less_items >> img:eq(0)","#rv_items").attr("src","../assets/site/images/buttons/btn_rv_on_up.gif")',100);
}
if (sCount == arrRvItemsHeight.length) {
window.setTimeout('$(".view_more_items >> img:eq(0)","#rv_items").attr("src","../assets/site/images/buttons/btn_rv_off_updown.gif")',100);
}
});
$(".view_less_items/a","#rv_items").click(function() {
if (animating == false && (sCount - 1 > 2)) {
animating = true;
sCount--;
curPos = parseInt($(".items_inner","#rv_items").css("top"));
animateTop = curPos + arrRvItemsHeight[sCount];
$(".items_inner","#rv_items").animate({top: animateTop},"normal",function(){
$(this).css("top",animateTop);
});
animating = false;
}
if (sCount == 3) {
window.setTimeout('$(".view_less_items >> img:eq(0)","#rv_items").attr("src","../assets/site/images/buttons/btn_rv_off_updown.gif")',100);
}
if (sCount >= 3) {
window.setTimeout('$(".view_more_items >> img:eq(0)","#rv_items").attr("src","../assets/site/images/buttons/btn_rv_on_down.gif")',100);
}
});
});
/* recently viewed items [ end ] */
/* endeca refinements menu [ begin ] */
$(function(){
$(".endeca_refinements").find(".r").hover(function(){
$(this).parent().css("background","#fff");
},function(){
$(this).parent().css("background","#dfe8f7");
});
$(".endeca_refinements").find(".close_menu").click(function(){
$(this).parent().parent().parent().css("visibility","hidden");
fixSelect(false);
return false;
});
$(".endeca_refinements").find(".d").parent().hover(function(){
fixSelect(true);
$(this).find("div").css("visibility","visible");
},function(){
fixSelect(false);
$(this).find("div").css("visibility","hidden");
});
});
/* endeca refinements menu [ end ] */
/* global dropdown menu [ begin ] */
$(function(){
$("ul:eq(0)","#wrapper_tnav").find(".ss").hover(function(){
swapImg($("img:eq(0)",this),"on");
$("ul:eq(0)",this).css("display","block");
},function(){
swapImg($("img:eq(0)",this),"off");
$("ul:eq(0)",this).css("display","none");
});
$("a","#wrapper_tnav").hover(function(){
$(this).parent().css("background","#fff");
fixSelect(true);
},function(){
$(this).parent().css("background","#dfe7f4");
fixSelect(false);
})
});
/* global dropdown menu [ end ] */
/* email a friend [ begin ] */
$(function(){
$(".email_a_friend").click(function(){
if ($("input[@name=source]") != null && $("input[@name=source]").val() == "ensemble") {
strId = "&ensembleId=" + $("input[@name=ensembleId]").val();
} else {
strId = "&productId=" + $("input[@name=productId]").val();
}
emailAFriend(this);
return false;
});
});
function emailAFriend(o) {
injectProcessing(o,"",true,"");
strData = "sendersName=" + $("input[@name=sendersName]").val() + "&sendersEmail=" + $("input[@name=sendersEmail]").val() + "&recipientName=" + $("input[@name=recipientName]").val() + "&recipientEmail=" + $("input[@name=recipientEmail]").val() + "&message=" + $("textarea[@name=message]").val() + strId;
$.ajax({
type: "POST",
url: $("input[@name=emailAFriendAction]").val(),
data: strData,
success: function(r) {
$("#email_a_friend_shell").html(r);
// The click must be rebound because we overwrote
// the old click element with our html() method call.
$(".email_a_friend").click(function(){
emailAFriend(this);
return false;
});
if ($(".eaf_success").length > 0) {
$("form","#email_a_friend_shell").find("input").val("");
$("form","#email_a_friend_shell").find("textarea").val("");
}
}
});
}
/* email a friend [ end ] */
/* generic functions [ begin ] */
$(function(){
$("input[@type=checkbox]").click(function(){
if ($(this).attr("class") != null && $(this).attr("class").indexOf("click_compare") != -1) {
if ($(this).attr("checked") == true) {
var checkedboxcount = $("input[@type=checkbox][@checked]").length;
if (checkedboxcount > 4) {
$(this).parent().find(".error_message").css("display","block").html("You can compare up to 4 products at once.");
$(this).removeAttr("checked");
} else {
$(this).parent().find(".error_message").css("display","none").html("");
$(this).parent().parent().find(".view_comparison_now").html("View Comparison Now");
}
} else if (($(this).attr("checked") == false || $(this).attr("checked") == undefined)) {
$(this).parent().find(".error_message").css("display","none").html("");
$(this).parent().parent().find(".view_comparison_now").html("");
}
}
});
});
$(function(){
initViewComparisonLink($(".click_compare"));
});
function initViewComparisonLink(o){
o.each(function(){
checked = $(this).attr("checked");
if ( checked == true) {
$(this).parent().parent().find(".view_comparison_now").html("View Comparison Now");
}
});
}
function fixSelect(state) {
var ie6 = /MSIE 6.0/i.test(navigator.appVersion);
if(ie6) {
if ($.browser.msie) {
if (state == true) {
$("select").css("visibility","hidden");
} else {
$("select").css("visibility","visible");
}
}
}
}
$(function(){ swapImg($(".rollover"),"both"); });
function swapImg(o,s){ // assumes "_on" and "_off" as the two states
if (o.attr("src")) {
o.unbind();
imgExt = o.attr("src").substr(o.attr("src").lastIndexOf('.'),o.attr("src").length);
imgPath = o.attr("src").substr(0,o.attr("src").lastIndexOf('/')) + '/';
if (s == "both") {
o.each(function(){
$(this).hover(function(){
$(this).attr("src",imgPath + $(this).attr("id") + "_on" + imgExt);
},function(){
$(this).attr("src",imgPath + $(this).attr("id") + "_off" + imgExt);
});
});
} else if (s == "on") {
o.attr("src",imgPath + o.attr("id") + "_on" + imgExt);
} else if (s == "off") {
o.attr("src",imgPath + o.attr("id") + "_off" + imgExt);
}
}
}
function injectProcessing(el,cssDisplay,state,classIt) {
if (state == true) {
$(el).css("display","none");
$("Processing...").insertAfter($(el));
} else {
if($(el).next() && $(el).next().attr("type") == "processing") {
$(el).next().remove();
}
$(el).css("display",cssDisplay);
}
}
function injectLoader(el,state) {
if (state == true) {
$(el).prepend("");
} else {
$(".loader",el).remove();
}
}
function truncateStringByClass(strClassName,strLength) {
$("." + strClassName).each(function(){
strDescription = $.trim($(this).text());
if (strDescription.length > strLength) {
for (idx = strLength; idx >= 0; idx--)
{
charVal = strDescription.charAt(idx);
if (charVal == "," || charVal == "-" || charVal == " ")
{
strDescription = strDescription.substring(0,idx) + "...";
$(this).html(strDescription);
break;
}
}
}
});
}
/* generic functions [ end ] */
function setOperation(opType,needSubmit,addressIndex) {
document.addUpdateDeleteAddressForm.operation.value = opType;
if(addressIndex)
document.addUpdateDeleteAddressForm.selectedAddressIndex.value = addressIndex;
if(needSubmit) {
if(opType == "EDIT")
window.location='/user/address_book.jsp?addressIndex=' + addressIndex;
else
document.addUpdateDeleteAddressForm.submit();
}
}
function setAddTo(addToType) {
document.productForm.addTo.value = addToType;
}
// This is an example of sending product data from the server
// to the client, then formatting the variants on the client-side
// based on certain criteria.
function cbFormatter(list, attribute, opt)
{
// Get the price for this variant.. If this is the primary list, get all related
// variants from the group and get their prices as well so we can build a range.
var pvds = list.productVariantDropdownSupport;
// Get all of the product variants for this attribute
var variantGroup = attribute.getVariant().getProductVariantGroup();
var groupVariants = variantGroup.getAllVariants()
// Are all of the prices the same within the group?
var lowGroupPrice = 999999.00;
var highGroupPrice = -1.00;
for (var idx = 0; idx < groupVariants.length; idx++)
{
lowGroupPrice = groupVariants[idx].numericPrice < lowGroupPrice ? groupVariants[idx].numericPrice : lowGroupPrice;
highGroupPrice = groupVariants[idx].numericPrice > highGroupPrice ? groupVariants[idx].numericPrice : highGroupPrice;
}
// Are all of the prices the same within the variant?
var variants = variantGroup.getVariantsMatching(attribute.name, attribute.value);
var lowVariantPrice = 999999.00;
var highVariantPrice = -1.00;
var lowVariantDisplay = variants[0].displayPrice;
var highVariantDisplay = variants[0].displayPrice;
for (var idx = 0; idx < variants.length; idx++)
{
// Display really needs to be done before the re-assignment...
lowVariantDisplay = variants[idx].numericPrice < lowVariantPrice ? variants[idx].displayPrice : lowVariantDisplay;
lowVariantPrice = variants[idx].numericPrice < lowVariantPrice ? variants[idx].numericPrice : lowVariantPrice;
highVariantDisplay = variants[idx].numericPrice > highVariantPrice ? variants[idx].displayPrice : highVariantDisplay;
highVariantPrice = variants[idx].numericPrice > highVariantPrice ? variants[idx].numericPrice : highVariantPrice;
}
if (lowGroupPrice != highGroupPrice)
{
// Primary list should display a range
if (pvds.isPrimary)
if (lowVariantPrice != highVariantPrice)
opt.text = opt.text + " " + lowVariantDisplay + " - " + highVariantDisplay;
else
opt.text = opt.text + " " + attribute.getVariant().displayPrice;
else // Secondary lists should show exact price
opt.text = opt.text + " " + attribute.getVariant().displayPrice;
}
return opt;
}
/* This function is called when a subject is changed so that actual subject text can be
* stored in to a hidden subject field. Since value of the subject list is a keyword define
* in the command configuration file to identify it's email address.
*/
function setSubject(thisRef)
{
var formRef = document.forms["contactUsForm"];
//set subject value
formRef.elements["subject"].value = (thisRef.options[thisRef.selectedIndex]).text;
}
/** Omniture functions **/
function sendOmnitureWishlishEvent(style) {
/* SiteCatalyst code version: H.10.
Copyright 1997-2007 Omniture, Inc. More info available at http://www.omniture.com*/
s.pageName="Gift Card";
s.channel="";
s.server="";
s.events="event4";
s.products=";" + style;
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code);
}
function sendOmnitureProductViewEvent(style) {
/* SiteCatalyst code version: H.10.
Copyright 1997-2007 Omniture, Inc. More info available at http://www.omniture.com*/
s.pageName="Product Quick View";
s.channel="";
s.server="";
s.events="event10";
s.products=";" + style;
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code);
}
/** Function for opneing old school pop up windows **/
$(function () {
$("a")
// add additional filters for pop up windows of different sizes
.filter(".newindow")
.click(function(){
window.open(this.href,"_blank","toolbar=1,location=1,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=573,height=600");
return false;
})
.end();
$(".newindow").attr("title","This link opens in a new window");
}
);
$(function () {
var checkBoxes = $(".click_compare");
var totalCheckBoxes = checkBoxes.length;
for(var i=0; i < totalCheckBoxes; i++) {
checkBoxes[i].onclick = selected;
}
function selected() {
// determine if the checkbox is marked
if(this.checked) {
$("#view-compare-now").css("display", "block");
}
else {
$("#view-compare-now").css("display", "none");
}
}
});
$(function () {
var relatedWrap = $(".sims")[0];
var relatedProds = $(".sim-prod",relatedWrap);
var totalProds = relatedProds.length;
for(var i = 0; i < totalProds; i++) {
if(i == 1) {
relatedWrap.id = "col2";
}
else if(i == 2) {
relatedWrap.id = "col3";
}
else if(i >= 3) {
relatedWrap.id = "col4";
}
}
});