').on('click', clearError);
if (prevErrors.length) {
clearError();
}
msg.append(close);
header.append(msg);
msg.slideDown();
}
}
function clearError() {
$(errorClass).remove();
return false;
}
function onGeolocateClicked() {
if (geolocateSupported) {
showLoading();
performSearch({});
}
}
function onZipSearchClicked() {
if (searchVal.val().length) {
showLoading();
performSearch({ zip: searchVal.val() });
} else {
presentError("Please enter an address or zipcode.");
}
}
function locationIcon(id, hover) {
var fill = hover ? 'fedf72' : 'fe7f72',
scale = '0.7',
text = alphabet[id];
return ('https://chart.apis.google.com/chart?chst=d_map_spin&chld=' + scale + '|0|' + fill + '|13|_|' + text);
}
function makeInfoHtml(id) {
html = $("#location-map-details-" + id).html();
if ($("#location_" + id).hasClass("location-details")) {
html = "
" + html;
}
return html;
}
function addMarker(address) {
var locId = address.id.split('location_')[1],
location = $('#' + address.id);
var icon = $('
')
.addClass("location-pin")
.html($('
', { src: locationIcon(locId) }));
if (!location.hasClass("location-details")) {
location
.wrapInner($('
', { 'class': 'location-address' }))
.prepend(icon);
var marker = new google.maps.Marker({
map: map,
position: address.latlong,
title: address.address,
animation: google.maps.Animation.DROP,
icon: locationIcon(locId, false)
});
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(makeInfoHtml(locId));
map.panTo(marker.getPosition());
infoWindow.open(map, marker);
sidebar.scrollTo(location, 300);
$('div.location-selected').removeClass("location-selected");
$('#' + address.id).addClass('location-selected');
});
location.bind('mouseover', function() {
marker.setIcon(locationIcon(locId, true));
icon.find('img').attr({ src: locationIcon(locId, true) });
});
location.bind('mouseout', function() {
marker.setIcon(locationIcon(locId, false));
icon.find('img').attr({ src: locationIcon(locId, false) });
});
location.bind('click', function(e, options) {
google.maps.event.trigger(marker, 'click');
var zoom = map.getZoom();
if (options && options.zoom && zoom <= 7) {
map.setZoom(10);
}
});
} else {
var marker = new google.maps.Marker({
map: map,
position: address.latlong,
title: address.address,
animation: google.maps.Animation.DROP,
icon: locationIcon(locId, false)
});
infoWindow.setContent(makeInfoHtml(locId));
infoWindow.open(map, marker);
}
}
return {
init: initialize
};
})();
$(document).ready(function(){
if ($('div.has-icons').is("*")) {
FBSM.W.fitHeaderIcons();
}
FBSM.W.recalculateUnitScroller();
if(FBSM.W.miniPromos) {
if($("#polarisPromo").length > 0) {
if($.grep(FBSM.W.miniPromos, function(a){ return a.name=="polaris"; }).length>0) {
FBSM.W.swapMiniPromos("polaris");
} else {
$("#polarisPromo").parents(".sidebarWidgetControl").css("display", "none");
}
}
if($("#suzukiPromo").length > 0) {
if($.grep(FBSM.W.miniPromos, function(a){ return a.name=="suzuki"; }).length>0) {
FBSM.W.swapMiniPromos("suzuki");
} else {
$("#suzukiPromo").parents(".sidebarWidgetControl").css("display", "none");
}
}
}
if (FBSM.W.promotionsWidgetType) {
if (FBSM.W.promotionsWidgetType == "brand") {
var factPromos = $('.sidebarWidgetControl.minipromo'),
brands = factPromos.find('.typeLayerList > li'),
holder = factPromos.find('.typeLayerList.holder');
var hidePromoList = function(e) {
e.preventDefault();
var li = $(this);
li.unbind('click').click(showPromoList);
li.find('.backUp').remove();
li.removeClass('typeSelected');
li.find('.promoList').append(holder.children()).hide();
li.siblings().show();
};
var showPromoList = function(e) {
e.preventDefault();
var li = $(this);
var closeLink = $('', { 'class': 'backUp' }).text('[x]');
closeLink.click(hidePromoList);
li.unbind('click').bind('click', hidePromoList);
li.addClass('typeSelected');
li.siblings().hide();
holder.append(li.find('.promoList').children());
li.append(closeLink);
};
brands.each(function() { $(this).click(showPromoList); });
brands.parent('li').hover(
function() { $(this).addClass('liHover') },
function() { $(this).removeClass('liHover') }
);
} else {
if (FBSM.W.miniPromoLogos.length > 0) {
if (FBSM.W.miniPromoLogos.length > 1) {
FBSM.W.swapMiniPromoLogo();
} else {
var img = new Image();
var imgsrc = FBSM.W.miniPromoLogos[0].imageUrl;
if (document.location.protocol == "https:") {
imgsrc = imgsrc.replace("http://images.endeavorsuite.com", "https://media.50below.com").replace("http://media.50below.com", "https://media.50below.com");
}
$(img).load(function() {
$(this).hide();
$('#miniPromo a').html(this);
$(this).fadeIn();
}).attr('src', imgsrc).css('border', 0);
}
} else {
$("#miniPromo").parents(".sidebarWidgetControl").css("display", "none");
}
}
}
$("#sidebarWidget_Container").on("click", "#ari_partStreamWidget_submit", function() {
if ($("#ari_brand option:selected").val() != "---") {
if ($.trim($("#ari_model").val()) != "" || $.trim($("#ari_part").val()) != "") {
window.location.href = "oempartfinder.htm#/s/" + $("#ari_brand option:selected").val().replace(/[_]/g, "%7C~") + "/" + $("#ari_model").val() + "/" + $("#ari_part").val() + "/1";
window.scrollTo(0, 0);
} else {
window.location.href = "oempartfinder.htm?aribrand=" + $("#ari_brand option:selected").val() + "&arian=" + $("#ari_type option:selected").val();
}
} else {
alert("Please select Brand to search");
}
});
$("#sidebarWidget_Container").on("change", "#ari_brand", function() {
var brand = $(this).find(":selected").val();
$.ajax({
url: "Services/PartStreamApiService.aspx",
type: "POST",
data: {
"action": "getassemblies",
"brandCode": brand
},
success: function(res) {
$("#ari_type").html("");
$("#ari_type").append(res);
$("#ari_type").append(" ");
},
error: function(e) {
$("#ari_type").html("");
$("#ari_type").append("--- ");
$("#ari_type").append(" ");
}
});
});
if(typeof(alphabet)!="undefined" && alphabet) {
if($('.location-info').length > 0) {
FBSM.C.LocationMappingWidget.init(alphabet, $('.location-info'));
}
if($('.locationmapping').length > 0) {
FBSM.C.LocationMappingWidget.init(alphabet, $('.locationmapping'));
}
}
$('#pd-more-shipping').click(function(event) {
$('#pd-cartwidget-selected-shipping').fadeOut(function() {
$('#pd-cartwidget-all-shipping').fadeIn();
});
event.preventDefault();
});
$('#pd-cartwidget-update-shipping').click(function() {
var $rdo = $('input[name=select-shipping]:checked', "#pd-cartwidget-all-shipping");
var selectedMethodId = $rdo.closest('div').find(".select-shipping-id").val();
$.ajax({
type: "POST",
url: 'Services/WidgetServices.aspx',
data: "action=updateshipping&shipping=" + selectedMethodId,
dataType: "html",
contentType: "application/x-www-form-urlencoded",
success: function(res) {
if (res == "") {
$('#pd-active-shipping').html($rdo.val());
$('#pd-cartwidget-selectedMethod').val(selectedMethodId);
$('#pd-cartwidget-all-shipping').fadeOut(function() {
$('#pd-cartwidget-selected-shipping').fadeIn();
});
} else {
alert(res);
}
}
});
});
if ($('#productGroupWidget .slidingWidgetRotator').length > 0) {
$('#productGroupWidget .slidingWidgetGroupRotator').serialScroll({
items: 'li',
prev: '#productGroupWidget .slidingWidgetControls a.prev',
next: '#productGroupWidget .slidingWidgetControls a.next',
offset: 0,
start: 0,
duration: 1200,
force: true,
stop: true,
lock: false,
cycle: true,
easing: 'easeOutQuart',
jump: false,
constant: false,
interval: 8000
});
} else {
$("#productGroupWidget").parents(".sidebarWidgetControl").css("display", "none");
}
if ($('#usedVehicleWidget .slidingWidgetRotator').length > 0) {
$('#usedVehicleWidget .slidingWidgetGroupRotator').serialScroll({
items: 'li',
prev: '#usedVehicleWidget .slidingWidgetControls a.prev',
next: '#usedVehicleWidget .slidingWidgetControls a.next',
offset: 0,
start: 0,
duration: 1200,
force: true,
stop: true,
lock: false,
cycle: true,
easing: 'easeOutQuart',
jump: false,
constant: false,
interval: 8000
});
} else {
$("#usedVehicleWidget").parents(".sidebarWidgetControl").css("display", "none");
}
if ($('#usedVehicleWidget #rotatorCount').html() > 15) {
$('#usedVehicleWidget .slidingWidgetViewLink').show();
if ($('#usedVehicleWidget #rotatorShowroom').html() != '') {
$('#usedVehicleWidget .viewAll').attr('href', 'showcaseproductlist.htm?showrooms=' + $('#usedVehicleWidget #rotatorShowroom').html());
}
}
if($("#nlEmail").length > 0) {
$("#nlEmail").click(function() {
$("#nlFormTable").fadeIn();
});
$("#nlSubmit").click(function() {
$.ajax({
type: "POST",
url: "Services/WidgetServices.aspx",
data: "action=SubmitNewsLetter&FirstName=" + $("#nlFirstName").val() + "&LastName=" + $("#nlLastName").val() + "&Email=" + $("#nlEmail").val() + "&Captcha=" + $("#nlCaptcha").val() + "&ReceiveOffers=" + $("#receiveOffers").is(":checked").toString(),
dataType: "html",
contentType: "application/x-www-form-urlencoded",
success: function(response) {
if (response != '') {
$("#nlFirstName,#nlLastName,#nlEmail,#nlCaptcha").removeClass("nlFieldError");
var responseParts = response.split('|');
$("#nlFieldError").html(responseParts[0]);
$("#nlFieldError").show();
if (responseParts.length > 1) {
var responseFields = responseParts[1].split(':');
for (var i = 0; i < responseFields.length; i++) {
$("#nl" + responseFields[i]).addClass("nlFieldError");
}
$("#nlFormTable").fadeIn();
}
} else {
$("#nlFieldError").hide();
$("#nlSubmitted,#newsletterForm").toggle();
FBSM.C.loadCustomJavascriptParametersFromSource('s.linkTrackVars="events,eVar7,eVar37,prop27";s.linkTrackEvents="event5";s.events="event5";s.eVar7="Lead: Newsletter Widget";s.prop27={@siteId};s.eVar37=s.prop27;');
}
FBSM.C.captchaRefresh('nlCaptchaImage');
}
});
});
$("#nlClose").click(function() {
$("#nlFirstName,#nlLastName,#nlEmail,#nlCaptcha").removeClass("nlFieldError");
$("#nlFirstName,#nlLastName,#nlEmail,#nlCaptcha").val('');
$("#nlFormTable").hide();
$("#nlSubmitted,#newsletterForm").toggle();
});
}
});