var currentPosition=1;$(document).ready(function(){$(document).on('click','.disabled',function(event){event.preventDefault();});$('#currency-changer select').change(function(){var selected_currency=$(this).val();window.location=selected_currency;});evaluate_confirm_boxes();$(document).on('change','.checkout_confirm',function(event){evaluate_confirm_boxes();});$(document).bind("ajaxStop",function(){evaluate_confirm_boxes();});$('[name="product_id"]').change(function(event){var wrap=$(this).closest('.product-wrapper');var options_el=$(this).find('option[value="'+$(this).val()+'"]');wrap.find('.product-image').attr('src',options_el.data('img'));wrap.find('.product-price').html(options_el.data('price'));wrap.find('.product-title').html(options_el.data('title'));wrap.find('.product-subtitle').html(options_el.data('subtitle'));wrap.find('.product-description').html(options_el.data('description'));});$(document).on('change','.select-images',function(event){event.preventDefault();var src=$(this).find(":selected").data('img');console.log(src);var $target=$($(this).data('img-target'));console.log($target);$target.attr('src',src);});$('input[name=apply_coupon_code_control]').click(function(event){event.preventDefault();$(this).getForm().sendRequest('add_discount_code',{onSuccess:function(data){$('input[name=apply_coupon_code_control]').parent().find('.flash').remove();if(data=='true'){$('input[name=apply_coupon_code_control]').parent().prepend('<p class="flash success">Thank you, discount will be applied at the checkout</p>');}
else{$('input[name=apply_coupon_code_control]').parent().prepend('<p class="flash error">This discount code doesn\'t exist</p>');$('#coupon_code').val('');}},preCheckFunction:function(){$('input[name=apply_coupon_code_control]').parent().find('.flash').remove();if(!$('#coupon_code').val()){$('input[name=apply_coupon_code_control]').parent().prepend('<p class="flash error">Please enter a discount code</p>');return false;}
return true;}});});$('.navbar-toggle-side').click(function(e){$(this).blur();if(!$(this).hasClass('transformed')){$('.navbar-toggle.transformed').trigger('click');$(this).addClass('transformed');$('.navbar-collapse-side').addClass('in');$('#logo').animate({marginTop:-28,opacity:0},100);}
else{$(this).removeClass('transformed');$('.navbar-collapse-side').removeClass('in');$('#logo').animate({marginTop:10,opacity:1},100);}});$(document).on('click','.flash',function(){clearFlashMessage();});$(document).bind("ajaxStart",function(){$(".ajax_loading_indicator").hide().fadeIn(100);}).bind("ajaxStop",function(){$(".ajax_loading_indicator").fadeOut(100,function(){$('[data-mh]').matchHeight();if($('.flash').length>0&&$('#flash_container').css('position')!='fixed')
{scrollToElement('.flash',500,-120);}
else if($('#flash_container').css('position')==='fixed'){setTimeout(function(){$('.flash').fadeOut('200');},5000);}
if($('#flash_container .go-to-link')){$('#flash_container .go-to-link').appendTo('#flash_container .flash');}});});$(document).on('click','.act-as-trigger',function(event){event.preventDefault();var target=$($(this).data('target'));if(target.length){target.trigger('click');}});$(document).on('change','select[name="act-as-nav"]',function(event){var dest=$(this).val();if(dest)
window.location=dest;});var slideWidth=$('.background'+currentPosition).width();var browserWidth=$(window).width();var slideTo=(slideWidth-browserWidth)/2;$('.slide_container').css({left:-slideTo});$('.boat').addClass('skip animate');});$(window).resize(function(){$('body').height('100%');var slideWidth=$('.background'+currentPosition).width();var browserWidth=$(window).width();var slideTo=(slideWidth-browserWidth)/2;for(var i=1;i<currentPosition;i++)
{slideTo+=$('.background'+i).width();};$('.slide_container').css({left:-slideTo});});$(function(){setInterval(function(){var browserWidth=$(window).width();if(browserWidth<768){}
$('.skinnies_bottle').animate({bottom:200},300,'easeInOutBack');if(currentPosition==3)
currentPosition=1;else
currentPosition=currentPosition+1;var currentElement=$('.background'+currentPosition);var slideWidth=currentElement.width();var slideTo=(slideWidth-browserWidth)/2;for(var i=1;i<currentPosition;i++)
slideTo+=$('.background'+i).width();currentElement.children().each(function(){if($(this).hasClass('skip'))
return true;var currentLeft=$(this).position().left;var newPosition=currentLeft+800;$(this).css('left',newPosition);});$('.slide_container').animate({left:-slideTo},1000,'easeInOutQuint');var slideInterval=1000;currentElement.children().each(function(){if($(this).hasClass('skip'))
return true;var currentLeft=$(this).position().left;var newPosition=currentLeft-800;$(this).animate({'left':newPosition},slideInterval,'easeInOutQuint');slideInterval=slideInterval+100;});if(currentPosition==3&&(!$('.burgsmall').hasClass('skip')))
{$('.burgsmall').animate({left:0},78000,'linear',function(){$('.burgsmall').removeClass('skip');}).addClass('skip');$('.burgbig').addClass('skip').animate({left:400},78000,'linear',function(){$('.burgbig').removeClass('skip');});}
$('.skinnies_bottle').delay(300).animate({bottom:$('.skinnies_bottle').css('bottom')},300,'easeInOutBack',function(){if(currentPosition!=3&&(!$('.burgsmall').hasClass('skip')))
{$('.burgbig').css('left',1260);$('.burgsmall').css('left',879);}
if(!$('.boat').hasClass('skip'))
{$('.boat').addClass('skip').animate({left:-350},480000,'linear',function(){$('.boat').removeClass('skip').css({left:6000});});}});},6000)});$(document).keydown(function(e){if(e.keyCode==27){if($('#slideout-form').hasClass('out')){$('#slideout-form').animate({width:39}).removeClass('out').addClass('in');}}});function evaluate_confirm_boxes(){var allowed=true,boxes=$('.checkout_confirm');boxes.each(function(index,el){if(!$(this).is(':checked'))
allowed=false;});if(!allowed){$('.checkout-actions .btn-arrow').attr('disabled',true).addClass('disabled');}
else{$('.checkout-actions .btn-arrow').attr('disabled',false).removeClass('disabled');}}
function is_int(value){if((parseFloat(value)==parseInt(value))&&!isNaN(value)){return true;}else{return false;}}
function clearFlashMessage(){$('.flash').animate({opacity:0},300,function(){$(this).slideUp(function(){$(this).remove();});});}
function scrollToElement(selector,time,verticalOffset){time=typeof(time)!='undefined'?time:1000;verticalOffset=typeof(verticalOffset)!='undefined'?verticalOffset:0;element=$(selector);offset=element.offset();offsetTop=offset.top+verticalOffset;$('html, body').animate({scrollTop:offsetTop,easing:'easeInOutQuad'},time);}