/*Updated 09-24-2015*/ /*! * DW JS LIBRARY 1.0 * * jQuery 1.4.2 * Colorbox 1.3.9 * jQuery Tools 1.2.5 * jQuery UI 1.8.5 * jScrollPane v2.0.0beta5 * scrollTo 1.4.2 * curvyCorners */ $(document).ready(function() { initFront(); $("td:empty").html(" "); //remove when all td elements are fixed in the backend var wins = $('.statsFeedWrap:eq(0) .stat_2 .feedDesc2').text(); calcTrophies(wins); checkFA(); }); function checkFA() { var mrpFaCookie = "mrpFaCheck"; function GetMrpFaCookie() { var keyValue = document.cookie.match('(^|;) ?' + mrpFaCookie + '=([^;]*)(;|$)'); return keyValue ? keyValue[2] : null; } if (GetMrpFaCookie()) { //check for old FA icons $("*").each(function () { if ($(this).hasClass("fa") && !$(this).hasClass("fas")) alert($(this).attr("class")); }); } else if (querySt("checkMrpFa")) { alert("setting cookie"); var date = new Date(); date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000)); var expires = '; expires=' + date.toUTCString(); document.cookie = mrpFaCookie + '=dismiss' + expires + "; path=/"; } } function newWindow(path, w, h, scroll) { var height = h; var width = w; var wleft = (screen.width - width - 20) / 2; var wtop = (screen.height - height) / 2; window.open(path, 'newwin', 'fullscreen=0,scrollbars=' + scroll + ',height=' + height + ',width=' + width + ',top=' + wtop + ',left=' + wleft + ''); } var iHeight = 500; var iWidth = 980; var iHeightDefault = 500; var iWidthDefault = 980; var iHeightOffset = 160; var iContentSrc = ""; var navTimers = []; var fileDomain = ""; //currently only used to prepend locally included files with "http://localhost" but could be used for different domains, etc. var isLocal = false; if (!location.host.indexOf("localhost") > 0) isLocal = true; if (isLocal) fileDomain = "http://localhost"; function iAdmin(aHref, stdUserOnly) { setPanelDimsByPage(aHref); // if (!stdUserOnly) // $(".iControls .adminOnly").show(); // else // $(".iControls .adminOnly").hide(); if ($("#siteBar, #sourceBar").size() > 1) iHeightOffset = 90; //if ((location.hostname == "localhost") && !stdUserOnly) { //strip out the port if we are on localhost // aHref = "http://localhost/admin" + aHref.split("/admin")[1]; // //alert(aHref); //} $("#iAdmin").attr("src", iContentSrc + aHref); //$("#mrpPanel .adminPanelWrap").siblings().hide(); $("#mrpPanel .adminPanelWrap").show(); if ($("#mrpPanel").length > 0) { if ((!$("#mrpPanel").is(":visible")) || ((iHeight != $("#mrpPanel").height()) || (iWidth != $("#mrpPanel").width()) && $("#mrpPanel").is(":visible"))) { showPanel($("#mrpPanel")); } } else if ($("body").attr("id") == "popAdminBody")//popped out { showPoppedAdmin(aHref); } } function iUser(aHref) { iAdmin(aHref, true, iHeight, iWidth); } function setPanelDimsByPage(page) { page = page.toLowerCase(); page = page.split(".aspx")[0]; if (page.indexOf(location.host.toString()) != -1) page = page.split(location.host.toString())[1]; //alert(page); switch (page) { //case '/admin/cr/myaccount/': iHeight = 400; iWidth = 730; allowPanelResize = false; break; case '/admin/cr/myaccount/signin': iHeight = 460; iWidth = 730; allowPanelResize = false; break; case '/admin/cr/myaccount/signup': iHeight = 460; iWidth = 730; allowPanelResize = false; break; case '/admin/cr/claim/request': iHeight = 520; iWidth = 730; allowPanelResize = false; break; case '/admin/cr/claim/submit': iHeight = 520; iWidth = 730; allowPanelResize = false; break; default: iHeight = iHeightDefault; iWidth = iWidthDefault; break; } } function iAdminResize(smart) { var curHeight = $("#mrpPanel").height(); var curWidth = $("#mrpPanel").width(); var availHeight = $(window).height() - iHeightOffset; //alert(getPanelLock()); if (getPanelLock() == false) { if (($("#mrpPanel").is(":visible")) && (allowPanelResize == true) && (!$("#mrpPanel").is(":animated"))) { //if (smart) { //if (curHeight > ($(window).height() - iHeightOffset)) { $("#mrpPanel").animate({ height: (availHeight) + "px" }, 500); //} //else { //$("#mrpPanel").animate({ height: iHeight + "px" }, 500); //} //} //else { //if (curHeight == iHeight) { //$("#mrpPanel").animate({ height: ($(window).height() - iHeightOffset) + "px" }, 500); //} else { //$("#mrpPanel").animate({ height: iHeight + "px" }, 500); //} //} } else if (curHeight > (availHeight) && !$("#mrpPanel").is(":animated")) { $("#mrpPanel").animate({ height: (availHeight) + "px" }, 500); } else if ((curHeight < iHeight) && (availHeight > iHeight)) { //full but strict if (iHeight == iHeightDefault) $("#mrpPanel").animate({ height: (availHeight) + "px" }, 500); else $("#mrpPanel").animate({ height: (iHeight) + "px" }, 500); } else if ((curHeight < iHeight) && (availHeight > curHeight)) { //full but less than strict (only do available) $("#mrpPanel").animate({ height: (availHeight) + "px" }, 500); } if ($("#iAdmin").contents().find(".smartHeight").length > 0) { //internal smart heights such as results page / schedule lookup page setTimeout('initSmartHeight()', 600); } } } function setPanelOffset(panel) { var topBarHeight = 26; if ($("#topBarWrap").length > 0) { topBarHeight = $("#topBarWrap").height(); } $(".panelWrap").css("padding-top", topBarHeight + "px"); } function showPanel(panel) { if (window.stopSite) { stopSite(); } $("html, body").css("overflow", "hidden").css("height", "100%"); winScroll(); $("#mrpOverlay").show().css({ opacity: '0.9' }); //setPanelOffset(panel); //only animate panel if it is already visible if ($(panel).is(":visible")) { $(panel).animate({ width: iWidth + "px", marginLeft: (iWidth / -2) + "px" }, 150) } //if it is not visible then we just do a quick set of the width and margin before showing else { $(panel).css("width", iWidth + "px") .css("margin-left", (iWidth / -2) + "px"); } $(panel).show(); if (($(window).height() - iHeightOffset) > iHeight) { if (iHeight == iHeightDefault) { //show panel full screen $("#mrpPanel").animate({ height: ($(window).height() - iHeightOffset) + "px" }, 500); } else { $(panel).animate({ height: iHeight + "px" }, 1000); } } else { $("#mrpPanel").animate({ height: ($(window).height() - iHeightOffset) + "px" }, 300); } var resizeTimer = null; $(window).resize(function() { resizeWindow(); }); function resizeWindow() { if (resizeTimer) { clearTimeout(resizeTimer); } resizeTimer = setTimeout('iAdminResize(true);', 500); } } function setPoppedAdminHeight() { var availHeight = ($(window).height() - $("#mrpBar").height()) / $(window).height() * 100; $("#iAdmin").height(availHeight + "%"); } function showPoppedAdmin(aHref) { setHash(aHref.split("/admin/")[1]); var resizeTimer = null; $(window).resize(function() { resizePoppedAdmin(); }); function resizePoppedAdmin() { if (resizeTimer) { clearTimeout(resizeTimer); } resizeTimer = setTimeout('setPoppedAdminHeight();', 500); } setPoppedAdminHeight(); } //function aniWindow() { // if (window.startSite) { // startSite(); // } // var panel = parent.document.getElementById("mrpPanel"); // $(panel).animate({ height: "0px" }, // 600, function() { $(this).hide(); $(".panelWrap").hide(); }); // $(".panelWrap iframe").each(function() { // $(this).attr("src", ""); // }); //} function buildPopOutLink(el) { $(el).attr("href", getHashFromIframe(true)); } function checkPopAdminHash() { //called when iframe loads var curHash = getHash(); if (curHash) { $("#iAdmin").attr("src", curHash); } } function refreshAdmin() { var f = document.getElementById('iAdmin'); f.contentWindow.location.reload(true); } ///INIT FUNCTIONS/// function initFront() { if ($("#mrpBar ul, #siteBar ul").length > 0) { $('#mrpBar ul, #siteBar ul').superfish({ hoverClass: 'active', delay: 300, animation: { height: 'show' }, speed: 'fast', pathClass: 'curActive', autoArrows: false }); } if ($(".txtMax").length > 0) { initMaxLengths(); } if ($(".wordCount").length > 0) { initWordCount(); } if ($(".modalBox").length > 0) { initModalBox(); } if ($("a.modalFrame").length > 0) { initModalFrame(); } if ($("#sourceBar .sourceHeadlineWrap li").length > 1) { custScroll(2000, 8500, -18, 'top', '.sourceHeadlineWrap', '.headlineList', 'headlineItem'); } //if (typeof initToolTips == 'function') if (!$("body").hasClass("mobileBody")) { initToolTips(); if ($(".mrp_contentMenu.menuAllowMore").length > 0) { $(".mrp_contentMenu.menuAllowMore").each(function(i) { checkMrpDropDown(i); //do we need a "more" dropdown }); } } if ($("body").attr("ID") == "productDetailBody") { bindSubItemInputs(); } //QUICK Contact $("#contactSet .fieldWrap input").click( function(){ markQCGood(this); } ); //Scrollable feeds if (($("div.resultsFeed .feedContent").length > 1) && ($("div.resultsFeed .resultsNext").length > 0)) { $("div.resultsFeedSub").scrollable({ clickable: false, loop: false, size: 1, keyboard: false, next: ".resultsNext", prev: ".resultsPrev", items: "div.resultsScrollable" }); } if (($("div.pointsFeed .feedContent").length > 1) && ($("div.pointsFeed .pointsNext").length > 0)) { $("div.pointsFeedSub").scrollable({ clickable: false, loop: false, size: 1, keyboard: false, next: ".pointsNext", prev: ".pointsPrev", items: "div.pointsScrollable" }); } } function initTabs() { //alert("tabs"); $("ul.tabs").tabs("div.panes > div.pane"); } function initModalBox() { if ($("a.modalForm").length > 0) { $("#colorbox").prependTo("form"); $("#cboxOverlay").prependTo("form"); } $("a.modalBox").colorbox(); $("a.inlineModal").colorbox({ transition: "none", inline: true, href: $(this).attr("href"), maxWidth: "98%", maxHeight: "98%", initialWidth: "100px", initialHeight: "100px" }); if (window.initEcomTypeModals) { initEcomTypeModals(); } } function initModalFrame() { $("a.modalFrame").each(function() { var modalDimensions = '350x350'; //&d= var modalCallBack = ''; //&f= var modalArgs = $(this).attr("rel"); if (modalArgs) { modalDimensions = parseArgs('d', modalArgs); modalCallBack = parseArgs('f', modalArgs); } modalWidth = parseInt(modalDimensions.split("x")[0]) + "px"; modalHeight = parseInt(modalDimensions.split("x")[1]) + "px"; $(this).colorbox({ iframe: true, width: modalWidth, height: modalHeight, rel: 'nofollow', onClosed: function() { eval(modalCallBack); } }); }); } function parseArgs(ji, toParse) { hu = toParse; gy = hu.split("|"); for (i = 0; i < gy.length; i++) { ft = gy[i].split(":"); if (ft[0] == ji) { return ft[1]; } } } function initAdminResize() { $("#mrpPanel").resizable({ maxHeight: 1000, maxWidth: 980, minHeight: 300, minWidth: 980, handles: 's', grid: 1 }); } function initScrollPane(el) { if (el) { $(el).jScrollPane({ reinitialiseOnImageLoad: true }); } $(".jScrollPane").jScrollPane({ reinitialiseOnImageLoad: true }); } function initValidate() { $("#aspnetForm").validate({ ignoreTitle: true, submitHandler: function(form) { form.submit(); }, invalidHandler: function(form, validator) { var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You missed ' + errors + ' fields. They have been highlighted'; $("div.err span").html(message); $("div.err").show(); } else { $("div.err").hide(); } }, rules: { email: { email: true }, password2: { equalTo: "password1" } } }); jQuery.validator.addClassRules({ fname: { required: true, minlength: 2 }, lname: { required: true, minlength: 2 }, zip: { required: true, digits: true, minlength: 5, maxlength: 5 } }); } function initMaxLengths() { $(".txtMax").each(function() { var max = parseInt($(this).attr("class").split("chars")[1]); initMax(this, max); }); } function initWordCount() { $('.wordCount').each(function() { wordCount(this); $(this).keyup(function() { wordCount(this) }); }); } function wordCount(el) { if ($(el).next().is(".curWordCount")) { $(el).next().remove(); } $(el).after("

"); var number = 0; var matches = $(el).val().match(/\b/g); if (matches) { number = matches.length / 2; } $(el).parent().find('.curWordCount').html('Approximately ' + number + ' word' + (number != 1 ? 's' : '')); } function initMax(el, max) { if ($(el).next().is(".charsRemaining")) { $(el).next().remove(); } $(el).after("

"); $(el).parent().find('.charsRemaining').html('You have ' + (max - $(el).val().length) + ' characters remaining.'); $(el).keydown(function() { $(el).parent().find('.charsRemaining').html('You have ' + (max - $(el).val().length) + ' characters remaining.'); if ($(el).val().length > max) { $(el).val($(el).val().substr(0, max)); } $(el).parent().find('.charsRemaining').html('You have ' + (max - $(el).val().length) + ' characters remaining.'); }); } function initSmartHeight(el) { if (el) { //setHeight(el); } else { $("#iAdmin").contents().find(".smartHeight").each(function() { setHeight(this); }); } function setHeight(el) { var elOffset = $(el).offset(); var winHeight = $("#mrpPanel").height(); var newHeight = (winHeight - elOffset.top - iHeightOffset) + "px"; $(el).css("height", newHeight); } } function initReplaceFont(siteName, class2Replace, fontWidth, fontHeight, container) { if (container) { } else { container = "body"; } $(container + " ." + class2Replace).each(function() { var unique = Math.floor(9999 * Math.random()); var textToReplace = escape($(this).text().replace(/ /g, " ")); //add extra space for this particular font var newElement = $(this).wrapInner(""); if (this.tagName == "A") { if ($(this).attr("onclick")) { var jsClick = $(this).attr("onclick"); $(this).mousedown(jsClick); $(this).attr("onclick", ""); replaceFont(textToReplace, "newId" + unique, "true", "", $(this).attr("onmousedown")); } else replaceFont(siteName, textToReplace, "newId" + unique, "true", $(this).attr("href"), "", fontWidth, fontHeight); } else { replaceFont(textToReplace, "newId" + unique, "false", fontWidth, fontHeight); } }); } ///END INIT FUNCTIONS/// function replaceFont(siteName, text, element, cursor, href, jsClick, fontWidth, fontHeight) { var flashvars = { setCursor: cursor, txtString: text }; var params = { quality: "best", allowFullScreen: "false", scale: "showall", wmode: "transparent" }; if (jsClick) var attributes = { onmousedown: jsClick }; else if (href) var attributes = { onmousedown: "window.location='" + href + "';" }; else var attributes = {}; swfobject.embedSWF("/css/" + siteName + ".swf", element, fontWidth, fontHeight, "9.0.28", false, flashvars, params, attributes); } function toggleDDbox(box, ref) { box = $("#ddBox" + box); if (box.is(":visible")) { box.fadeOut("fast"); } else { $(".ddBox").fadeOut("fast"); box.fadeIn("fast"); } $("#siteWrapper").click(function(e) { box.fadeOut("fast"); }); } function swapEl(toShow, toHide, navClicked) { if (navClicked) { $(navClicked).siblings().removeClass("genUrl"); $(navClicked).addClass("genUrl"); } $(toShow).show(); $(toHide).hide(); } function quickToggle(el) { //pass an element and it will toggle the children that have a class of "quickHide" $(el).find(".quickHide").toggle(); } function quickToggleAll(el) { //pass an element to change the text. it will toggle all elements that have a class of "quickHide" $(".mrp_schedule").find(".quickHide").toggle(); } function moneyConvert(value) { var buf = ""; var sBuf = ""; var j = 0; value = String(value); if (value.indexOf(".") > 0) { buf = value.substring(0, value.indexOf(".")); } else { buf = value; } if (buf.length % 3 != 0 && (buf.length / 3 - 1) > 0) { sBuf = buf.substring(0, buf.length % 3) + ","; buf = buf.substring(buf.length % 3); } j = buf.length; for (var i = 0; i < (j / 3 - 1); i++) { sBuf = sBuf + buf.substring(0, 3) + ","; buf = buf.substring(3); } sBuf = sBuf + buf; if (value.indexOf(".") > 0) { value = sBuf + value.substring(value.indexOf(".")); } else { value = sBuf; } return value; } function allowInputNumbersOnly(e) { var key = e.charCode || e.keyCode || 0; // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY return ( key != 229 || key == 8 || key == 9 || key == 46 || (key >= 37 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105) ); } function querySt(ji) { hu = window.location.search.substring(1); gy = hu.split("&"); for (i = 0; i < gy.length; i++) { ft = gy[i].split("="); if (ft[0] == ji) { return ft[1]; } } } function getHash() { return document.location.hash.replace("#", ""); } function setHash(newHash) { return document.location.hash = newHash; } function getHashFromIframe(withDomain) { //withDomain includes http://domain.com/admin/ var iframe = $('#iAdmin'); var contentWnd = iframe.attr('contentWindow'); var curDomain = ""; var curAdmin = contentWnd.window.location.href; var newHash = "#"; if (withDomain) { curDomain = curAdmin.split('/admin/')[0]; curDomain = curDomain + "/admin/"; } newHash = newHash + curAdmin.split('/admin/')[1]; newHash = curDomain + newHash; //alert(newHash); return newHash; } function winScroll(id, CssClass) { if (id) { $.scrollTo($("#" + id), 'slow', { offset: { top: -50, left: 0} }); } else if (CssClass) $.scrollTo($("." + CssClass), 'slow', { offset: { top: -50, left: 0} }); else { $('html, body').animate({ scrollTop: 0 }, 'slow'); } return false; } function isOnScreen(element) { var curPos = element.offset(); var curTop = curPos.top; var screenHeight = $(window).height(); if (curTop > screenHeight) return false; else return true; } function stickySide(id, gutter) { if (window.XMLHttpRequest) { if (document.documentElement.scrollTop > gutter || self.pageYOffset > gutter) { $('#' + id).css('position', 'fixed'); $('#' + id).css('top', '8px'); } else if (document.documentElement.scrollTop < gutter || self.pageYOffset < gutter) { $('#' + id).css('position', 'absolute'); $('#' + id).css('top', gutter + 'px'); } } } function initPhotoFader(picFadeSelector, interval, speed, startItem) { var photoItems; var currPhotoItem = 0; if (!speed) var speed = 3000; function fadePhotos(picFadeSelector, currPhotoItem, photoItems) { $(picFadeSelector + ":eq(" + currPhotoItem + ")").fadeOut(speed); currPhotoItem = ++currPhotoItem % photoItems; $(picFadeSelector + ":eq(" + currPhotoItem + ")").fadeIn(speed); return currPhotoItem; } function updateCurrPhotoItem() { currPhotoItem = fadePhotos(picFadeSelector, currPhotoItem, photoItems); } $(picFadeSelector).fadeIn("fast"); photoItems = $(picFadeSelector).hide().size(); if (startItem) { if (startItem == "random") currPhotoItem = Math.ceil(photoItems * Math.random()) - 1; else currPhotoItem = startItem - 1; } $(picFadeSelector + ":eq(" + currPhotoItem + ")").show(); setInterval(updateCurrPhotoItem, interval); //time in milliseconds } function custScroll(custScrollSpeed, custScrollPause, itemOffset, cssDir, wrap1, wrap2, itemClass) { var curScrollWrap2 = ''; var curScrollItem = ''; function getItems() { curScrollWrap2 = $(wrap1 + ' ' + wrap2); curScrollItem = $(wrap1 + ' .' + itemClass + ':first'); } function doScroll() { getItems(); //animate if (cssDir == "top") { curScrollWrap2.animate({ top: itemOffset + "px" }, custScrollSpeed, function () { curScrollWrap2.append(curScrollItem.fadeIn(custScrollSpeed)); } ); curScrollItem.fadeOut(custScrollSpeed, function() { curScrollWrap2.css("top", "0px"); }); } else { curScrollWrap2.animate({ left: itemOffset + "px" }, custScrollSpeed, function () { curScrollWrap2.append(curScrollItem.fadeIn(custScrollSpeed)); }); curScrollItem.fadeOut(custScrollSpeed, function() { curScrollWrap2.css("left", "0px"); }); } } getItems(); //setInterval(doScroll, custScrollPause); var wait = setInterval(function() { if ((!curScrollWrap2.is(":animated")) && (!curScrollItem.is(":animated"))) { //clearInterval(wait); doScroll(); } }, custScrollPause); } function LoadGallery(pictureName, imageFile, titleCaption, captionText, curEl) { if (curEl) { $(".activeThumb").removeClass("activeThumb"); $(curEl).parent().addClass("activeThumb"); } var picture = document.getElementById(pictureName); if (picture.filters) { picture.style.filter = "blendTrans(duration=1)"; picture.filters.blendTrans.Apply(); } picture.src = imageFile; if (picture.filters) { picture.filters.blendTrans.Play(); } document.getElementById(titleCaption).innerHTML = captionText; if(document.getElementById("picPrintLink") != null) { $('#picPrintLink a').attr('href', imageFile); } // if ($.colorbox) { // var newWidth = picture.clientWidth; // if (newWidth < $("#picThumbsWrap").width()) // newWidth = $("#picThumbsWrap").width(); // $.colorbox.resize({ innerWidth: newWidth + 40 + 'px' }); // } } function LoadPicture(pictureName, imageFile, captionText, photographer, photographerLink, nextId, picId) { var picture = document.getElementById(pictureName); var refId = pictureName.replace("photo", ""); picture.src = imageFile; if($("#captionCredit").length > 0) { if (photographerLink != "" && photographerLink != null) { if (photographerLink.match("http://")) { document.getElementById("captionCredit").innerHTML = "" + photographer + ""; } else if (photographerLink.match("mailto:")) { document.getElementById("captionCredit").innerHTML = "" + photographer + ""; } else { document.getElementById("captionCredit").innerHTML = photographer; } } else document.getElementById("captionCredit").innerHTML = photographer; } if($("#captionText").length > 0) { document.getElementById("captionText").innerHTML = captionText; if (captionText == "" && photographer == "") { document.getElementById("picCaption").style.visibility = "hidden"; } else { if (captionText == "") { document.getElementById("captionText").style.visibility = "hidden"; } else { document.getElementById("picCaption").style.visibility = "visible"; document.getElementById("captionText").style.visibility = "visible"; } if (photographer == "") { document.getElementById("captionCredit").style.visibility = "hidden"; } else { document.getElementById("picCaption").style.visibility = "visible"; document.getElementById("captionCredit").style.visibility = "visible"; } } } SetPicLink(nextId, refId); } function SetPicLink(nextId, refId) { var curPic = document.getElementById("picLink" + refId); var nextPic = document.getElementById(nextId); curPic.setAttribute("href", nextPic.getAttribute("href")); setActiveThumb(nextId.split("ga")[1]); }; function setActiveThumb(i) { //some pretty weird stuff, but it works... i = i - 2; if (i < 0) { i = $(".thumbWrap:last-child").index(); } $(".activeThumb").removeClass("activeThumb"); $(".thumbWrap:eq(" + i + ")").addClass('activeThumb'); } function loadComments_MRP(refId, refType, ele) { var com = $(ele); var stamp = new Date().getMilliseconds(); com.html("
Loading Comments...
").load("/ui/comment.aspx?a=get&r=" + refId + "&t=" + refType + "&dt=" + stamp); } function addComment_MRP(id, ele) { var board = $(ele); var u = "/ui/comment.aspx?i=" + id; $.get(u, function(data) { board.fadeIn(400).prepend(data); }); } function delComment_MRP(refId, refType, element, commentId) { var removeComment = confirm("Are you sure you want to remove this comment?"); if (removeComment) { $.get("/ui/comment.aspx?a=del&r=" + refId + "&t=" + refType + "&i=" + commentId, function(data) { if (data == "1") { quickAlert("commentAlert", "Comment Deleted"); removeElement(element); } else { quickAlert("commentAlert", "An error has occurred. Please refresh the page."); } }); } } function simpleRatings(el, wrapper) { //el is the achor clicked //wrapper is the meta wrapper //class 'upValue' is the span with the up value in it //class 'downValue' is the span with the down value in it if (!wrapper) wrapper = ".numThumbsUp"; //wrapper = $(el).parent(); $.ajax({ cache:false, url: el.href, async: true, success: function updateValues(data) { $(wrapper + ' .upValue').text(data.split(",")[0]); $(wrapper + ' .downValue').text(data.split(",")[1]); } }); } function initEcomTypeModals() { $(".iInvoice").colorbox({ iframe: true, transition: "none", width: 680, height: 600, overlayClose: true, scrolling: true }); } function updateSubItemPrice() { var qty = 0; var price = 0; var rowSum = 0; var rowQty = 0; $(".subItemWrap .qtyCol input.txtQtyOfficial").each(function() { qty = $(this).val(); price = $(this).next().val(); if (qty > 0) { rowQty = rowQty + parseInt(qty); rowSum += qty * price; } }); if (rowSum > 0) { rowSum = moneyConvert(rowSum.toFixed(2)); var dollars = "$" + rowSum.substring(0, rowSum.indexOf(".")) + "."; var cents = "" + rowSum.split(".")[1] + ""; $(".addWrapper .priceWrap p").hide(); $(".addWrapper .addQty").removeClass("visHide"); $(".addWrapper .priceWrap .itemPrice").show().html(dollars + cents); $("#txtSubQty").text(rowQty); } else { $(".addWrapper .priceWrap p").show(); $(".addWrapper .addQty").addClass("visHide"); $(".addWrapper .priceWrap .itemPrice").hide().text(""); ; $("#txtSubQty").text(""); } } function bindSubItemInputs() { if($("body").hasClass("mobileBody")){ $(".subItemWrap .qtyCol input.txtQtyOfficial").each(function() { $(this).hide(); $(this).prev().removeClass("hide"); $(this).prev().keydown(function (e) { // Allow: backspace, delete, tab, escape, enter and . if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || // Allow: Ctrl+A (e.keyCode == 65 && e.ctrlKey === true) || // Allow: Ctrl+C (e.keyCode == 67 && e.ctrlKey === true) || // Allow: Ctrl+X (e.keyCode == 88 && e.ctrlKey === true) || // Allow: home, end, left, right (e.keyCode >= 35 && e.keyCode <= 39)) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { e.preventDefault(); } }); $(this).prev().keyup(function() { $(this).next().val($(this).val()); updateSubItemPrice(); }); }); } else{ $(".subItemWrap .qtyCol input.txtQtyOfficial").each(function() { // $(this).keydown(function(e) { // return allowInputNumbersOnly(e); // }); $(this).keydown(function (e) { // Allow: backspace, delete, tab, escape, enter and . if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || // Allow: Ctrl+A (e.keyCode == 65 && e.ctrlKey === true) || // Allow: Ctrl+C (e.keyCode == 67 && e.ctrlKey === true) || // Allow: Ctrl+X (e.keyCode == 88 && e.ctrlKey === true) || // Allow: home, end, left, right (e.keyCode >= 35 && e.keyCode <= 39)) { // let it happen, don't do anything return; } // Ensure that it is a number and stop the keypress if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { e.preventDefault(); } }); $(this).keyup(function() { updateSubItemPrice(); }); }); } } function ec_showCartAddPrompt(id, actn) { ec_openCartPrompt(); $.ajax({ type: "GET", url: "/shopping/cart.aspx?actn=" + actn + "&i=" + id, dataType: 'json', cache:false, success: function(data) { if (data) ec_processCartJson(data.cart[0].status, data.cart[0].message, data.cart[0].items, data.cart[0].total); } }); } function ec_updateCart(id, actn) { $.ajax({ type: "GET", url: "/shopping/cart.aspx?actn=" + actn + "&i=" + id, dataType: 'json', cache:false, success: function(data) { if (data) ec_process_CartNoPrompt(data.cart[0].status, data.cart[0].message, data.cart[0].items, data.cart[0].total); } }); } function ec_addToCartStd(id) { ec_openCartPrompt(); var qtyWrap = $(".item_" + id + ' .addQty input'); $.ajax({ type: "GET", url: "/shopping/cart.aspx?actn=addToCart&i=" + id + "&q=" + qtyWrap.val(), dataType: 'json', cache:false, success: function(data) { if (data) ec_processCartJson(data.cart[0].status, data.cart[0].message, data.cart[0].items, data.cart[0].total); } }); } function ec_addToCartGroup(wrapClass) { var items = ""; var sId; $("." + wrapClass + " .qtyCol input:visible").each(function() { sId = $(this).attr("rel"); if (sId != null) { qty = $(this).val(); if (qty > 0) { //add the item into a keyValue string items = items + sId + "x" + qty + ","; } } }); //alert(items); if (items != "") { ec_openCartPrompt(); $.ajax({ type: "GET", url: "/shopping/cart.aspx?actn=groupAdd&i=" + items, dataType: 'json', cache:false, success: function(data) { if (data) ec_processCartJson(data.cart[0].status, data.cart[0].message, data.cart[0].items, data.cart[0].total); } }); } } function ec_process_CartNoPrompt(status, message, items, total) { $("#mrp_cartPrompt").hide(); $(".mrp_cartFeedItems").html(items); $(".mrp_cartFeedTotal").html(total); } function ec_processCartJson(status, message, items, total) { //TODO. //make the prompt fade out if a close link is not clicked $("#mrp_cartPromptMess").html(message); $("#mrp_cartPromptItems").html(items); $("#mrp_cartPromptTotal").html(total); //a catch for updating the cart feed on the page. $(".mrp_cartFeedItems").html(items); $(".mrp_cartFeedTotal").html(total); $("#mrp_cartPromptInner, #mrp_cartPromptFeed").show(); $("#mrp_cartPromptLoader").hide(); } function ec_openCartPrompt() { $("#mrp_cartPromptWrap").fadeIn("fast"); $("#mrp_cartPromptInner, #mrp_cartPromptFeed").hide(); $("#mrp_cartPromptLoader").show(); } function ec_closeCartPrompt() { $("#mrp_cartPromptWrap").fadeOut("slow"); $("#mrp_cartPromptInner, #mrp_cartPromptFeed").hide(); $("#mrp_cartPromptLoader").show(); } function ec_showShipLoader(){ $("#mrp_shipLoader").show(); } function ec_swapShirtPic(thumbnail, full) { $(".zoomContainer").remove(); $("#productThumb").attr('src', thumbnail); $("#productThumb").load(function(){ $(".productPics a.modalBox").colorbox({ transition: "none", inline: true, href: $(this).attr("href"), maxWidth: "98%", maxHeight: "98%", initialWidth: "100px", initialHeight: "100px" }); $("#productThumb").attr('data-zoom-image', full); $('#productThumb').elevateZoom({ zoomType: "inner", cursor: "crosshair", zoomWindowFadeIn: 500, zoomWindowFadeOut: 750 }); }) } function rn_driverYear(box) { var path = $("#" + box + " option:selected").val(); window.location = path; } function rn_schStatsScroll() { $("div.quickStats").css("width", $("div.quickStats").parent().width() + "px") .addClass("isScrollable") .prepend("
Previous|Next
"); ; $("div.quickStats .statSection").wrapAll("
"); $("div.quickStats").scrollable({ clickable: false, loop: false, size: 1, keyboard: false, next: ".statSectionFeedNext", prev: ".statSectionFeedPrev", items: "div.statSectionScrollable" }); } function load_scheduleStats(){ if($(".mrp_statLoad").length > 0){ $(".mrp_statLoad").each(function() { $(this).html("Loading"); $(this).load("/ui/sch.aspx?actn=getStats&rel=" + $(this).attr("rel")); }); } } function proFav(refId, refType, button) { var link = true; if ($(button).hasClass('active')) link = false; $.post("/ui/fav.aspx", { r: refId, rt: refType, fav: link }, function(data) { if (data == "1") { $(button).addClass('active'); showInfoBoxMessage(""); } else { $(button).removeClass('active'); } }); //alert(refId + " " + refType); return false; } function showInfoBoxMessage(message) { var box = $("#siteInfoBox"); if (box != null) { $(box).html("
You can access your favorites in the \"Lists\" section. Click here to view
"); $(box).show(); } } function markQCGood(parent) { $("#inputCheck").val("yep") } function validateQuickContact(){ if($("#inputCheck").val() =="yep"){ return true; }else { return false; } } //END Quick Contact // Trophy widget function calcTrophies(wins) { if (wins > 0) { $('body').append("
"); if (wins <= 3 && wins > 0) { for (var x = 0; x < wins; x++) { $('.mrp_trophyWrap').append("
"); } } else if (wins > 3) { for (var x = 0; x < 3; x++) { $('.mrp_trophyWrap').append("
"); } wins -= 3; var win = '+' + wins if (wins > 1) { $('.mrp_trophyWrap').append("
" + win + "wins
"); } else { $('.mrp_trophyWrap').append("
" + win + "win
"); } } } } //END Trophy Widget //Event Countdown function initMRPCountdown(cYear, cMonth, cDay, cHours, cMinutes) { var austDay = new Date(); austDay = new Date(cYear, cMonth - 1, cDay, cHours, cMinutes, 0, 0); $('.mrp_counterWrap').countdown({ until: austDay, format: 'DHMS', onTick: function () { $(".mrp_countdown_amount:eq(0)").addClass("first"); $(".mrp_countdown_amount:eq(0)").text(zeroPad(parseInt($(".mrp_countdown_amount:eq(0)").text()), 3)); $(".mrp_countdown_amount:gt(0)").each(function () { $(this).text(zeroPad(parseInt($(this).text()), 2)); }); } }); } //AJAX Ads //Added 1/7/2017 //Used By: RBN, ChiliBowl function lazyloadAds() { $.ajaxSetup({ // Disable caching of AJAX responses cache: false }); var wt = $(window).scrollTop(); //* top of the window var wb = wt + $(window).height(); //* bottom of the window $(".adPlacement:empty").not(".mrp-ad-found").each(function () { var ot = $(this).offset().top; //* top of object (i.e. advertising div) var ob = ot + $(this).height(); //* bottom of object //if ((!$(this).attr("loaded")) && (wt <= ob && wb >= ot) || (ot - 500 <= wb)) { if ((wt <= ob && wb >= ot) || (ot - 100 <= wb)) { initAdSingle(this); $(this).addClass("mrp-ad-found"); } }); } function initAdSingle(el) { var attrib = ""; for (var i = 0; i < el.attributes.length; i++) { if ((el.attributes.item(i).nodeValue != null) && el.attributes.item(i).nodeValue != "") { //IE7 includes attributes that are not explicitly set attrib = attrib + '&' + el.attributes.item(i).nodeName + '=' + el.attributes.item(i).nodeValue + ''; } } requestAd(attrib, $(el)); } function requestAd(extraArgs, ele) { //show ad loader and also put in some html right away so :empty doesn't catch again from above $(ele).html('

'); var pullUrl = "/api/get/ad.aspx"; $.get(pullUrl + "?data=ads" + extraArgs, function (data) { $(ele).html(data); if (extraArgs.split("numtoshow=")[1].split("&")[0] > 0) { var numtoshow = extraArgs.split("numtoshow=")[1].split("&")[0]; var scrolldir = extraArgs.split("scrolldir=")[1].split("&")[0]; var scrolldist = extraArgs.split("scrolldist=")[1].split("&")[0]; //this needs to be more generalized if ((extraArgs.split("placement=")[1].split("&")[0] == "sponsor") && $(".sponsorWrapper .singleAdWrap").length > numtoshow) { $(".sponsorWrapper .adWrap").css('width', '3000em').css('text-align', 'left'); custScroll(1200, 4000, scrolldist, scrolldir, '.sponsorWrapper', '.adWrap', 'singleAdWrap'); } } }); } //End AJAX Ads