/*Created By Darwin Ngo*/ function df() { //Do Nothing for now } $(document).ready(function () { //Global page javascripts $('#ErrorMessage').click(function () { $(this).fadeOut(); }); $(document).mousemove(function (e) { $('.loadingAjax').css({ 'left': e.pageX + 5, 'top': e.pageY - 0 }); }); /*Show the progress Ajax spin icon for the form*/ //Show all categories $(document).on("click", ".click-spin", function (e) { UpdatePanelSendingData(); }) $(document).on("change", ".change-spin", function (e) { UpdatePanelSendingData(); }) /*auto scroll the image at the product page*/ if ($(".scroll")[0]) { $(function () { $(".scroll").jScroll({ speed: "slow" }); }); } /*show/hide. To use this function assign the class="ShowHide showAdvanceOption". The focus area must have cmd in front of the class for example cmdshowAdvanceOption. The id should be use for server side only.*/ $(document).on("click", ".CmdShowHide", function (e) { var _x = $(this).attr("class").split(" ")[1]; $(".cmd" + _x).slideToggle("slow"); }); if ($(".scroll")[0]) { $(function () { $(".scroll").jScroll({ speed: "slow" }); }); } //css navigator fixer for internet explorer browsers if (navigator.userAgent.match(/msie/i) != null) { $(".navmenu-h li, .navmenu-v li").hover(function () { $(this).addClass("iehover"); }, function () { $(this).removeClass("iehover"); }); } // //Control SearchTxtBox // $(document).on("focusin", ".SearchTxtBox", function (e) { // if ($(this).val().toLowerCase() == "keyword search") { $(this).val("") } // }); // $(document).on("focusout", ".SearchTxtBox", function (e) { // if ($(this).val() == "") { $(this).val("Keyword Search") } // }); // $(document).on("keydown", ".SearchTxtBox", function (e) { // if ($(this).val() == "Keyword Search") { $(this).val("") } // }); //Scroll back to top $(".footerBackToTop").click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); $(document).on("focusin", ".HomePageProducts", function (e) { if ($(this).val().toLowerCase() == "keyword search") { $(this).val("") } }); //Limit the category results if ($(".HomePageProducts").hasClass("HomePageProducts")) { var limit = $(".HomePageProducts").attr("class").split(" "); if (limit.length > 1) { var _value = limit[1].replace("LimitTo", ""); $(".phold").each(function (index, element) { if (index > _value - 1) { $(element).hide(); } }); } $(".ViewAllCategories").show(); } //Show all categories $(document).on("click", ".ViewAllCategoriesLnk", function (e) { $(".phold").each(function (index, element) { $(element).fadeIn(); }) $('html,body').animate({ scrollTop: '+=170px' })//Scroll down 100px $(".ViewAllCategoriesLnk").hide(); }) //Product page click within the product area $(document).on("click", ".phr", function (e) { window.location = $(this).find('a').attr('href') }); ///Show and hide sizing chart $(".sizingChart").hide(); $(document).on("click", ".sizingOnOff", function (e) { $(".sizingChart").slideToggle("slow"); return false; }); //Show Hide usage pass class and ID to call function "ShowHide TargetID" $(document).on("click", ".ShowHide", function (e) { var _x = $(this).attr("class").split(" "); $("#" + _x[1]).slideToggle("slow"); return false; }); $(document).on("click", "#image1", function (e) { PopWindowZoom(); return false; }); //PMS -100 -Begin var _pmsClickedA = ""; var _LastColorList = ""; //Click on the PMS color box $(document).on("click", ".showPMSBox", function (e) { $("#" + _LastColorList).hide(); _pmsClickedA = $(this); //Change ID if click on textbox, set it to imagebox if (_pmsClickedA.attr("id").indexOf("ImprintColor") >= 0) { _pmsClickedA = $("#" + _pmsClickedA.attr("id").replace("ImprintColor", "PMSAreaColorBox")); } var _colorList = _pmsClickedA.attr("id").split("PMSAreaColorBox")[0] + "PMSAreaColorBoxList"; _LastColorList = _colorList; $("#" + _colorList).html($("#ImprintType_" + $("#imprintType_0").prop("checked", true).val()).html()); $("#" + _LastColorList).show(); return false; }) //Click on the select PMS color box $(document).on("click", ".CaptPMS", function (e) { //Click on color image _pmsClickedA.attr("src", $(this).attr("src")) $("#" + _pmsClickedA.attr("id").replace("PMSAreaColorBox", "ImprintImageSrc")).val($(this).attr("src")); $("#" + _pmsClickedA.attr("id").replace("PMSAreaColorBox", "ImprintColor")).val($(this).attr("title")); //Save value $("#" + _pmsClickedA.attr("id").replace("PMSAreaColorBox", "ImprintColor")).hide(); //hide textbox $("#" + _pmsClickedA.attr("id")).show(); //show colorbox $("#" + _LastColorList).hide(); return false; }) //Close the pms screen $(document).on("click", ".closeit", function (e) { $("#" + _LastColorList).hide(); return false; }) //Click on the Custom PMS Box $(document).on("click", ".ClickCustomPMS", function (e) { var _customPMS = $("#PMSCustom").html().replace("PMSCode", "PMSCodeActive"); $("#" + _LastColorList).html(_customPMS); $('#PMSCodeActive').focus(); return false; }) //Confirm PMS $(document).on("click", ".PMSCustom_Confirm", function (e) { $("#" + _pmsClickedA.attr("id").replace("PMSAreaColorBox", "ImprintColor")).val($('#PMSCodeActive').val()); //Save value $("#" + _pmsClickedA.attr("id")).hide(); //Hide color box $("#" + _pmsClickedA.attr("id").replace("PMSAreaColorBox", "ImprintImageSrc")).val(''); //Set to nothing $("#" + _pmsClickedA.attr("id").replace("PMSAreaColorBox", "ImprintColor")).show(); //show textbox $("#" + _LastColorList).hide(); return false; }); //PMS -100 -End //Fixed drop down when mouseover //$('.dropdown').hover(function () { // if ($(window).width() > 768) { // $('.dropdown-toggle', this).trigger('click'); // } else { // $('.dropdown-toggle', this).trigger('hover'); // } //}); }); function LiveChat(theurl) { NewWindow(theurl, 'livechat', '525', '525', 'no'); } function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; var winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable'; var win = window.open(mypage, myname, winprops); if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } /*Blink Error*/ var BlinkTimer; var IsClicked = ""; var LastKeyPressed = ""; //Detect click $(document).click(function (e) { IsClicked = "1"; }); //Detect keyboard $(document).keypress(function (e) { LastKeyPressed = e.which; }); function BlinkRequireForQ_E(blinkID) { if (IsClicked == "" && LastKeyPressed == "") { BlinkIt(blinkID); BlinkTimer = setTimeout("BlinkRequireForQ_E('" + blinkID + "')", 600); } else { if (blinkID != "") { var blinkIt = document.getElementById(blinkID) blinkIt.style.borderColor = '#FFFFFF'; blinkID = ""; } } } function BlinkIt(box) { var blinkIt = document.getElementById(box) var done; var myborder = '' + blinkIt.style.borderStyle + '' if (myborder.search('solid') == -1) { blinkIt.style.borderStyle = 'solid' blinkIt.style.borderColor = '#fa834e'; blinkIt.style.borderWidth = '2px'; done = "Y"; } if (myborder.search('solid') == 0 && done != 'Y') {/*make it invisible*/ blinkIt.style.borderStyle = 'dotted'; blinkIt.style.borderColor = '#FFFFFF'; } } /*zoom and popup zoomed image*/ function RunZoom() { $(document).ready(function () { var _wh = parseInt($(".rightcolumn").css("width")) - parseInt($(".pImages").css("width")) - 4 $("#image1").elevateZoom({ gallery: 'gallery_01', scrollZoom: true, borderSize: 2, maxZoomLevel: false, zoomWindowWidth: _wh, zoomWindowHeight: _wh, cursor: 'pointer', galleryActiveClass: 'active', imageCrossfade: true, loadingIcon: '/fs/ajax-spinner.gif.c' }); return false; }); } //Additional codes written to add extra features by by Darwin Ngo //Open new window if click instead of mouseover function PopWindowZoom() { var ez = $('#image1').data('elevateZoom'); //alert("test yyr" + ez.zoomImage); //To view object infor use following .toSource()/ var _popUrl = new Image(); //Create element to get the origional image size instead of the zoomed size _popUrl.src = ez.zoomImage; NewWindow('/largeimage/?q=' + escape($("#image1").attr("src")).replace("/m/", "/l/"), 'largeIm', _popUrl.width + 20, _popUrl.height + 20, 'yes'); } /*JS Cookie - Begin This section is for helping browser to refocus the last click on the qty for jon ie browser */ function saveFocus(targetId) { createCookie("LastFocus", targetId.id, 20); } function ReFocus() { setTimeout("ffocus()", 200); } function ffocus() { if (navigator.userAgent.match(/msie/i) == null) { var lf = readCookie("LastFocus"); $('#' + lf).focus(); } } function createCookie(c_name, value, seconds) { var exdate = new Date(); exdate.setSeconds(exdate.getDate() + seconds); var c_value = escape(value) + ((seconds == null) ? "" : "; expires=" + exdate.toUTCString()); document.cookie = c_name + "=" + c_value; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function eraseCookie(name) { createCookie(name, "", -1); } //Popup new window function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable' win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } //Auto fill function calc_averages(reset) { var _RemainingAutofill; $(".sizeAF").each(function (index, element) { if (reset == true) { $("#" + $(element).attr("id").replace("sizeAF", "qty")).val(''); } for (var i = 0; i < _autoFill.length; i++) { if ($(element).html() == _autoFill[i][0]) { if (reset == false) { $("#" + $(element).attr("id").replace("sizeAF", "qty")).val(parseInt(_autoFill[i][1] * parseInt($("#desired_quantity").val()))); if (_autoFill[i][0] == "Adult-Large" || _RemainingAutofill == null) { _RemainingAutofill = $(element).attr("id").replace("sizeAF", "qty"); } } } } }); var totalQty = 0; $(".enter-qty").each(function () { if ($.isNumeric($(this).val())) { totalQty = parseFloat(totalQty) + parseFloat($(this).val()); } }); if (totalQty != parseInt($("#desired_quantity").val())) { if (_RemainingAutofill != null && reset != true) { $("#" + _RemainingAutofill).val(parseInt($("#" + _RemainingAutofill).val()) + parseInt($("#desired_quantity").val()) - totalQty) } }; __doPostBack('ctl00_ct_UpdatePanel1', ''); } function FullPostBackShowSpin() { $("#showLoading").show(); } function UpdatePanelSendingData() { $("#ctl00_ct_UpdateProgress1").show(); }