var DontShowStoreItems = 0; var customerStatis = 0; var StoreCheckoutLayout=1; /* from base */ function checkvalues2(frm){ var i= 0 ; var fname = ""; var ret = ""; var qret = ""; var fval=""; for (i=0;i 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); } function cwImageSlide(img, ar, tm, txtDiv, textAr, href, hrefID, useToolTip){ var internalVal = tm; var theID = ""; var tot = ar.length; var c = 1; var hrf = ""; var preLoad = new Array(); for (var i = 0; i < tot; i++){ preLoad[i] = new Image(); preLoad[i].src = ar[i]; } function timoutFunc(){ if (document.all){ document.getElementById(img).style.filter="blendTrans(duration=1)"; document.getElementById(img).style.filter="blendTrans(duration=1)"; document.getElementById(img).filters.blendTrans(duration=1).Apply(); document.getElementById(img).filters.blendTrans.Apply(); } document.getElementById(img).src = preLoad[c].src; if (document.all){ document.getElementById(img).filters.blendTrans.Play(); } if (href){ if (!href[c]){ hrf = "#"; }else{ hrf = href[c];} document.getElementById(hrefID).setAttribute('href', hrf); } if (textAr) { document.getElementById(img).setAttribute('title', textAr[c]); document.getElementById(img).setAttribute('alt', textAr[c]); if (document.getElementById('overlay'+img)) document.getElementById('overlay'+img).innerHTML = '

'+textAr[c]+'

'; if (!useToolTip){ //alert(txtDiv); document.getElementById(txtDiv).innerHTML = textAr[c]; } } c++; if (c >= tot) c=0;//clearInterval(intervalID); } this.startSlide = function(){ theID = setInterval(timoutFunc, internalVal); }; } function startSlideShow(divid, ar, tm, textAr, hrefAr, wid, hgt, altData, useToolTip){ var hrf = ''; var hrfend = ''; var hrfend2 = ''; var overlay = ''; var h = "#"; var exstyle = ""; var txtDiv = divid+'_text'; var hrefID = divid+'_href'; if (hrefAr){ if (hrefAr[0]) h = hrefAr[0]; if (textAr && useToolTip){ hrf = ''; }else{ hrf = ''; } hrfend = ''; if (textAr) { hrfend = ''; hrfend2 = ''; exstyle = ' style="cursor:hand;"'; } } if (textAr && useToolTip) overlay = '

'+textAr[0]+'

'; document.write('
'+hrf+''+altData+''+hrfend+overlay+'
'); if (textAr && !useToolTip) document.write(''+textAr[0]+''+hrfend2); var obj = new cwImageSlide(divid, ar, tm, txtDiv, textAr, hrefAr, hrefID, useToolTip); obj.startSlide(); } function addRowToTable(tblID, MyType, txtBox){ var tbl = document.getElementById(tblID); var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow); var MyText = document.frmReview[txtBox]; var cellRightSel = row.insertCell(0); cellRightSel.align='right'; var checkb = document.createElement('input'); checkb.type = 'checkbox'; checkb.name = MyType + '_' + MyText.value; //MyType + iteration; checkb.value = MyText.value; checkb.id = MyType + iteration; cellRightSel.appendChild(checkb); checkb.checked = true; var cellLeft = row.insertCell(1); cellLeft.align='left'; var textNode = document.createTextNode(MyText.value); cellLeft.appendChild(textNode); MyText.value = ''; textlimit(txtBox); } function textlimit(txt, mylen){ var m = document.frmReview[txt]; var b = document.getElementById(txt+'spid'); //var mylen = 30; if (!mylen) mylen=40; if (m.value.length > mylen) m.value = m.value.substring(0,mylen); b.innerHTML = mylen - m.value.length+' characters left'; } function VerifyTheReview(jAr){ var frm = document.frmReview; var err = ""; var x = ""; if (frm.yourname.value == "") err = "Your name"; if (frm.emailorder.value == "") if (!err) err = "Email address or Order number"; else err += "\nEmail address or Order number"; if (frm.ReviewHeading.value == "") if (!err) err = "Review heading"; else err += "\nReview heading"; if (frm.screenname.value == "") if (!err) err = "Screen (nick name)"; else err += "\nScreen (nick name)"; if (frm.selfdescription.value == "") if (!err) err = "Self description"; else err += "\nSelf description"; if (frm.verifyCode.value == "") if (!err) err = "Verify Code"; else err += "\nVerify Code"; if (jAr){ var ar = new Array(); ar = jAr.split(","); for (var i=0; i'+comm+'

'; } } } function cw_roll_gallery_comm(im, comm){ if (document.getElementById){ if ((comm != "undefined") && comm) { document.getElementById('overlay'+im).innerHTML = '

'+comm+'

'; } } } function do_preload_images(img, img2, spid, im, rows, twid, thgt, wid, hgt, bclass, imgstyle, comms) { var ret = ""; var c = 0; var overlay_st = ""; var overlay_fn = ""; var my_img = ""; var cmm = ""; if (!comms) comms = ""; if (document.images){ if(img.length){ var NewImg1 = new Array(); var NewImg2 = new Array(); for (var i=0; i"; overlay_fn = "

"+comms[0]+"

"; } } for (i=0;i"+overlay_fn; if (typeof(comms[i]) != "undefined") cmm = comms[i]; else cmm = ""; if (i==0) { ret = ""; if (imgstyle==3) ret = ret+""; ret = ret+""; if (imgstyle==2) ret = ret+""; ret = ret+"
"+my_img+"
"+my_img+""; } if (c==1) ret = ret+""; ret = ret+""; if (c==rows){ c=0; ret = ret+""; } } if (c > 0){ for (i=c;i<=c;i++){ ret = ret+""; } ret = ret+""; } my_img = overlay_st+""+overlay_fn; if (imgstyle==0) ret = ret+"
 
"+my_img+"
"; if (imgstyle==1) ret = ret+""+my_img+""; if (imgstyle==2) ret = ret+""; document.getElementById(spid).innerHTML = ret; } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); }; } } /* custom */ function openWindow(theURL, wid, hg, rsize, scrl, stbar, menubar) { var st = ""; lt = ((screen.width/2)-(wid/2)); tp = ((screen.height/2)-(hg/2)); if (!wid) wid=600; if (!hg) hg = 600; if (!rsize) rsize = "no"; else rsize = "yes"; if (typeof scrl=="undefined") scrl = 1; if (!scrl) scrl = "no"; else scrl = "yes"; if (!stbar) stbar = "no"; else stbar = "yes"; if (!menubar) menubar = "no"; else menubar = "yes"; st = "left="+lt+","; st = st + "top="+tp+","; st = st + "status="+stbar+","; st = st + "menubar="+menubar+","; st = st + "width="+wid+","; st = st + "height="+hg+","; st = st + "resizable="+rsize+","; st = st + "scrollbars="+scrl; window.open(theURL,'_blank',st); } function findPos(num){ //alert(num) if(bw.ns4){ //Netscape 4 x = document.layers["layerMenu"+num].pageX; y = document.layers["layerMenu"+num].pageY; }else{ //other browsers x=0; y=0; var el,temp; el = bw.ie4?document.all["divMenu"+num]:document.getElementById("divMenu"+num); if(el.offsetParent){ temp = el; while(temp.offsetParent){ //Looping parent elements to get the offset of them as well temp=temp.offsetParent; x+=temp.offsetLeft; y+=temp.offsetTop; } } x+=el.offsetLeft; y+=el.offsetTop; } //Returning the x and y as an array return [x,y]; } function verify_checkout(val){ var i = 0; if (!document.frmbank.payment_method.length){ return true; } for (i = 0; i <= document.frmbank.payment_method.length; i++){ if (document.frmbank.payment_method[i].checked){ return true; } } alert('Please select a payment option'); return false; } var galleryTotalImages = 0; var galleryPosition = 0; var galleryImPerSlide = 4; $(function(){ if ($('#main-pic img').length){ var mpicwid = $('#main-image').attr('data-image-size') - 20; if (mpicwid < 320){ galleryImPerSlide = 3; $('#main-gallery-nav').css('width', '184px'); } $('#main-pic').parent().css('height', mpicwid+80+'px'); var arrpush = parseInt(mpicwid - $('#main-gallery-nav').outerWidth() - 76)/2; $('#main-gallery-navwrap').css('margin-left', arrpush+'px'); //console.log(arrpush); $('#main-pic img').attr('width', mpicwid); doImageZoom($('.gallery-link img:first-child')); var arrow = parseInt($('#arrow-left').attr('data-arrow')); var thumb = parseInt($('#main-gallery').attr('data-thumb')); if (isNaN(arrow)) arrow = 0; if (isNaN(thumb)) thumb = 60; arrow = (arrow * 72); $('#arrow-left').css('background', 'url(/templates/arrows-36.png) -'+arrow+'px'); $('#arrow-right').css('background', 'url(/templates/arrows-36.png) -'+(arrow + 36)+'px'); $('#arrow-left').addClass('greyout'); galleryTotalImages = $('#main-gallery li img').length; if (galleryTotalImages <= galleryImPerSlide) { $('#arrow-right').addClass('greyout').children('a').css({ width: '0', height: '0' }); }else{ $('#arrow-right').removeClass('greyout').children('a').css({ width: '100%', height: '100%' }); } $('#main-gallery li').css('width', '60px'); } }); $('#move-next').on('click', function(e){ e.preventDefault(); var w = $('#main-gallery-nav').outerWidth(); var num = Math.ceil((galleryTotalImages / galleryImPerSlide )); galleryPosition += w; $('#main-gallery').animate({left: '-'+galleryPosition+'px'}); if ((galleryPosition/w)+1 == num){ $('#arrow-right').addClass('greyout').children('a').css({ width: '0', height: '0' }); } $('#arrow-left').removeClass('greyout').children('a').css({ width: '100%', height: '100%' }); }); $('#move-prev').on('click', function(e){ e.preventDefault(); var w = $('#main-gallery-nav').outerWidth(); var num = Math.ceil((galleryTotalImages / galleryImPerSlide )); galleryPosition -= w; $('#main-gallery').animate({left: '-'+galleryPosition+'px'}); if (!galleryPosition){ $('#arrow-left').addClass('greyout').children('a').css({ width: '0', height: '0' }); } $('#arrow-right').removeClass('greyout').children('a').css({ width: '100%', height: '100%' }); }); function doImageZoom($img){ var mainwid = $('#main-pic').outerWidth(); var extra = ''; $('#main-pic').trigger('zoom.destroy'); var fn = $img.attr('data-zoom-img'); var ar = $img.attr('data-image-size').split(','); var width = parseInt(ar[0]); var height = parseInt(ar[1]); if (width > height) imgsize = width; else imgsize = height; if (imgsize < mainwid) { imgsize = mainwid; extra = '&cr'; } $('#main-image').attr('src', '/includes/imcnv.php?f='+fn+'&wh='+imgsize+extra); if ($('html').hasClass('ie8')) extra = 'ie8'; if (extra == '') $('#main-pic').zoom(); } $('.gallery-link img').on('click', function(e){ e.preventDefault(); doImageZoom($(this)); }); function getEdgeDim(itm, doHgt){ var a = 'left'; var b = 'right'; if (doHgt){a = 'top'; b = 'bottom';} var tot = 1; if ($(itm).length){ var ar = new Array( parseInt(($(itm).css('margin-'+a)).replace('auto', '0').replace('px', '')), parseInt(($(itm).css('margin-'+b)).replace('auto', '0').replace('px', '')), parseInt(($(itm).css('padding-'+a)).replace('auto', '0').replace('px', '')), parseInt(($(itm).css('padding-'+b)).replace('auto', '0').replace('px', '')), parseInt(($(itm).css('border-'+a+'-width')).replace('medium', '0').replace('px', '')), parseInt(($(itm).css('border-'+b+'-width')).replace('medium', '0').replace('px', '')) ); for(var i=0;i<6; i++){ if (isNaN(ar[i])) ar[i] = 0; tot += ar[i]; } } return tot; } function resizeMainContentArea(){ var wid = parseFloat($('#main-content-area').outerWidth()); var edge = getEdgeDim('.box-column ul li'); var edgeHgt = getEdgeDim('.box-column ul li', 1); var imrow = 3; var rows = 0; $('.box-column .store-row').each(function(){ var $itm = $(this).children(); rows = $itm.length; var onew = 0; if (rows==1)onew = 1; if ($('html').hasClass('ie8')){ onew = -2 * rows; if (rows==1) onew = 2; } if ($('html').hasClass('ie11')){ onew = 5; } $itm.css('width', parseInt(wid/rows) - edge - onew); }); imrow = rows; if (rows > 3){ imrow = 4; }else if(rows < 1){ imrow = 1; } var hasSmallCl = $('.box-image').hasClass('small-image-group'); if (hasSmallCl) imrow = 4; $('.box-image').addClass('box-image-'+imrow); var imEdge = getEdgeDim('.box-image'); if (!hasSmallCl){ $('.box-column .store-row li:last-child').addClass('box-edge-right'); $('.store-section .box-column:last-child li').addClass('box-edge-bottom'); }else{ $('.store-row').addClass('box-edge-right'); } $('.box-image img').each(function(){ var boxwid = $(this).parent().parent().outerWidth()-imEdge; var boxhgt = $(this).parent().parent().outerHeight()-imEdge; var im = $(this).attr('data-image'); var ar = ($(this).attr('data-image-size')).split(','); var wid = ar[0]; var hgt = ar[1]; var extra = ''; if ((wid < boxwid) && (hgt < boxhgt)) extra = '&cr'; $(this).attr('src', '/includes/imcnv.php?f='+im+'&w='+boxwid+'&h='+boxhgt+extra); /* var ar = ($(this).attr('data-cnr-flag')).split(','); var flag = ar[0]; var fstyle = ar[1]; var fop = ar[2]; if (flag != ''){ var el = $(document.createElement('span')).css({ display: 'block', width: '88px', height: '88px', 'background':' url(/templates/'+flag+'.png) -'+(90 * fstyle)+'px', position: "absolute", opacity: fop, filter:'alpha(opacity='+(fop*100)+')', right: 0, top: 0 }).appendTo($(this).parent().parent()); } */ }); $('.store-row').each(function(){ var hgt = $(this).innerHeight() - edgeHgt; if ($('html').hasClass('ie8')){ $(this).children().css('height', hgt + 10); }else{ $(this).children().css('height', hgt); } }); $('.box-old-price').css({ height: $('.box-sale-price').css('height') , 'line-height': $('.box-sale-price').css('height') }); var $viewmore = $('').addClass('view-more-cnr view-opac-30').click(function() { window.location.href = $(this).parent().find('a').attr('href'); });; $('.box-image').append($viewmore); $('.on-sale').each(function() { var $sale = $('').addClass('is-on-sale-cnr view-opac-30').click(function() { window.location.href = $(this).parent().find('a').attr('href'); }); $(this).append($sale); }); } $(function(){ resizeMainContentArea(); }); $('.box-image').hover(function() { $(this).find('.view-more-cnr').removeClass('view-opac-30').addClass('view-opac-70'); $(this).find('.is-on-sale-cnr').removeClass('view-opac-30').addClass('view-opac-70'); }, function() { $(this).find('.view-more-cnr').removeClass('view-opac-70').addClass('view-opac-30'); $(this).find('.is-on-sale-cnr').removeClass('view-opac-70').addClass('view-opac-30'); }); $('.view-more-link-only').click(function() { window.location.href = $(this).parent().parent().find('a').attr('href'); }); // // jquery.store.js // cw00007.compweb.com.au // // Created by Vlado Golub on 2014-11-11. // Copyright 2014 Vlado Golub. All rights reserved. // var usingInterOptions = 0; var InterOptionsComplete = 0; /* * function called later now */ function refreshCart(){ var url = '/includes/ajax/ajax-refresh-cart.php', data = { rcheck: $('#page-check').val() }, $cart = $('#mycartdiv'); $cart.empty(); $.getJSON(url, data,function(resp){ if (resp.Success == 1){ if (customerStatis == 1){ var $div = $('
'); $div.addClass('account-wrapper'); $div.append(''); var $accel = $(''); $accel.click(function(e){ e.preventDefault(); showLoginBox(); }); $accel.hover(function () { $(this).addClass('account-link-hover'); }, function () { $(this).removeClass('account-link-hover'); }); $div.append($accel); $cart.append($div); } var $el = $('Cart ('+resp.quantity+') $'+resp.total + ''); $el.click(function(e){ e.preventDefault(); goToCheckOut(); }); $cart.append($el); } }); } function checkAllPrices(frmid){ if (usingInterOptions == 0){ var $frm = $('#frmAdd_' + frmid), $selPrice = $($frm.find('.selected-price')[0]), theprice = parseFloat($selPrice.attr('data-base')), datadep = $selPrice.attr('data-dep'), datamin = $selPrice.attr('data-min'), addedw = 0, apnd = ''; if (isNaN(theprice)) theprice = 0; theprice = (datadep == "1") ? parseFloat($frm.find('input[name="price"]').attr('data-base')) : theprice; $('#frmAdd_'+frmid+' .select-options').each(function(){ var val = $(this).val(), ar = val.split('@'); if (ar.length>1){ var added = parseFloat(ar[1]); if (isNaN(added)) added = 0; theprice += added; } if (ar.length>2){ var added = parseFloat(ar[2]); if (isNaN(added)) added = 0; addedw += added; } if (ar.length > 3){ // for image selection var img = ar[3]; //console.log(img); } //if (!apnd) apnd = ' ('+ar[0]; else apnd +=', '+ar[0]; }); $('#frmAdd_'+frmid+' .user-question').each(function(){ var q = $(this).attr('data-question'), val = $(this).val(), ar = val.split('@'); if (!apnd) apnd = ' (' + q + ': ' +ar[0]; else apnd +=', ' + q + ': ' +ar[0]; }); //$('#the-price').text(theprice.toFixed(2)); $frm.find('#price').val(theprice.toFixed(2)); if (datadep != "1"){ $($('.selected-price')[0]).val(theprice.toFixed(2)); }else{ $selPrice.attr('data-total', theprice); $('input[name="isdeposit"]').val(theprice); } $('#cw-price').text('$' + theprice.toFixed(2)); if (!datamin) $selPrice.val(theprice);; $('#addedweight').val(addedw); if (apnd) $('#product-desc').val($('#product-desc').attr('data-base')+apnd+')'); } } function goToCheckOut(){ if (StoreCheckoutLayout !== 1){ window.location.href='/?go=checkout'; }else{ window.location.href='/checkout/'; } } var touchOrClickEvent = ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) ? 'click change' : 'change'; $(function(){ if ($('.interoptions select').length) usingInterOptions = 1; $('.button-link').each(function(index) { $(this).button(); }); $('#quantity').spinner({ spin: function(event, ui){ var max = $(this).attr('data-stock'); if (typeof max !== typeof undefined && max !== false) { if (max != -1){ if (ui.value > max) return false; } } if (ui.value < 1) {$(this).spinner('value', 1);return false;} } }); //if ($('#quantity').attr('data-enabled') == 'disable') if ($('#quantity').attr('data-enabled') == 'disable'){ $('#quantity').spinner("disable"); $('#add_item_wrapper a').unbind('click'); $('#add_item_wrapper a').text('Sold out'); } $('#login-popup').dialog({ autoOpen: false, width: 400, modal: true, show: { effect: 'blind' } }); $('.product-select-options').dialog({ autoOpen: false, width: 300, modal: true, show: { effect: 'blind' }, buttons: { Cancel : function () { $(this).dialog('option', 'hide', 'blind' ); $(this).dialog('close'); allOk = 0; }, OK : function (){ var $diag = $(this); var $sels = $diag.find('.select-options'); var isok = 1; $.each($sels, function(){ var val = $(this).val(); if (val == 'Please Select') val = ''; if (val == ''){ isok = 0; $(this).parent().find('.required-option').text('Required'); } }); if (isok == 1){ $diag.dialog('close'); addItemToBasket($(this).data('item'), 1); } } } }); $('.product-error-message').dialog({ autoOpen: false, width: 300, modal: true, show: { effect: 'blind' }, buttons: { OK : function (){ $(this).dialog('option', 'hide', 'blind' ); $(this).dialog('close'); } } }); refreshCart(); var $sp = $('').addClass('selected-menu-1'); $('.selected-menu').prepend($sp); $('#rp-reset-submit').button().button('widget').css({ 'padding' : '2px', 'font-size' : '0.8em' }); $('.cust-buttons').each(function(index) { $(this).button().button('widget').css('font-size', '80%'); }); $('.cust-reqd').each(function(){ $(this).parent().find('label').addClass('cust-aster2'); }); $('#customer-rp-pop').dialog({ autoOpen: false, modal: true, width: 470, buttons: { 'Reset' : function(){ var url = '/includes/ajax/cust-upd-passw.php', data = { rcheck: $('#page-check').val(), p1: $.trim($('#rp-passw-1').val()), p2: $('#rp-passw-2').val(), }, $err = $('#rp-error-mess'); if (data.p1 == ''){ $err.html('Password cannot be blank').slideDown().delay(3000).slideUp(); return; } if (data.p1 != data.p2){ $err.html('Passwords do not match').slideDown().delay(3000).slideUp(); return; } $.post(url, data, function(resp){ if (resp.success == 1){ if (resp.error == 1){ $err.html(resp.message).slideDown().delay(3000).slideUp(); }else{ $('#rp-success-mess').html(resp.message).slideDown().delay(3000).slideUp('slow', function(){ $('#customer-rp-pop').dialog('close'); }); } } }, 'json'); }, 'Cancel' : function() { $(this).dialog('close'); } }, open: function(){ $('#rp-passw-1').val(''); $('#rp-passw-2').val(''); for(var i = 1; i <= 6; i++) $('#rp-passw-strength').removeClass('pw-strength-' + i); } }); $('#popup-past-order').dialog({ autoOpen: false, modal: true, width: 800, buttons : { 'Download PDF' : function(){ var url = '/includes/generatepdf.php?dinv=' + $(this).attr('data-inv') + '&rcheck=' + $('#page-check').val(); window.location.href = url; $('#popup-past-order').dialog('close'); }, 'Close' : function() { $(this).dialog('close'); } } }); $('#send-reset-pw').button().button('widget').css('font-size', '80%'); if ($('#box-sale-spec-main').length){ loadProductSpecialData(); } if ($('.store-spec-groups').length){ loadStoreSpecialItems(); } $('.store-show-new-items').each(function(index) { var url = '/includes/ajax/get-new-store-items.php', $el = $(this), data = { rcheck: $('#page-check').val(), days: $(this).attr('data-days'), numprow : $(this).attr('numpy-rows') }; $el.empty(); $.getJSON(url, data, function(resp){ if (resp.success == 1){ $.each(resp.items, function(index, box) { $box = $(box); $box.hover(function(e){ $(this).addClass('spec-hover'); }, function(e){ $(this).removeClass('spec-hover'); }); $el.append($box); }); } }); }); }); function loadStoreSpecialItems(){ var url = '/includes/ajax/store-spec-groups.php'; if (!$('.store-spec-groups').hasClass('columnWrap')) $('.store-spec-groups').addClass('columnWrap'); $('.store-spec-groups').each(function(index) { $el = $(this), data = { rcheck: $('#page-check').val(), group: $el.attr('data-group'), ipr: $el.attr('data-ipr'), wid: $el.width() }; $el.empty(); $.getJSON(url, data, function(resp){ if (resp.success == 1){ //$el.append(resp.items); $.each(resp.items, function(index, box) { $box = $(box); $box.hover(function(e){ $(this).addClass('spec-hover'); }, function(e){ $(this).removeClass('spec-hover'); }); $el.append($box); }); } }); }); } var specTimeInterval = null; function pad (str, max) { str = str.toString(); return str.length < max ? pad("0" + str, max) : str; } function showSpecialClock(days, hours, mins, secs){ if (specTimeInterval) clearInterval(specTimeInterval); var s = secs; specTimeInterval = setInterval(function(){ var html = '

' + pad(days, 2) + ':' + pad(hours, 2) + ':' + pad(mins, 2) + ':' + pad(s, 2) + '

'; html += '

Days Hours Mins Secs

'; s -= 1; if (s <= 0){ clearInterval(specTimeInterval); loadProductSpecialData(); } $('#box-sale-spec-main').html(html); }, 1000); } function loadProductSpecialData(){ var url = '/includes/ajax/get-product-special.php', data = { rcheck: $('#page-check').val(), id: $('#cw-product-id').val() }; //console.log(data); $.getJSON(url, data, function(resp){ if (resp.success == 1){ if (resp.isok == 1){ if (resp.clock == 1){ $('#box-sale-spec-main').show(); showSpecialClock(resp.days, resp.hours, resp.mins, resp.secs); } }else{ window.location.reload(true); } } }); } $('#quantity').on('input propertychange paste focusout', function() { var stock = $(this).attr('data-stock'); if (stock != -1){ var num = ($.isNumeric($(this).val())) ? $(this).val() : 1; if ((num * 1) > (stock * 1)) num = stock; $(this).val(num); } }); $('.continue-shopping').on('click', function(e){ e.preventDefault(); window.location.href='/store/'; }); $('.select-options').on(touchOrClickEvent, function(){ checkAllPrices($(this).attr('data-id')); var v = $(this).val(); if (v.indexOf('@') != -1){ var ar = v.split('@'); if (ar.length > 3 && ar[3] != ''){ var img = ar[3]; $('.cw-img-thumbs[data-src="' + img + '"]').trigger('click'); } } }); function cwParseInt(val){ var i = parseInt(val); if (isNaN(i)) return 0; else return i; } function addItemToBasket($this, ismall){ var $par = $this.parent(), frmid = $this.attr('data-id'), $frm = $('#frmAdd_'+frmid), url = '/includes/ajax/ajax.itemadd.verity.php', datadep = cwParseInt($frm.find('.selected-price').attr('data-dep')), data = { price: (datadep == 0) ? $frm.find('.selected-price').val() : $frm.find('.selected-price').attr('data-total'), depamount: (datadep == 0) ? 0 : $frm.find('.selected-price').val(), qty: $frm.find('#quantity').val(), allowz: $this.attr('data-allowz'), pt: $this.attr('data-pt'), min: $frm.find('.selected-price').attr('data-min'), pmax: $this.attr('data-pmax'), rcheck: $('#page-check').val() }; $.getJSON(url, data, function(resp){ if (resp.success == 1){ if (ismall == 1){ var w = $this.width(); var h = $this.height(); $par.removeClass('std-button std-button-small').text('').addClass('wait-box-checkout'); }else{ $par.empty().addClass('wait-box'); } var url = '/includes/ajax/ajax-cartadd.php'; $.getJSON(url, $frm.serialize()).done(function(resp){ if (resp.Success){ if (ismall == 0){ $par.removeClass('wait-box').removeClass('add_item_layout').css('width', 'auto').hide().show(800, function(){ $('Go to Checkout').addClass('check-button ui-corner-all').click(function() { goToCheckOut();}).appendTo($(this)); }); }else{ var $el = $('Added').addClass('std-button std-button-small').click(function() { goToCheckOut();}); $par.removeClass('wait-box-checkout').hide().text('Added') .addClass('std-button-checkout std-button-small') .show('slide',{direction:'right'}, 800).hover(function() { $(this).addClass('std-button-hover'); }, function() { $(this).removeClass('std-button-hover'); }) .click(function() { goToCheckOut();}) .hide('bounce', 2000, function(){ $(this).text('Checkout').show(); }); } if (resp.message != ''){ $('.cw-prod-but-holder').append('
' + resp.message + '
'); $('#quantity').val(resp.max); } refreshCart(); }else{ $par.removeClass('wait-box').html('An error occurred'); } }); }else{ isok = 0; } $('#add_item_error_'+frmid).text(resp.message); if (ismall && (resp.message != '')){ $('#product-popop-'+frmid).dialog('open'); } }); } function AddItemClickEvent($el){ checkAllPrices($el.attr('data-id')); var isok = 1; $('.required-option').text(''); if (usingInterOptions == 0){ $('#frmAdd_'+$el.attr('data-id')+' .select-options').each(function(){ var val = $.trim($(this).val()); if (val == 'Please Select') val = ''; if (val == ''){ $(this).parent().find('.required-option').text('Required'); isok = 0; } }); if (isok == 0) return; }else{ $('#frmAdd_'+ $el.attr('data-id') + ' .interoptions select').each(function(index) { if ($(this).val() == '-Select-'){ $(this).parent().find('.required-option').text('Required'); isok = 0; } }); } if (isok == 1) addItemToBasket($el, 0); } $('#add_item_wrapper a').on('click', function(e){ e.preventDefault(); AddItemClickEvent($(this)); }); $('.store-page-itpp').on('change', function(){ window.location.href = '/store/' + $(this).attr('data-url') + '&itpp=' + $(this).val(); }); $('.store-page-cnum').on('change', function(){ window.location.href = '/store/' + $(this).attr('data-url') + '&cnum=' + $(this).val(); }); $('.store-page-ordr').on('change', function(){ window.location.href = '/store/' + $(this).attr('data-url') + '&ordr=' + $(this).val(); }); $('.edit-my-account').on('click', function(e){ e.preventDefault(); window.location.href = '/?go=updateme'; }); $('.std-button').mouseover(function() { $(this).css('cursor', 'pointer').addClass('std-button-hover') .find('.std-button-triangle').removeClass('std-button-triangle-off').addClass('std-button-triangle-on'); }).mouseleave(function() { $(this).css('cursor', 'default').removeClass('std-button-hover') .find('.std-button-triangle').removeClass('std-button-triangle-on').addClass('std-button-triangle-off'); }); $('.quick-add-wrapper .std-button').on('click', function(){ var dopop = $(this).attr('data-dopop'); var id = $(this).attr('data-id'); var $par = $(this).parent().parent(); var allOk = 1; if (dopop == 1){ $('#product-popop-'+id).data('item', $(this)).dialog('open'); }else{ addItemToBasket($(this), 1); } }); /** * section for interactive options */ function interOptionChange(that){ var $select = $(that); var id = $select.attr('data-id'); var $opt = $('option:selected', that); var selopt = $select.parent().attr('class'); var $par = $select.parent().parent(); var name = $opt.val(); if (selopt == 'primary-option'){ $par.find('.secondary-option').slideUp('slow'); $par.find('.tertiary-option').slideUp('slow'); }else if (selopt == 'secondary-option'){ $par.find('.tertiary-option').slideUp('slow'); } if (name != '-Select-'){ var weight = $opt.attr('data-weight'), adval = $opt.attr('data-value'), simg = $opt.attr('data-image'), itemid = $opt.attr('data-item-id'), rc = $select.parent().parent().attr('data-rc'), $pForm = $('#frmAdd_'+id), $price = $pForm.find('#price'), base = $price.attr('data-base'), $desc = $pForm.find('#product-desc'), url = '/includes/ajax/ajax.interoptions.php', data = { rcheck: rc, so: selopt, n: name, w: weight, sm: simg, av: adval, prid: id, optid: itemid, bs: base }; $.getJSON(url, data, function(resp){ usingInterOptions = 1; if (resp.success==1){ InterOptionsComplete = resp.complete; if (resp.complete == 0){ if (resp.drop.length){ var cls = resp.fillobj; var heading = resp.drop[0].heading; var $sel = $(''); $frm.append($rcitem); }else{ $rcitem.val($('#page-check').val()); } data = $frm.serialize(); $.post(url, data, function(resp){ if (resp.success == 1){ $frm.empty(); var $el = $('
'); $el.addClass('cont-success-message'); $el.html(resp.message); $frm.append($el); $el.slideDown('slow'); }else if (resp.error == 1){ $mesbox.html(resp.message).slideDown(); } }, 'json'); }); var mClickHandler = 'click'; //('touchstart' in document.documentElement ? 'touchstart' : 'click'); $(function(){ setupQuickBuy(); FoundationRockHack(); TomThumbsHach(); }); var $frockbox = null; function FoundationRockHack(){ if (cw_version_site != 1053) return; $frockbox = $('
'); $('#side-prod-info').append($frockbox); var img = $('#cw-image-main').attr('data-src'); if (img) makeFoundationRockLink(img); } function makeFoundationRockLink(img){ if ($frockbox == null) return; $frockbox.empty(); var $a = $('Full image ' + img + ''); $frockbox.append($a); } function TomThumbsHach(){ if (cw_version_site != 1106) return; var $copyright = $('