document.write("<script language='javascript' type='text/javascript' src='/javascript/jquery.footer.js'><\/sc" + "ript>");//Plugin to fix footers position
/* ----- Main Menu functions ----- */

function paymentOptionStyle(){
    var doc = document.getElementById("payment_frame").contentWindow.document;
    var html = doc.getElementsByTagName("html")[0];
    var head = html.getElementsByTagName("head")[0];
    var siteLink = document.createElement("link")
    siteLink.rel = "stylesheet";
    siteLink.media = "screen";
    siteLink.type = "text/css";
    siteLink.href = "../css/payment_area.css";
    head.appendChild(siteLink);
}

function priceSlider(minVal, maxVal){
    if (minVal != maxVal) {
    
        $slider = $("#slider");
        $amountMin = $("#amountMin");
        $amountMax = $("#amountMax");
        $milestone1 = $("#milestone1");
        $slider.slider({
            range: true, // necessary for creating a range slider
            min: parseInt(minVal), // minimum range of slider
            max: parseInt(maxVal), // maximimum range of slider
            values: [parseInt(minVal), parseInt(maxVal)], //initial range of slider
            slide: function(event, ui){ // This event is triggered on every mouse move during slide.
                $amountMin.val(ui.values[0]);
                $amountMax.val(ui.values[1]);
                $('.ui-slider-range').css('background-image', imageUrl);
                
            },
            stop: function(event, ui){
                imageUrl = $('.ui-slider-range').css("background-image").replace('_over', '');
                $('.ui-slider-range').css('background-image', imageUrl);
                // Add the over again so when the user slides it will be shown
                imageUrl = $('.ui-slider-range').css("background-image").replace(".png", "_over.png");
                //Call ajax function here so the products are updated.
                // Example
                // $products.load('ajaxSlider.php?minValue='+ui.values[0]+'&maxValue='+ui.values[1],'',function() });
                EndecaHelperJS.refreshProductsByPriceRange(ui.values[0], ui.values[1]);
            }
            
        });
        imageUrl = $('.ui-slider-range').css("background-image").replace(".png", "_over.png");
        //preLoadImagePath = imageUrl.replace('url("','');
        //preLoadImagePath = preLoadImagePath.replace('")','');
        //jQuery.preLoadImages("slider_gradient_over.png", "preLoadImagePath");
        $amountMin.val($slider.slider("values", 0));
        $milestone1.html($slider.slider("values", 0));
        $amountMax.val($slider.slider("values", 1));
        var children = $('#price-milestone-wrapper').children().size();
        var mileStoneValue = new Number(0);
        var newPos = 0;
        var range = $slider.slider("values", 1) - $slider.slider("values", 0);
        var newValue = 0;
        for (i = 1; i <= children; i++) {
            if (i != 1) {
                mileStoneValue += (1 / (children - 1));
                newValue = Number($slider.slider("values", 0) + (range * mileStoneValue)).toFixed();
                $("#milestone" + i).html(newValue);
            }
            // 6.5 is the half the width of the slider button in px
            /*newPos = ($("#milestone"+ i).width()/2) - 5;
            
             
            
             $("#milestone"+ i).offset({top:$("#milestone"+ i).offset().top,   left:$("#milestone"+ i).offset().left - newPos });*/
            
        }
        
        $("#amountMin").blur(function(){
            $slider.slider("values", 0, Math.min($slider.slider("values", 1), parseInt($(this).val())));
            $(this).val(Math.min($slider.slider("values", 1), parseInt($(this).val())));
            EndecaHelperJS.refreshProductsByPriceRange($slider.slider("values", 0), $slider.slider("values", 1));
            
        });
        $("#amountMax").blur(function(){
            $slider.slider("values", 1, Math.max($slider.slider("values", 0), parseInt($(this).val())));
            $(this).val(Math.max($slider.slider("values", 0), parseInt($(this).val())));
            EndecaHelperJS.refreshProductsByPriceRange($slider.slider("values", 0), $slider.slider("values", 1));
        });
    }
    else {
        $("#page #main_content_wrapper .cl-side .price-range-container").css("display", "none");
        
    }
}

var ddmenuitem = 0;
var delay = true;
var currentMenu;
$(document).ready(function(){
    $("#main-menu").mouseleave(function(){
        delay = true;
    });
});


function menuOpen(){

    currentMenu = $(this);
    if (delay) {
    
        $(this).addClass("delay");
        var timeout = setTimeout("delayMenuOpen()", 500);
        ddmenuitem = $(this).find("ul");
        
    }
    else {
        $(this).addClass("selected");
        
        ddmenuitem = $(this).find("ul").css("visibility", "visible");
        //  $("#page_shadow").addClass("products-background");
        $("#menu-shadow").css("display", "block");
    }
}

function delayMenuOpen(){
    //alert(delay);
    if (delay) {
        if ($(currentMenu).hasClass("delay")) {
            $(currentMenu).addClass("selected");
            delay = false;
            ddmenuitem = $(currentMenu).find("ul").css("visibility", "visible");
            //  $("#page_shadow").addClass("products-background");
            $("#menu-shadow").css("display", "block");
        }
    }
    
}

function menuClose(){
    $(this).removeClass("delay");
    $(this).removeClass("selected");
    ddmenuitem.css("visibility", "hidden");
    $("#menu-shadow").css("display", "none");
    //  $("#page_shadow").removeClass("products-background");

    //delay = true;

}


/* ----- end Main Menu ----- */

function repopulateShippingAddress(){
    if ($("#WC_MSOrderItemDetails_td_1_1 #WC_MSOrderItemDetails_div_3_1").length > 0) {
        if ($(".shippingMethods").length > 0) {
            $('shippingMethods').remove();
        }
        if ($(".shippingAddressTextArea").length > 0) {
            $('shippingAddressTextArea').remove();
        }
        if ($(".shippingAddressSelect").length > 0) {
            $('shippingAddressSelect').remove();
        }
        
        $("#WC_MSOrderItemDetails_td_1_1 select").clone(false).removeAttr("id").removeAttr('onchange').addClass('shippingAddressSelect').appendTo($(".shippingAddress"));
        $('.shippingAddressSelect').change(function(){
            $('#WC_MSOrderItemDetails_td_1_1 select').val($(this).val());
            $('#WC_MSOrderItemDetails_td_1_1 select').trigger("onchange");
        });
        
        $("#WC_MSOrderItemDetails_td_1_1 .shipping_address_MS_shipping_info_page div div:eq(0)").clone().addClass('shippingAddressTextArea').attr("id", "shippingAddressTextArea").appendTo($(".shippingAddress"));
        
        if ($(".editAddress").length == 0) {
            $("#WC_MSOrderItemDetails_td_1_1 .shipping_address_MS_shipping_info_page div div:eq(1)").clone().removeAttr("id").addClass('editAddress').appendTo($(".shippingAddress"));
        }
        if ($(".createAddress").length == 0) {
            $("#WC_MSOrderItemDetails_td_1_1 .shipping_address_MS_shipping_info_page div div:eq(2)").clone().removeAttr("id").addClass('createAddress').appendTo($(".shippingAddress"));
        }
        refreshShipingMethodData();
    }
}

function arrangeShippingBilling(){
    if ($("#WC_MSOrderItemDetails_td_1_1 #WC_MSOrderItemDetails_div_3_1").length > 0) {
        $("<div class='shippingAddress'> </div>").prependTo('#shipping');
        $("<h2>Shipping Address</h2>").prependTo('.shippingAddress');
        repopulateShippingAddress();
        $(".radioWrapper input:radio").click(function(){
            $(".radioWrapper").removeClass("selected");
            $("input:checked").parent().addClass("selected");
        });
        $(".radioWrapper").click(function(){
            $(".radioWrapper").removeClass("selected");
            $(this).find("input:radio").attr("checked", true);
            $("input:checked").parent().addClass("selected");
        });
    }
}

function refreshShipingMethodData(){
    count = 1;
    var html = '<div class="shippingMethods"></div>';
    $(html).insertAfter('.shippingAddress');
    var displayApplianceMethod = false;
    var displayAccessoryMethod = false;
    var applianceMethods = [];
    var accessoryMethods = [];
    while ($('#WC_MSOrderItemDetails_td_1_' + count).length > 0) {
        orderValue = $('#orderItem_' + count).val();
        //10551 is for appliances 10601 is for accesories
        ffmCenter = $('#ffmCenter_' + count).val();
        if (ffmCenter == "10551") {
            if (displayApplianceMethod == false) {
                displayApplianceMethod = true;
                var applianceSelected = $('#WC_MSOrderItemDetails_td_2_' + count + ' select').val();
                $('#MS_ShippingMode_' + orderValue + " option").each(function(){
                    applianceMethods[$(this).val()] = $(this).text();
                });
            }
            applianceMethods[0] = 'WC_MSOrderItemDetails_td_2_' + count;
            $('#WC_MSOrderItemDetails_td_2_' + count + ' select').addClass("applianceSelect");
        }
        if (ffmCenter == "10601") {
            if (displayAccessoryMethod == false) {
                var accessorySelected = $('#WC_MSOrderItemDetails_td_2_' + count + ' select').val();
                $('#MS_ShippingMode_' + orderValue + " option").each(function(){
                    accessoryMethods[$(this).val()] = $(this).text();
                });
                displayAccessoryMethod = true;
            }
            accessoryMethods[0] = 'WC_MSOrderItemDetails_td_2_' + count;
            $('#WC_MSOrderItemDetails_td_2_' + count + ' select').addClass("accessorySelect");
        }
        $('#WC_MSOrderItemDetails_td_1_' + count).addClass("shippingAddressTD");
        $('#WC_MSOrderItemDetails_td_2_' + count).addClass("shippingModeTD");
        count++;
    }
    if (displayApplianceMethod == true) {
        html = '<h2>Shipping Method for Appliances</h2>';
        $(html).appendTo('.shippingMethods');
        //html = '<input type="hidden" id="applianceShippingModeID" value="'+applianceMethods[0]+'" name="applianceShippingModeID">';
        //$(html).appendTo('.shippingMethods');
        for (var i in applianceMethods) {
        
            if (applianceSelected == i) {
                html = '<div onclick="changeSelectValues(' + i + ',\'' + applianceMethods[0] + '\');" class="radioWrapper selected"><input onchange="changeSelectValues(' + i + ',\'' + applianceMethods[0] + '\');" type="radio" name="appliance" value="' + i + '" checked="checked"> <span>' + applianceMethods[i] + '</span></div>';
                $(html).appendTo('.shippingMethods');
            }
            else 
                if (i != 0) {
                    html = '<div onclick="changeSelectValues(' + i + ',\'' + applianceMethods[0] + '\');" class="radioWrapper"><input onchange="changeSelectValues(' + i + ',\'' + applianceMethods[0] + '\');" type="radio" name="appliance" value="' + i + '"> <span>' + applianceMethods[i] + '</span></div>';
                    $(html).appendTo('.shippingMethods');
                }
        }
    }
    if (displayAccessoryMethod == true) {
        html = '<h2>Shipping Method for Accessories</h2>';
        $(html).appendTo('.shippingMethods');
        //	html = '<input type="hidden" id="accessoryShippingModeID" value="'+accessoryMethods[0]+'" name="accessoryShippingModeID">';
        //	$(html).appendTo('.shippingMethods');
        for (var i in accessoryMethods) {
            if (accessorySelected == i) {
                html = '<div onclick="changeSelectValues(' + i + ',\'' + accessoryMethods[0] + '\');" class="radioWrapper selected"><input onchange="changeSelectValues(' + i + ',\'' + accessoryMethods[0] + '\');" type="radio" name="accessory" value="' + i + '" checked="checked"><span>' + accessoryMethods[i] + '</span></div>';
                $(html).appendTo('.shippingMethods');
            }
            else 
                if (i != 0) {
                    html = '<div onclick="changeSelectValues(' + i + ',\'' + accessoryMethods[0] + '\');" class="radioWrapper"><input onchange="changeSelectValues(' + i + ',\'' + accessoryMethods[0] + '\');" type="radio" name="accessory" value="' + i + '"><span>' + accessoryMethods[i] + '</span></div>';
                    $(html).appendTo('.shippingMethods');
                }
        }
    }
}

function changeSelectValues(value, selectorId){
    $('#' + selectorId + ' select').val(value);
    $('#' + selectorId + ' select').trigger("onchange");
}

//dojo.addOnLoad(arrangeShippingBilling);

$(document).ready(function(){
    //arrangeShippingBilling();
    /*pop up for no support for ie6 */
    if ($.browser.msie && $.browser.version == "6.0") {
        $("#MessageArea").load("/other-assets/fr_FR/ie6-popup/ie6.html");
        $("#MessageArea").dialog({
            modal: true,
            autoOpen: true
        });
    }
    /*end pop up for no support for ie6 */
    
    $("#main-menu > li").mouseenter(menuOpen);
    $("#main-menu > li").mouseleave(menuClose);
    //  myaccountpage toggle menus
    $("span.header").bind("click", myAccountMenu);
    
    // set the value of the search input field
    if ($("#searchTermValue").html() && $("#searchTermValue").html().length > 0) {
        $("#searchTerm").val($("#searchTermValue").html());
    }
    // magnifying glass functionality for UK:
    $("#header .textsearch-container .glassLink").click(function(){
        $("#header .textsearch-container .search-textbox").focus();
        return false;
    });
    $("#header .textsearch-container .search-textbox").focus(function(){
        this.select();
    });
    
    // [checkout] Shipping Method Drop-Down width
    if ($.browser.msie) {
        $("select").fixSelect(200);
    }
    
});

/*
 Andrey Bolanos
 Fix select dropdown list in IE (width doesn't display full text / cut off)
 http://plugins.jquery.com/node/15415
 */
$.fn.fixSelect = function(minWidth){
    return (!($.browser.msie && $.browser.version < 9)) ? this : this.each(function(){
        if (this.tagName.toLowerCase() == 'select') {
            var el = this, $this = $(this), minWidth = minWidth ? minWidth : el.offsetWidth, elementWidth = $this.outerWidth(), $wrapper = $('<span class="selectFix"></span>').css({
                display: ($this.css('display') == 'block') ? 'block' : 'inline-block',
                cssFloat: $this.css('float'),
                overflowX: 'hidden',
                overflowY: 'visible',
                width: minWidth
            }), naturalWidth;
            $.each('marginTop marginRight marginBottom marginLeft'.split(' '), function(i, prop){
                $wrapper.css(prop, $this.css(prop));
                $this.css(prop, 0);
            });
            if ($this.is(':visible')) {
                $this.width('auto');
                naturalWidth = $this.outerWidth();
                $this.width(minWidth);
                $this.wrap($wrapper).bind('mousedown keyup applyfix', function(){
                    $this.width((naturalWidth < elementWidth) ? minWidth : 'auto');
                    if ($.browser.version == 6) 
                        $this.css('marginLeft', 1);
                }).blur(function(){
                    $this.width(minWidth);
                    if ($.browser.version == 6) 
                        $this.css('marginLeft', 0);
                }).bind('initfix', function(){
                    $this.width('auto');
                    naturalWidth = $this.outerWidth();
                    $this.width(minWidth);
                });
            }
        }
    });
}

function myAccountMenu(){

    var htmlText = $(this).html();
    
    if (htmlText == "Laatste bestellingen") {
        if ($(this).hasClass('expanded')) {
            $(this).parent().removeClass('expanded');
            $(this).removeClass('expanded');
        }
        else {
            $(this).addClass('expanded');
            $(this).parent().addClass('expanded');
        }
        
        
        $(".order_status_table").toggle();
    }
    else 
        if (htmlText == "Producten die u onlangs aan uw verlanglijstje hebt toegevoegd") {
            if ($(this).hasClass('expanded')) {
                $(this).parent().removeClass('expanded');
                $(this).removeClass('expanded');
            }
            else {
                $(this).addClass('expanded');
                $(this).parent().addClass('expanded');
            }
            $("#four-grid").toggle();
        }
        else {
            exit;
        }
    
}

function toggleClass(e, add, remove){
    e.preventDefault();
    $(".body588").removeClass(remove);
    $(".body588").addClass(add);
}

function showInfo(e, classy, state){
    e.preventDefault();
    $(".personal-information").removeClass(classy);
    $(".form-div").addClass(classy);
    $(".form-div").addClass(state);
}

$(document).ready(function(){

    /*Uk MywishList page it's used to make the left menu same size as the content*/
    
    //$("#page #left_nav").height($(document).height());	
    $(".product_detail_page .product-carousel .carousel-item a").click(function(e){
        selectPic(e, this)
    });
    $("#page.product_detail_page .video_box .closeLink").click(function(){
        $("#page.product_detail_page .video_box img").trigger("click");
        return false;
    });
    $(".color-available li").click(colorPicker);
    //positionMiniCart();
    $(".ContactUs .ok_button").click(function(e){
        e.preventDefault();
        showHide(".contactus_form", "")
    });
    $(".ContactUs .send_request a").click(function(e){
        e.preventDefault();
        showHide(".thank_submission", "#by_e-mail_box,#by_mail_box,#by_phone_box,.tittle_text,.contactus_form")
    });
    $("#SameShippingAndBillingAddress").click(copyAddress);
    
    
    /*addressbook_.php*/
    $(document).ready(function(){
        $(".btn_edit").click(function(){
            $('.edit-form').show();
            $('#view-form').hide();
            $('.btn_remove').hide();
            $('.btn_edit').hide();
            $('.btn_update').show();
            
        });
        $(".btn_update").click(function(){
            $('.edit-form').hide();
            $('#view-form').show();
            $('.btn_remove').show();
            $('.btn_edit').show();
            $('.btn_update').hide();
        });
    });
    
    /*END addressbook_.php*/
    
    
    BindCompareCheckBoxes();
    
    /* ----- End Product List Page ----- */
    /* --------------------------------- */
    
    $(".PersonalInformationPage a.edit-button").click(function(e){
        showInfo(e, "showdiv", "")
    });
    $(".PersonalInformationPage a.update_link").click(function(e){
        showInfo(e, "showdiv", "error")
    });
    
    /* ----- language drop down ----- */
    $("#header .language-select").click(function(){
        if ($("#header .language-list").is(":visible")) {
            $("#header .language-list").fadeOut("fast");
        }
        else {
            $("#header .language-list").fadeIn("fast");
        }
        return false;
    });
    
    
    $("#header .language-list ul li a").click(function(){
        var lang = $(this).html();
        $("#header .language-select .current-language").html(lang);
        
        $("#header .language-list").fadeOut("fast");
        return false;
    });
    
    
    /*
     $( "#box .packages .summary .add-to-cart" ).click( function()
     {
     $( "#popup-added-to-cart" ).fadeIn( "fast" );
     $( "#popup-added-to-cart" ).center();
     return false;
     });
     
     */
    /*This is the functionality of the selector for display adress
     * by: Melania Gonzalez
     */
    $("#dropdown_1_a.adress-select").toggle(function(){
        $("#dropdown_1.adress-list").show();
        return false;
    }, function(){
        $("#dropdown_1.adress-list").hide();
        return false;
    });
    
    $("#dropdown_1_a.adress-select ul li a").toggle(function(){
        $("#dropdown_1.adress-list").show();
        return false;
    }, function(){
        $("#dropdown_1.adress-list").hide();
        return false;
    });
    /*END of code for select
     * by: Melania Gonzalez
     */
    $("#popup-added-to-cart a").click(function(){
        $("#popup-added-to-cart").fadeOut("fast");
        return false;
    });
    
    
    $("#box .choose-a-coupon").click(function(){
        $("#popup-choose-coupon").fadeIn("fast");
        $("#popup-choose-coupon").center();
        return false;
    });
    
    $("#popup-choose-coupon a").click(function(){
        $("#popup-choose-coupon").fadeOut("fast");
        return false;
    });
    
    
    $("#box .shipping-costs-container .shipping-costs-link").click(function(){
        $("#popup-shipping-costs").fadeIn("fast");
        $("#popup-shipping-costs").center();
        return false;
    });
    
    $("#popup-shipping-costs .close").click(function(){
        $("#popup-shipping-costs").fadeOut("fast");
        return false;
    });
    
    $("#box .promo-codes .ok").click(function(){
        $("#box .promo-codes .error-message").html("This code is not valid");
        return false;
    });
    
    
    $("#returning-customer-container .sign-in").click(function(){
        $("#returning-customer-container .email-error").slideDown("fast");
        $("#returning-customer-container .password-error").slideDown("fast");
        return false;
    });
    
    
    
    
    $("#order_details .increment, #order_details .decrement").click(function(){
        $("#popup-quantity-error").fadeIn("fast");
        $("#popup-quantity-error").center();
    });
    
    $("#popup-quantity-error .close").click(function(){
        $("#popup-quantity-error").fadeOut("fast");
        return false;
    });
    
    
    $(".table-compare-products .section-toggle").toggle(function(){
        var section = $(this).attr("section");
        $(".table-compare-products ." + section).fadeOut("fast");
        $(this).addClass("collapsed");
        var $dif = $(this).find("span.differences").fadeIn("fast");
        return false;
    }, function(){
        var section = $(this).attr("section");
        $(".table-compare-products ." + section).fadeIn("fast");
        $(this).removeClass("collapsed");
        var $dif = $(this).find("span.differences").fadeOut("fast");
        return false;
    });
    
    $(".table-compare-products .remove").click(function(){
        var col = $(this).attr("column");
        $(".table-compare-products ." + col).fadeOut("fast");
    });
    
    
    $(".search-results-page .button-compare").click(function(){
        var compares = "";
        $(".search-results-page .compare-checkbox:checked").each(function(index){
            if (compares.length > 0) {
                compares += "&";
            }
            compares += "compare[]" + "=" + $(this).attr("sku");
        });
        window.location = "CompareProductsDisplay.html?" + compares;
        return false;
    });
    
});


/* ----- Product Details Page ----- */

$(document).ready(function(){
    $(".send_share_link").click(function(){
        $("#popup-send-to-friend").show();
        return false;
    });
    
});

/*
 function closeAll()
 {
 $( ".selected" ).removeClass( "selected" );
 $( ".open" ).fadeOut( "fast" );
 }
 */
/* positions the mini cart hover over popup */
/*
 function positionMiniCart()
 {
 var pos = $( "#header .header_line2 a.popUpLinkHover" ).offset();
 if ( pos )
 {
 //	$( "#quick_cart_container" ).css( "left", ( pos.left - 20 ) + "px" );
 }
 }
 $( window ).resize( function()
 {
 positionMiniCart();
 });
 */
function copyAddress(e){
    //e.preventDefault();
    if ($(this).attr("checked")) {
        var source = $("#my_account_billing input");
        var dest = $("#my_account_shipping input");
        for (var i = 0; i < source.length - 1; i++) {
            $(dest[i + 1]).val($(source[i]).val());
        }
        var source = $("#my_account_billing select");
        var dest = $("#my_account_shipping select");
        for (var i = 0; i < source.length; i++) {
            $(dest[i]).val($(source[i]).val());
        }
    }
}

function colorPicker(e){
    selectPic(e, this, false);
    var text = $(this).children("img").attr("alt");
    $(".color-available li img").removeClass("selected");
    $(this).children("img").addClass("selected");
    $(this).closest("ul").siblings("p.selected_color").html(text);
}

var pictureProduct = "";

function selectPic(e, obj, flag){
    e.preventDefault();
    var c = $(obj).attr("className");
    var tempSelector = "";
    c = c.split(" ");
    var i = 0;
    while (c[i].indexOf("src|") == -1) {
        i++;
    }
    c = c[i].split("|");
    //Added the selector .video_box to avoid image load problems 
    tempSelector = ".video_box " + c[3];
    //Set original picture here 
    if (pictureProduct == "") 
        pictureProduct = $(tempSelector).attr("src");
    //Set a loading image
    $(tempSelector).attr("src", "/wcsstore/WERStorefrontAssetStore/images/colors/color2/loading.gif");
    //Set the new image
    $(tempSelector).attr("src", c[1]);
    $(tempSelector).click(selectPicOnClick);
    
    if (!flag) 
        $("#large img").attr("src", c[1].replace(".jpg", "_zoom.jpg"));
    $(c[3]).parent().next().css("display", "none");
    $(obj).parent().parent().parent().siblings(".video_box").css("margin-bottom", "100px");
    $(obj).parent().parent().parent().siblings(".video_box").css("width", "650px");
    $("#page.product_detail_page .video_box .closeLink").css("display", "block");
}

function selectPicOnClick(){
    $("#page.product_detail_page .video_box .closeLink").css("display", "none");
    $("#page.product_detail_page .video_box img").attr("src", pictureProduct);
    $(this).parent().next().css("display", "block");
    $(this).parent().css("margin-bottom", "0px");
    $(this).parent().css("width", "350px");
}

function showHide(show, hide){
    $(show).css("display", "block");
    $(hide).css("display", "none");
}

/* --------------------------- */
/* ----- Glossary Popups ----- */

var glossaryPos;

// fired when someone clicks on a ? icon
function glossaryPopup(storeId, catalogId, langId, term, obj){
    var link = "/webapp/wcs/stores/servlet/WHRGlossaryPopupDisplayView?storeId={0}&catalogId={1}&langId={2}&term={3}";
    //	var link = "ajax_glossary.php?storeId={0}&catalogId={1}&langId={2}&term={3}";
    
    //link = link.replace( "{0}", storeId ).replace( "{1}", catalogId ).replace( "{2}", langId ).replace( "{3}", term ); WHPUK-822
    link = link.replace("{0}", storeId).replace("{1}", catalogId).replace("{2}", langId).replace("{3}", encodeURIComponent(term));
    glossaryPos = $(obj).offset();
    
    if ($("#question-tooltip").length > 0) {
        $("#question-tooltip").remove();
    }
    
    $.ajax({
        url: link,
        success: glossaryPopupSuccess
    });
    
    return false;
}

// positions the glossary popup, loads the data that was returned
function glossaryPopupSuccess(data, textStatus, xhr){
    $("#page").append(data + '<div class="glossPos">' + ' - ' + glossaryPos.top + '</div>');
    if ($.browser.webkit) {
        $("#question-tooltip").css({
            "top": glossaryPos.top - $("#page").position().top + "px",
            "left": ((glossaryPos.left - $("#page").position().left) - 171) + "px"
        });
    }
    else {
        $("#question-tooltip").css({
            "top": glossaryPos.top - $("#page").position().top + "px",
            "left": glossaryPos.left - $("#page").position().left + "px"
        });
    }
    $("#question-tooltip .closeLink").click(function(){
        $("#question-tooltip").fadeOut("fast");
        return false;
    });
    
    $("#question-tooltip").fadeIn("fast");
}

/* ----- END Glossary Popups ----- */
/* ------------------------------- */

/* ------------------------- */
/* ----- Glossary Page ----- */

$(document).ready(function(){
    $("#page.glossary .category ul.category_item li a").click(function(){
        if ($(this).parent().hasClass("expanded")) {
            $(this).parent().removeClass("expanded");
            $(this).siblings(".glossary_content").slideUp("fast");
        }
        else {
            $(this).parent().addClass("expanded");
            $(this).siblings(".glossary_content").slideDown("fast");
        }
        return false;
    });
    
    
    $("#page.glossary #glossary a.open-all").click(function(){
        $("#page.glossary .category ul.category_item li .glossary_content").css("display", "block");
        $("#page.glossary .category ul.category_item li .glossary_content").slideDown("fast");
    });
    
    
    $("#page.glossary #glossary a.close-all").click(function(){
        $("#page.glossary .category ul.category_item li .glossary_content").css("display", "none");
        $("#page.glossary .category ul.category_item li .glossary_content").slideUp("fast");
    });
    
});

/* ----- END Glossary Page ----- */
/* ----------------------------- */


/* ----- FAQ Page ----- */

$(document).ready(function(){

    $(".open-close li.close-link a").click(function(e){
        expandCollapse(e, this, 1)
    });
    $(".open-close li.open-link a").click(function(e){
        expandCollapse(e, this, 2)
    });
    
    $(".send-print li.print-a print-a").click(function(e){
        $(".open-close li.open-link a").click();
    });
    
    $("#page.faqPage .open-link .open-a").click(function(){
        $("#page.faqPage .content-faq .faqList .faqItem .faqQuestion .faqAnswer").each(function(){
            if (!$(this).hasClass("expanded")) {
                $(this).addClass("expanded");
            }
            $("#page.faqPage .content-faq .faqList .faqItem .faqQuestion .faqAnswer").slideDown("fast");
        });
        return false;
    });
    
    $("#page.faqPage .close-link .close-a").click(function(){
        $("#page.faqPage .content-faq .faqList .faqItem .faqQuestion .faqAnswer").each(function(){
            if ($(this).hasClass("expanded")) {
                $(this).removeClass("expanded");
            }
            $("#page.faqPage .content-faq .faqList .faqItem .faqQuestion .faqAnswer").slideUp("fast");
        });
        return false;
    });
});


// This will bind the click events of the Compare checkboxes on the product list page
function BindCompareCheckBoxes(){
    searchResultConf();
    fixStyleProductListPage();
    fixPersonalInformation();
    // Add compare checkboxes the event Click   
    $(".compare-product .compare-product-chk").click(CompareCheckBoxes);
    if (getCookie(cookieItemProducts) != null) {
        getCheckboxCookie();
    }//end if cookie
    $(".compare-product a.compare_link").click(function(e){
        e.preventDefault();
        var itemsChecked;
        if (getCookie(cookieItemProducts) == null) 
            itemsChecked = 0;
        else {
            var arrayItems = getCookie(cookieItemProducts).split("|");
            itemsChecked = arrayItems.length - 1
        }
        if ($(this).siblings(".compare-product-chk").attr("checked") == true) {
            $(this).siblings(".compare-product-chk").attr("checked", false);
            $(this).siblings(".compare-product-chk").click();
            $(this).siblings(".compare-product-chk").attr("checked", false);
        }
        else {
            if (itemsChecked < 4) {
                $(this).siblings(".compare-product-chk").attr("checked", true);
                $(this).siblings(".compare-product-chk").click();
                $(this).siblings(".compare-product-chk").attr("checked", true);
            }
            else {
                showPopupCss("#compare-products-error-popup-v2");
            }
        }
    });
    /*End*/
}

/*This method is going to update the values and styles chechbox and also management the cookie of the items to compare
 By: Victor Redondo Quiros, July 23, 2010
 */
function CompareCheckBoxes(){
    var itemsChecked;
    if (getCookie(cookieItemProducts) == null) 
        itemsChecked = 0;
    else {
        var arrayItems = getCookie(cookieItemProducts).split("|");
        itemsChecked = arrayItems.length - 1
    }
    if (itemsChecked <= 4) {
        if ($(this).attr("checked") == true) {
            if (itemsChecked < 4) {
                var tempItems;
                if (getCookie(cookieItemProducts) == null) {
                    setCookie(cookieItemProducts, "");
                    tempItems = "";
                }
                else 
                    tempItems = getCookie(cookieItemProducts);
                
                tempItems += $(this).attr("sku") + "|"
                setCookie(cookieItemProducts, tempItems);
            }
            else {
                $(this).attr("checked", false);
                showPopupCss("#compare-products-error-popup-v2");
            }
        }
        else {
            var sku = $(this).attr("sku");
            var arrayItems = getCookie(cookieItemProducts).split("|");
            var tempItems = "";
            var index = 0;
            for (index = 0; index < arrayItems.length; index++) {
                if ((sku != arrayItems[index]) && (arrayItems[index] != "")) {
                    tempItems += arrayItems[index] + "|";
                }
                else {
                    $(".product-list-header-controls .product-list-header .compare-controls ul li .checked:eq(" + index + ")").attr("sku", "");
                    $(".product-list-header-controls .product-list-header.list-bottom .compare-controls ul li .checked:eq(" + index + ")").attr("sku", "");
                }//end if sku
            }//end for arrayItems
            setCookie(cookieItemProducts, tempItems);
        }//end if checked
        getCheckboxCookie();
    }
    else {
        $(this).attr("checked", false);
        showPopupCss("#compare-products-error-popup-v2");
    }//end if itemsChecked
}

/*This method is going to swicht the style names of the checkboxs and sku values too
 By: Victor Redondo Quiros, July 23, 2010
 */
var IE = /*@cc_on!@*/ false;

function getCheckboxCookie(){
    if (getCookie(cookieItemProducts) != null) {
        var arrayItems = getCookie(cookieItemProducts).split("|");
        var itemsChecked = arrayItems.length - 1;
        $(".compare-controls ul li .checked").removeClass("checked").addClass("unchecked");
        var selector = ".product-list-header-controls .product-list-header .compare-controls ul li .unchecked:lt(" + itemsChecked + ")";
        if ($(".product_detail_page").length == 0) {
            $(selector).removeClass("unchecked").addClass("checked");
            selector = ".product-list-header-controls .product-list-header.list-bottom .compare-controls ul li .unchecked:lt(" + itemsChecked + ")";
            $(selector).removeClass("unchecked").addClass("checked");
        }
        else {
            selector = ".compare-controls ul li .unchecked:lt(" + itemsChecked + ")";
            $(selector).removeClass("unchecked").addClass("checked");
        }
        var indexItem = 0;
        for (indexItem = 0; indexItem <= itemsChecked; indexItem++) {
            var valueIndex = arrayItems[indexItem];
            if (valueIndex != "") {
                if ($(".product_detail_page").length == 0) {
                    selector = ".product-list-header-controls .product-list-header .compare-controls ul li .checked:eq(" + indexItem + ")";
                    $(selector).attr("sku", valueIndex);
                    selector = ".product-list-header-controls .product-list-header.list-bottom .compare-controls ul li .checked:eq(" + indexItem + ")";
                    $(selector).attr("sku", valueIndex);
                    selector = ".compare-product .compare-product-chk[sku|=" + valueIndex + "]";
                }
                else {
                    selector = ".compare-controls ul li .checked:eq(" + indexItem + ")";
                    $(selector).attr("sku", valueIndex);
                    selector = ".compare-product .compare-product-chk[sku|=" + valueIndex + "]";
                }//end if product_detail_page        
                $(selector).attr("checked", true);
            }//end if valueIndex
        }//end for arrayItems
        var counter = itemsChecked;
        if (IE) 
            counter = counter + "&nbsp;";
        $(".compare-controls .compare-link .count").html(counter);
        if (itemsChecked == 1) {
            $(".compare-controls .compare-link .count").html("");
        }
    }
    else {
        $(".compare-controls ul li .checked").removeClass("checked").addClass("unchecked");
        $(".compare-controls ul li .compare-prod").attr("sku", "");
        $(".compare-controls .compare-link .count").html("");
    }
}

//Content Pages - Landing Pages
$(document).ready(function(){
    var object = ".expanded_freshness";
    $(object).click(function(e){
        content_landing_expandCollapse(e, this, object, 0)
    });
    
    object = ".expanded_defrosting";
    $(object).click(function(e){
        content_landing_expandCollapse(e, this, object, 0)
    });
    
    /*
     Leo Vega
     Fix for aligned of "Distributeurs d'eau" box in IE (The solution was made with CSS3)
     */
    $('#page.ContentPage #main_content_wrapper .main-content ul.content-list li.content-box:nth-child(3)').addClass('left_box_FAQ');
    $('#page.ContentPage #main_content_wrapper .main-content ul.content-list li.content-box:nth-child(5)').addClass('left_box_FAQ');
    $('#page.ContentPage #main_content_wrapper .main-content ul.content-list li.content-box:nth-child(7)').addClass('left_box_FAQ');
    $('#page.ContentPage #main_content_wrapper .main-content ul.content-list li.content-box:nth-child(9)').addClass('left_box_FAQ');
    
});

function content_landing_expandCollapse(e, This, object, openall){

    if ($(This).hasClass('expanded')) {
        $(This).removeClass('expanded');
    }
    else {
        $(This).addClass('expanded');
    }
    
    $(object + ".content").toggle();
}

function cleanCookie(){
    if (getCookie(cookieLocation) != null) {
        if (getCookie(cookieLocation) != location.pathname) {//is not a refresh
            if ($(".product_detail_page").length == 0) {
                var tempCookie;
                tempCookie = "";
                setCookie(cookieItemProducts, tempCookie);
                var currentPath = "";
                currentPath = location.pathname;
                setCookie(cookieLocation, currentPath);
                var currentSearchTerm = "";
                currentSearchTerm = getUrlVars()["searchTerm"];
                if (currentSearchTerm == undefined) 
                    currentSearchTerm = "";
                setCookie(cookieSearchTerm, currentSearchTerm);
                cleanCompareBoxs();
            }
        }
        else {
            var currentSearchTerm = "";
            currentSearchTerm = getUrlVars()["searchTerm"];
            if (currentSearchTerm == undefined) 
                currentSearchTerm = "";
            if (getCookie(cookieSearchTerm) != null) {
                if (getCookie(cookieSearchTerm) != currentSearchTerm) {
                    var tempCookie;
                    tempCookie = "";
                    setCookie(cookieItemProducts, tempCookie);
                    setCookie(cookieSearchTerm, currentSearchTerm);
                    cleanCompareBoxs();
                }
            }
            else {
                setCookie(cookieSearchTerm, currentSearchTerm);
            }
        }
    }
    else {
        var currentSearchTerm = "";
        currentSearchTerm = getUrlVars()["searchTerm"];
        if (currentSearchTerm == undefined) 
            currentSearchTerm = "";
        setCookie(cookieLocation, location.pathname);
        setCookie(cookieSearchTerm, currentSearchTerm);
    }
}

/*
 * Config variables for make enable the cookie functionality
 * By: Victor Redondo Quiros
 * */
var cookieOptions = {
    path: '/',
    expires: 10
};
var cookieItemProducts = "compareItemsUk";
var cookieLocation = "locationPathUk";
var cookieSearchTerm = "searchTermPathUk";

$(window).load(function(){
    cleanCookie();
});

function getCookie(cookieName){
    return $.cookie(cookieName);
}

function setCookie(cookieName, cookieValue){
    $.cookie(cookieName, cookieValue, cookieOptions);
}

/*This method get the parameters from the URL
 By: Victor Redondo Quiros, 9 Ago, 2010*/
function getUrlVars(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function cleanCompareBoxs(){
    var tempCookie;
    tempCookie = "";
    setCookie(cookieItemProducts, tempCookie);
    $(".compare-product .compare-product-chk").attr("checked", false);
    $(".compare-controls ul li .checked").removeClass("checked").addClass("unchecked");
    $(".compare-controls ul li .compare-prod").attr("sku", "");
    $(".compare-controls .compare-link .count").html("");
}

/*
 * This method put the events mouse over and out for the products, basically it enable the
 * background animation when the user put the mouse over or out from it
 * By: Victor Redondo Quiros, 29 July,2010
 */
$(window).load(function(){
    $("#quick_cart .container .list .product").mouseover(quickCartProductMouseOver);
    $("#quick_cart .container .list .product").mouseout(quickCartProductMouseOut);
    $(".close_shopping_cart .close_shopping_cart_item").click(function(e){
        e.preventDefault();
        $(this).closest(".quick_cart_container").css("visibility", "hidden");
    });
});

/*
 * This method catch the event mouseOver from the products on the quickCart
 * By: Victor Redondo Quiros, 29 July,2010
 */
function quickCartProductMouseOver(){
    $(this).next().height($(this).height());
    $(this).addClass("order_link_bg");
    $(this).next().addClass("order_link_bg");
}

/*
 * This method catch the event mouseOut from the products on the quickCart
 * By: Victor Redondo Quiros, 29 July,2010
 */
function quickCartProductMouseOut(){
    $(this).removeClass("order_link_bg");
    $(this).next().removeClass("order_link_bg");
}

/*
 * This is for the Share in the Wishlist. Makes visible the right nav and sends focus to form
 * Juan Jimenez, Jul/29/2010
 */
function wishListBind(){
    $("div#right_nav").css('display', 'none');
    $("input#SendWishListForm_Recipient_Email").focus();
}

/*
 * Add product to cart (change button on ajax success)
 * Andrey Bolanos Sandoval Ago/02/2010
 */
function successAddedItemToCart(buttonAddToCartRef){
    // When button is clicked location change to NULL, ï¿½maybe it should link to cart page?
    $(buttonAddToCartRef).removeClass("add-to-cart").addClass("added-to-cart").html("In Your Cart").removeAttr("href");
}

/*Scripts necesary for the Content pages*/

/*starts our_history script___Andres Lopez*/
$(document).ready(function(){
    $(".date_lst li a").click(selected_date);
});
function selected_date(e){
    e.preventDefault();
    $(".date_lst li a img").css("visibility", "hidden");
    $(this).children().css("visibility", "visible");
    
    $(".date").removeClass("selected");
    var className = $(this).attr("class");
    var selector = "#" + className.split("-")[1];
    $(selector).addClass("selected");
}

/*ends our history script*/

/*starts our_vision script___Allan Estrada*/

$(document).ready(function(){
    $(".descriptions_lst li a").click(selected_item);
});
function selected_item(e){
    e.preventDefault();
    $(".descriptions_lst li a img").css("visibility", "hidden");
    $(this).children().css("visibility", "visible");
    
    $(".descriptions").removeClass("selected");
    var className = $(this).attr("class");
    var selector = "#" + $(this).attr("class");
    $(selector).addClass("selected");
}

/*starts your_carrer_at_whirpool script___Andres Lopez*/
$(document).ready(function(){
    $("#your_career_whirlpool_content ul.career_boxes li .testimonial_box .testimonials_link").click(selected_test);
    $(".test_pop .closeLink").click(closeTestPop);
    
    $("#amountMin").focus(function(){
        // Select input field contents
        this.select();
    });
    
    $("#amountMax").focus(function(){
        // Select input field contents
        this.select();
    });
    
});
$(document).ready(function(){
    $("#why_work_whirlpool_content .testimonial_box .testimonial_link").click(selected_test);
});
function selected_test(e){
    e.preventDefault();
    var selector = $(this).attr("id");
    
    $(".test_pop").css("display", "none");
    
    switch (selector) {
        case "test_Content1":
            showPopupCss("#intcartestimony");
            break;
        case "test1":
            showPopupCss("#careertesti1");
            break;
        case "test2":
            showPopupCss("#careertesti2");
            break;
        case "test3":
            showPopupCss("#careertesti3");
            break;
        case "test6":
            showPopupCss("#careertesti6");
            break;
    }
}

function closeTestPop(e){
    $(".test_pop").fadeOut("fast");
    return false;
    
}

/*ends your_carrer_at_whirpool script*/
function searchResultConf(){
    if ($(".search-results-page").length > 0) {
        var currentSearchTerm = "";
        //Sometimes when filter, the searchTerm var contains some text after a '#' char
        try {
            currentSearchTerm = (getUrlVars()["searchTerm"]).split('#')[0];
        } 
        catch (err) {
            currentSearchTerm = "";
        }
        if (currentSearchTerm != undefined) {
            if (currentSearchTerm != "") {
                $(".search-results-page").highlight(currentSearchTerm);
                $("#ajaxRefreshURL").removeHighlight();
            }
        }
        if ($("div.list-view").length > 0) {
            $("div.list-view .product-row").each(function(){
                var titleHeight = $(this).find(".product-title-link").height();
                $(this).find(".product-primaryactiongroup").css("marginTop", "-" + titleHeight + "px");
                $(this).find(".image-group").css("marginTop", "-" + titleHeight + "px");
            });
        }
        //Line moved here, because an IE bug
        $("#left_nav_container").css("height", ($("#content_wrapper_box").height() - 66) + "px");
    }
}

function printPage(){
    window.print();
}

$(document).ready(function(){
    if ($("#page.product_detail_page").length > 0) {
        $("input.color-product-radio").click(function(){
            $(".color-available li").unbind("click");
            $("input.color-product-radio").attr("checked", false);
            $(this).attr("checked", true);
        });
    }
});
function fixStyleProductListPage(){
    /*if ($("#page.productlist-page").length > 0) {
     if ($("div.list-view").length > 0) {
     $("div.list-view .product-row").each(function(){
     var titleHeight = $(this).find(".product-title-link").height();
     if ($(this).find(".add-to-cart").length > 0) {
     $(this).find(".add-to-cart").css("marginTop", "21px");
     $(this).find(".add-to-wishlist").css("marginTop", "8px");
     }
     $(this).find(".product-primaryactiongroup").css("top", "-" + titleHeight + "px");
     if ($.browser.webkit) {
     $(this).find("a.product-link").css("paddingLeft", "20px");
     }
     
     });
     }
     }*/
}

$(document).ready(function(){
    //fixHeadCrumbBar
    if ($("#page.OrderShippingBillingView .crumb").length > 0) {
        var htmlChanged = $("#page.OrderShippingBillingView .crumb").html().replace("|", " ");
        htmlChanged = jQuery.trim(htmlChanged);
        htmlChanged = htmlChanged.replace(/\n/g, ' ');
        htmlChanged = htmlChanged.replace("|", ' ');
        htmlChanged = htmlChanged.replace(/[|]/g, ' ');
        $("#page.OrderShippingBillingView .crumb").html(htmlChanged);
        $("#page.OrderShippingBillingView .crumb span:gt(0)").each(function(){
            if ($(this).hasClass("on")) {
                $(this).before("<img src='/images/arrow_status_green.jpg' style='vertical-align: bottom;'>");
            }
            else {
                $(this).before("<img src='/images/arrow_status_grey.jpg' style='vertical-align: bottom;'>");
            }
        });
    }
    //FixHeigthMemberPages
    if (($("#page.ContentPage.submenu").length > 0) ||
    ($("#page.ContentPage.generic").length > 0) ||
    ($("#page.ContentPage.glossary").length > 0) ||
    ($("#page.search-results-page").length > 0)) {
        if ($("#left_nav").height() < $("#left_nav").next().height()) {
            $("#left_nav").css("height", $("#left_nav").next().height() + "px");
        }
        else {
            var tempHeight = $("#left_nav").height() + 8;
            $("#left_nav").next().css("height", tempHeight + "px");
            $("#left_nav").css("height", tempHeight + "px");
        }
        if ($(".leftnav-title").height() < $(".leftnav-title").next().height()) {
            $(".leftnav-title").css("height", $(".leftnav-title").next().height() + "px");
        }
        else {
            var tempHeight = $(".leftnav-title").height() + 8;
            $(".leftnav-title").next().css("height", tempHeight + "px");
            $(".leftnav-title").css("height", tempHeight + "px");
        }
        if ($(".left_nav_container").height() < $(".left_nav_container").next().height()) {
            var tempHeight = $(".left_nav_container").next().height() - 78;
            $(".left_nav_container").css("height", tempHeight + "px");
        }
        else {
            var tempHeight = $(".left_nav_container").height() + 8;
            $(".left_nav_container").next().css("height", tempHeight + "px");
            $(".left_nav_container").css("height", tempHeight + "px");
        }
    }
    //fixContactUsPage
    if ($("#page.ContactUs").length > 0) {
        $("#page.ContactUs").addClass("ContentPage");
    }
});
function fixPersonalInformation(){
    if ($("#WC_PersonalInfoExtension_mobile_div_mobileCountryCode").length > 0) {
        var parentPhoneExt = $("#WC_PersonalInfoExtension_mobile_div_mobileCountryCode").parent();
        $(parentPhoneExt).children("input").before("#WC_PersonalInfoExtension_mobile_div_mobileCountryCode");
    }
}

/*fix position of discover whirlpool tab on page like 404,500 and session timeout*/
$(document).ready(function(){
    if (($("#error404").length > 0) || (($("#error500").length > 0)) || (($("#session").length > 0))) {
        $("#main-menu .menu .menu-header-short").css("left", 215 + "px");
    }
});


/*fix the add to cart background in IE7*/
$(document).ready(function(){
    if (($("#page.productlist-page #WC_ContentAreaESpot_div_1_PLTEspot.genericESpot").length > 0)) {
        $('a:contains("Ajouter au panier")').addClass("addCart");
    }
});

var middleNames = new Array("a","a'","aan","aan de","aan den","aan der",
"aan het","aan 't","af","al",
"auf","auf dem","auf den","auf der","aus dem","bij de","bij 't",
"d'","da","de","de l'","de la","de le","de los","del","den","der","des","di"
,"do","dos","du","el","het","in","in de","in den","in der","in het","in 't","l'"
,"la","la de","le","lo","los","o'","onder","onder de","op","op de","op den","op der"
,"op het","op 't","op ten","over","over de","'s","'t","t'","te","ten","ter","thoe","toe"
,"uijt den","uit","uit de","uit den","uit het","uit ten","uyt den","v.d.","v.h.","van","van de"
,"van den","van der","van het","van 't","van ter","ver","vom","von","von dem","von den","von der"
,"voor","voor de","voor den","voor het","voor 't","zur");

//Fixing the user name width
$(document).ready(function(){
    if ($("#header .header_line2 ul li.menu-sign-in").length == 0) {//check if the user is logged in
        var maxLength = 30;
        var text = $("#header .header_line2 ul li:first-child").text();
        if ((($("#header .header_line2 ul li:first-child").text()).length) > maxLength) {
            var text2 = text.split("");
            text = "";
            for (var i = 0; i <= maxLength; i++) {
                text += text2[i];
            }
            $("#header .header_line2 ul li:first-child").text(text);
        }
    }
	if($("#page.ContactUs").length == 0){
		if ($("#middleName").length > 0) {
			new AutoSuggest(document.getElementById('middleName'), middleNames);
			$("#middleName").keydown(function(event){
				disableEnterKey(event);
			});
		}
	}
});

function AutoSuggest(elem, suggestions){

    //The 'me' variable allow you to access the AutoSuggest object
    //from the elem's event handlers defined below.
    
    var me = this;
    
    //A reference to the element we're binding the list to.
    this.elem = elem;
    
    this.suggestions = suggestions;
    
    //Arrow to store a subset of eligible suggestions that match the user's input
    this.eligible = new Array();
    
    //The text input by the user.
    this.inputText = null;
    
    //A pointer to the index of the highlighted eligible item. -1 means nothing highlighted.
    this.highlighted = -1;
    
    //A div to use to create the dropdown.
    this.div = document.getElementById("autosuggest");
    
    
    //Do you want to remember what keycode means what? Me neither.
    var TAB = 9;
    var ENTER = 13;
    var ESC = 27;
    var KEYUP = 38;
    var KEYDN = 40;
    
    
    //The browsers' own autocomplete feature can be problematic, since it will 
    //be making suggestions from the users' past input.
    //Setting this attribute should turn it off.
    elem.setAttribute("autocomplete", "off");
    
    //We need to be able to reference the elem by id. If it doesn't have an id, set one.
    if (!elem.id) {
        var id = "autosuggest" + idCounter;
        idCounter++;
        
        elem.id = id;
    }
    
    
    /********************************************************
     onkeydown event handler for the input elem.
     Enter key = use the highlighted suggestion, if there is one.
     Esc key = get rid of the autosuggest dropdown
     Up/down arrows = Move the highlight up and down in the suggestions.
     ********************************************************/
    elem.onkeydown = function(ev){
        var key = me.getKeyCode(ev);
        
        switch (key) {
            case ENTER:
                me.useSuggestion();
                break;
                
            case ESC:
                me.hideDiv();
                break;
                
            case KEYUP:
                if (me.highlighted > 0) {
                    me.highlighted--;
                }
                me.changeHighlight(key);
                break;
                
            case KEYDN:
                if (me.highlighted < (me.eligible.length - 1)) {
                    me.highlighted++;
                }
                me.changeHighlight(key);
                break;
        }
    };
    
    /********************************************************
     onkeyup handler for the elem
     If the text is of sufficient length, and has been changed,
     then display a list of eligible suggestions.
     ********************************************************/
    elem.onkeyup = function(ev){
        var key = me.getKeyCode(ev);
        switch (key) {
            //The control keys were already handled by onkeydown, so do nothing.
            case ENTER:
            case ESC:
            case KEYUP:
            case KEYDN:
                return;default:
                
                if (this.value != me.inputText && this.value.length > 0) {
                    me.inputText = this.value;
                    me.getEligible();
                    me.createDiv();
                    me.positionDiv();
                    me.showDiv();
                }
                else {
                    me.hideDiv();
                }
        }
    };
    
    
    /********************************************************
     Insert the highlighted suggestion into the input box, and
     remove the suggestion dropdown.
     ********************************************************/
    this.useSuggestion = function(){
        if (this.highlighted > -1) {
            this.elem.value = this.eligible[this.highlighted];
            this.hideDiv();
            //It's impossible to cancel the Tab key's default behavior. 
            //So this undoes it by moving the focus back to our field right after
            //the event completes.
            setTimeout("document.getElementById('" + this.elem.id + "').focus()", 0);
        }
    };
    
    /********************************************************
     Display the dropdown. Pretty straightforward.
     ********************************************************/
    this.showDiv = function(){
        this.div.style.display = 'block';
    };
    
    /********************************************************
     Hide the dropdown and clear any highlight.
     ********************************************************/
    this.hideDiv = function(){
        this.div.style.display = 'none';
        this.highlighted = -1;
    };
    
    /********************************************************
     Modify the HTML in the dropdown to move the highlight.
     ********************************************************/
    this.changeHighlight = function(){
        var lis = this.div.getElementsByTagName('LI');
        for (i in lis) {
            var li = lis[i];
            
            if (this.highlighted == i) {
                li.className = "selected";
            }
            else {
                li.className = "";
            }
        }
    };
    
    /********************************************************
     Position the dropdown div below the input text field.
     ********************************************************/
    this.positionDiv = function(){
        var el = this.elem;
        var x = 0;
        var y = el.offsetHeight;
        
        //Walk up the DOM and add up all of the offset positions.
        while (el.offsetParent && el.tagName.toUpperCase() != 'BODY') {
            x += el.offsetLeft;
            y += el.offsetTop;
            el = el.offsetParent;
        }
        
        x += el.offsetLeft;
        y += el.offsetTop;
        
        this.div.style.left = x + 'px';
        this.div.style.top = y + 'px';
    };
    
    /********************************************************
     Build the HTML for the dropdown div
     ********************************************************/
    this.createDiv = function(){
        var ul = document.createElement('ul');
        
        //Create an array of LI's for the words.
        for (i in this.eligible) {
            var word = this.eligible[i];
            
            var li = document.createElement('li');
            var a = document.createElement('a');
            a.href = "javascript:false";
            a.innerHTML = word;
            li.appendChild(a);
            
            if (me.highlighted == i) {
                li.className = "selected";
            }
            
            ul.appendChild(li);
        }
        
        this.div.replaceChild(ul, this.div.childNodes[0]);
        
        
        /********************************************************
         mouseover handler for the dropdown ul
         move the highlighted suggestion with the mouse
         ********************************************************/
        ul.onmouseover = function(ev){
            //Walk up from target until you find the LI.
            var target = me.getEventSource(ev);
            while (target.parentNode && target.tagName.toUpperCase() != 'LI') {
                target = target.parentNode;
            }
            
            var lis = me.div.getElementsByTagName('LI');
            
            
            for (i in lis) {
                var li = lis[i];
                if (li == target) {
                    me.highlighted = i;
                    break;
                }
            }
            me.changeHighlight();
        };
        
        /********************************************************
         click handler for the dropdown ul
         insert the clicked suggestion into the input
         ********************************************************/
        ul.onclick = function(ev){
            me.useSuggestion();
            me.hideDiv();
            me.cancelEvent(ev);
            return false;
        };
        
        this.div.className = "suggestion_list";
        this.div.style.position = 'absolute';
        
    };
    
    /********************************************************
     determine which of the suggestions matches the input
     ********************************************************/
    this.getEligible = function(){
        this.eligible = new Array();
        for (i in this.suggestions) {
            var suggestion = this.suggestions[i];
            
            if (suggestion.toLowerCase().indexOf(this.inputText.toLowerCase()) == "0") {
                this.eligible[this.eligible.length] = suggestion;
            }
        }
    };
    
    /********************************************************
     Helper function to determine the keycode pressed in a
     browser-independent manner.
     ********************************************************/
    this.getKeyCode = function(ev){
        if (ev) //Moz
        {
            return ev.keyCode;
        }
        if (window.event) //IE
        {
            return window.event.keyCode;
        }
    };
    
    /********************************************************
     Helper function to determine the event source element in a
     browser-independent manner.
     ********************************************************/
    this.getEventSource = function(ev){
        if (ev) //Moz
        {
            return ev.target;
        }
        
        if (window.event) //IE
        {
            return window.event.srcElement;
        }
    };
    
    /********************************************************
     Helper function to cancel an event in a
     browser-independent manner.
     (Returning false helps too).
     ********************************************************/
    this.cancelEvent = function(ev){
        if (ev) //Moz
        {
            ev.preventDefault();
            ev.stopPropagation();
        }
        if (window.event) //IE
        {
            window.event.returnValue = false;
        }
    }
}

//counter to help create unique ID's
var idCounter = 0;



function disableEnterKey(e){
    var key;
    
    if (window.event) 
        key = window.event.keyCode; //IE
    else 
        key = e.which; //firefox
    if (key == 13) 
        return false;
    else 
        return true;
}
$(document).ready(function (){
	if(($(".whp100_years").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('../images/bg_sensing.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});

/* Start script for Ambient Page Fusion */
$(document).ready(function (){
	if(($(".ambient_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/ambient/bg_ambient-line.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* End script for Ambient Page Fusion */

/* Start script for Zephyr Page Fusion */
$(document).ready(function (){
	if(($("#zephyr").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/zephyr/bg-page.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* End script for Zephyr Page Fusion */

/* Script for promo-waterfilter Page */
$(document).ready(function (){
	if(($(".promoWaterfilter_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/promoWaterfilter/background.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* Script for promoBaking-moulds Page */
$(document).ready(function (){
	if(($(".promoBaking-moulds_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/promoWaterfilter/background.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* Script for promoCleaning-hobs_page Page */
$(document).ready(function (){
	if(($(".promoCleaning-hobs_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/promoWaterfilter/background.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* Script for promoLuxury-accessories_page Page */
$(document).ready(function (){
	if(($(".promoLuxury-accessories_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/promoWaterfilter/background.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* Script for promoCrisp-plates_page Page */
$(document).ready(function (){
	if(($(".promoCrisp-plates_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/promoWaterfilter/background.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* Script for promoStainless-steel-cleaning_page Page */
$(document).ready(function (){
	if(($(".promoStainless-steel-cleaning_page").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/promoWaterfilter/background.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* Start script for Starclean */
$(document).ready(function (){
	if(($("#starclean").length > 0)){
		$("#page").css("background","none").css("marginTop","45px");
		$("body").css("background","url('/images/nl_NL/marketing-landing-pages/starclean/bg_ambient-line.jpg') no-repeat scroll center 0 #FFFFFF");
	}
});
/* End script for Starclean */

$(document).ready(function(){
	  $("#page.UserRegistration #box #WC_UserRegistrationAddForm_div_3 #WC_UserRegistrationAddForm_div_6 #WC_UserRegistrationAddForm_div_7 #WC_UserRegistrationAddForm_div_8 #WC_UserRegistrationAddForm_div_22 #WC_UserRegistrationAddForm_div_23 #WC_PersonalInfoExtension_mobile_div_mobileCountryCode").remove();  
      $("#page.UserRegistration #box #WC_UserRegistrationAddForm_div_3 #WC_UserRegistrationAddForm_div_6 #WC_UserRegistrationAddForm_div_7 #WC_UserRegistrationAddForm_div_8 #WC_UserRegistrationAddForm_div_22 #WC_UserRegistrationAddForm_FormInput_phoneNum_In_Register_1").before('<span id="WC_PersonalInfoExtension_mobile_div_mobileCountryCode">+31&nbsp;</span>'); 

	  //$("#page.UserRegistration #box #WC_UserRegistrationAddForm_div_3 #WC_UserRegistrationAddForm_div_6 #WC_UserRegistrationAddForm_div_7 #WC_UserRegistrationAddForm_div_8 #WC_PersonalInfoExtension_mobile_div_6 #WC_PersonalInfoExtension_mobile_div_mobileCountryCode").remove();  
      //$("#page.UserRegistration #box #WC_UserRegistrationAddForm_div_3 #WC_UserRegistrationAddForm_div_6 #WC_UserRegistrationAddForm_div_7 #WC_UserRegistrationAddForm_div_8 #WC_UserRegistrationAddForm_div_22 #WC_UserRegistrationAddForm_FormInput_phoneNum_In_Register_1").before('<span id="WC_PersonalInfoExtension_mobile_div_mobileCountryCode">+31&nbsp;</span>'); 
});

