$(document).ready(function() {
reviewPos = 0;
$("#review_navi div:nth-child(2) a:nth-child(1)").fadeTo('slow', 0.4);
//Turn off autocomplete
$("#search_box #ctl00_search").attr("autocomplete", "off");
//Left menu products click effect on whole button
$("#left_column .products li, #header_container .icons div").click(
function() {
window.location = $(this).find('a').attr("href");
}
);
if ($("#ctl00_main_content_home_banners").length > 0) {
slideHomeBanner("right", false);
}
//Product overview click effect on whole button
productClickAction();
//Homepage brand buttons mouseovers
$("#ctl00_main_content_home_brands img, #ctl00_main_content_brands img, #ctl00_main_content_content_block .block_rs img").hover(function() {
//Mouseover
filename = $(this).attr("src").split('/')[3];
$(this).attr("src", "/dynamic/brand_logos/" + filename.split('.')[0] + "_over." + filename.split('.')[1])
}, function() {
//Mouseout
$(this).attr("src", "/dynamic/brand_logos/" + filename);
}).click(function() { $(this).attr("src", "/dynamic/brand_logos/" + filename); });
//Attach click actions
$("#ctl00_login_button:not(:contains('backoffice')):not(:contains('afmelden'))").click(function() {
createLoginOverlay();
return false;
});
//Attach click actions on register button
$("#ctl00_register_button").click(function() {
createRegisterOverlay();
return false;
});
$("input[type=submit].checkform").click(function() {
checkForm($(this).parents('form').attr("id"));
return false;
});
$("#afleveradres_container input[type=text]").change(function() {
$("#afleveradres, #quick_afleveradres").checkBox('changeCheckStatus', true);
});
//Create tooltips
$(".spec_icons img[alt]").each(function() {
if ($(this).attr('alt') != '') {
$(this).qtip({
content: { text: false },
position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle'} },
style: { name: 'cream', width: { min: 200, max: 400 }, border: { radius: 4} }
});
}
});
$("img.ctip").each(function() {
if ($(this).attr('alt') != '') {
$(this).qtip({
content: { text: false },
position: { corner: { target: 'bottomMiddle', tooltip: 'topMiddle'} },
style: { name: 'cream', width: { min: 200, max: 400 }, border: { radius: 4} }
});
}
});
$("area[alt], a.qtip").each(function() {
if ($(this).attr('alt') != '') {
$(this).qtip({
content: { text: false },
position: { corner: { target: 'topMiddle', tooltip: 'bottomMiddle' }, adjust: { y: -5} },
style: { name: 'cream', border: { radius: 4} },
show: { delay: 0 },
effect: { length: 0 }
});
}
});
$("a.pin[title]").each(function() {
if ($(this).attr('title') != '') {
$(this).qtip({
content: { text: false },
position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle'} },
style: { name: 'cream', width: { min: 200, max: 400 }, border: { radius: 4} }
});
}
});
$(".review_products b[title], .fullreview span[title]").each(function() {
if ($(this).attr('title') != '') {
$(this).qtip({
content: { text: false },
position: { corner: { target: 'topMiddle', tooltip: 'bottomMiddle' }, adjust: { y: -5} },
style: { name: 'cream', width: { max: 190 }, border: { radius: 4} }
});
}
});
//Newsletter input field functions
$("#nieuwsbrief_email").focus(function() {
if ($(this).val() == "E-mail adres") {
$(this).addClass("black");
$(this).val("");
}
});
$("#nieuwsbrief_email").blur(function() {
if ($(this).val() == "") {
$(this).removeClass("black");
$(this).val("E-mail adres");
}
});
$("#search_box #ctl00_search").keyup(function(e) {
dropdownbox = $(".search_suggestion");
if ($("#search_box #ctl00_search").val().length > 0) {
$.get("/ajax/search", { searchinput: $("#search_box #ctl00_search").val() },
function(data) {
dropdownbox.css({ "right": "75px", "top": "70px", "display": "block" });
dropdownbox.html(data);
$("#ctl00_page_container").append(dropdownbox);
});
} else {
dropdownbox.slideUp("fast");
}
});
$("#search_box #ctl00_search").blur(function() {
$(".search_suggestion").delay(150).slideUp("fast");
});
//Convert checkboxes
$("input[type=checkbox], input[type=radio]").each(function() { $(this).checkBox() });
$(".faq .q").toggle(
function() {
$(this).next().slideDown();
$(this).next(".active").slideUp();
},
function() {
$(this).next().slideUp();
$(this).next(".active").slideDown();
}
);
//Create nice search URL
$("#search_box form").submit(function() {
var params = $("#search_box form #ctl00_search").val().replace(new RegExp(" ", "g"), "+");
location.href = $(this).attr("action") + '/' + params + '/';
return false;
});
$("#frm_quicksearch a[rel=submit]").click(function() {
$(this).parent("form").submit();
return false;
});
//Clear out dotted line on all link focus
$("a").focus(function() { this.blur(); });
//Check if filter block is open or closed
if ($("#ctl00_main_content_filter_block.quicksearch").length > 0) {
filter_open = true;
}
else {
filter_open = false;
}
pinned = false;
//Filter block display toggle and pin
$(".brandfilter #filter_content a.link").toggle(function() {
$("#ctl00_main_content_filter_block #filter_content").animate({ height: "220px" }, 500);
filter_open = true;
$(this).css("background-position", "right 6px");
}, function() {
$("#ctl00_main_content_filter_block #filter_content").animate({ height: "0" }, 500);
filter_open = false;
$(this).css("background-position", "right -8px");
});
//Filter block display toggle and pin on quick search page
$(".quicksearch #filter_content a.link").toggle(function() {
$("#ctl00_main_content_filter_block #filter_content").animate({ height: "0" }, 500);
filter_open = false;
$(this).css("background-position", "right -8px");
$(this).text("Klik hier om dit venster uit te klappen");
}, function() {
$("#ctl00_main_content_filter_block #filter_content").animate({ height: "220px" }, 500);
filter_open = true;
$(this).css("background-position", "right 6px");
$(this).text("Klik hier om dit venster in te klappen");
});
$("#filter_content a.pin").toggle(function() {
pinned = true;
$(this).css("background-position", "0 0px");
}, function() {
pinned = false;
$(this).css("background-position", "0 -21px");
});
$("#quick_zakelijk").click(function() {
if ($("#ctl00_main_content_zakelijk_container:hidden").length > 0) {
$("#ctl00_main_content_zakelijk_container").show();
} else {
$("#ctl00_main_content_zakelijk_container").hide();
$("#ctl00_main_content_zakelijk_container input").val("");
}
});
//Submit basket action
$("a.basket_add").click(function() {
lengt_arr = $(this).attr("href").split('/').length;
get_product_id = $(this).attr("href").split('/')[lengt_arr - 1];
if ($(this).parents("div.transfer_src").length > 0) {
src_item = $(this).parents("div.transfer_src");
} else {
src_item = $(".photo_container");
}
$.ajax({
type: "POST",
url: "ajax/order",
cache: true,
dataType: "html",
data: "auth=782579&product_id=" + get_product_id,
error: checkAjaxError,
success: function(msg) {
if (msg != "NONE") {
createOverlay();
container_obj = createOverlayContainer(140);
container_obj.html(msg);
$("#frm_addbasket select").sSelect();
$("#frm_addbasket input[type=submit]").click(function() {
submitToBasket(get_product_id, $("#frm_addbasket #garantie").val(), src_item);
closeOverlay();
return false;
})
} else {
submitToBasket(get_product_id, 0, src_item);
}
}
});
return false;
});
//Tabs
$(".tabs a").click(function() {
$(".tabs a").removeClass("active");
$(this).addClass("active");
$(".tab_subcontainer .content").addClass("hidden");
$("div#" + $(this).attr("id").split('_')[1]).removeClass("hidden");
return false;
});
//Payment radio behaviour
$("input[type=radio][name=verzendwijze]").click(function() {
if ($(this).val() == "3") {
$("input[type=radio][name=betaalmethode]:not(#betaalmethode_rembours)").attr({ disabled: true });
$("#betaalmethode_rembours").checkBox('changeCheckStatus', true);
} else if ($(this).val() == "4") {
$("input[type=radio][name=betaalmethode]:not(#betaalmethode_paypal)").attr({ disabled: false });
$("#betaalmethode_contant").checkBox('changeCheckStatus', false);
} else {
$("input[type=radio][name=betaalmethode]:not(#betaalmethode_paypal)").attr({ disabled: false });
$("#betaalmethode_rembours").checkBox('changeCheckStatus', false);
$("#betaalmethode_contant").attr({ disabled: true });
$("#betaalmethode_contant").checkBox('changeCheckStatus', false);
}
});
$("input[type=radio][name=betaalmethode]").click(function() {
if ($(this).val() == "rembours") {
$("#verzendwijze_3").checkBox('changeCheckStatus', true);
} else {
$("#verzendwijze_3").checkBox('changeCheckStatus', false);
}
});
if ($("#ctl00_main_content_quickorder_container").css("display") == "block") {
$("#frm_klantgegevens select").sSelect();
}
//Basket
runBasketActions();
$("#quick_account_postcode").change(function() {
if ($("#quick_account_land").val() == "137") {
formatPostcode($(this));
}
});
$("#quick_account_land").change(function() {
if ($("#quick_account_land").val() == "137") {
formatPostcode($("#quick_account_postcode"));
}
formatPhoneNumber("quick_account_telefoon", $("#quick_account_land").val());
});
$("#quick_account_postcode").change(function() {
if ($("#quick_account_land").val() == "137") {
formatPostcode($(this));
}
});
$("#quick_aflever_land").change(function() {
if ($("#quick_aflever_land").val() == "137") {
formatPostcode($("#quick_aflever_postcode"));
}
});
$("#quick_aflever_postcode").change(function() {
if ($("#quick_aflever_land").val() == "137") {
formatPostcode($(this));
}
});
$("#aflever_land").change(function() {
if ($("#aflever_land").val() == "137") {
formatPostcode($("#aflever_postcode"));
}
});
$("#aflever_postcode").change(function() {
if ($("#aflever_land").val() == "137") {
formatPostcode($(this));
}
});
//Ajax filter en sorteer
if ($("#frm_filtersort #action").val() == "submit") {
$("#frm_filtersort #action").val("");
filterSorteer("frm_filtersort");
}
$("#ctl00_main_content_filter_block input[type=submit]").click(function() {
form_id = $(this).parents('form').attr("id");
filterSorteer(form_id);
return false;
});
//Indien pagina wordt gescrolled
if ($("#ctl00_main_content_filter_block").length > 0) {
$(document).scroll(setBlockOffset);
}
$(".star1, .star2, .star3, .star4, .star5").click(function() {
var map_id = $(this).parent("map").attr("id");
var star_value = $(this).attr("class").charAt(4);
$("#input_" + map_id).val(star_value);
$("#" + map_id.replace("map_", "")).attr("src", "images/stars_" + star_value + ".png");
});
$("#merken_filter").change(function() {
location.href = $("#merken_filter").parent("form").attr("action") + "/" + $(this).val();
});
if ($(".icon_review").length > 0)
swapRateImg();
if ($(".news").length > 0)
writeNews();
$("#ctl00_main_content_news_tag, .newspaper").click(
function() { window.location = "/nieuws"; }
);
$("#advantage_buttons div:not(.active)").hover(function() {
$(this).css("background", "url('/images/advantage_buttons_hover.png') no-repeat");
$(this).find("img").css("margin", "10px 0 0 0");
}, function() {
$(this).css("background", "none");
$(this).find("img").css("margin", "8px 0 0 0");
});
});
function writeNews() {
$(".news div:first a").jTypeWriter({ duration: 2, onComplete: scrollNews });
}
function scrollNews() {
$(".news div:first a").append('
');
setTimeout(function() { $(".news div:first").appendTo(".news"); writeNews(); }, 5000);
}
function swapRateImg() {
setTimeout(function() { $(".icon_review").attr("src", "/images/read_brandreviews_3.png"); }, 3500);
setTimeout(function() { $(".icon_review").attr("src", "/images/read_brandreviews_5.png"); }, 7000);
setTimeout(function() { $(".icon_review").attr("src", "/images/read_brandreviews_4.png"); swapRateImg(); }, 10500);
}
function formatPhoneNumber(inputfield, country) {
if (country == "137") {
$("#" + inputfield).val("+31(0)");
}
else if (country == "19") {
$("#" + inputfield).val("+32(0)");
}
else if (country == "116") {
$("#" + inputfield).val("+352(0)");
}
else if (country == "75") {
$("#" + inputfield).val("+49(0)");
}
$("#" + inputfield).focus();
}
function submitToBasket(product_id, garantie, src_block) {
$.ajax({
type: "POST",
url: "ajax/orderproduct",
cache: true,
dataType: "html",
data: "auth=283071&product_id=" + product_id + "&garantie=" + garantie,
error: checkAjaxError,
success: function(msg) {
src_block.delay(400).effect('transfer', { to: ".basket", className: 'ui-effects-transfer' }, 1200, function() {
$("#ctl00_basket_size span").html(msg.split(';')[0]);
$("#ctl00_total_price span").html("€ " + addThousandSep(msg.split(';')[1]) + ",00");
});
}
});
}
function addThousandSep(input) {
var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
while (sRegExp.test(input)) {
input = input.replace(sRegExp, '$1.$2');
}
return input;
}
function runBasketActions() {
$("#ctl00_main_content_winkelmandje input[type=text]").focus(function() { $(this).select(); });
$("#ctl00_main_content_winkelmandje input[type=text]").keyup(function() {
return checkForm($(this).parents('form').attr("id"));
});
$("#ctl00_main_content_winkelmandje img").click(function() {
product_id = $(this).parents("tr").attr("id").split('_')[1];
updateBasket(product_id);
});
}
function productClickAction() {
$(".content_producten .item, #ctl00_main_content_home_offers .item").click(
function() {
window.location = $(this).find('a').attr("href");
}
)
}
function updateBasket(delete_id) {
add_query = "";
if (isNaN(delete_id) == false) {
add_query = "delete_id=" + delete_id + "&";
}
$.ajax({
type: "POST",
url: "ajax/updatebasket",
cache: true,
dataType: "html",
data: "auth=656559&" + add_query + createAjaxPost("frm_basket"),
error: checkAjaxError,
success: function(msg) {
$("#ctl00_basket_size span").html(msg.split('[;]')[0]);
$("#ctl00_total_price span").html("€ " + addThousandSep(msg.split('[;]')[1]) + ",00");
$("#ctl00_main_content_mandje_contents").html(msg.split('[;]')[2]);
runBasketActions();
}
});
}
function setBlockOffset() {
var currentOffset = $(document).scrollTop();
if ($("#ctl00_main_content_filter_block.quicksearch").length > 0) {
offsetTrigger = 279;
} else {
offsetTrigger = 684;
}
if (pinned == true) {
if (currentOffset > offsetTrigger) {
if (filter_open == true) {
$("#ctl00_main_content_producten").css("margin-top", "251px");
} else {
$("#ctl00_main_content_producten").css("margin-top", "45px");
}
$("#ctl00_main_content_filter_block").css("position", "fixed");
$("#ctl00_main_content_filter_block").css("top", "0");
if (window.location.hostname.split(".")[0] == "otto-shopping" || "otto")
$("#ctl00_main_content_filter_block").css("width", "765px");
else
$("#ctl00_main_content_filter_block").css("width", "780px");
} else {
$("#ctl00_main_content_producten").css("margin-top", "0");
$("#ctl00_main_content_filter_block").css("position", "relative");
$("#ctl00_main_content_filter_block").css("top", "");
}
} else if (pinned == false && currentOffset < (offsetTrigger + 1)) {
$("#ctl00_main_content_producten").css("margin-top", "0");
$("#ctl00_main_content_filter_block").css("position", "relative");
$("#ctl00_main_content_filter_block").css("top", "");
}
}
function filterSorteer(form_id) {
disableSubmitButton(form_id);
$.ajax({
type: "POST",
url: "ajax/filtersorteer",
cache: true,
dataType: "html",
data: createAjaxPost(form_id),
error: checkAjaxError,
success: function(msg) {
$("#ctl00_main_content_producten").html(msg);
$("#ctl00_main_content_producten").fadeTo(0, 0).fadeTo(1000, 1);
enableSubmitButton(form_id);
productClickAction();
}
});
}
function slideHomeBanner(dir, manual) {
if (manual == true) {
clearTimeout(autorun);
manualrun = setTimeout(function() { animateHomeBanner(dir); }, 50);
$("#progress").stop();
$("#progress").css("height", "0");
} else {
$("#progress").animate({ height: '268px' }, 9000, function() { $("#progress").css("height", "0"); });
autorun = setTimeout(function() { animateHomeBanner(dir); }, 9000);
}
}
function animateHomeBanner(dir) {
if (dir == "left") {
$(".text_container").slideUp(500, function() {
//Set link on image overlay for correct banner click
link = $("#ctl00_main_content_home_banners img").eq(0).parent("a").attr("href");
if (link.length > 0) {
$("#home_banner_link a").attr("href", link);
} else {
$("#home_banner_link a").removeAttr("href");
}
var clonedText = $("#ctl00_main_content_text_placeholder .item:last").remove();
$("#ctl00_main_content_text_placeholder").prepend(clonedText);
curr_active = $("#ctl00_main_content_item_blocks div.active").index();
$("#ctl00_main_content_item_blocks div").eq(curr_active).removeClass("active");
if ((curr_active + 1) < 1) { new_active = $("#ctl00_main_content_item_blocks div").length; }
else { new_active = (curr_active - 1); }
$("#ctl00_main_content_item_blocks div").eq(new_active).addClass("active");
});
$("#ctl00_main_content_home_banners").animate({ left: '+=600' }, 1000, 'easeInOutBack', function() {
$(".text_container").slideDown(350, function() {
var clonedElm = $("#ctl00_main_content_home_banners img:last").parents("a").remove();
$("#ctl00_main_content_home_banners").prepend(clonedElm);
newpos = (parseInt($("#ctl00_main_content_home_banners").css("left")) - 600);
$("#ctl00_main_content_home_banners").css("left", newpos + "px");
slideHomeBanner("right", false);
});
});
}
else {
$(".text_container").slideUp(500, function() {
//Set link on image overlay for correct banner click
link = $("#ctl00_main_content_home_banners img").eq(2).parent("a").attr("href");
if (link.length > 0) {
$("#home_banner_link a").attr("href", link);
} else {
$("#home_banner_link a").removeAttr("href");
}
var clonedText = $("#ctl00_main_content_text_placeholder .item:first").remove();
$("#ctl00_main_content_text_placeholder").append(clonedText);
curr_active = $("#ctl00_main_content_item_blocks div.active").index();
$("#ctl00_main_content_item_blocks div").eq(curr_active).removeClass("active");
if ((curr_active + 1) > ($("#ctl00_main_content_item_blocks div").length - 1)) { new_active = 0; }
else { new_active = (curr_active + 1); }
$("#ctl00_main_content_item_blocks div").eq(new_active).addClass("active");
});
$("#ctl00_main_content_home_banners").animate({ left: '-=600' }, 1000, 'easeInOutBack', function() {
$(".text_container").slideDown(350, function() {
var clonedElm = $("#ctl00_main_content_home_banners img:first").parents("a").remove();
$("#ctl00_main_content_home_banners").append(clonedElm);
newpos = (parseInt($("#ctl00_main_content_home_banners").css("left")) + 600);
$("#ctl00_main_content_home_banners").css("left", newpos + "px");
slideHomeBanner("right", false);
});
});
}
}
function createRegisterOverlay(lsection) {
$.getScript('/js/pwd_meter.js', function() {
createOverlay();
container_obj = createOverlayContainer(504);
container_obj.html(
"
Er is succesvol een e-mail verstuurd naar " + msg.split(":")[1] + ".
"); setTimeout(function() { closeOverlay() }, 4000); } else { $(".overlay .container .subcontainer").html(msg); } } }); } function createLoginOverlay(lsection) { if ($(".overlay").length == 0) { createOverlay(); } if ($(".overlay .container").length > 0) { $(".container").remove(); $(".container_bottom").remove(); } container_obj = createOverlayContainer(140); container_obj.html( "" ); $("#login_email").focus(); $(".overlay form input[type=submit]").click(function() { return checkForm($(this).parents('form').attr("id")); }) } function login() { $.ajax({ type: "POST", url: "/webservices/authenticate", dataType: "xml", data: "username=" + $('#login_email').val() + "&password=" + $('#login_password').val(), error: checkAjaxError, success: function(result) { result_string = $(result).find("string").text().split('[;]'); if (result_string[0] == "AUTH-SUCCESS") { if (result_string[1] == "NONE") { location.reload(); } else { location.href = result_string[1]; } } else { markErrorField("login_email", ""); markErrorField("login_password", ""); } } }); } function register(form_id) { $.ajax({ type: "POST", url: "/ajax/saveaccount", dataType: "html", data: createAjaxPost(form_id), error: checkAjaxError, success: function(result) { $(".subcontainer").html(result); } }); } function tempLang(lang) { createOverlay(); container_obj = createOverlayContainer(80); if (lang == "en") { container_obj.html("The BensonTrade website will soon be available in english.
"); } else if (lang == "de") { container_obj.html("Unsere Deutsche BensonTrade Webseite ist bald verfügbar.
"); } } function quickOrder() { $("#validation").val("715390"); if ($("#ctl00_main_content_quickorder_container:visible").size() == 0) { $("#ctl00_main_content_quickorder_container").slideDown(1200, function() { $("#klantgegevens_container a:lt(2)").delay(250).fadeTo(1000, 0.4); }); $("#frm_klantgegevens select").sSelect(); } } function navReviewRight() { if (reviewPos < ($("#review_container .review_item").length - 1)) { reviewPos++; $("#review_viewport").animate({ marginLeft: '-=750' }, 1500, 'easeInOutBack', function() { $("#review_no").text((reviewPos + 1)) }); $("#review_navi div:nth-child(2) a:nth-child(1)").fadeTo('slow', 1); if (reviewPos == ($("#review_container .review_item").length - 1)) $("#review_navi div:nth-child(2) a:nth-child(2)").fadeTo('slow', 0.4); } } function navReviewLeft() { if (reviewPos > 0) { reviewPos--; $("#review_viewport").animate({ marginLeft: '+=750' }, 1500, 'easeInOutBack', function() { $("#review_no").text((reviewPos + 1)) }); $("#review_navi div:nth-child(2) a:nth-child(2)").fadeTo('slow', 1); if (reviewPos == 0) $("#review_navi div:nth-child(2) a:nth-child(1)").fadeTo('slow', 0.4); } }