var orderMinimums = {"White":"10000","Natural":"10000","Coloured":"10000","Transparent":"10000"}; function prettyPhotoInit() { //prettyPhoto jQuery('a[rel^="prettyPhoto"], a[rel^="nyromodal"]').prettyPhoto({ deeplinking: false, slideshow: 5000, social_tools: '' }); } jQuery(document).ready(function() { //tab link handling jQuery('a[href="#tabs-1"], a[href="#tabs-2"], a[href="#tabs-3"], a[href="#tabs-4"]').click(function (event) { event.preventDefault(); return false; }); //custom dropdown //jQuery("SELECT").selectbox(); //dropdown extra handling jQuery('body').delegate('.sbHolder a','click', function() { var holder = jQuery(this).closest('.sbHolder'); //only add open class if select is not disabled if (!holder.hasClass('sbHolderDisabled')) { if (!jQuery(holder).hasClass('open')) { jQuery('.sbHolder').removeClass('open'); jQuery(holder).addClass('open'); } else { jQuery('.sbHolder').removeClass('open'); } } } ); //close dropdown on click outside jQuery('div').live('click', function(e) { e.stopPropagation(); if (!jQuery(this).hasClass('sbHolder') && !jQuery(this).hasClass('sbToggle') && !jQuery(this).hasClass('sbSelector') && !jQuery(this).hasClass('sbOptions')) { jQuery('select').selectbox('close'); jQuery('.sbHolder').removeClass('open'); } } ); // //products caroussel - activate only, if there are more than 5 elements in the list function createCaroussel() { //activate (show) buttons jQuery('#familyJar a#carousselPrev, #familyJar a#carousselNext').addClass('visible'); //disable caroussel navigation prev link on first load jQuery('#carousselPrev').addClass('disabled'); //disable caroussel navigation next if number of products less or equal than 5 if ( jQuery('#familyJar #caroussel ul li').size() <= 5 ) { jQuery('#carousselNext').addClass('disabled'); } else { jQuery('#carousselNext').removeClass('disabled'); } //append carousel jQuery('#familyJar #caroussel').jCarouselLite({ btnNext: '#carousselNext', btnPrev: '#carousselPrev', visible: 5, speed: 400, circular: false, easing: 'easeInOutQuad' }); } //disable caroussel navigation link jQuery('#carousselNext, #carousselPrev').live('click', function(e){ e.preventDefault(); }); /*PRODUCT CONFIGURATOR - FIRST PAGE ------------------------------------------------------------------------------------*/ var families = jQuery('[id^=family-]').live('click', function(){ var thisFamily = jQuery(this); var id = jQuery(this)[0].id.substr(parseInt(jQuery(this)[0].id.indexOf('-'))+1); var reselectSlider = false; jQuery.getJSON('index.php?r=ProductSearch&l=en&family='+id, function(data){ volumeValMap = data; }) .complete(function() { //when json loading complete var slider = jQuery('#slider'); //destroy slider and rebuild slider.slider('destroy'); createSlider(); //set re-select var or delete volume data if (jQuery('body').data('family') == undefined && jQuery('body').data('volume') != undefined) { reselectSlider = true; } else { jQuery('body').removeData('volume'); toggleProductDetailsLink(true); } //save value to data var readableValue = jQuery.trim(thisFamily.find('span').text()); storeData('family', id, readableValue); //re-select right volume if already chosen if (reselectSlider) { var idIndex; for (i = 0; i < volumeValMap.length; i++) { if (volumeValMap[i][0] == jQuery('body').data('volume').id) { //alert(i); idIndex = i; break; } } slider.slider('value', idIndex); } //add selected class to family jQuery('[id^=family-]').removeClass('selected'); thisFamily.addClass('selected'); //show reset button jQuery('a#showAllVolumes').show(); }); }); //handle product details link jQuery('a#prodDetailsLink.inactive').live('click', function(e){ e.preventDefault(); jQuery('div.boxRight span.infoBox').show(); return false; }); //handle reset buttons jQuery('a#showAllVolumes, a#showAllFamilies').click(function(e) { e.preventDefault(); //reset all volumes and families to default volumeValMap = defaultVolumeValMap; jQuery('#families').html(defaultFamilies); //destroy slider and rebuild var slider = jQuery('#slider'); slider.slider('destroy'); createSlider(); //destroy caroussel and rebuild jQuery('#familyJar #caroussel').jCarouselLite = null; jQuery('#carousselPrev').unbind('click'); jQuery('#carousselNext').unbind('click'); createCaroussel(); //empty saved data and reset view jQuery('body').removeData('volume'); jQuery('body').removeData('family'); toggleProductDetailsLink(true); return false; }); //PRODUCT VOLUME SLIDER var defaultVolumeValMap = []; //save default array var defaultFamilies = jQuery('#families').html(); //fill volume map on first load volumeValMap = defaultVolumeValMap; jQuery('#volumes li').each(function(){ var id = jQuery(this)[0].id.substr(parseInt(jQuery(this)[0].id.indexOf('-'))+1); var value = jQuery.trim(jQuery(this).text()); defaultVolumeValMap.push([id, value]); }); function createSlider() { jQuery('#slider').slider({ min: 0, max: volumeValMap.length - 1, change: function( event, ui ) { var id = volumeValMap[ui.value][0]; //only call json if we do not have a family selected if (jQuery('body').data('family') == undefined) { jQuery.getJSON('index.php?r=ProductSearch&l=en&volume='+id, function(data){ jQuery('#families').html(''); jQuery.each(data, function(i, v) { jQuery('#families').append(v); }); }) .complete(function() { //when json loading complete //destroy caroussel and rebuild jQuery('#familyJar #caroussel').jCarouselLite = null; jQuery('#carousselPrev').unbind('click'); jQuery('#carousselNext').unbind('click'); createCaroussel(); }); } //alert(ui.value); //save value to data var readableValue = volumeValMap[ui.value][1]; storeData('volume', id, readableValue); //alert(readableValue); //show reset button jQuery('a#showAllFamilies').show(); //select right tick selectTick(ui.value); }, slide: function( event, ui ) { selectTick(ui.value); } }); generateTicks(); } createSlider(); createCaroussel(); function generateTicks() { //remove all previous ticks jQuery('#slider').find('div.tick').remove(); jQuery(volumeValMap).each(function(i) { var tick = jQuery('
' + this[1] + '
').appendTo(jQuery('#slider')); //position tick tick.css({ left: (100 / (volumeValMap.length-1) * i) + '%' }); //label visible on first and last tick if (i == 0 || i == volumeValMap.length-1) { jQuery(tick).addClass('tick-visible-txt'); } //when all generated append hover events if (i == volumeValMap.length-1) { jQuery('#slider div.tick').hover( function () { if (!jQuery(this).hasClass('selected')) { jQuery(this).addClass('tick-hover'); } }, function () { if (!jQuery(this).hasClass('selected')) { jQuery(this).removeClass('tick-hover'); } }); } }) jQuery('div.tick span:first').append(' ml'); if(jQuery('div.tick span').length > 1) { jQuery('div.tick span:last').append(' ml'); } } function selectTick(ui) { //show text on underlaying tick var slider = jQuery('#slider'); if (ui != 0 && ui != volumeValMap.length-1) { slider.parent().find('div.tick').removeClass('tick-hover'); slider.parent().find('div.tick:eq('+ui+')').addClass('selected'); } else { slider.parent().find('div.tick').removeClass('selected'); } //show handle slider.find('a.ui-slider-handle').show(); } //store data in jquery data object function storeData(variable, id, value) { jQuery('body').data(variable, {id: id, readValue: value}); var selectedVolume = jQuery('body').data('volume'); var selectedFamily = jQuery('body').data('family'); if (selectedVolume != undefined && selectedFamily != undefined) { toggleProductDetailsLink(); } } //show (and fill text) or hide product details link function toggleProductDetailsLink($reset) { var $reset = typeof($reset) != 'undefined' ? $reset : false; if (!$reset) { var selectedVolumeId = jQuery('body').data('volume').id; var selectedVolumeValue = jQuery('body').data('volume').readValue; var selectedFamilyId = jQuery('body').data('family').id; var selectedFamilyValue = jQuery('body').data('family').readValue; jQuery('a#prodDetailsLink').removeClass('inactive').attr('href', 'index.php?t=product&l=en&volume=' + selectedVolumeId + '&family=' + selectedFamilyId); jQuery('div.boxRight div.selectedJarInfo p:first strong').text(selectedVolumeValue + ' ml'); jQuery('div.boxRight div.selectedJarInfo p:last strong').text(selectedFamilyValue); jQuery('div.boxRight span.infoBox').hide(); jQuery('div.boxRight div.selectedJarInfo').show(); jQuery('div.boxRight p.info').hide(); } else { jQuery('a#prodDetailsLink').addClass('inactive').attr('href', ''); jQuery('a#showAllVolumes').hide(); jQuery('a#showAllFamilies').hide(); //jQuery('div.boxRight span.infoBox').show(); if (jQuery('div.boxRight div.selectedJarInfo').is(":visible")) { jQuery('div.boxRight p.info, div.boxRight div.selectedJarInfo, a.ui-slider-handle').toggle(); jQuery('a.ui-slider-handle').removeAttr('style'); } } } /*-----------------------------------------------------------------------------------------------------------------*/ /*PRODUCT CONFIGURATOR - DETAILED*/ jQuery.ajaxSetup({ cache: false }); // bind only once var jsonObj = []; //declare array jQuery('[id^=continue-]').click(function(e){ e.preventDefault(); if (validateForm()) { jQuery.get('index.php?r=Tabs&mode=setCurrentStep&l=en', function (data){ if (data != -1) { data = data > whereAmI+1 ? whereAmI+1 : data; jQuery( "#tabs" ).tabs('select', (data-1)); } }) } }); // add to selection validation jQuery('#add-to-selection').click(function(e){ // hide all errors var error = false; jQuery('span.error').remove(); // for each li active with select jQuery('li.active').each(function(){ if(jQuery(this).children('[id^="extras"]').length > 0) { jQuery(this).removeClass('error'); var hasOneChecked = false; // for each hidden input jQuery(this).children('[id^="extras"]').each( function(){ if(jQuery(this).attr('checked') == 'checked') { // at least one checked hasOneChecked = true; } } ); if(!hasOneChecked) { jQuery(this).addClass('error'); // display error jQuery(this).after('select an option'); error = true; } } }); if(error) { // don't go to my selection e.preventDefault(); } }); var select = jQuery('select[id^="select-"]').bind('change', function(){ var index = jQuery(this)[0].id.substr(parseInt(jQuery(this)[0].id.indexOf('-'))+1); if (jQuery(this).val() != -1) { jQuery.getJSON('index.php?r=Tabs&mode=getSelect&l=en&select='+index+'&value='+jQuery(this).val(), function(data){ var selects = jQuery('select[id^=select-]'); var next = selects.index(jQuery('#select-'+index))+1; jQuery.each(selects, function(i, v) { if (data[v.id.substr(7)]) { jQuery(v).html(data[v.id.substr(7)]); //destroy and create selectbox beautify createPrettySelect(v, data[v.id.substr(7)]); } }); // #44611 kjer je v dropdownih ena vrednost, naj bo že v defaultu selectana var current = jQuery('#select-'+index); if(jQuery(selects[next]).find('option').length == 2 && current.parents('div[id^=tabs-]').find(jQuery(selects[next])).length) { jQuery(selects[next]).val(jQuery(selects[next]).find('option').eq(1).val()).trigger('change'); //jQuery(selects[next]).attr('disabled', 'disabled'); } // destroy and create selectbox beautify jQuery.each(selects, function(i, v) { if (data[v.id.substr(7)]) { createPrettySelect(v, data[v.id.substr(7)]); } }); // #46071 dropdown z eno samo možnostjo naj bo disablan if(jQuery(selects[next]).find('option').length == 2 && current.parents('div[id^=tabs-]').find(jQuery(selects[next])).length) { jQuery(selects[next]).selectbox('disable'); } else { jQuery(selects[next]).selectbox('enable'); } updateLabels(data); }); } }); var extras = jQuery('#extraConf').delegate('input','change', function(){ var selects = jQuery('#extraConf').find('input').not('[id^="fake-extra"]'); var array = new Array(selects.length); jQuery.each(selects, function(i, v) { var string = v.id.replace('extras_', ''); var index = parseInt(string); array[i] = index+'-'+(jQuery('#extras_'+index).is(':checked') ? '1' : '0'); }); jQuery.post("index.php?r=Tabs&l=en&mode=extras", {'i': array }, function ( response ) { }); //toggle checked on parent (li) jQuery(this).parent().toggleClass('active'); }); jQuery('#tabs').tabs({ select: function(event, ui) { if ((ui.index+1) > whereAmI) { if (validateForm()) { if (!canGoToStep((ui.index+1))) { event.preventDefault(); } else { whereAmI = ui.index+1; } } else event.preventDefault(); } else { if (!canGoToStep((ui.index+1))) { event.preventDefault(); } else { whereAmI = ui.index+1; } } }, show: function(event, ui) { if (ui.index == 0) { if (!canGoToStep((ui.index+1))) { event.preventDefault(); } } window.location.hash = ui.tab.hash; }, ajaxOptions: { error: function( xhr, status, index, anchor ) { } } }); //CYCLE jQuery('#bannerImg').cycle({ timeout: 3000 }); //PRODUCT SEARCH - on hover on family show big image jQuery('#familyJar ul').delegate('li','hover', function( event ) { if( event.type === 'mouseenter' ) { var $thisLi = jQuery(this); var imgPopup = $thisLi.find('img.imgBig').clone().appendTo('#familyJar').addClass('imgBigPopup'); } else { jQuery('#familyJar img.imgBigPopup').remove(); } }); jQuery(window).bind('hashchange', function() { switch(window.location.hash) { // hardcoding FTW case '#tabs-1': jQuery('#tabs').tabs( "select", 0 ); break; case '#tabs-2': jQuery('#tabs').tabs( "select", 1 ); break; case '#tabs-3': jQuery('#tabs').tabs( "select", 2 ); break; case '#tabs-4': jQuery('#tabs').tabs( "select", 3 ); break; } }); prettyPhotoInit(); }); /*end document ready*/ function jQueryFriendly(data) { data = data.replace('[', '\['); data = data.replace(']', '\]'); return data; } function updateLabels(data, num) { // logged in hack if(data['isLoggedIn'] && data['isLoggedIn'] == 1) { jQuery('body').data('isLoggedIn', data['isLoggedIn']); } else { // is not logged in jQuery('body').data('isLoggedIn', 0); jQuery('#seal-quantity').attr('disabled', 'disabled'); jQuery('#cap-quantity').attr('disabled', 'disabled'); } // extras // quantity hacks if(data['jar-quantity']) { jQuery('#jar-quantity').val(data['jar-quantity']); } if(data['cap-quantity']) { jQuery('#cap-quantity').val(data['cap-quantity']); } if(data['seal-quantity']) { jQuery('#seal-quantity').val(data['seal-quantity']); } // selected cap hack if(data['selectedCap']) { jQuery('#selected-cap-height').html(data['selectedCap']['height']); jQuery('#selected-cap-diameter').html(data['selectedCap']['diameter']); jQuery('#selected-cap-type').html(data['selectedCap']['type']); jQuery('#selected-cap-caps-in-box').html(data['selectedCap']['capsInBox']); jQuery('#selected-cap-box-dimensions').html(data['selectedCap']['boxDimensions']); jQuery('#selected-cap-boxes-on-pallet').html(data['selectedCap']['boxesOnPallet']); //fade jar img to img with cap if (!jQuery('#selected-cap-appendedImg').length) { var appendHTMLnewImg = '' + jQuery('#selected-cap-image1').attr('alt') + ''; var appendHTMLoriginalImg = '' + jQuery('#selected-cap-image1').attr('alt') + ''; jQuery('#selected-cap-image2').append(appendHTMLnewImg).append(appendHTMLoriginalImg); jQuery('#selected-cap-appendedImg').addClass('visible'); jQuery('#selected-cap-image1').fadeOut(500); } else if (jQuery('#selected-cap-appendedImg').hasClass('visible') && jQuery('#selected-cap-appendedImg').attr('src') != data['selectedCap']['image'][0]) { jQuery('#selected-cap-image1').attr('src', data['selectedCap']['image'][0]); if (!jQuery('#tabs-2').hasClass('ui-tabs-hide')) { jQuery('#selected-cap-image1').fadeIn(500); } else { jQuery('#selected-cap-image1').show(); } if (!jQuery('#tabs-2').hasClass('ui-tabs-hide')) { jQuery('#selected-cap-appendedImg').fadeOut(500); } else { jQuery('#selected-cap-appendedImg').hide(); } jQuery('#selected-cap-appendedImg').removeClass('visible'); } else if (jQuery('#selected-cap-image1').attr('src') != data['selectedCap']['image'][0]) { jQuery('#selected-cap-appendedImg').attr('src', data['selectedCap']['image'][0]); if (!jQuery('#tabs-2').hasClass('ui-tabs-hide')) { jQuery('#selected-cap-appendedImg').fadeIn(500); } else { jQuery('#selected-cap-appendedImg').show(); } jQuery('#selected-cap-appendedImg').addClass('visible'); if (!jQuery('#tabs-2').hasClass('ui-tabs-hide')) { jQuery('#selected-cap-image1').fadeOut(500); } else { jQuery('#selected-cap-image1').hide(); } } // jQuery('#selected-cap-image2').attr('rel', jQuery('#selected-cap-image1').attr('rel')); jQuery('#selected-cap-image2').attr('href', data['selectedCap']['image'][1]); if(data['selectedCap']['image'][2]) { jQuery('#selected-cap-image3').attr('rel', jQuery('#selected-cap-image2').attr('rel')); jQuery('#selected-cap-image3').attr('href', data['selectedCap']['image'][2]); } if(data['selectedCap']['image'][3]) { jQuery('#selected-cap-image4').attr('rel', jQuery('#selected-cap-image2').attr('rel')); jQuery('#selected-cap-image4').attr('href', data['selectedCap']['image'][3]); } // jQuery('#selected-seal-image1').attr('src', data['selectedCap']['image'][0]); jQuery('#selected-seal-image1').attr('rel', jQuery('#selected-seal-image1').attr('rel')); jQuery('#selected-seal-image2').attr('href', data['selectedCap']['image'][1]); jQuery('#selected-seal-image2').attr('rel', jQuery('#selected-seal-image2').attr('rel')); if(data['selectedCap']['image'][2]) { jQuery('#selected-seal-image3').attr('rel', jQuery('#selected-seal-image2').attr('rel')); jQuery('#selected-seal-image3').attr('href', data['selectedCap']['image'][2]); } if(data['selectedCap']['image'][3]) { jQuery('#selected-seal-image4').attr('rel', jQuery('#selected-seal-image3').attr('rel')); jQuery('#selected-seal-image4').attr('href', data['selectedCap']['image'][3]); } // jQuery('#selected-extra-image1').attr('src', data['selectedCap']['image'][0]); jQuery('#selected-extra-image2').attr('href', data['selectedCap']['image'][1]); // pdf if(data['selectedCap']['pdf']) { jQuery('#selected-cap-pdf').html('3D VIEW'); jQuery('#selected-seal-pdf').html('3D VIEW'); jQuery('#selected-extra-pdf').html('3D VIEW'); } else { jQuery('#selected-cap-pdf').html(''); jQuery('#selected-seal-pdf').html(''); jQuery('#selected-extra-pdf').html(''); } } else { jQuery('#selected-cap-height').html(''); jQuery('#selected-cap-diameter').html(''); jQuery('#selected-cap-type').html(''); jQuery('#selected-cap-caps-in-box').html(''); jQuery('#selected-cap-box-dimensions').html(''); jQuery('#selected-cap-boxes-on-pallet').html(''); //show img with no cap var originalImg = jQuery('#selected-cap-originalImg').attr('src') if (jQuery('#selected-cap-appendedImg').length) { if (jQuery('#selected-cap-appendedImg').hasClass('visible')) { jQuery('#selected-cap-image1').attr('src', originalImg); jQuery('#selected-cap-image1').fadeIn(500); jQuery('#selected-cap-appendedImg').fadeOut(500); jQuery('#selected-cap-appendedImg').removeClass('visible'); } else { jQuery('#selected-cap-appendedImg').attr('src', originalImg); jQuery('#selected-cap-appendedImg').fadeIn(500); jQuery('#selected-cap-appendedImg').addClass('visible'); jQuery('#selected-cap-image1').fadeOut(500); } } jQuery('#selected-cap-image2').attr('href', originalImg); jQuery('#selected-cap-image3').attr('rel', ''); jQuery('#selected-cap-image4').attr('rel', ''); //jQuery('#selected-seal-image2').attr('href', originalImg); //jQuery('#selected-seal-image3').attr('rel', ''); //jQuery('#selected-seal-image4').attr('rel', ''); } // selected seal hack jQuery('.thirdCol .boxRight .boxWrap .productSummary').show(); jQuery('.thirdCol .boxRight .boxWrap #productSummaryNoData').hide(); if(data['selectedSeal']) { if(data['selectedSeal']['sealsInBox'] && data['selectedSeal']['sealsInBox'] > 0) { // seal packaging data jQuery('.thirdCol .boxRight .boxWrap .productSummary').show(); jQuery('.thirdCol .boxRight .boxWrap .productSummaryNoData').hide(); jQuery('.thirdCol .boxRight .boxWrap #productSummaryNoData').hide(); jQuery('#selected-seal-seals-in-box').html(data['selectedSeal']['sealsInBox']); jQuery('#selected-seal-box-dimensions').html(data['selectedSeal']['boxDimensions']); jQuery('#selected-seal-boxes-on-pallet').html(data['selectedSeal']['boxesOnPallet']); } else { // no seal packaging data jQuery('.thirdCol .boxRight .boxWrap .productSummary').hide(); jQuery('.thirdCol .boxRight .boxWrap #productSummaryNoData').show(); jQuery('.thirdCol .boxRight .boxWrap .productSummaryNoData').show(); } jQuery('#selected-seal-thickness').html(data['selectedSeal']['thickness']); jQuery('#selected-seal-diameter').html(data['selectedSeal']['diameter']); jQuery('#selected-seal-material').html(data['selectedSeal']['material']); if(jQuery('#selected-seal-thickness').html().length < 4) { jQuery('#selected-seal-thickness').parent().hide(); } else { jQuery('#selected-seal-thickness').parent().show(); } if(jQuery('#selected-seal-diameter').html().length < 4) { jQuery('#selected-seal-diameter').parent().hide(); } else { jQuery('#selected-seal-diameter').parent().show(); } } else { jQuery('#selected-seal-seals-in-box').html(''); jQuery('#selected-seal-box-dimensions').html(''); jQuery('#selected-seal-boxes-on-pallet').html(''); jQuery('#selected-seal-thickness').html(''); jQuery('#selected-seal-diameter').html(''); jQuery('#selected-seal-material').html(''); } if(num == 3) { if(!data['seals']) { // hide seal stuff if there are no seals available jQuery('#tabs-3 .secondCol').html('

This jar or cap does not contain a seal. Please, continue to Extras configuration.

'); } } // extras if(data['extras']) { jQuery('#extraConf').html(data['extras']).ready(function(){ jQuery('[id^="fake-select-"]').each( function (a,b){jQuery(b).selectbox('detach');jQuery(b).selectbox();}); jQuery('#tabs-4 div.sbHolder').hide(); jQuery(this).find('input:checked').each(function(){ jQuery(this).parent().addClass('active'); jQuery(this).parent().children('div').show(); }); }); jQuery('[id^="fake-select-"]').change(function (){ // uncheck others jQuery(this).children().each(function(){jQuery("#"+jQueryFriendly(jQuery(this).val())).removeAttr('checked')}); if(jQuery(this).val() != '-1') { jQuery(this).attr('checked', 'checked'); jQuery("#"+jQueryFriendly(jQuery(this).val())).attr('checked', 'checked'); jQuery("#"+jQueryFriendly(jQuery(this).val())).trigger('change'); jQuery(this).parent().addClass('active'); } }); jQuery('[id^="fake-extra"]').bind('change', function (){ if(jQuery(this).is(':checked')) { // unchecked to checked jQuery(this).parent().children('li div').show(); jQuery(this).parent().removeClass('active'); } else { // checked to unchecked jQuery(this).parent().children('li div').hide(); jQuery(this).parent().addClass('active'); // uncheck others jQuery(this).parent().children().each(function(){jQuery("#"+jQueryFriendly(jQuery(this).val())).removeAttr('checked')}); } }); } // jar label if(data['selectedJarLabel']) { jQuery('#labels-cap-selected-jar').html(data['selectedJarLabel']); jQuery('#labels-extras-selected-jar').html(data['selectedJarLabel']); jQuery('#labels-seals-selected-jar').html(data['selectedJarLabel']); } // cap label if(data['selectedCapLabel']) { jQuery('#labels-extras-selected-cap').html(data['selectedCapLabel']); jQuery('#labels-seals-selected-cap').html(data['selectedCapLabel']); } //seal label if(data['selectedSealLabel']) { jQuery('#labels-extras-selected-seal').html(data['selectedSealLabel']); jQuery('#labels-extras-selected-seal').parent().show(); } // seal optional if(jQuery('#labels-extras-selected-seal').html().length < 4) { jQuery('#labels-extras-selected-seal').parent().hide(); } if(data['overallHeight']) { jQuery('#labels-cap-overall-height').html(data['overallHeight'] + ' mm'); jQuery('#labels-extras-overall-height').html(data['overallHeight'] + ' mm'); jQuery('#labels-seals-overall-height').html(data['overallHeight'] + ' mm'); } if(data['selectedCapPrintableDiameter']) { jQuery('#selectedCapPrintableDiameter').html(data['selectedCapPrintableDiameter']); if(data['selectedCapPrintableDiameter'].length < 6) { jQuery('#selectedCapPrintableDiameter').closest('tr').hide(); } else { jQuery('#selectedCapPrintableDiameter').closest('tr').show(); } } if(data['selectedCapMaxColors']) { jQuery('#selectedCapMaxColors').html(data['selectedCapMaxColors']); if(data['selectedCapMaxColors'].length < 1) { jQuery('#selectedCapMaxColors').closest('tr').hide(); } else { jQuery('#selectedCapMaxColors').closest('tr').show(); } } prettyPhotoInit(); } function canGoToStep(num) { var rtrn = true; jQuery.ajax({ type: 'GET', url: 'index.php?r=Tabs&l=en&mode=getStep&step='+num, dataType: 'json', success: function(data){ if (data !== null && data !== undefined && data !== '' && data != '-1') { var selects = jQuery('select[id^="select-"]'); jQuery.each(selects, function(i, v) { jQuery(v).html(data[v.id.substr(7)]); //alert(v.id); createPrettySelect(v, data[v.id.substr(7)]); }) updateLabels(data, num); var disableSelects = []; // #44611 select the (non-empty) option if there is only one if (num == 1 && jQuery('select[id^="select-jar-color"]').find('option').length == 2 && jQuery('select[id^="select-jar-color"]').val() == -1) { disableSelects[1] = true; jQuery('select[id^="select-jar-color"]').val(jQuery('select[id^="select-jar-color"]').find('option').eq(1).val()).trigger('change'); } else if (num == 2 && jQuery('select[id^="select-caps"]').find('option').length == 2 && jQuery('select[id^="select-caps"]').val() == -1) { disableSelects[2] = true; jQuery('select[id^="select-caps"]').val(jQuery('select[id^="select-caps"]').find('option').eq(1).val()).trigger('change'); } else if (num == 3 && jQuery('select[id^="select-seals"]').find('option').length == 2 && jQuery('select[id^="select-seals"]').val() == -1) { disableSelects[3] = true; jQuery('select[id^="select-seals"]').val(jQuery('select[id^="select-seals"]').find('option').eq(1).val()).trigger('change'); } jQuery.each(selects, function(i, v) { createPrettySelect(v, data[v.id.substr(7)]); }); if (num == 1 && disableSelects[1] == true) { jQuery('select[id^="select-jar-color"]').selectbox('disable'); } else if (num == 2 && disableSelects[2] == true) { jQuery('select[id^="select-caps"]').selectbox('disable'); } else if (num == 3 && disableSelects[3] == true) { jQuery('select[id^="select-seals"]').selectbox('disable'); } } }, data: {}, async: false }); return rtrn; } var whereAmI = 1; function validateForm() { var jar = whereAmI == 1; var cap = whereAmI == 2; if (jar) { var q = parseInt(jQuery('#jar-quantity').val()); } else if(cap) { var q = parseInt(jQuery('#cap-quantity').val()); } else { var q = parseInt(jQuery('#seal-quantity').val()); } if(isNaN(q)) { q = 0; } switch(whereAmI) { case 1: var fields = ['select-jar-color', 'select-jar-treatment', 'select-jar-cartridge-material', 'select-jar-cartridge-color', 'jar-quantity']; break; case 2: var fields = ['select-caps', 'select-cap-material', 'select-cap-treatment', 'select-cap-color']; break; case 3: var fields = ['select-seals', 'select-seal-color']; break; } var errors = new Array(); var quantityLimit = orderMinimums[jQuery('#select-jar-color :selected').text()]; for (var field in fields) { //alert(jQuery('#'+fields[field]).val()); var errorField = jQuery('#'+fields[field]); var isLoggedIn = jQuery('body').data('isLoggedIn'); if( jQuery('#select-seals option').size() == 0 && (errorField.attr('id') == 'select-seal-color' || errorField.attr('id') == 'select-seal-material')) { // if num of seals == 0, don't validate seal color and material } else if (errorField.attr('id') == 'jar-quantity' && (isLoggedIn == 0 && ((q < 10000 && jQuery('#select-jar-color :selected').text()=='White') || (q < 10000 && jQuery('#select-jar-color :selected').text()=='Natural') || (q < 10000 && jQuery('#select-jar-color :selected').text()=='Coloured') || (q < 10000 && jQuery('#select-jar-color :selected').text()=='Transparent')))) { errors.push(errorField); } else if((errorField.attr('id') == 'select-jar-cartridge-material' && jQuery('#select-jar-cartridge-material').length == 0) || (errorField.attr('id') == 'select-jar-cartridge-color' && jQuery('#select-jar-cartridge-color').length == 0)){ // cartridge = optional } else if (errorField.val() == '-1') { errors.push(errorField); } else { errorField.parent().removeClass('error'); errorField.siblings('span').removeClass('error'); errorField.siblings('span').html(''); } } var errorsDisplay = jQuery('#errors' + whereAmI); errorsDisplay.removeClass('error'); errorsDisplay.html(''); if (errors.length != 0) { errorsDisplay.addClass('error'); errorsDisplay.wrapInner('