/**
* site.js
*
* common scripts, site events v3.0
* !!optimize later !!
*
* RichardG - 08.22.2013
*/
/** OCS namespace **/
var OCS = (function () {
"use strict";
var s;
function alertLoaded() {
// !! Remove on production site !!
if (s.debug == true) {
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
console.log("You're using Safari, my friend.. No perfomance timing for you.");
} else {
var now = new Date().getTime(); //current time
var page_load_time = now - performance.timing.navigationStart; //page load time
if (window.console) console.log('OCS DOMContent loaded in: ' + page_load_time + ' ms');
}
}
}
return {
settings: {
debug: false //set to FALSE on production
},
init: function () {
s = this.settings;
this.bindUIActions();
alertLoaded();
},
bindUIActions: function () {
var brands = $("#select-brands"); //Brands drop-down on header
var backToTop = $("a.back-to-top"); //Back-to-Top links on pages
/////////////////////////////////////////////////////////////////
// 'Brands' search on site header SiteV2.Master
/////////////////////////////////////////////////////////////////
brands.change(function () {
if ($(this).val()) {
window.location = $(this).val();
}
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Expander function AttributesFilterControl.ascx
/////////////////////////////////////////////////////////////////
$("span.expander").on("click", function (e) {
var p = $(this).parent().next();
if ($(this).hasClass("minus")) {
$(this).removeClass("minus").addClass("plus");
$(p).slideUp();
} else {
$(this).removeClass("plus").addClass("minus");
$(p).slideDown();
}
});
$("span.table-expander").on("click", function (e) {
var t = $(this).parent().next();
if ($(this).hasClass("minus")) {
$(this).removeClass("minus").addClass("plus");
$(t).slideUp();
} else {
$(this).removeClass("plus").addClass("minus");
$(t).slideDown();
}
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//'remove' items on product-compare table -
// [1] also adjust scrollbar to reflect removed columns
// [2] width of columns also auto-adjust to fit table especially when there are few columns to compare
/////////////////////////////////////////////////////////////////
$("#dgCompare").on("click", "a.delete", function (e) {
var colnum = $(this).closest("td").prevAll("td").length;
$(this).closest("table.products-table tbody").children("tr").each(function () {
$(this).children("td:eq('" + colnum + "')").animate({ opacity: "toggle" }, 1000, function () {
$(this).remove();
});
});
e.preventDefault();
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Product reviews - slide up|down /CarAudio/ProductReview.aspx
/////////////////////////////////////////////////////////////////
$(document).on("click", "a.write-review", function (e) {
$("#divReviewForm").slideDown(750);
$('html, body').animate({ scrollTop: $('#hTitle2').offset().top - 100 }, 'slow');
e.preventDefault();
});
//'more info' hide|show effect (smoother) on Product Review page
$("a.more-info").on("click", function (e) {
$("p#more-info").slideToggle(250, function () {
$("a.more-info").text($(this).is(":visible") ? "(-) less info" : "(+) more info");
}).removeClass('hidden');
e.preventDefault();
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// back-to-top button all applicable pages
//'document' added to make it work on Safari
/////////////////////////////////////////////////////////////////
backToTop.on("click", function (e) {
$("body,html,document").animate({ scrollTop: 0 }, 800);
e.preventDefault();
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Tabs - scroll effect when clicked for mobile
// - default.aspx, caraudio/productdetails.aspx
/////////////////////////////////////////////////////////////////
/*$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
//smooth scroll on mobile browser
if (window.innerWidth <= 800) {
$('html, body').animate({
scrollTop: $($.attr(e.target, 'href')).offset().top - 200
}, 500);
return false;
}
});*/
$("ul.nav-tabs li a").on("click", function (e) {
//smooth scroll on mobile browser
if (window.innerWidth <= 800) {
$("body,html,document").stop(true, true);
$("body,html,document").animate({ scrollTop: $("ul.nav-tabs").offset().top - 20 }, 500);
}
e.preventDefault();
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Star ratings on Product Details page
// - caraudio/productdetails.aspx, UIControlsV2/ProductDetailControl.ascx
/////////////////////////////////////////////////////////////////
$('a.star-review').on('click', function (e) {
$('#product-detail-tabs a[href="#divProdReviews"]').tab('show');
$("body,html,document").animate({ scrollTop: $("ul.nav-tabs").offset().top - 20 }, 500);
e.preventDefault();
})
/////////////////////////////////////////////////////////////////
// - hide the newsletter slider
/////////////////////////////////////////////////////////////////
$('a.slide-hide').on('click', function (e) {
var slider = $('#newsletter-slider');
//slide-down
slider.animate({ bottom: '-=240' }, 240);
e.preventDefault();
})
/////////////////////////////////////////////////////////////////
// - Smarter Track integration SiteV2.Master
/////////////////////////////////////////////////////////////////
var stChat = $("#chat"),
stPhone = $("#phone"),
stEmail = $("#email");
//SmarterTrack sliders
stChat.on({
mouseenter: function () { $(this).stop().animate({'margin-right':'150px'}, 240); },
mouseleave: function () { $(this).stop().animate({'margin-right':'0'}, 240); }
});
stPhone.on({
mouseenter: function () { $(this).stop().animate({'margin-right':'120px'}, 240); },
mouseleave: function () { $(this).stop().animate({'margin-right':'0'}, 240); }
});
stEmail.on({
mouseenter: function () { $(this).stop().animate({'margin-right':'152px'}, 240); },
mouseleave: function () { $(this).stop().animate({'margin-right':'0'}, 240); }
});
/////////////////////////////////////////////////////////////////
},
/////////////////////////////////////////////////////////////////
//HOME page default.aspx
/////////////////////////////////////////////////////////////////
//enable 'BestSellers' tab on load
runShowcaseTabs: function () {
$('#showcaseProducts a:first').tab('show');
},
//Why OCs pop-ups on home page (Bootstrap Pop-over)
showPopUps: function () {
$(".pop").popover({
trigger: "hover",
placement: "top",
animation: false,
html: true
});
},
//manual initialize for main slider box - /UIControlsV2/SliderControl.ascx on the home page
//fix for FOUC
//->see CSS solution: https://github.com/artpolikarpov/fotorama/issues/182
showFotoramaMainSlider: function () {
var fotoramaMainSlider = $('.fotorama-main');
var loader = $('img.fotorama-loader');
fotoramaMainSlider
.on('fotorama:ready + fotorama:show',
function () {
loader.hide();
$('img.main-slide').removeClass('hidden');
}
)
.fotorama();
},
//manual initialize for TopSellers box - /UIControlsV2/TopSellersControl.ascx on the home page
//fix for FOUC
showFotoramaTopSellers: function () {
var fotoramaTopSellers = $('.foto-topsellers');
fotoramaTopSellers
.on('fotorama:ready + fotorama:show',
function (e, fotorama, extra) {
$('.top-sellers-image').removeClass('hidden');
$('.top-sellers-details').removeClass('hidden');
}
)
//initialize fotorama manually
.fotorama();
},
//banners or promotions on bottom of home page
getPromotions: function (endpoint) {
var loading = $('img.loading');
var promotions = $('#promo-banner');
$.ajax({
url: endpoint,
dataType: 'json'
})
.done(function (data) {
promotions.append(data.Html);
loading.hide();
})
.fail(function () {
if (s.debug == true) {
console.log("Ooops! getPromotions() error!");
}
})
.always(function () {
if (s.debug == true) {
console.log("getPromotions() Completed!");
}
});
},
//testimonials on home page, also on Cart page
getRandomTestimonial: function (endpoint) {
// Send an AJAX request
var random = $('#rc-testimonials');
$.ajax({
url: endpoint,
dataType: 'json'
})
.done(function (data) {
var item = '
' +
'
' +
'
' +
'
' + data.Detail + '' +
'
' +
'
' +
'
' +
'
';
random.html(item);
})
.fail(function () {
if (s.debug == true) {
console.log("Ooops! getRandomTestimonial() error!");
}
})
.always(function () {
if (s.debug == true) {
console.log("getRandomTestimonial() Completed!");
}
});
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// PRODUCT DETAILS page CarAudio/ProductDetail.aspx
/////////////////////////////////////////////////////////////////
//tabs on Product Detail page
runProductDetailTabs: function () {
$("#detailsSpecs a:first").tab("show");
},
//extra images on Product Detail page (bxSlider)
runExtraImageSlider: function () {
var extraImgeSlider = $("#ExtraImageContainer");
var extraContainer = $("#bx-extra");
//only if there are extra images
if (extraImgeSlider.length >= 1) {
extraImgeSlider.bxSlider({
minSlides: 1,
maxSlides: 8,
slideWidth: 50,
moveSlides: 1,
controls: true,
hideControlOnEnd: true,
infiniteLoop: false,
captions: false,
pager: false,
useCSS: true,
onSliderLoad: function () {
extraContainer.css('visibility', 'visible');
}
});
}
},
//product details email link
emailPage: function (subject) {
var body = 'Get the ' + subject + ' from Onlinecarstereo.com \n\r' + String.fromCharCode(13) + String.fromCharCode(10) + window.location.href;
window.location.href = 'mailto:?subject=' + subject + '&body=' + body;
return true;
},
//product details 'Suggestion' pop-up box
launchWindow: function (url, winheight, winwidth, popupSettings) {
var ChildWindow = null
var popup = "height=" + winheight + ",width=" + winwidth + ",";
var popupSettings = "status=no,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no";
var winleft, wintop;
if (ChildWindow != null && !ChildWindow.closed) ChildWindow.close();
winleft = ($(window).width() / 2) - (winwidth / 2);
wintop = ($(window).height() / 2) - (winheight / 2);
if (navigator.userAgent.indexOf("AOL") == -1) popup += "left=" + winleft + ",top=" + wintop + ",";
if (popupSettings == null || popupSettings == "") {
popup += "status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes";
}
else {
popup += popupSettings;
}
ChildWindow = window.open(url, null, popup);
ChildWindow.opener = self;
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// PRODUCT LIST page CarAudio/ProductList.aspx
/////////////////////////////////////////////////////////////////
//product list - attributes column - every product list form load
setupAttributes: function () {
$("span.expander").addClass('minus');
$("span.table-expander").addClass('plus');
$("table.attrib-table .attrib-items").slideUp();
},
//'Show Filter' is clicked
toggleAttributeContainer: function () {
if ($('#AttributeContainer').is(':visible')) {
$('a.filter').html('Show Filter');
} else {
$('a.filter').html('Hide Filter');
}
$('#AttributeContainer').toggle();
},
//'Show more' (+/-) on attrributes filter column - AttributesFilterControl.ascx
showMore: function (a, b) {
$(a).toggle(300);
if ($(b).html().indexOf("Show More") > 0) {
$(b).html("- Show Less");
} else {
$(b).html("+ Show More");
}
},
//'Show more' (+/-) on attrributes filter column - AttributesFilterControl.ascx
showCategory: function (c, e, d, b, a) {
$(c).toggle(300);
if ($(e).html().indexOf("img-cat-right.jpg") > 0) {
$(e).html(" " + d)
} else {
$(e).html(" " + d)
}
},
//Product list page
compareProducts: function (ItemsInGrid, theForm, location) {
var CompareIds = "";
var ItemsToCompare = 0;
var i = 0;
if (ItemsInGrid < 1) { return }
for (i = 0; i < ItemsInGrid; i++) {
var bChecked = eval("document.getElementsByName('chkCompare" + i + "')[0].checked");
if (bChecked == true) {
var CompareID = eval("document.getElementsByName('ProdID" + i + "')[0].value");
CompareIds += CompareID + ","; ItemsToCompare += 1
}
}
if (ItemsToCompare >= 2) {
CompareIds = CompareIds.substring(0, CompareIds.length - 1);
window.location = location + "CompareItems.aspx?CompareItems=" + CompareIds
} else {
alert("Please check at least 2 items you want to compare.");
}
},
//dynamic scrollbar on Compare items page
//NOTE: currently not used
adjustHorizontalScroll: function () {
//dynamic custom x-axis scrollbar
var oCompare = $("#compare"),
vport = $("#compare .viewport"),
dGrid = $("#dgCompare"),
rscroll = $("span.scroll-right"),
thumb = $(".thumb").width();
//set viewport height
vport.height(dGrid.height() + 1);
rscroll.css("margin-left", thumb - 32);
},
//Product list page - top pager
sortProducts: function (url0, url1, url2, url3, url4) {
var selected = $("#ddlSort").val();
switch (selected) {
case "5": //top sellers
window.location = url0;
break;
case "1": //lowest price
window.location = url1;
break;
case "2": //highest price
window.location = url2;
break;
case "0": //brand
window.location = url3;
break;
case "3": //newest
window.location = url4;
break;
default:
window.location = url0; //top sellers
}
},
//Product list page - bottom pager
sortProducts2: function (url0, url1, url2, url3, url4) {
var selected = $("#ddlSort2").val();
switch (selected) {
case "5": //top sellers
window.location = url0;
break;
case "1": //lowest price
window.location = url1;
break;
case "2": //highest price
window.location = url2;
break;
case "0": //brand
window.location = url3;
break;
case "3": //newest
window.location = url4;
break;
default:
window.location = url0; //top sellers
}
},
//Product list page
changeItemsPerPage: function (sender, var1, var2, var3, var4) {
var val = $(sender).val();
var loc;
switch (val) {
case "25":
loc = var1;
break;
case "50":
loc = var2;
break;
case "100":
loc = var3;
break;
default:
loc = var4;
break;
}
window.location = loc;
},
//newsletter box on product list page
submitNewsLetter: function () {
var emailField = $("#nlEmail2");
var emailField1 = $("#nlEmail1"); // this field is in SiteV2.Master
if (($(emailField).val() == null) || ($(emailField).val() == "")) {
alert("Please enter a valid Email Address");
emailField.focus();
return false;
}
$(emailField1).val($(emailField).val());
if (this.validateNewsLetterEmail(emailField1)) {
document.LeftNavNewsletter.submit();
}
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// SHOPPING CART page CarAudio/ShoppingCart.aspx
/////////////////////////////////////////////////////////////////
//warranty options toggle on Shopping Cart page
toggleWarrantyOptions: function (senderId, objId, e) {
if ($(objId).is(":visible")) {
$(objId).slideUp("slow");
$(this).data("show", "no");
$(senderId).css("background-position", "right -17px");
} else {
$(objId).slideDown("slow");
$(this).data("show", "yes");
$(senderId).css("background-position", "right 0");
}
},
//'Guests who shopped this item also shopped' slider on Shopping Cart's page
//using responsive carousel - http://basilio.github.io/responsiveCarousel/
runCrossShopSlider: function () {
$('#cross-shop-items').carousel({
visible: 4,
itemMinWidth: 280,
itemMargin: 10
});
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// CATEGORIES page CarAudio/Categories.aspx
/////////////////////////////////////////////////////////////////
//
//'Most Popular Items in Category' slider on Categories page
// - UIControlsV2/WhatsHotByCategory.ascx
// using responsive carousel - http://basilio.github.io/responsiveCarousel/
runCategoryMostPopularItemsSlider: function () {
$('#most-popular-items').carousel({
visible:4,
itemMinWidth:280,
itemMargin:10
});
},
//'Most Popular Brands in Category' slider on Categories page
// - UIControlsV2/TopBrandsByCategoryControl.ascx
// using responsive carousel - http://basilio.github.io/responsiveCarousel/
runCategoryMostPopularBrandsSlider: function () {
$('#most-popular-brands').carousel({
visible:7,
itemMinWidth:150,
itemMargin:10
});
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// CHECKOUT pages
/////////////////////////////////////////////////////////////////
//tabs on CheckOut page - secure/checkout-delivery.aspx
runCheckoutTabs: function () {
$('#checkoutTabs a:first').tab('show');
},
//Checkout page pop-ups - (AFP/FPO) secure/checkout.aspx
showCheckoutPopUps: function () {
$('.checkout-tip').popover({
html: true,
content: function () {
return $('.checkout-tip-wrapper').html();
},
trigger: 'hover',
placement: 'top'
});
},
//Checkout page popups - (CVV2) secure/checkout-delivery.aspx
showCVVPopUps: function () {
$('.cvv2').popover({
html: true,
content: function () {
return $('.cvv2-tip-wrapper').html();
},
trigger: 'hover',
placement: 'top'
});
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// MANUFACTURER'S page
/////////////////////////////////////////////////////////////////
//Manufacturer's Top Sellers slider on Manufacturer's page
//see: /UIControlsV2/ManufacturerTopSellers.ascx
runManufacturersTopSellersSlider: function () {
$('#BrandTopSeller-items').carousel({
visible: 4,
itemMinWidth: 280,
itemMargin: 10
});
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// COMMON ELEMENTS
/////////////////////////////////////////////////////////////////
//fancybox
runFancyBox: function () {
var pop = $('a.fbpop');
pop.fancybox({
maxWidth: 600,
maxHeight: 480,
width: '100%',
height: '100%',
fitToView: false,
autoSize: false,
closeClick: false,
openEffect: 'none',
closeEffect: 'none'
});
},
//site header search box type-ahead
runTypeAhead: function () {
//search type-ahead on header
var searchPhrase = $("#SearchPhrase");
searchPhrase.typeahead({
minLength: 2,
source: function (query, process) {
return $.get("/AutoComplete.aspx", { query: query }, function (data) {
if (typeof data.options === "undefined") {
return false;
} else {
return process(data.options);
}
});
},
updater: function (item) {
searchPhrase.val(item);
$("#SiteSearch").submit();
return item;
},
sorter: function (item) {
item.unshift(this.query);
return item;
},
autoSelect: false
});
},
isSearchValid: function () {
var searchPhrase = $("#SearchPhrase");
if (s.debug == true) console.log("Phrase is: " + searchPhrase);
return (searchPhrase.val().length > 0);
},
isValidEmailAddress: function (emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
},
//site footer
validateNewsLetterEmail: function (emailField) {
if (this.isValidEmailAddress($(emailField).val()) == false) {
$(emailField).val("");
alert("Please enter a valid email.");
return false;
}
return true;
},
//print screen
printWindow: function () {
var bV = parseInt(navigator.appVersion);
if (bV >= 4) {
window.print();
} else {
alert("Your browser doesn't support this feature please select File->Print");
}
},
handleEnter: function (field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13) {
var i; for (i = 0; i < field.form.elements.length; i++)
if (field == field.form.elements[i]) break;
i = (i + 1) % field.form.elements.length; field.form.elements[i].focus();
return false;
}
else
return true;
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// TESTIMONIALS page /Testimonials.aspx
/////////////////////////////////////////////////////////////////
getTestimonials: function (endpoint) {
var options = {
autoResize: true, // Auto-update the layout when the browser window is resized.
container: $('#p-testimonials'), // Optional, used for some extra CSS styling
offset: 20 // Optional, the distance between grid items
};
$.ajax({
url: endpoint,
dataType: 'json'
})
.done(function (data) {
var items = "";
$.each(data, function (i, testimonial) {
items += '' +
'
' +
'
' +
'
' + testimonial.Detail + '' +
'
' +
'
' +
' - ' + testimonial.Author + '' +
' | ' +
'' + testimonial.DateStampFormatted + '
' +
'
' +
'
' +
'
' +
'
' +
'
';
});
//write to DOM once
$('#p-testimonials').html('').append(items);
//layout function.
$('.p-testimonials').wookmark(options);
})
.fail(function () {
if (s.debug == true) {
console.log("Ooops! getTestimonials() error!");
}
})
.always(function () {
if (s.debug == true) {
console.log("getTestimonials() Completed!");
}
});
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Social Media page /SocialMedia.aspx
/////////////////////////////////////////////////////////////////
showSocialBoxes: function () {
var options = {
autoResize: true, // Auto-update the layout when the browser window is resized.
container: $('#media-box'), // Optional, used for some extra CSS styling
offset: 20, // Optional, the distance between grid items
itemwidth: 300
};
// $('#media-box').imagesLoaded(function () {
// $('.social-media-box').wookmark(options);
// });
//document.getElementsByClassName('g-page')[0].setAttribute('data-width', document.getElementById('gplus-box').clientWidth - 48);
$('.social-media-box').wookmark(options);
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Instagram Feed /SocialMedia.aspx
//
// using instafeed,js (http://instafeedjs.com/)
/////////////////////////////////////////////////////////////////
getInstagramFeed: function () {
var userFeed = new Instafeed({
get: 'user',
userId: 428008006,
accessToken: '428008006.09dfab6.6685b7c95b4f4bb58fbc54e7214b3d78',
template: '',
limit: 12
});
userFeed.run();
},
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Newsletter Pop-up
// needs jquery.cookie
/////////////////////////////////////////////////////////////////
// newsLetterPop: function () {
// var visited = $.cookie('ocs-pop-cookie');
// var pop = $('a.newletter-pop');
// if (visited == 'yes') {
// return false;
// } else {
// setTimeout(function () {
// pop.trigger('click');
// }, 5 * 1000); //5-second delay before pop-up
// }
// //expires in 7 days
// $.cookie('ocs-pop-cookie', 'yes', { expires: 7 });
// //Pop-up via FancyBox
// pop.fancybox({
// margin: 0,
// padding: 0,
// maxWidth: 700,
// maxHeight: 210,
// width: '100%',
// height: '100%',
// scrolling: 'no',
// closeClick: false,
// openEffect: 'none',
// closeEffect: 'none'
// });
// },
/////////////////////////////////////////////////////////////////
// Newsletter slide-up effect
// needs jquery.cookie
/////////////////////////////////////////////////////////////////
newsLetterSlide: function () {
var visited = $.cookie('ocs-pop-cookie');
var slider = $('#newsletter-slider');
if (visited == 'yes') {
return false;
} else {
setTimeout(function () {
//slide-up effect with 5-second delay
slider.animate({ bottom: '+=240' }, 240);
}, 5 * 1000);
}
//set the cookie, expires in 7 days
$.cookie('ocs-pop-cookie', 'yes', { expires: 7 });
},
//NOTE: currently not used
checkWidth: function () {
var windowsize = $(window).width();
if (windowsize > 1200) {
console.log('< 1200');
return 1170;
}
else if (windowsize > 980 && windowsize < 1199) {
console.log('980 <> 1199');
}
else if (windowsize > 768 && windowsize < 979) {
console.log('768 <> 979');
}
else if (windowsize < 767) {
console.log('< 767');
}
else if (windowsize > 481 && windowsize < 612) {
console.log('481 <> 612');
}
else if (windowsize < 480) {
console.log(' < 480');
}
else {
console.log('default');
}
}
/////////////////////////////////////////////////////////////////
};
})();
//fire it up..
OCS.init();
////load 3rd-party scripts async and and after 'onLoad()'
//(function (w, d, s) {
// function go() {
// var js, fjs = d.getElementsByTagName(s)[0], load = function (url, id) {
// if (d.getElementById(id)) { return; }
// js = d.createElement(s); js.src = url; js.id = id;
// fjs.parentNode.insertBefore(js, fjs);
// };
// load('//connect.facebook.net/en_US/all.js#xfbml=1&appId=163715470352444', 'facebook-jssdk');
// }
// if (w.addEventListener) { w.addEventListener("load", go, false); }
// else if (w.attachEvent) { w.attachEvent("onload", go); }
//} (window, document, 'script'));
// !! ENABLE ON LIVE SITE !!
/**
* Google Analytics tracking script
*/
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-168534-1'], ['_setDomainName', 'www.onlinecarstereo.com']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
//ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
//jason 27Mar2014: replaced above with latest google tracking code to support more tracking features
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();