var sc = jQuery.noConflict(true); sc(document).ready(function() { var speed = 'normal'; var min_size = 0; var max_size = 300; sc('#sc-top > a').click(function(event) { event.preventDefault(); var clicked = sc(this); var myClass = sc(this).attr('class').split(' ')[0]; //console.log(myClass); sc('#sc-top > a').removeClass('active'); sc(clicked).addClass('active'); sc('#sc-slider').removeClass() sc('#sc-slider').addClass(myClass); sc('#sc-middle #sc-slide-wrap > div:visible').fadeOut(speed, function() { //sc('#sc-middle .'+myClass).fadeIn(speed); }); sc('#sc-middle .'+myClass).fadeIn(speed); }); var slides = sc('#sc-middle #sc-slide-wrap > div'); var links = sc('#sc-top > a'); sc(slides).first().show() sc('#right-arrow-wrap').click(function(event) { event.preventDefault(); var currentSlide = sc(slides).filter(':visible'); var currentLink = sc(links).filter('.active'); var nextSlide = sc(currentSlide).next().is('div') ? sc(currentSlide).next() : sc(slides).first(); var nextLink = sc(currentLink).next().is('a') ? sc(currentLink).next() : sc(links).first(); var myClass = sc(nextLink).attr('class'); sc('#sc-slider').removeClass(); sc('#sc-slider').addClass(myClass); sc(currentSlide).animate({'right': '-100%'}, speed, function() { sc(this).css({'display': '', 'left': '', 'right': ''}); }); sc(nextSlide).css({display: 'block', right: '100%'}).animate({'right': '0%'}, speed, function() { sc(this).css({'right': ''}); }); sc(currentLink).removeClass('active'); sc(nextLink).addClass('active'); }); sc('#left-arrow-wrap').click(function(event) { event.preventDefault(); var currentSlide = sc(slides).filter(':visible'); var currentLink = sc(links).filter('.active'); var prevSlide = sc(currentSlide).prev().is('div') ? sc(currentSlide).prev() : sc(slides).last(); var prevLink = sc(currentLink).prev().is('a') ? sc(currentLink).prev() : sc(links).last(); var myClass = sc(prevLink).attr('class'); sc('#sc-slider').removeClass(); sc('#sc-slider').addClass(myClass); sc(currentSlide).animate({'left': '-100%'}, speed, function() { sc(this).css({'display': '', 'left': '', 'right': ''}); }); sc(prevSlide).css({display: 'block', left: '100%'}).animate({'left': '0%'}, speed, function() { sc(this).css({'left': ''}); }); sc(currentLink).removeClass('active'); sc(prevLink).addClass('active'); }); sc('.plus, .minus').disableSelection(); sc('.plus').click(function(event) { event.preventDefault(); var input = sc(this).parent().find('input'); var val = parseInt(sc(input).val()); if (isNaN(val)) { val = 0 } val += 1; sc(input).val(val); sc(input).keyup(); }); sc('.minus').click(function(event) { event.preventDefault(); var input = sc(this).parent().find('input'); var val = parseInt(sc(input).val()); if (isNaN(val)) { val = 0 } val -= 1; if (val < 0) { val = 0 } sc(input).val(val); sc(input).keyup(); }); var inputs = sc('#sc-wrap input'); inputs.off(); inputs.keyup(function(event) { event.preventDefault(); //console.log(event); var total = 0; sc(inputs).each(function() { var num = parseInt( sc(this).val() ); if (isNaN(num) || num < 0) { num = 0; } if ( sc(this).is(':focus') ) { if(event.keyCode == 38) { num += 1; } else if (event.keyCode == 40) { num -= 1; if (num < 0) { num = 0; } } sc(this).val(num); } var value = sc(this).data('value'); if (isNaN(value)) { value = 0; } total += ( num * value ); if ( sc(this).is(':focus') ) { //console.log(num); //console.log(value); //console.log(total); } }); total = Math.round( total * 1.15 ); var size; var section; if (total <= 20 && min_size <= 2 && max_size >= 2) { size = '1x2'; total /= 0.2; section = 0; } else if (total <= 150 && min_size <= 15 && max_size >= 15) { size = '3x5'; total /= 1.5; section = 0; } else if (total <= 200 && min_size <= 20 && max_size >= 20) { size = '2.5x8'; total /= 2; section = 0; } else if (total <= 250 && min_size <= 25 && max_size >= 25) { size = '5x5'; total /= 2.5; section = 0; } else if (total <= 300 && min_size <= 30 && max_size >= 30) { size = '5x6'; total /= 3; section = 0; } else if (total <= 320 && min_size <= 32 && max_size >= 32) { size = '4x8'; total /= 3.2; section = 0; } else if (total <= 400 && min_size <= 40 && max_size >= 40) { size = '5x8'; total /= 4; section = 0; } else if (total <= 480 && min_size <= 48 && max_size >= 48) { size = '6x8'; total /= 4.8; section = 0; } else if (total <= 500 && min_size <= 50 && max_size >= 50) { size = '5x10'; total /= 5; section = 0; } else if (total <= 640 && min_size <= 64 && max_size >= 64) { size = '8x8'; total /= 6.4; section = 0; } else if (total <= 720 && min_size <= 72 && max_size >= 72) { size = '6x12'; total /= 7.2; section = 0; } else if (total <= 750 && min_size <= 75 && max_size >= 75) { size = '5x15'; total /= 7.5; section = 0; } else if (total <= 800 && min_size <= 80 && max_size >= 80) { size = '8x10'; total /= 8; section = 1; } else if (total <= 960 && min_size <= 96 && max_size >= 96) { size = '8x12'; total /= 9.6; section = 1; } else if (total <= 1200 && min_size <= 120 && max_size >= 120) { size = '8x15'; total /= 12; section = 2; } else if (total <= 1440 && min_size <= 144 && max_size >= 144) { size = '12x12'; total /= 14.4; section = 2; } else if (total <= 1600 && min_size <= 160 && max_size >= 160) { size = '8x20'; total /= 16; section = 2; } /* else if (total => 1601 || total > max_size * 10) { size = 'Call Us!'; total /= 16.01; section = 2; }*/ else{ size = 'Call Us!'; total /= 16.01; section = 2; } total = Math.round(total); //console.log({'total': total, 'size': size}); sc('#sc-bottom #sc-size-fill').css({'height': (100-total)+'px', 'margin-bottom': total+'px'}); sc('#sc-bottom #sc-size, #sc-bottom #sc-size-fill').html(size); sc('#sc-bottom #sc-button').attr('data-section', section); }); });